[zeromq-dev] thread affinity

Pieter Hintjens ph at imatix.com
Sun Dec 1 14:50:03 CET 2013


A long time ago ZeroMQ would crash, even with locking. Since version
2.1, socket migration is explicitly supported providing you do a full
memory barrier between threads. A lock will cover it. Nonetheless it
is strongly warned against in the man pages because people were
systematically misusing it, and getting crashes.

-Pieter

On Sat, Nov 30, 2013 at 9:09 PM, Justin Karneges <justin at affinix.com> wrote:
> On 11/30/2013 10:02 AM, Min RK wrote:
>>> On Nov 30, 2013, at 9:30, Justin Karneges <justin at affinix.com> wrote:
>>>
>>> Great, it sounds like the answer to my question is that it is possible
>>> to use the same socket from different threads provided I do my own
>>> locking. That's perfectly workable. I mainly wanted to be sure there
>>> wasn't something in libzmq explicitly preventing this kind of usage. For
>>> example, I believe it is impossible to share a socket across threads
>>> with pyzmq, but this must be a limitation imposed in the binding rather
>>> than in libzmq.
>>
>> Pyzmq imposes no restrictions on how you use sockets, so it is perfectly possible to share them across threads using locks (or not, and just risk segfault).
>
> Good to hear. I could have sworn I hit some "attempt to use socket from
> thread it wasn't created in" exception when I tried to do it (even with
> locking) but it's been awhile so I could be mistaking things.
>
> Justin
> _______________________________________________
> 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