mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
[NOD-1285] Fix deadlock on connection manager (#880)
This commit is contained in:
parent
8dd409dc1c
commit
8dae378bd9
@ -89,22 +89,24 @@ func (c *ConnectionManager) AddConnectionRequest(address string, isPermanent boo
|
||||
// spawn goroutine so that caller doesn't wait in case connectionManager is in the midst of handling
|
||||
// connection requests
|
||||
spawn("ConnectionManager.AddConnectionRequest", func() {
|
||||
c.connectionRequestsLock.Lock()
|
||||
defer c.connectionRequestsLock.Unlock()
|
||||
|
||||
if _, ok := c.activeRequested[address]; ok {
|
||||
return
|
||||
}
|
||||
|
||||
c.pendingRequested[address] = &connectionRequest{
|
||||
address: address,
|
||||
isPermanent: isPermanent,
|
||||
}
|
||||
|
||||
c.addConnectionRequest(address, isPermanent)
|
||||
c.run()
|
||||
})
|
||||
}
|
||||
|
||||
func (c *ConnectionManager) addConnectionRequest(address string, isPermanent bool) {
|
||||
c.connectionRequestsLock.Lock()
|
||||
defer c.connectionRequestsLock.Unlock()
|
||||
if _, ok := c.activeRequested[address]; ok {
|
||||
return
|
||||
}
|
||||
|
||||
c.pendingRequested[address] = &connectionRequest{
|
||||
address: address,
|
||||
isPermanent: isPermanent,
|
||||
}
|
||||
}
|
||||
|
||||
// RemoveConnection disconnects the connection for the given address
|
||||
// and removes it entirely from the connection manager.
|
||||
func (c *ConnectionManager) RemoveConnection(address string) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user