peerwithTokenService no longer uses Leave so as to preserve lock
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Dan Ballard 2021-12-17 22:52:53 -05:00
parent ff012313be
commit 13811def94
1 changed files with 3 additions and 5 deletions

View File

@ -157,9 +157,7 @@ func (e *engine) eventHandler() {
}
go e.peerWithTokenServer(ev.Data[event.GroupServer], ev.Data[event.ServerTokenOnion], ev.Data[event.ServerTokenY], signature)
case event.LeaveServer:
e.ephemeralServicesLock.Lock()
e.leaveServer(ev.Data[event.GroupServer])
e.ephemeralServicesLock.Unlock()
case event.DeleteContact:
onion := ev.Data[event.RemotePeer]
// We remove this peer from out blocklist which will prevent them from contacting us if we have "block unknown peers" turned on.
@ -336,7 +334,7 @@ func (e *engine) peerWithTokenServer(onion string, tokenServerOnion string, toke
return
}
// Otherwise...we are going to rebuild the connection(which will result in a bandwidth heavy resync)...
e.leaveServer(onion)
connectionService.service.Shutdown()
}
// Otherwise...let's reconnect
}
@ -634,9 +632,9 @@ func (e *engine) handlePeerRetVal(hostname string, getValData, retValData []byte
}
// leaveServer disconnects from a server and deletes the ephemeral service
// REQUIREMENTS: must be called inside a block with e.ephemeralServicesLock.Lock()
// can't do it iself because is called from inside peerWithTokenServer which holds the lock
func (e *engine) leaveServer(server string) {
e.ephemeralServicesLock.Lock()
defer e.ephemeralServicesLock.Unlock()
ephemeralService, ok := e.ephemeralServices[server]
if ok {
ephemeralService.service.Shutdown()