Commit 27c28bdc authored by Pieter Hintjens's avatar Pieter Hintjens

Mark sockets as invalid when closed, not when destroyed

Previously, sockets were still "valid" after being closed and only marked
as invalid when destroyed. This meant programs could access closed sockets.
Now the socket is marked "invalid" when closed.
parent 6f720f00
...@@ -136,9 +136,6 @@ zmq::socket_base_t::socket_base_t (ctx_t *parent_, uint32_t tid_, int sid_) : ...@@ -136,9 +136,6 @@ zmq::socket_base_t::socket_base_t (ctx_t *parent_, uint32_t tid_, int sid_) :
zmq::socket_base_t::~socket_base_t () zmq::socket_base_t::~socket_base_t ()
{ {
zmq_assert (destroyed); zmq_assert (destroyed);
// Mark the socket as dead.
tag = 0xdeadbeef;
} }
zmq::mailbox_t *zmq::socket_base_t::get_mailbox () zmq::mailbox_t *zmq::socket_base_t::get_mailbox ()
...@@ -666,6 +663,9 @@ int zmq::socket_base_t::recv (msg_t *msg_, int flags_) ...@@ -666,6 +663,9 @@ int zmq::socket_base_t::recv (msg_t *msg_, int flags_)
int zmq::socket_base_t::close () int zmq::socket_base_t::close ()
{ {
// Mark the socket as dead
tag = 0xdeadbeef;
// Transfer the ownership of the socket from this application thread // Transfer the ownership of the socket from this application thread
// to the reaper thread which will take care of the rest of shutdown // to the reaper thread which will take care of the rest of shutdown
// process. // process.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment