Skip to content

Commit 5b5dde9

Browse files
committed
fix: Potential send on closed channel
1 parent eaacbca commit 5b5dde9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

peer/channel.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ func (c *Channel) init() {
106106
// write operations to block once the threshold is set.
107107
c.dc.SetBufferedAmountLowThreshold(bufferedAmountLowThreshold)
108108
c.dc.OnBufferedAmountLow(func() {
109+
// Grab the lock to protect the sendMore channel from being
110+
// closed in between the isClosed check and the send.
111+
c.closeMutex.Lock()
112+
defer c.closeMutex.Unlock()
109113
if c.isClosed() {
110114
return
111115
}

0 commit comments

Comments
 (0)