From 7919ca8de1647bbdd5ed5210811252596c29f457 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Fri, 26 Aug 2016 17:55:50 -0400
Subject: [PATCH] dht: fail pending operations before clearing them

---
 src/dht.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/dht.cpp b/src/dht.cpp
index 96228371..655240a2 100644
--- a/src/dht.cpp
+++ b/src/dht.cpp
@@ -461,6 +461,17 @@ struct Dht::Search {
     std::map<size_t, LocalListener> listeners {};
     size_t listener_token = 1;
 
+    ~Search() {
+        for (auto& get : callbacks) {
+            get.second.done_cb(false, {});
+            get.second.done_cb = {};
+        }
+        for (auto& put : announce) {
+            put.callback(false, {});
+            put.callback = {};
+        }
+    }
+
     /**
      * @returns true if the node was not present and added to the search
      */
-- 
GitLab