Merge pull request #405 from jimenezrick/master

Fix LIBZMQ-404: zmq_term not truly re-entrant
This commit is contained in:
Pieter Hintjens 2012-07-29 00:45:20 -07:00
commit 84560c1607

View File

@ -169,21 +169,24 @@ int zmq_ctx_destroy (void *ctx_)
errno = EFAULT; errno = EFAULT;
return -1; return -1;
} }
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 ();
wsa_assert (rc != SOCKET_ERROR); wsa_assert (rc != SOCKET_ERROR);
#endif #endif
#if defined ZMQ_HAVE_OPENPGM #if defined ZMQ_HAVE_OPENPGM
// Shut down the OpenPGM library. // Shut down the OpenPGM library.
if (pgm_shutdown () != TRUE) if (pgm_shutdown () != TRUE)
zmq_assert (false); zmq_assert (false);
#endif #endif
}
errno = en; errno = en;
return rc; return rc;