server: eliminate possibly deadlock, peerConnected now async
This commit eliminates a possible deadlock (or repeated peer connection failures) that can arise due to the [inbound|outbound]PeerConnected methods holding the peer mutex too long. We now alleviate this concurrency issue by calling s.peerConnected in an asynchronous manner. This is safe as all operations within the method are themselves goroutine-safe.
This commit is contained in:
parent
35c9a12a73
commit
a22ba92630
@ -644,7 +644,7 @@ func (s *server) inboundPeerConnected(conn net.Conn) {
|
|||||||
}
|
}
|
||||||
s.pendingConnMtx.RUnlock()
|
s.pendingConnMtx.RUnlock()
|
||||||
|
|
||||||
s.peerConnected(conn, nil, false)
|
go s.peerConnected(conn, nil, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// outboundPeerConnected initializes a new peer in response to a new outbound
|
// outboundPeerConnected initializes a new peer in response to a new outbound
|
||||||
@ -669,7 +669,7 @@ func (s *server) outboundPeerConnected(connReq *connmgr.ConnReq, conn net.Conn)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
s.peerConnected(conn, connReq, true)
|
go s.peerConnected(conn, connReq, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// addPeer adds the passed peer to the server's global state of all active
|
// addPeer adds the passed peer to the server's global state of all active
|
||||||
|
Loading…
Reference in New Issue
Block a user