I recently found a deadlock when using czmq's zbeacon_t.
Code to reproduce:

int main()
{
    zbeacon_t* beacon = zbeacon_new( 2000 );
    assert( beacon );
    zbeacon_publish( beacon, (byte*)"Hello", 6 );
    zbeacon_subscribe( beacon, 0, 0 );
    while (!zctx_interrupted)
    {
         zmsg_t* msg = zmsg_recv( zbeacon_socket(beacon) );
         zmsg_destroy( &msg );
    }

    // Do some long term cleanups..
    sleep(1);
    zbeacon_destroy( &beacon );
}

Once SIGINT or SIGTERM are sent to the process, the zbeacons agent task
exits the processing loop, so that the final destroy can't send TERMINATE to  
the  agent. So the application gets stuck in zbeacon_destroy.
My suggestion is to not test for zctx_interrupted in the s_agent_task 
function, so that the user can control the cleanup process.

Kind Regards
Max Drechsler

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to