Skip to content

Commit

Permalink
fix: close closed chan in pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
nange committed Aug 1, 2024
1 parent 270b4eb commit 54abadd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions util/netpipe/pipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,18 @@ func (p *pipe) Close() error {
p.cond.L.Lock()
defer p.cond.L.Unlock()

p.closed = true
if !p.closed {
p.closed = true
close(p.closing)
}

p.buf.CloseWithError(ErrPipeClosed)
p.cond.Broadcast()
if len(p.back) > 0 {
bytespool.MustPut(p.back)
p.back = nil
}
close(p.closing)

return nil
}

Expand Down

0 comments on commit 54abadd

Please sign in to comment.