Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#129 Asyncchannel stall

closed
nobody
5
2012-09-14
2007-12-28
Anonymous
No

If we use the AsyncChannel in a multithread shenariou it is possible (during closing of channel) that the close method will go in stall.

This happens becouse AsyncChannel::close() call _queue.wakeUpAll(); when the AsyncChannel::run() is executing _pChannel->log(pNf->message()).

In this case _queue.wakeUpAll() does not wakeup the right queue and the following execution of nf = _queue.waitDequeueNotification(); will stall all the system.

I attach my first solution to this problem.

My email is michele.dionisio@gmail.com

Discussion

  •  
    Attachments
  • Logged In: NO

    Sorry My previous solution is bugged. A right (I hope) solution is using the following function

    void AsyncChannel::run()
    {
    AutoPtr<Notification> nf = _queue.waitDequeueNotification();
    while ( (!closing) && (nf) ) //updated
    {
    MessageNotification* pNf = dynamic_cast<MessageNotification*>(nf.get());

    {
      FastMutex::ScopedLock lock(_mutex);
    
      if (pNf && _pChannel) _pChannel->log(pNf->message());
    }
    _mutexclose.lock(); //added
    if (!closing) //added
    {
      _mutexclose.unlock(); //added
      nf = _queue.waitDequeueNotification();
    } //added
    else //added
    { //added
      _mutexclose.lock(); //added
    } //added
    

    }
    }

     
  • fixed in 1.3.3/trunk by ryppka.