From bd08506146eabe95d4b8eaef378a963fcd1e964b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Fri, 27 May 2016 15:39:48 -0400
Subject: [PATCH] dht: wait for connection before running searches

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

diff --git a/src/dht.cpp b/src/dht.cpp
index 2b4a1565..d2cc5376 100644
--- a/src/dht.cpp
+++ b/src/dht.cpp
@@ -722,6 +722,8 @@ void
 Dht::searchStep(std::shared_ptr<Search> sr)
 {
     if (not sr or sr->expired or sr->done) return;
+    if (sr->nodes.empty() and (sr->af == AF_INET ? buckets : buckets6).isEmpty())
+        return; // wait for connection
 
     const auto& now = scheduler.time();
     DHT_LOG.DEBUG("[search %s IPv%c] step (%d requests)", sr->id.toString().c_str(), sr->af == AF_INET ? '4' : '6', sr->currentGetRequests());
-- 
GitLab