[zeromq-dev] Pub/sub, inproc shutdown Assert failure

Marc Criley mcriley.1979 at gmail.com
Sat Jun 9 21:19:36 CEST 2012

I'm getting:

Assertion failed: ok (mailbox.cpp:79)

when trying to shut down my application. After having searched the archives
and whitepapers I'm still at a loss. Here's the structure of what I have
and am trying to do (version 2.1.9-1, distributed with Ubuntu):

- One main thread establishes a PUB socket using the 'inproc' transport.
- Four separate threads each open a SUB socket.
- 'inproc' requires the pub and sub sockets to use the same context, so
that is done.
- Each subscriber socket waits on 'recv()' for something to arrive, which
is then processed, and returns back to waiting for the next message.

Everything runs fine in the application. However, at shutdown:

- There is no pending traffic, it has all been cleared.
- The main thread closes its PUB socket.
- The main thread invokes zmq_term, which blocks.
- This unblocks the four subscriber threads waiting on recv().
- Each subscriber thread closes its socket and the thread terminates.

At this point I expect the main thread call of zmq_term() to complete.
That's not what happens, instead I get:

Assertion failed: ok (mailbox.cpp:79)

I believe I did this in accordance with the 0MQ Termination whitepaper (
http://www.zeromq.org/whitepapers:0mq-termination), and this is the
sequence I use to shutdown a tcp transport client thread, which works
without problem.

Deferring closing the PUB socket until after zmq_term doesn't work, as
zmq_term blocks until the socket is closed.

Any suggestions would be appreciated.

Marc C
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120609/c278be1d/attachment.htm>

More information about the zeromq-dev mailing list