Skip to content

Commit 409561a

Browse files
committed
lnd: rename removePeer to removePeerUnsafe
rename `removePeer` to highlight that the mutex has to be acquired before calling it.
1 parent 0151993 commit 409561a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

server.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4091,7 +4091,7 @@ func (s *server) InboundPeerConnected(conn net.Conn) {
40914091
// Remove the current peer from the server's internal state and
40924092
// signal that the peer termination watcher does not need to
40934093
// execute for this peer.
4094-
s.removePeer(connectedPeer)
4094+
s.removePeerUnsafe(connectedPeer)
40954095
s.ignorePeerTermination[connectedPeer] = struct{}{}
40964096
s.scheduledPeerConnection[pubStr] = func() {
40974097
s.peerConnected(conn, nil, true)
@@ -4208,7 +4208,7 @@ func (s *server) OutboundPeerConnected(connReq *connmgr.ConnReq, conn net.Conn)
42084208
// Remove the current peer from the server's internal state and
42094209
// signal that the peer termination watcher does not need to
42104210
// execute for this peer.
4211-
s.removePeer(connectedPeer)
4211+
s.removePeerUnsafe(connectedPeer)
42124212
s.ignorePeerTermination[connectedPeer] = struct{}{}
42134213
s.scheduledPeerConnection[pubStr] = func() {
42144214
s.peerConnected(conn, connReq, false)
@@ -4730,7 +4730,7 @@ func (s *server) peerTerminationWatcher(p *peer.Brontide, ready chan struct{}) {
47304730

47314731
// First, cleanup any remaining state the server has regarding the peer
47324732
// in question.
4733-
s.removePeer(p)
4733+
s.removePeerUnsafe(p)
47344734

47354735
// Next, check to see if this is a persistent peer or not.
47364736
if _, ok := s.persistentPeers[pubStr]; !ok {
@@ -4939,11 +4939,11 @@ func (s *server) connectToPersistentPeer(pubKeyStr string) {
49394939
}()
49404940
}
49414941

4942-
// removePeer removes the passed peer from the server's state of all active
4943-
// peers.
4942+
// removePeerUnsafe removes the passed peer from the server's state of all
4943+
// active peers.
49444944
//
49454945
// NOTE: Server mutex must be held when calling this function.
4946-
func (s *server) removePeer(p *peer.Brontide) {
4946+
func (s *server) removePeerUnsafe(p *peer.Brontide) {
49474947
if p == nil {
49484948
return
49494949
}
@@ -5147,7 +5147,7 @@ func (s *server) DisconnectPeer(pubKey *btcec.PublicKey) error {
51475147
delete(s.persistentPeersBackoff, pubStr)
51485148

51495149
// Remove the peer by calling Disconnect. Previously this was done with
5150-
// removePeer, which bypassed the peerTerminationWatcher.
5150+
// removePeerUnsafe, which bypassed the peerTerminationWatcher.
51515151
//
51525152
// NOTE: We call it in a goroutine to avoid blocking the main server
51535153
// goroutine because we might hold the server's mutex.

0 commit comments

Comments
 (0)