[zeromq-dev] [PATCH] Section about thread-safeness in zmq(7) simplified

Martin Sustrik sustrik at 250bpm.com
Fri May 20 10:43:12 CEST 2011


>> So what is the "best practice" then?
>> Or are you just trying to put people off from migrating sockets as much as
>> possible? I.e. the "If you don't know what this means, don't use it"
>> approach?
> You missed the key story here, which was that people were
> systematically passing sockets between threads, and doing it wrong,
> and getting asserts. This was happening 2-3 times a week.
> So we looked at this thread spawning pattern and decided it was better
> to pass contexts but not sockets, and then we changed the Guide to
> explain that. This piece of the doc should have been fixed too but
> escaped.
> Basically, passing sockets around is for system-level work only, i.e.
> language bindings that have to do this, not application level work.
> Undocumenting this and providing alternate patterns that were more
> robust did in fact reduce the number of accidents to close to zero.

This is kind of unrelated but it would be also useful if the manpages 
explained the algorithm for shutting down multithreaded application 
(main thread closes all the sockets it owns and calls zmq_term; worker 
threads get ETERM, close the sockets they own; zmq_term unblocks and 
main thread is free to exit the process).

This could probably go to zmq_term(3).


More information about the zeromq-dev mailing list