From a0dc8d19fa715617555ced49bd2fa856a226be8e Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Mon, 23 Apr 2018 16:26:29 +0200 Subject: [PATCH] don't error if pipe is already closed. --- transport/pipe/impl.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/transport/pipe/impl.go b/transport/pipe/impl.go index 8956bc18..7299f6c5 100644 --- a/transport/pipe/impl.go +++ b/transport/pipe/impl.go @@ -37,13 +37,13 @@ func (p *pipe) getState(forRead bool) error { } return nil case closed: - if forRead { - if !p.data.IsEmpty() { - return nil - } - return io.EOF + if !forRead { + return io.ErrClosedPipe } - return io.ErrClosedPipe + if !p.data.IsEmpty() { + return nil + } + return io.EOF case errord: return io.ErrClosedPipe default: @@ -139,7 +139,9 @@ func (p *pipe) CloseError() { p.Lock() defer p.Unlock() - p.state = errord + if p.state == closed || p.state == errord { + return + } if !p.data.IsEmpty() { p.data.Release()