From a24a7c15a824bb48da38809bff9416673dc5a176 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Tue, 31 May 2011 14:36:51 +0200 Subject: Session termination induced by socket fixed Signed-off-by: Martin Sustrik --- src/pipe.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/pipe.cpp') diff --git a/src/pipe.cpp b/src/pipe.cpp index fd7223c..26f7d85 100644 --- a/src/pipe.cpp +++ b/src/pipe.cpp @@ -301,8 +301,11 @@ void zmq::pipe_t::process_pipe_term_ack () delete this; } -void zmq::pipe_t::terminate () +void zmq::pipe_t::terminate (bool delay_) { + // Overload the value specified at pipe creation. + delay = delay_; + // If terminate was already called, we can ignore the duplicit invocation. if (state == terminated || state == double_terminated) return; @@ -321,9 +324,13 @@ void zmq::pipe_t::terminate () // There are still pending messages available, but the user calls // 'terminate'. We can act as if all the pending messages were read. - else if (state == pending) { - send_pipe_term_ack (peer); - state = terminating; + else if (state == pending && !delay) { + send_pipe_term_ack (peer); + state = terminating; + } + + // If there are pending messages still availabe, do nothing. + else if (state == pending && delay) { } // We've already got delimiter, but not term command yet. We can ignore @@ -338,8 +345,7 @@ void zmq::pipe_t::terminate () else zmq_assert (false); - // Stop inbound and outbound flow of messages. - in_active = false; + // Stop outbound flow of messages. out_active = false; // Rollback any unfinished outbound messages. -- cgit v1.2.3