diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2012-02-16 10:04:04 +0900 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2012-02-16 10:04:04 +0900 |
commit | f7efe9ca0edfc417f0d0c3631dc0c47c84b22437 (patch) | |
tree | 92192ee97671eddb1d83e6b4e5779ef30e860b34 | |
parent | a025fb7713709b7176b99d7403e05c9d99c6b703 (diff) |
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 <sustrik@250bpm.com>
-rw-r--r-- | src/socket_base.cpp | 6 |
1 files 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. |