summaryrefslogtreecommitdiff
path: root/src/socket_base.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-02-09 15:32:15 +0100
committerMartin Sustrik <sustrik@250bpm.com>2011-02-09 15:32:15 +0100
commit80ac398bba928fa7f245d2e107071677a13185cf (patch)
tree57c51a7adb5f4cb1a91396fe0b223538a4d428d7 /src/socket_base.cpp
parent889424e675eecd9d9c7d1121456401d5c43029a5 (diff)
Initial implementation of reaper thread.
Reaper thread destroys the socket asynchronously. zmq_term() can be interrupted by a signal (EINTR). zmq_socket() will return ETERM after zmq_term() was called. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/socket_base.cpp')
-rw-r--r--src/socket_base.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/socket_base.cpp b/src/socket_base.cpp
index f19187f..0643d4d 100644
--- a/src/socket_base.cpp
+++ b/src/socket_base.cpp
@@ -570,13 +570,10 @@ int zmq::socket_base_t::recv (::zmq_msg_t *msg_, int flags_)
int zmq::socket_base_t::close ()
{
- // Start termination of associated I/O object hierarchy.
- terminate ();
-
- // Ask context to zombify this socket. In other words, transfer
- // the ownership of the socket from this application thread
- // to the context which will take care of the rest of shutdown process.
- zombify_socket (this);
+ // Transfer the ownership of the socket from this application thread
+ // to the reaper thread which will take care of the rest of shutdown
+ // process.
+ send_reap (this);
return 0;
}
@@ -627,7 +624,7 @@ zmq::session_t *zmq::socket_base_t::find_session (const blob_t &name_)
return session;
}
-bool zmq::socket_base_t::dezombify ()
+bool zmq::socket_base_t::reap ()
{
// Process any commands from other threads/sockets that may be available
// at the moment. Ultimately, socket will be destroyed.
@@ -635,6 +632,11 @@ bool zmq::socket_base_t::dezombify ()
// If the object was already marked as destroyed, finish the deallocation.
if (destroyed) {
+
+ // Remove the socket from the context.
+ destroy_socket (this);
+
+ // Deallocate.
own_t::process_destroy ();
return true;
}