From 76bd6e73c335dbebd8bd30565f83a810058f2cc8 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Wed, 11 Aug 2010 17:06:49 +0200 Subject: engine termination on disconnect fixed --- src/connect_session.cpp | 2 +- src/connect_session.hpp | 6 +++--- src/session.cpp | 14 ++++++++++++-- src/session.hpp | 1 + src/transient_session.cpp | 2 +- src/transient_session.hpp | 5 +++-- 6 files changed, 21 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/connect_session.cpp b/src/connect_session.cpp index 5c088f6..896cc48 100644 --- a/src/connect_session.cpp +++ b/src/connect_session.cpp @@ -104,7 +104,7 @@ void zmq::connect_session_t::start_connecting () zmq_assert (false); } -void zmq::connect_session_t::detach () +void zmq::connect_session_t::detached () { // Clean up the mess left over by the failed connection. clean_pipes (); diff --git a/src/connect_session.hpp b/src/connect_session.hpp index 8303dda..32f8f44 100644 --- a/src/connect_session.hpp +++ b/src/connect_session.hpp @@ -39,11 +39,11 @@ namespace zmq const char *protocol_, const char *address_); ~connect_session_t (); - // i_inout interface implementation. - void detach (); - private: + // Hook into session's disconnection mechanism. + void detached (); + // Start the connection process. void start_connecting (); diff --git a/src/session.cpp b/src/session.cpp index 0494ff1..e208ebf 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -49,8 +49,10 @@ zmq::session_t::~session_t () void zmq::session_t::terminate () { - // TODO: - zmq_assert (false); + if (in_pipe) + in_pipe->terminate (); + if (out_pipe) + out_pipe->terminate (); } bool zmq::session_t::read (::zmq_msg_t *msg_) @@ -228,6 +230,14 @@ void zmq::session_t::process_attach (i_engine *engine_, attached (peer_identity_); } +void zmq::session_t::detach () +{ + // Engine is dead. Let's forget about it. + engine = NULL; + + detached (); +} + void zmq::session_t::process_term () { // Here we are pugging into the own_t's termination mechanism. diff --git a/src/session.hpp b/src/session.hpp index ba259dc..e009a90 100644 --- a/src/session.hpp +++ b/src/session.hpp @@ -46,6 +46,7 @@ namespace zmq bool read (::zmq_msg_t *msg_); bool write (::zmq_msg_t *msg_); void flush (); + void detach (); void attach_pipes (class reader_t *inpipe_, class writer_t *outpipe_, const blob_t &peer_identity_); diff --git a/src/transient_session.cpp b/src/transient_session.cpp index 9dd7431..6711bc2 100644 --- a/src/transient_session.cpp +++ b/src/transient_session.cpp @@ -29,7 +29,7 @@ zmq::transient_session_t::~transient_session_t () { } -void zmq::transient_session_t::detach () +void zmq::transient_session_t::detached () { // There's no way to reestablish a transient session. Tear it down. terminate (); diff --git a/src/transient_session.hpp b/src/transient_session.hpp index 30d4c29..69e2217 100644 --- a/src/transient_session.hpp +++ b/src/transient_session.hpp @@ -36,9 +36,10 @@ namespace zmq class socket_base_t *socket_, const options_t &options_); ~transient_session_t (); - // i_inout interface implementation. - void detach (); + private: + // Hook into session's disconnection mechanism. + void detached (); }; } -- cgit v1.2.3