1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-05 00:47:51 -05:00

don't error if pipe is already closed.

This commit is contained in:
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

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 {
return io.ErrClosedPipe
}
if !p.data.IsEmpty() { if !p.data.IsEmpty() {
return nil return nil
} }
return io.EOF return io.EOF
}
return io.ErrClosedPipe
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()