Skip to content

Commit a108baa

Browse files
authored
network: call erlIPClient.m.Unlock() before calling OnClose() (#6451)
1 parent 32ab091 commit a108baa

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

data/txHandler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,13 +707,16 @@ func (eic *erlIPClient) OnClose(f func()) {
707707
// by adding a helper closer function to track connection closures
708708
func (eic *erlIPClient) register(ec util.ErlClient) {
709709
eic.m.Lock()
710-
defer eic.m.Unlock()
711710
if _, has := eic.clients[ec]; has {
712711
// this peer is known => noop
712+
eic.m.Unlock()
713713
return
714714
}
715715
eic.clients[ec] = struct{}{}
716+
eic.m.Unlock()
716717

718+
// Register the OnClose callback without holding eic.m to avoid
719+
// lock ordering deadlock with wsPeer.closersMu
717720
ec.OnClose(func() {
718721
eic.connClosed(ec)
719722
})

0 commit comments

Comments
 (0)