From f7efe9ca0edfc417f0d0c3631dc0c47c84b22437 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Thu, 16 Feb 2012 10:04:04 +0900 Subject: Improve checking for the invalid sockets Till now the "valid" tag of the socket was removed only after the socket was properly deallocated by the reaper thread. That allowed user to access it while it was in the process of being deallocated. Now, the "valid" tag is removed as soon as zmq_close is called. Signed-off-by: Martin Sustrik --- src/socket_base.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/socket_base.cpp b/src/socket_base.cpp index ea6d3ed..3854dc2 100644 --- a/src/socket_base.cpp +++ b/src/socket_base.cpp @@ -129,9 +129,6 @@ xs::socket_base_t::socket_base_t (ctx_t *parent_, uint32_t tid_, int sid_) : xs::socket_base_t::~socket_base_t () { xs_assert (destroyed); - - // Mark the socket as dead. - tag = 0xdeadbeef; } xs::mailbox_t *xs::socket_base_t::get_mailbox () @@ -623,6 +620,9 @@ int xs::socket_base_t::recv (msg_t *msg_, int flags_) int xs::socket_base_t::close () { + // Mark the socket as dead. + tag = 0xdeadbeef; + // Transfer the ownership of the socket from this application thread // to the reaper thread which will take care of the rest of shutdown // process. -- cgit v1.2.3