[prev in list] [next in list] [prev in thread] [next in thread] 

List:       zeromq-dev
Subject:    Re: [zeromq-dev] zmq multithread bug
From:       Martin Sustrik <sustrik () 250bpm ! com>
Date:       2010-01-27 8:06:12
Message-ID: 4B5FF3F4.2010109 () 250bpm ! com
[Download RAW message or body]

Guo,

> Ok. I read the zmq_init document and it states that "Initialises 0MQ 
> context. app_threads specifies maximal number of application threads 
> that can own open sockets at the same time", so I thought multi-thread 
> is supported.

Yes. That means that you can open socket A from thread 1 and socket B 
from thread 2. If you specified just 2 application threads, attempt to 
open socket C from thread 3 will fail.

Still, each socket should be used from at most one thread. See 
zmq_socket(3) man page:

"Note that each socket is owned by exactly one thread (the one that it 
was created from) and should not be used from any other thread."

> Also, I have put my lock before the the call to send, isn't it enough to 
> make it thread-safe?

No, it won't. Socket is simply exclusive to the thread that created it.

Martin
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic