From 483e5fc20e8c7a936b85525ee29ed1e94422ac86 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Tue, 19 Jul 2016 15:29:29 +0800 Subject: [PATCH] msg/simple: fix wrong condition checking of writing TAG_CLOSE on closing The sd is initialized to -1 and will be resetted to -1 whenever it is invalidated. So "if (sd)" is not reasonable enough to determine whether or not the sd is currently still in use. Signed-off-by: xie xingguo --- src/msg/simple/Pipe.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/msg/simple/Pipe.cc b/src/msg/simple/Pipe.cc index 2c2efb097f7b..835868a36851 100644 --- a/src/msg/simple/Pipe.cc +++ b/src/msg/simple/Pipe.cc @@ -887,7 +887,7 @@ int Pipe::connect() __u32 cseq = connect_seq; __u32 gseq = msgr->get_global_seq(); - // stop reader thrad + // stop reader thread join_reader(); pipe_lock.Unlock(); @@ -1736,7 +1736,7 @@ void Pipe::writer() state = STATE_CLOSED; state_closed.set(1); pipe_lock.Unlock(); - if (sd) { + if (sd >= 0) { // we can ignore return value, actually; we don't care if this succeeds. int r = ::write(sd, &tag, 1); (void)r; -- 2.47.3