From 92df1f5a2b6713979b9c3b9990e910bc29de2459 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Mon, 2 May 2016 18:42:14 -0400
Subject: [PATCH] dht: recompute step time for existing searches

---
 src/dht.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/dht.cpp b/src/dht.cpp
index 75bd32b2..64980457 100644
--- a/src/dht.cpp
+++ b/src/dht.cpp
@@ -1138,13 +1138,15 @@ Dht::search(const InfoHash& id, sa_family_t af, GetCallback callback, DoneCallba
         if (search_id == 0)
             search_id++;
     }
-    if (not sr->nextSearchStep)
-        sr->nextSearchStep = scheduler.add(scheduler.time(), std::bind(&Dht::searchStep, this, sr));
 
     if (callback)
         sr->callbacks.push_back({.start=scheduler.time(), .filter=filter, .get_cb=callback, .done_cb=done_callback});
-
     bootstrapSearch(*sr);
+
+    if (sr->nextSearchStep)
+        scheduler.edit(sr->nextSearchStep, sr->getNextStepTime(types, scheduler.time()));
+    else
+        sr->nextSearchStep = scheduler.add(scheduler.time(), std::bind(&Dht::searchStep, this, sr));
     return sr;
 }
 
-- 
GitLab