[zeromq-dev] Issue in zGuide
john skaller
skaller at users.sourceforge.net
Tue Feb 28 22:15:30 CET 2012
On 29/02/2012, at 6:48 AM, Jacky Wang wrote:
> Hi there,
>
> I'm reading the ØMQ guide and found an issue in this section: http://zguide.zeromq.org/page:all#Programming-with-MQ. It says: "In the end, the problem was that the application was passing sockets between threads, which crashed weirdly. It became legal behavior in ØMQ/2.1, but remains dangerous and something we advise against doing."
>
> However:
>
> 1) In the sample code, only context is passed between threads. The sockets are generated separately in each threads.
It appears the problem has nothing
to do with threading. The problem is that the topic message is being
sent repeatedly without being re-initialised. Sending a message
evacuates its buffer.
> 2) AFAIK, the zmq_socket is not thread-safe thus could not be passed around. Does ØMQ/2.1 removed this limitation? Otherwise many threads can easily reuse the same TCP connection...
0MQ socket functions aren't thread safe.
I implemented thread safe socket functions for 0MQ but the
community didn't seem to want it so I removed it. It was seen
to encourage sharing sockets between threads rather than
adding an extra layer of inproc transport.
--
john skaller
skaller at users.sourceforge.net
http://felix-lang.org
More information about the zeromq-dev
mailing list