[Boost-bugs] [Boost C++ Libraries] #8799: named condition notify_all does not wake up waiting process

Subject: [Boost-bugs] [Boost C++ Libraries] #8799: named condition notify_all does not wake up waiting process
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-07-08 13:21:20


#8799: named condition notify_all does not wake up waiting process
----------------------------------------+--------------------------
 Reporter: peter.knafl@… | Owner: igaztanaga
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: interprocess
  Version: Boost 1.53.0 | Severity: Problem
 Keywords: named_condition notify_all |
----------------------------------------+--------------------------
 The underlying snippet never catches the notify_all() signal. Operating
 System used is Linux 3.5.0-17-generic.

 Can anybody confirm this as a bug or am I doing something wrong?

 === Code snippet ===
 {{{
 #include <iostream>
 #include <boost/interprocess/sync/named_condition.hpp>
 #include <boost/interprocess/sync/named_mutex.hpp>
 #include <boost/interprocess/sync/scoped_lock.hpp>
 #include <boost/interprocess/shared_memory_object.hpp>
 #include <boost/interprocess/mapped_region.hpp>
 #include <boost/version.hpp>
 #include <sys/types.h>
 #include <sys/wait.h>

 using namespace std;
 using namespace boost::interprocess;


 void* consumer(void*)
 {
     cout << "Started child" << endl;

     named_mutex mtx(create_only, "somemutex");
     named_condition signal_empty (create_only, "signal_empty");
     for(;;)
     {
         cout << "Child tries to lock" << endl;
         scoped_lock<named_mutex> lock(mtx);
         cout << "Child got lock and waits" << endl;
         signal_empty.wait(lock);
         cout << "Child WOKE up" << endl;
     }
     cout << "Finished child" << endl;
 }

 void* producer(void*)
 {
     cout << "Started parent" << endl;
     sleep(1);
     named_mutex mtx(open_only, "somemutex");
     named_condition signal_empty (open_only, "signal_empty");

     for(;;)
     {
         cout << "Parent tries to get lock" << endl;
         scoped_lock<named_mutex>lock(mtx);
         cout << "Parent got lock and notifies" << endl;
         sleep(1);
         cout << "Parent notifies child" << endl;
         signal_empty.notify_all();
     }
 }

 int main(int argc, char** argv)
 {
     pid_t pid = fork();

     if(pid == 0)
     {
         consumer(NULL);
     }
     else
     {
         producer(NULL);
     }
 }
 }}}


 === Application output ===
 {{{
 Started parent
 Started child
 Child tries to lock
 Child got lock and waits
 Parent tries to get lock
 Parent got lock and notifies
 Parent notifies child
 Parent tries to get lock
 Parent got lock and notifies
 .....
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8799>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC