diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ctx.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/ctx.cpp b/src/ctx.cpp index 6fb2b36..22c4908 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -83,11 +83,11 @@ xs::ctx_t::~ctx_t () int xs::ctx_t::terminate () { + slot_sync.lock (); if (!starting) { // Check whether termination was already underway, but interrupted and now // restarted. - slot_sync.lock (); bool restarted = terminating; terminating = true; slot_sync.unlock (); @@ -115,8 +115,8 @@ int xs::ctx_t::terminate () xs_assert (cmd.type == command_t::done); slot_sync.lock (); xs_assert (sockets.empty ()); - slot_sync.unlock (); } + slot_sync.unlock (); // Deallocate the resources. delete this; @@ -154,6 +154,7 @@ int xs::ctx_t::setctxopt (int option_, const void *optval_, size_t optvallen_) xs::socket_base_t *xs::ctx_t::create_socket (int type_) { + slot_sync.lock (); if (unlikely (starting)) { starting = false; @@ -194,8 +195,6 @@ xs::socket_base_t *xs::ctx_t::create_socket (int type_) } } - slot_sync.lock (); - // Once xs_term() was called, we can't create new sockets. if (terminating) { slot_sync.unlock (); |