[zeromq-dev] zbeacon deadlock
Max Drechsler
mdrechsler at rst-automation.de
Tue Jan 28 08:40:08 CET 2014
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140128/f82ca12b/attachment.sig>
More information about the zeromq-dev
mailing list