mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-18 17:36:57 +00:00
Fix race condition on shutdown
This commit is contained in:
parent
86717b2a29
commit
2742c4afd4
@ -91,7 +91,6 @@ int zmq::ctx_t::terminate ()
|
|||||||
// restarted.
|
// restarted.
|
||||||
bool restarted = terminating;
|
bool restarted = terminating;
|
||||||
terminating = true;
|
terminating = true;
|
||||||
slot_sync.unlock ();
|
|
||||||
|
|
||||||
// First attempt to terminate the context.
|
// First attempt to terminate the context.
|
||||||
if (!restarted) {
|
if (!restarted) {
|
||||||
@ -99,13 +98,12 @@ int zmq::ctx_t::terminate ()
|
|||||||
// First send stop command to sockets so that any blocking calls
|
// First send stop command to sockets so that any blocking calls
|
||||||
// can be interrupted. If there are no sockets we can ask reaper
|
// can be interrupted. If there are no sockets we can ask reaper
|
||||||
// thread to stop.
|
// thread to stop.
|
||||||
slot_sync.lock ();
|
|
||||||
for (sockets_t::size_type i = 0; i != sockets.size (); i++)
|
for (sockets_t::size_type i = 0; i != sockets.size (); i++)
|
||||||
sockets [i]->stop ();
|
sockets [i]->stop ();
|
||||||
if (sockets.empty ())
|
if (sockets.empty ())
|
||||||
reaper->stop ();
|
reaper->stop ();
|
||||||
slot_sync.unlock ();
|
|
||||||
}
|
}
|
||||||
|
slot_sync.unlock();
|
||||||
|
|
||||||
// Wait till reaper thread closes all the sockets.
|
// Wait till reaper thread closes all the sockets.
|
||||||
command_t cmd;
|
command_t cmd;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user