From ac08beb5821294e78daa8d6fd1fb9579fcbc9525 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Fri, 21 Aug 2015 14:54:32 -0400
Subject: [PATCH] dht: search own id

---
 include/opendht/dht.h | 4 ++--
 src/dht.cpp           | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/opendht/dht.h b/include/opendht/dht.h
index e062f8ef..524e4f43 100644
--- a/include/opendht/dht.h
+++ b/include/opendht/dht.h
@@ -240,13 +240,13 @@ public:
      * @param f a filter function used to prefilter values.
      */
     void get(const InfoHash& key, GetCallback cb, DoneCallback donecb=nullptr, Value::Filter f = Value::AllFilter());
-    void get(const InfoHash& key, GetCallback cb, DoneCallbackSimple donecb=nullptr, Value::Filter f = Value::AllFilter()) {
+    void get(const InfoHash& key, GetCallback cb, DoneCallbackSimple donecb, Value::Filter f = Value::AllFilter()) {
         get(key, cb, bindDoneCb(donecb), f);
     }
     void get(const InfoHash& key, GetCallbackSimple cb, DoneCallback donecb=nullptr, Value::Filter f = Value::AllFilter()) {
         get(key, bindGetCb(cb), donecb, f);
     }
-    void get(const InfoHash& key, GetCallbackSimple cb, DoneCallbackSimple donecb=nullptr, Value::Filter f = Value::AllFilter()) {
+    void get(const InfoHash& key, GetCallbackSimple cb, DoneCallbackSimple donecb, Value::Filter f = Value::AllFilter()) {
         get(key, bindGetCb(cb), bindDoneCb(donecb), f);
     }
 
diff --git a/src/dht.cpp b/src/dht.cpp
index 3a0e1f79..bf609fc5 100644
--- a/src/dht.cpp
+++ b/src/dht.cpp
@@ -2531,6 +2531,10 @@ Dht::periodic(const uint8_t *buf, size_t buflen,
     if (now >= confirm_nodes_time) {
         bool soon = false;
 
+        if (searches.empty()) {
+            get(myid, GetCallbackSimple{});
+        }
+
         soon |= bucketMaintenance(buckets);
         soon |= bucketMaintenance(buckets6);
 
-- 
GitLab