Uploaded image for project: 'ActiveMQ C++ Client'
  1. ActiveMQ C++ Client
  2. AMQCPP-325

Failover transport exception can cause CPU spin

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 3.2.3
    • None
    • Transports
    • None
    • Windows 2003, Windows 7, Windows XP

    Description

      We find that when use the failover transport to connect the broker, if failed to connect, then the thread will not release and become a DEADLESS LOOP cause CPU spin.

      See the source code:

      file: ~\activemq-cpp-library-3.2.3\src\main\activemq\transport\failover\failovertransport.cpp
      500 bool FailoverTransport::iterate() {
      ......................................................................
      510 if( connectedTransport != NULL || closed || connectionFailure != NULL )

      { 511 return false; ...................................................................... 702 }

      file: ~\activemq-cpp-library-3.2.3\src\main\activemq\threads\compositetaskrunner.cpp
      97 void CompositeTaskRunner::run() {
      98
      99 try {
      100
      101 while( true ) {
      102
      103 synchronized( &mutex ) {
      104 pending = false;
      105 if( shutDown )

      { 106 return; 107 }

      108 }
      109
      110 if( !this->iterate() ) {
      111
      112 // wait to be notified.
      113 synchronized( &mutex ) {
      114 if( shutDown )

      { 115 return; 116 }

      117 while( !pending )

      { 118 mutex.wait(); 119 }

      120 }
      121 }
      122 }
      123 }
      124 AMQ_CATCH_NOTHROW( Exception )
      125 AMQ_CATCHALL_NOTHROW()
      126
      127 // Make sure we notify any waiting threads that thread
      128 // has terminated.
      129 synchronized( &mutex )

      { 130 threadTerminated = true; 131 mutex.notifyAll(); 132 }

      133 }

      ............................................................................

      160 bool CompositeTaskRunner::iterate() {
      161
      162 synchronized( &tasks ) {
      163
      164 auto_ptr< Iterator<CompositeTask*> > iter( tasks.iterator() );
      165
      166 while( iter->hasNext() ) {
      167
      168 CompositeTask* task = iter->next();
      169
      170 if( task->isPending() )

      { 171 task->iterate() ; 173 174 // Always return true, so that we check again for 175 // any of the other tasks that might now be pending. 176 return true; 177 }

      178 }
      179 }
      180
      181 return false;
      182 }

      Attachments

        Activity

          People

            tabish Timothy A. Bish
            ebony FangYu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 120h
                120h
                Remaining:
                Remaining Estimate - 120h
                120h
                Logged:
                Time Spent - Not Specified
                Not Specified