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

Pieter Hintjens ph at imatix.com
Mon Dec 31 17:08:04 CET 2012


I'll add this clarification (about not sharing zctx structures) to the
doc, it's worth making.

-Pieter

On Mon, Dec 31, 2012 at 12:42 PM, Andy Ballingall TF
<ballingall at thefoundry.co.uk> wrote:
> 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
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



More information about the zeromq-dev mailing list