From 2742c4afd416cb206976fbc2d1a1e81117252ea7 Mon Sep 17 00:00:00 2001 From: Richard Newton Date: Wed, 6 Nov 2013 15:19:04 +0000 Subject: [PATCH] Fix race condition on shutdown --- src/ctx.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ctx.cpp b/src/ctx.cpp index 552ffec6..972dd53c 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -91,7 +91,6 @@ int zmq::ctx_t::terminate () // restarted. bool restarted = terminating; terminating = true; - slot_sync.unlock (); // First attempt to terminate the context. if (!restarted) { @@ -99,13 +98,12 @@ int zmq::ctx_t::terminate () // First send stop command to sockets so that any blocking calls // can be interrupted. If there are no sockets we can ask reaper // thread to stop. - slot_sync.lock (); for (sockets_t::size_type i = 0; i != sockets.size (); i++) sockets [i]->stop (); if (sockets.empty ()) reaper->stop (); - slot_sync.unlock (); } + slot_sync.unlock(); // Wait till reaper thread closes all the sockets. command_t cmd;