[zeromq-dev] Fwd: ZMQ Closure - Change of Beginners Documentation
Martin Sustrik
sustrik at 250bpm.com
Wed May 25 17:35:58 CEST 2011
Hi Mike,
> For information, I am not convinced that ETERM will always be the exit
> value returned. In reality It does not matter and I prefer not to test
> for this value. My loop is of the form
>
> while (!stopped)
> {
> rc=zmq_recv();
> if (rc!=0)
> {
> if (stopped)
> break;
> }
> }
> zmq_close();
>
> In the main loop -
>
> reader.stop(); // sets stopped=true
> zmq_term();
> reader.wait(100) // wait for the reader thread to finish etc.
You need to place "stopped" into critical section to make that work
properly. That in turn will ruin your performance.
> So it is not so important what zmq_recv returns because I know that I am
> exiting.
>
> When I looked at messageBox.recv for nbytes=0 I found that it is called
> from several call points and not all of them cater for ETERM. I am not
> convinced that ETERM is properly implemented but I did not spend the
> time to analyse each call point to see if it could occur during a
> shutdown scenario.
ETERM is generated by sending "stop" command to individual sockets.
Check zmq::ctx_t::terminate() function. You'll find the following code
there:
for (sockets_t::size_type i = 0; i != sockets.size (); i++)
sockets [i]->stop ();
Martin
More information about the zeromq-dev
mailing list