From: Matt Corallo Date: Mon, 24 Feb 2020 23:47:38 +0000 (-0500) Subject: Dont treat a timer tick as no_connection_possible and log X-Git-Tag: v0.0.12~117^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=de24150203a7866b34cd090ebda07ad9fbd59f35;p=rust-lightning Dont treat a timer tick as no_connection_possible and log 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. --- diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 049aae70..29e67e6b 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -1089,10 +1089,15 @@ impl PeerManager 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; }