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

john skaller skaller at users.sourceforge.net
Fri Feb 17 16:07:16 CET 2012


On 17/02/2012, at 3:09 PM, Gary Wright wrote:

> 
> On Feb 16, 2012, at 8:56 PM, john skaller wrote:
>> There is an analogue in Posix: optional locking. It's fairly useless.
>> Because anyone can write into a locked region of a file by ignoring
>> the locks. 
> 
> That is a pretty broad generalization.  Advisory locks are quite useful
> when you are dealing with co-operative access, which happens automatically
> if you've got multiple clients utilizing the same library code.
> 
> I think it would be unusual to have arbitrary clients accessing something like
> a shared file (or shared socket...).

Actually thread-safe sockets have another use. Debugging.
This actually just happened: two Felix fibres accidentally
got at the same socket. In Felix, it's like in 0MQ: you're not supposed
to share sockets across fibres.

Interestingly in this case, the threads were cooperative not pre-emptive!
One fibre was put to sleep waiting for a data transfer, and another one
tried to do one as well. One of them woke up and did its thing,
then the second one woke up and found the object used to transfer
control back was gone. Luckily trapped by an assertion failure.

If you have bad stuff happening, making your sockets thread safe
temporarily is useful for eliminating some corruptions. It may help
find a bug caused by sharing sockets incorrectly.

Anyhow, since no one wants thread safe sockets they probably
should be removed. I'd prefer with 

	#ifdef ZMQ_SUPPORT_THREAD_SAFE_SOCKETS

so I can trial it or use it if I want, without needing to fork the repo.

EIther way its bad to have a feature people actively dislike.

--
john skaller
skaller at users.sourceforge.net







More information about the zeromq-dev mailing list