From 938689a49128ca17d2bc9662f311c6dbb70240db Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Sun, 19 Sep 2010 21:40:26 +0200 Subject: synchronisation problem fixed in ctx_t --- src/ctx.cpp | 2 ++ src/zmq_init.cpp | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ctx.cpp b/src/ctx.cpp index 267f7d0..b17fac0 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -108,8 +108,10 @@ int zmq::ctx_t::terminate () { // First send stop command to sockets so that any // blocking calls are interrupted. + slot_sync.lock (); for (sockets_t::size_type i = 0; i != sockets.size (); i++) sockets [i]->stop (); + slot_sync.unlock (); // Close the logging infrastructure. log_sync.lock (); diff --git a/src/zmq_init.cpp b/src/zmq_init.cpp index 3c8f288..ee5741a 100644 --- a/src/zmq_init.cpp +++ b/src/zmq_init.cpp @@ -139,7 +139,10 @@ void zmq::zmq_init_t::finalise_initialisation () if (sent && received) { // If we know what session we belong to, it's easy, just send the - // engine to that session and destroy the init object. + // engine to that session and destroy the init object. Note that we + // know about the session only if this object is owned by it. Thus, + // lifetime of this object in contained in the lifetime of the session + // so the pointer cannot become invalid without notice. if (session) { engine->unplug (); send_attach (session, engine, peer_identity, true); -- cgit v1.2.3