engine termination on disconnect fixed

This commit is contained in:
Martin Sustrik 2010-08-11 17:06:49 +02:00
parent d13933bc62
commit 76bd6e73c3
6 changed files with 21 additions and 9 deletions

View File

@ -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 ();

View File

@ -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 ();

View File

@ -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.

View File

@ -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_);

View File

@ -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 ();

View File

@ -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 ();
};
}