[zeromq-dev] zmq::signaler_t::make_fdpair hangs application on crash

Felipe Farinon felipe.farinon at powersyslab.com
Fri Nov 8 20:46:22 CET 2013


In windows, the code that creates a mutual exclusive section uses the 
'Event' mechanism.

     HANDLE sync = CreateEvent (&sa, FALSE, TRUE, TEXT 
("Global\\zmq-signaler-port-sync"));
     if (sync == NULL && GetLastError () == ERROR_ACCESS_DENIED)
       sync = OpenEvent (SYNCHRONIZE | EVENT_MODIFY_STATE, FALSE, TEXT 
("Global\\zmq-signaler-port-sync"));

     win_assert (sync != NULL);

     //  Enter the critical section.
     DWORD dwrc = WaitForSingleObject (sync, INFINITE);
     zmq_assert (dwrc == WAIT_OBJECT_0);

     // Some code here...

     brc = SetEvent (sync);
     brc = CloseHandle (sync);


win_assert and zmq_asserts abort the program if the conditions passed to 
them aren't met. If the program is aborted before calling 'SetEvent' on 
sync, the event is unsetted forever and all zeromq applications that 
call this code will block on 'WaitForSingleObject'. A preferred way to 
handle this is using 'Mutex' since if this scenario happens, 
WaitForSingleObject will not freeze forever but will return WAIT_ABANDONED.



More information about the zeromq-dev mailing list