network: fix unregistration on peer Disconnect
It should always signal to the server, not duplicating this send and not missing it like it happened in the Server.run().
This commit is contained in:
parent
907a236285
commit
f39d5d5a10
1 changed files with 1 additions and 2 deletions
|
@ -109,7 +109,6 @@ func (p *TCPPeer) handleConn() {
|
|||
}
|
||||
}
|
||||
}
|
||||
p.server.unregister <- peerDrop{p, err}
|
||||
p.Disconnect(err)
|
||||
}
|
||||
|
||||
|
@ -171,7 +170,6 @@ func (p *TCPPeer) StartProtocol() {
|
|||
}
|
||||
}
|
||||
if err != nil {
|
||||
p.server.unregister <- peerDrop{p, err}
|
||||
timer.Stop()
|
||||
p.Disconnect(err)
|
||||
return
|
||||
|
@ -284,6 +282,7 @@ func (p *TCPPeer) Done() chan error {
|
|||
|
||||
// Disconnect will fill the peer's done channel with the given error.
|
||||
func (p *TCPPeer) Disconnect(err error) {
|
||||
p.server.unregister <- peerDrop{p, err}
|
||||
p.conn.Close()
|
||||
select {
|
||||
case p.done <- err:
|
||||
|
|
Loading…
Reference in a new issue