Commit 76bd6e73 authored by Martin Sustrik's avatar Martin Sustrik

engine termination on disconnect fixed

parent d13933bc
...@@ -104,7 +104,7 @@ void zmq::connect_session_t::start_connecting () ...@@ -104,7 +104,7 @@ void zmq::connect_session_t::start_connecting ()
zmq_assert (false); 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 up the mess left over by the failed connection.
clean_pipes (); clean_pipes ();
......
...@@ -39,11 +39,11 @@ namespace zmq ...@@ -39,11 +39,11 @@ namespace zmq
const char *protocol_, const char *address_); const char *protocol_, const char *address_);
~connect_session_t (); ~connect_session_t ();
// i_inout interface implementation.
void detach ();
private: private:
// Hook into session's disconnection mechanism.
void detached ();
// Start the connection process. // Start the connection process.
void start_connecting (); void start_connecting ();
......
...@@ -49,8 +49,10 @@ zmq::session_t::~session_t () ...@@ -49,8 +49,10 @@ zmq::session_t::~session_t ()
void zmq::session_t::terminate () void zmq::session_t::terminate ()
{ {
// TODO: if (in_pipe)
zmq_assert (false); in_pipe->terminate ();
if (out_pipe)
out_pipe->terminate ();
} }
bool zmq::session_t::read (::zmq_msg_t *msg_) bool zmq::session_t::read (::zmq_msg_t *msg_)
...@@ -228,6 +230,14 @@ void zmq::session_t::process_attach (i_engine *engine_, ...@@ -228,6 +230,14 @@ void zmq::session_t::process_attach (i_engine *engine_,
attached (peer_identity_); 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 () void zmq::session_t::process_term ()
{ {
// Here we are pugging into the own_t's termination mechanism. // Here we are pugging into the own_t's termination mechanism.
......
...@@ -46,6 +46,7 @@ namespace zmq ...@@ -46,6 +46,7 @@ namespace zmq
bool read (::zmq_msg_t *msg_); bool read (::zmq_msg_t *msg_);
bool write (::zmq_msg_t *msg_); bool write (::zmq_msg_t *msg_);
void flush (); void flush ();
void detach ();
void attach_pipes (class reader_t *inpipe_, class writer_t *outpipe_, void attach_pipes (class reader_t *inpipe_, class writer_t *outpipe_,
const blob_t &peer_identity_); const blob_t &peer_identity_);
......
...@@ -29,7 +29,7 @@ zmq::transient_session_t::~transient_session_t () ...@@ -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. // There's no way to reestablish a transient session. Tear it down.
terminate (); terminate ();
......
...@@ -36,9 +36,10 @@ namespace zmq ...@@ -36,9 +36,10 @@ namespace zmq
class socket_base_t *socket_, const options_t &options_); class socket_base_t *socket_, const options_t &options_);
~transient_session_t (); ~transient_session_t ();
// i_inout interface implementation. private:
void detach ();
// Hook into session's disconnection mechanism.
void detached ();
}; };
} }
......
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