From 8c9595effe514068c8f051b06636ab6b5cf7e67a Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Thu, 5 Apr 2012 05:46:32 +0200 Subject: Allow pipe_t::flush() to be called from pipe_t::terminate() Previous patch have broken flushing a delimiter in pipe_t::terminate() function. This patch allows the flush to happen even if pipe state is set to 'terminated'. Signed-off-by: Martin Sustrik --- src/pipe.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/pipe.cpp') diff --git a/src/pipe.cpp b/src/pipe.cpp index 77893d2..0a15cc0 100644 --- a/src/pipe.cpp +++ b/src/pipe.cpp @@ -346,9 +346,9 @@ void xs::pipe_t::terminate (bool delay_) // 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 && !delay) { - outpipe = NULL; - send_pipe_term_ack (peer); - state = terminating; + outpipe = NULL; + send_pipe_term_ack (peer); + state = terminating; } // If there are pending messages still availabe, do nothing. @@ -381,7 +381,8 @@ void xs::pipe_t::terminate (bool delay_) msg_t msg; msg.init_delimiter (); outpipe->write (msg, false); - flush (); + if (state != terminating && !outpipe->flush ()) + send_activate_read (peer); } } -- cgit v1.2.3