[zeromq-dev] Exiting blocking calls on shutdown
sustrik at 250bpm.com
Sun Apr 11 17:27:59 CEST 2010
> would it be possible to add something like 'zmq_ping' to check if the
> socket is still usable? I would imagine currently seeing whether
> socket is still usable is to send/recv.
> For example in PHP bindings the context and the socket are persisted
> between multiple requests so 'zmq_ping' would allow checking the
> liveness of the socket when it's being retrieved. In theory the
> context should never be freed before the socket but there should be no
> harm in additional checks. I think 'zmq_ping' could also check the
> liveness of the actual connections and possibly reconnect if needed.
The current state of affairs is that any function you call after the
context is closed returns ETERM, so whatever you do with 0MQ you get the
message about context being dead.
The obvious case of:
rc = zmq_ping ();
if (rc == ETERM)
Won't help in any way as the context may be closed after zmq_ping and
Thus the only scenario I can imagine for zmq_ping would be say when you
are generating a message and the generation is very time expensive. Thus
you would like to check once in a while that the context is still alive
and the message being produced can be sent later on. If the context is
dead, you can stop generating the message.
This use case is pretty rare IMO and can be solved (more cleanly?) by
sending an explicit termination message from main thread to worker
(generating) thread via inproc transport.
Let us see what others have to say on this topic...
More information about the zeromq-dev