From 9d96e0037a9d027fd286f771fa2a8db5def485c8 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Wed, 13 Oct 2010 10:09:46 +0200 Subject: Clean-up of the code related to attaching/detaching engines to sessions. Session base class now handles the engine events exclusively. It notifies derived session types using dedicated "attached" and "detached" events. Couple of bugs was fixed along the way. Signed-off-by: Martin Sustrik --- src/session.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/session.cpp') diff --git a/src/session.cpp b/src/session.cpp index 76e782b..d5c6fdd 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -260,7 +260,15 @@ void zmq::session_t::detach () // Engine is dead. Let's forget about it. engine = NULL; + // Remove any half-done messages from the pipes. + clean_pipes (); + + // Send the event to the derived class. detached (); + + // Just in case, there's only a delimiter in the inbound pipe. + if (in_pipe) + in_pipe->check_read (); } void zmq::session_t::process_term () @@ -293,16 +301,6 @@ void zmq::session_t::unregister_session (const blob_t &name_) socket->unregister_session (name_); } -void zmq::session_t::attached (const blob_t &peer_identity_) -{ -} - -void zmq::session_t::detached () -{ - if (in_pipe) - in_pipe->check_read (); -} - void zmq::session_t::terminate () { force_terminate = true; -- cgit v1.2.3