From f7681cb51df90a5fcaf9f0d6e2707ac5f30f8a28 Mon Sep 17 00:00:00 2001 From: eugene Date: Tue, 21 Jun 2022 16:28:00 -0400 Subject: [PATCH] server.go: replace call to removePeer with Disconnect in DisconnectPeer Without this, calls to DisconnectPeer would bypass the peerTerminationWatcher and allow subsequent connect requests to go through before the peer's links were fully shut down. This could lead to force closes. --- server.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/server.go b/server.go index 7ee149fbb..90cf60444 100644 --- a/server.go +++ b/server.go @@ -4217,11 +4217,9 @@ func (s *server) DisconnectPeer(pubKey *btcec.PublicKey) error { delete(s.persistentPeers, pubStr) delete(s.persistentPeersBackoff, pubStr) - // Remove the current peer from the server's internal state and signal - // that the peer termination watcher does not need to execute for this - // peer. - s.removePeer(peer) - s.ignorePeerTermination[peer] = struct{}{} + // Remove the peer by calling Disconnect. Previously this was done with + // removePeer, which bypassed the peerTerminationWatcher. + peer.Disconnect(fmt.Errorf("server: DisconnectPeer called")) return nil }