]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Dont treat a timer tick as no_connection_possible and log 2020-02-ping-connection-possible
authorMatt Corallo <git@bluematt.me>
Mon, 24 Feb 2020 23:47:38 +0000 (18:47 -0500)
committerMatt Corallo <git@bluematt.me>
Thu, 27 Feb 2020 20:46:52 +0000 (15:46 -0500)
In testing, due to other patches, I managed to flood the send queue
with messages and cause us not to be able to send pings, thus
getting a peer disconnected for ping timeout. To my surprise, this
also force-closed all of my channels with that peeer.

Obviously a ping timeout does not indicate that no future connection
with said peer will be possible, and we shouldn't be force-closing
channels as a result.

This also logs when a peer is disconnected to ping timeout to make
debug easier.

lightning/src/ln/peer_handler.rs

index 049aae7015a905d9508e05c1bd33768e5d7c6df0..29e67e6ba999e054b123927fdf4538099b5bb096 100644 (file)
@@ -1089,10 +1089,15 @@ impl<Descriptor: SocketDescriptor, CM: Deref> PeerManager<Descriptor, CM> where
                                        descriptors_needing_disconnect.push(descriptor.clone());
                                        match peer.their_node_id {
                                                Some(node_id) => {
+                                                       log_trace!(self, "Disconnecting peer with id {} due to ping timeout", node_id);
                                                        node_id_to_descriptor.remove(&node_id);
-                                                       self.message_handler.chan_handler.peer_disconnected(&node_id, true);
+                                                       self.message_handler.chan_handler.peer_disconnected(&node_id, false);
                                                }
-                                               None => {}
+                                               None => {
+                                                       // This can't actually happen as we should have hit
+                                                       // is_ready_for_encryption() previously on this same peer.
+                                                       unreachable!();
+                                               },
                                        }
                                        return false;
                                }