Skip to content

Commit

Permalink
Merge pull request #1184 from nats-io/1183
Browse files Browse the repository at this point in the history
[FIXED] Clustering: possible panic on shutdown
  • Loading branch information
kozlovic committed Apr 26, 2021
2 parents 379bb2d + 06a7ebc commit f9e5bcf
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions server/raft_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,20 @@ func (n *natsConn) onMsg(msg *nats.Msg) {
return
}
pb.buf = msg.Data
var notify bool
if n.pendingT != nil {
n.pendingT.next = pb
} else {
n.pendingH = pb
notify = true
}
n.pendingT = pb
n.mu.Unlock()

if notify {
// Need to notify under the lock since this channel gets closed
// on natsConn.close(), which could then cause a panic of
// "send on closed channel".
select {
case n.ch <- struct{}{}:
default:
}
}
n.pendingT = pb
n.mu.Unlock()
}

func (n *natsConn) Read(b []byte) (int, error) {
Expand Down

0 comments on commit f9e5bcf

Please sign in to comment.