[zeromq-dev] zmq_term can not safely be re-entered with pgm transport
Steven McCoy
steven.mccoy at miru.hk
Sun Jul 22 16:46:31 CEST 2012
Plus its a similar problem with Windows. Pre-emptive patch attached.
--
Steve-o
On 22 July 2012 07:39, Pieter Hintjens <ph at imatix.com> wrote:
> Hi Toralf,
>
> Thanks for spotting this. Would you like to create an issue for this
> in our issue tracker?
>
> And, if you have time, fix this and send us pull requests?
>
> Cheers
> Pieter
>
> On Sat, Jul 21, 2012 at 5:03 PM, Toralf Wittner <tw at dtex.org> wrote:
> > According to the man page of zmq_term, it should be safe to re-enter
> > zmq_term if it previously returned with EINTR. This is actually not
> > true if used with OpenPGM. zmq_term invokes pgm_shutdown which is
> > reading and modifying the static variable pgm_ref_count and will
> > return FALSE on second invocation which makes zmq_term abort with
> > "Assertion failed: false (zmq.cpp:185)". This affects version 2.2 as
> > well as 3.2.
> >
> > -- Toralf
> > _______________________________________________
> > zeromq-dev mailing list
> > zeromq-dev at lists.zeromq.org
> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> >
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120722/5747e254/attachment.htm>
-------------- next part --------------
--- zmq.cpp.orig 2012-07-22 10:42:24.000000000 -0400
+++ zmq.cpp 2012-07-22 10:44:36.000000000 -0400
@@ -292,17 +292,20 @@
int rc = ((zmq::ctx_t*) ctx_)->terminate ();
int en = errno;
+ // Shut down only if termination was not interrupted by a signal.
+ if (!rc && en == EINTR) {
#ifdef ZMQ_HAVE_WINDOWS
- // On Windows, uninitialise socket layer.
- rc = WSACleanup ();
- wsa_assert (rc != SOCKET_ERROR);
+ // On Windows, uninitialise socket layer.
+ rc = WSACleanup ();
+ wsa_assert (rc != SOCKET_ERROR);
#endif
#if defined ZMQ_HAVE_OPENPGM
- // Shut down the OpenPGM library.
- if (pgm_shutdown () != TRUE)
- zmq_assert (false);
+ // Shut down the OpenPGM library.
+ if (pgm_shutdown () != TRUE)
+ zmq_assert (false);
#endif
+ }
errno = en;
return rc;
More information about the zeromq-dev
mailing list