[zeromq-dev] Warning about attached and detached threads in czmq

Andy Ballingall TF ballingall at thefoundry.co.uk
Mon Dec 31 12:42:54 CET 2012


For anyone who might have wandered into the same problem I had, the czmq
documentation is clear:

https://github.com/zeromq/czmq

*"If you want to connect sockets over inproc:// they must share the same
ØMQ context, i.e. be attached threads."*

It isn't good enough to create *detached *threads and have them share the
same *czmq context*. A zeromq context is not a czmq context. The czmq
context contains extra information (e.g. a list of sockets) which must only
be manipulated by the thread it belongs to.

Although attached threads share the same underlying zeromq context, if you
share the same czmq context explicitly (as I did), then you'll run into
problems. Only by using zthread_fork() does czmq correctly duplicate the
czmq context to ensure thread safety.

Hope this helps someone,

Andy


-- 
Andy Ballingall
Senior Software Engineer

The Foundry
6th Floor, The Communications Building,
48, Leicester Square,
London, WC2H 7LT, UK
Tel: +44 (0)20 7968 6828 - Fax: +44 (0)20 7930 8906
Web: http://www.thefoundry.co.uk/

The Foundry Visionmongers Ltd.
Registered in England and Wales No: 4642027
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20121231/5efbae8b/attachment.htm>


More information about the zeromq-dev mailing list