Acceleration interprocess named mutex stays acquired after crash

I use boost::interpocess::scoped_lock, using named_mutexand a timeout; I work in Linux OS.

During one of my tests, I had a crash: since then, every time I try to start the application again, it gets stuck at the point where I created the lock; it seems that the mutex has remained acquired in some way (without the possibility of using it).

Also, if you look at the code below, I expect that after 150 microseconds, timed scoped_lockwill come back to give me an error .. but it’s not ... 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 as follows:

  • How to make sure boost::interprocessmutex is destroyed? (so how to see the general mutex through processes and how to destroy them).
  • 150 ? - ?

AFG

+5
4

:

 boost::interprocess::named_mutex::remove( "MutexName" );

.

+4
boost::interprocess::named_mutex::remove( "MutexName" ); 

. .

+2

mutex unix, boost:: interprocess:: file_lock. , .

+1

local_time() universal_time(): boost:: posix_time:: ptime abs_time = boost:: posix_time:: microsec_clock:: universal_time() + boost:: posix_time:: (150);

scoped_lock locker (mutex, abs_time);

, named_mutex .

boost:: interprocess:: file_lock , !!!

+1

All Articles