summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2010-08-06 20:55:37 +0200
committerMartin Sustrik <sustrik@250bpm.com>2010-08-25 15:39:20 +0200
commitf77edfce26bf50ab6eae6550d33f345c9785acca (patch)
tree5032230e78bf21451f1a6e1643140734f0fada15 /src
parent05d908492dc382941fc633ad7082b5bd86e84e67 (diff)
Destruction of session is delayed till both in & out pipes are closed
Diffstat (limited to 'src')
-rw-r--r--src/pipe.cpp5
-rw-r--r--src/pipe.hpp4
-rw-r--r--src/session.cpp7
3 files changed, 4 insertions, 12 deletions
diff --git a/src/pipe.cpp b/src/pipe.cpp
index 1903422..14fc753 100644
--- a/src/pipe.cpp
+++ b/src/pipe.cpp
@@ -130,11 +130,6 @@ void zmq::reader_t::terminate ()
send_pipe_term (writer);
}
-bool zmq::reader_t::is_terminating ()
-{
- return terminating;
-}
-
void zmq::reader_t::process_revive ()
{
// Forward the event to the sink (either socket or session).
diff --git a/src/pipe.hpp b/src/pipe.hpp
index 34c5600..12b0dfe 100644
--- a/src/pipe.hpp
+++ b/src/pipe.hpp
@@ -67,10 +67,6 @@ namespace zmq
// Ask pipe to terminate.
void terminate ();
- // Returns true if the pipe is already terminating
- // (say if delimiter was already read).
- bool is_terminating ();
-
private:
reader_t (class object_t *parent_, pipe_t *pipe_, uint64_t lwm_);
diff --git a/src/session.cpp b/src/session.cpp
index 86086fb..3c74898 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -71,7 +71,8 @@ zmq::session_t::~session_t ()
bool zmq::session_t::is_terminable ()
{
- return in_pipe->is_terminating ();
+ // The session won't send term_ack until both in & out pipe are closed.
+ return !in_pipe && !out_pipe;
}
bool zmq::session_t::read (::zmq_msg_t *msg_)
@@ -81,8 +82,6 @@ bool zmq::session_t::read (::zmq_msg_t *msg_)
if (!in_pipe->read (msg_)) {
active = false;
- if (in_pipe->is_terminating ())
- finalise ();
return false;
}
@@ -179,11 +178,13 @@ void zmq::session_t::terminated (reader_t *pipe_)
{
active = false;
in_pipe = NULL;
+ finalise ();
}
void zmq::session_t::terminated (writer_t *pipe_)
{
out_pipe = NULL;
+ finalise ();
}
void zmq::session_t::activated (reader_t *pipe_)