I am using a boost::interpocess::scoped_lock using a named_mutex and a timeout; I am running in Linux OS.
During one of my tests I had a crash: since then, everytime I try to run again the application, it gets stuck on the point where I created the lock; it looks like the mutex remained acquired some way ( no possible process using it is running ).
On top of that if you look at the code below I am expecting that after 150 microseconds, the timed scoped_lock returns to give me an error..but this is not the case..it just hangs there.
      #include <boost/interprocess/sync/named_mutex.hpp>
      namespace bi = boost::interprocess;
      bi::named_mutex m_mutex;
 try{
      boost::posix_time::ptime pt( 
          boost::posix_time::microsec_clock::local_time() ) ;
      pt+= boost::posix_time::microseconds( 150 );
      bi::scoped_lock< bi::named_mutex > lock( m_mutex, pt );
      if( !lock.owns() ){
        FATAL( "I didn't acquire the lock." );
           return EXIT_FAILURE;
      }
     ....
My questions are the following:
boost::interprocess named mutex is destroyed? ( so how to see the shared mutex across the processes and how to destroy them )Thanks a lot
AFG
I found the solution: I missed to call the following to destroy the mutex
 boost::interprocess::named_mutex::remove( "MutexName" );
This code makes all the necessary clean up.
boost::interprocess::named_mutex::remove( "MutexName" ); 
This should not be correct. This will unlock the mutex for all other processes, too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With