peerwithTokenService no longer uses Leave so as to preserve lock
This commit is contained in:
parent
ff012313be
commit
13811def94
|
@ -157,9 +157,7 @@ func (e *engine) eventHandler() {
|
||||||
}
|
}
|
||||||
go e.peerWithTokenServer(ev.Data[event.GroupServer], ev.Data[event.ServerTokenOnion], ev.Data[event.ServerTokenY], signature)
|
go e.peerWithTokenServer(ev.Data[event.GroupServer], ev.Data[event.ServerTokenOnion], ev.Data[event.ServerTokenY], signature)
|
||||||
case event.LeaveServer:
|
case event.LeaveServer:
|
||||||
e.ephemeralServicesLock.Lock()
|
|
||||||
e.leaveServer(ev.Data[event.GroupServer])
|
e.leaveServer(ev.Data[event.GroupServer])
|
||||||
e.ephemeralServicesLock.Unlock()
|
|
||||||
case event.DeleteContact:
|
case event.DeleteContact:
|
||||||
onion := ev.Data[event.RemotePeer]
|
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.
|
// 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
|
return
|
||||||
}
|
}
|
||||||
// Otherwise...we are going to rebuild the connection(which will result in a bandwidth heavy resync)...
|
// 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
|
// 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
|
// 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) {
|
func (e *engine) leaveServer(server string) {
|
||||||
|
e.ephemeralServicesLock.Lock()
|
||||||
|
defer e.ephemeralServicesLock.Unlock()
|
||||||
ephemeralService, ok := e.ephemeralServices[server]
|
ephemeralService, ok := e.ephemeralServices[server]
|
||||||
if ok {
|
if ok {
|
||||||
ephemeralService.service.Shutdown()
|
ephemeralService.service.Shutdown()
|
||||||
|
|
Loading…
Reference in New Issue