From 03c28411d892da23ae1a17728a368e38b9a072ad Mon Sep 17 00:00:00 2001 From: Mika Fischer Date: Tue, 19 Feb 2013 11:01:13 +0100 Subject: [PATCH] Work around for LIBZMQ-496 The problem is that other threads might still be in mailbox::send() when it is destroyed. So as a workaround, we just acquire the mutex in the destructor. Therefore the running send will finish before the mailbox is destroyed. See also the fix for LIBZMQ-281 in zeromq2-x. Signed-off-by: Mika Fischer --- src/mailbox.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mailbox.cpp b/src/mailbox.cpp index d2eff56f..fc09338c 100644 --- a/src/mailbox.cpp +++ b/src/mailbox.cpp @@ -33,6 +33,11 @@ zmq::mailbox_t::mailbox_t () zmq::mailbox_t::~mailbox_t () { // TODO: Retrieve and deallocate commands inside the cpipe. + + // Work around problem that other threads might still be in our + // send() method, by waiting on the mutex before disappearing. + sync.lock (); + sync.unlock (); } zmq::fd_t zmq::mailbox_t::get_fd ()