[zeromq-dev] Thread-safe sockets (cont.)

john skaller skaller at users.sourceforge.net
Fri Feb 17 01:32:17 CET 2012


On 17/02/2012, at 9:05 AM, Chuck Remes wrote:

> On Feb 16, 2012, at 3:51 PM, Pieter Hintjens wrote:
> 
>> Hi,
>> 
>> Does anyone have a valid use case for thread-safe sockets? It seems
>> that the semantics are fuzzy and using this would lead to poor design.
>> What happens if two threads are polling the same sockets, but one
>> message arrives?
> 
> zmq_poll() would probably need to be modified to disallow multiple threads from polling. Alternately, zmq_poll() would need to disallow a poll_item list that contained a socket that is already a member of another call to zmq_poll() from another thread.
> 
> Ugly. Error prone. I don't see how this could work well without some hacks. And now "thread safety" would generate a shit-ton of additional questions about why zmq_poll() was so strict, broken, etc.

No need to change it at all. It is the same as now: if you misuse a feature, you can't
expect reliable results.

The difference is now you get unexpected results instead of a segfault.

--
john skaller
skaller at users.sourceforge.net







More information about the zeromq-dev mailing list