Fix LIBZMQ-404: zmq_term not truly re-entrant

zmq_term can not safely be re-entered with pgm transport.
Fix proposed by Steven McCoy.
parent 631e12d4
...@@ -173,6 +173,8 @@ int zmq_ctx_destroy (void *ctx_) ...@@ -173,6 +173,8 @@ int zmq_ctx_destroy (void *ctx_)
int rc = ((zmq::ctx_t*) ctx_)->terminate (); int rc = ((zmq::ctx_t*) ctx_)->terminate ();
int en = errno; int en = errno;
// Shut down only if termination was not interrupted by a signal.
if (!rc || en != EINTR) {
#ifdef ZMQ_HAVE_WINDOWS #ifdef ZMQ_HAVE_WINDOWS
// On Windows, uninitialise socket layer. // On Windows, uninitialise socket layer.
rc = WSACleanup (); rc = WSACleanup ();
...@@ -184,6 +186,7 @@ int zmq_ctx_destroy (void *ctx_) ...@@ -184,6 +186,7 @@ int zmq_ctx_destroy (void *ctx_)
if (pgm_shutdown () != TRUE) if (pgm_shutdown () != TRUE)
zmq_assert (false); zmq_assert (false);
#endif #endif
}
errno = en; errno = en;
return rc; return rc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment