karllen commented on issue #52: Get Transport death lock if all brokers 
shutdown unnormally
URL: 
https://github.com/apache/rocketmq-client-cpp/issues/52#issuecomment-451652907
 
 
   @ShannonDing ok! Thank you for your attention, look at the code below
   
   `
   tcpConnectStatus TcpTransport::connect(const string &strServerURL,
                                          int timeOutMillisecs /* = 3000 */) {
    //....
    m_ReadDatathread = new boost::thread(boost::bind(&TcpTransport::runThread, 
this));
       while(!m_event_base_status) {
         LOG_INFO("Wait till event base is looping");
         boost::system_time const timeout=boost::get_system_time()+ 
boost::posix_time::milliseconds(1000);
         boost::unique_lock<boost::mutex> lock(m_event_base_mtx);
         m_event_base_cv.timed_wait(lock, timeout);
       }
   void TcpTransport::runThread() {
     while (m_ReadDatathread) {
       if (m_eventBase != NULL) {
         
         if (!m_event_base_status) {
           boost::mutex::scoped_lock lock(m_event_base_mtx);
           m_event_base_status.store(true);
           m_event_base_cv.notify_all();
           LOG_INFO("Notify on event_base_dispatch");
         }
         event_base_dispatch(m_eventBase);
         // event_base_loop(m_eventBase, EVLOOP_ONCE);//EVLOOP_NONBLOCK should 
not
         // be used, as could not callback event immediatly
       }
       LOG_INFO("event_base_dispatch exit once");
       boost::this_thread::sleep(boost::posix_time::milliseconds(1));
       if (getTcpConnectStatus() != e_connectSuccess) return;
     }
   }
   
   `
   I think m_ReadDatathread  is nullptr  when the runThread function call 
thread loop in the TcpTransport.cpp, so the thread loop depends on the 
m_ReadDatathread is unreasonable.
   If the runThread function return because of m_ReadDatathread  is nullptr, 
the m_event_base_cv condition variables will won't able notify and fire, so the 
thread called the connect function will be endless loop.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to