]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Ensure handlers see a consistent set of peers on conn rejection 2023-10-peer-race-send-discon-test
authorMatt Corallo <git@bluematt.me>
Fri, 13 Oct 2023 19:55:24 +0000 (19:55 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 18 Oct 2023 20:07:06 +0000 (20:07 +0000)
If a message handler decides to reject a connection, other handlers
should see the disconnection if they've already seen the
connection. We weren't previously doing that, and do it here.

lightning/src/ln/peer_handler.rs

index 77087f38cff2ef50a329046b385aefe24db1bb6d..4298f715146be656ec65d7dca116b28d369bd306 100644 (file)
@@ -1561,10 +1561,13 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
                        }
                        if let Err(()) = self.message_handler.onion_message_handler.peer_connected(&their_node_id, &msg, peer_lock.inbound_connection) {
                                log_debug!(self.logger, "Onion Message Handler decided we couldn't communicate with peer {}", log_pubkey!(their_node_id));
+                               self.message_handler.chan_handler.peer_disconnected(&their_node_id);
                                return Err(PeerHandleError { }.into());
                        }
                        if let Err(()) = self.message_handler.custom_message_handler.peer_connected(&their_node_id, &msg, peer_lock.inbound_connection) {
                                log_debug!(self.logger, "Custom Message Handler decided we couldn't communicate with peer {}", log_pubkey!(their_node_id));
+                               self.message_handler.onion_message_handler.peer_disconnected(&their_node_id);
+                               self.message_handler.chan_handler.peer_disconnected(&their_node_id);
                                return Err(PeerHandleError { }.into());
                        }