don't error if pipe is already closed.

pull/1086/head
Darien Raymond 2018-04-23 16:26:29 +02:00
parent 97341693f3
commit a0dc8d19fa
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 9 additions and 7 deletions

View File

@ -37,13 +37,13 @@ func (p *pipe) getState(forRead bool) error {
} }
return nil return nil
case closed: case closed:
if forRead { if !forRead {
if !p.data.IsEmpty() { return io.ErrClosedPipe
return nil
}
return io.EOF
} }
return io.ErrClosedPipe if !p.data.IsEmpty() {
return nil
}
return io.EOF
case errord: case errord:
return io.ErrClosedPipe return io.ErrClosedPipe
default: default:
@ -139,7 +139,9 @@ func (p *pipe) CloseError() {
p.Lock() p.Lock()
defer p.Unlock() defer p.Unlock()
p.state = errord if p.state == closed || p.state == errord {
return
}
if !p.data.IsEmpty() { if !p.data.IsEmpty() {
p.data.Release() p.data.Release()