summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/session.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/session.cpp b/src/session.cpp
index ef17d6d..ac2dd12 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -36,11 +36,8 @@ zmq::session_t::session_t (object_t *parent_, socket_base_t *owner_,
zmq::session_t::~session_t ()
{
- // Ask associated pipes to terminate.
- if (in_pipe)
- in_pipe->term ();
- if (out_pipe)
- out_pipe->term ();
+ zmq_assert (!in_pipe);
+ zmq_assert (!out_pipe);
}
bool zmq::session_t::read (::zmq_msg_t *msg_)
@@ -82,6 +79,7 @@ void zmq::session_t::attach_inpipe (reader_t *pipe_)
active = true;
in_pipe->set_endpoint (this);
}
+
void zmq::session_t::attach_outpipe (writer_t *pipe_)
{
zmq_assert (!out_pipe);
@@ -141,6 +139,16 @@ void zmq::session_t::process_unplug ()
bool ok = owner->unregister_session (name.c_str ());
zmq_assert (ok);
+ // Ask associated pipes to terminate.
+ if (in_pipe) {
+ in_pipe->term ();
+ in_pipe = NULL;
+ }
+ if (out_pipe) {
+ out_pipe->term ();
+ out_pipe = NULL;
+ }
+
if (engine) {
engine->unplug ();
delete engine;