]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Avoid double-panic in full_stack_target to assist debugging 2018-10-peer-free-panic
authorMatt Corallo <git@bluematt.me>
Fri, 2 Nov 2018 14:54:25 +0000 (10:54 -0400)
committerMatt Corallo <git@bluematt.me>
Fri, 2 Nov 2018 14:54:25 +0000 (10:54 -0400)
fuzz/fuzz_targets/full_stack_target.rs

index 19b3e843ae6706c7ef99d095b76b0c736b8a22c5..f943945531e834a854ebca0927288c57e46c108b 100644 (file)
@@ -209,15 +209,17 @@ impl<'a> MoneyLossDetector<'a> {
 
 impl<'a> Drop for MoneyLossDetector<'a> {
        fn drop(&mut self) {
-               // Disconnect all peers
-               for (idx, peer) in self.peers.borrow().iter().enumerate() {
-                       if *peer {
-                               self.handler.disconnect_event(&Peer{id: idx as u8, peers_connected: &self.peers});
+               if !::std::thread::panicking() {
+                       // Disconnect all peers
+                       for (idx, peer) in self.peers.borrow().iter().enumerate() {
+                               if *peer {
+                                       self.handler.disconnect_event(&Peer{id: idx as u8, peers_connected: &self.peers});
+                               }
                        }
-               }
 
-               // Force all channels onto the chain (and time out claim txn)
-               self.manager.force_close_all_channels();
+                       // Force all channels onto the chain (and time out claim txn)
+                       self.manager.force_close_all_channels();
+               }
        }
 }