From 259986e786eb27be401d3cd7123c67d21d0baab8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Sun, 1 Dec 2019 14:10:11 -0500
Subject: [PATCH] network engine: don't throw in case of unknown transaction

---
 src/dht.cpp            | 5 ++---
 src/network_engine.cpp | 5 +++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/dht.cpp b/src/dht.cpp
index dfa0558e..312e1512 100644
--- a/src/dht.cpp
+++ b/src/dht.cpp
@@ -78,8 +78,7 @@ Dht::shutdown(ShutdownCallback cb)
 
     if (!*remaining) {
         DHT_LOG.w("shuting down node: %u ops remaining", *remaining);
-        if (cb)
-            cb();
+        if (cb) cb();
     }
 }
 
@@ -1920,7 +1919,7 @@ Dht::periodic(const uint8_t *buf, size_t buflen, SockAddr from)
         try {
             network_engine.processMessage(buf, buflen, std::move(from));
         } catch (const std::exception& e) {
-            DHT_LOG.e("Can't process message: %s", e.what());
+            DHT_LOG.w("Can't process message: %s", e.what());
         }
     }
     return scheduler.run();
diff --git a/src/network_engine.cpp b/src/network_engine.cpp
index 3530a12b..d15a3e5f 100644
--- a/src/network_engine.cpp
+++ b/src/network_engine.cpp
@@ -246,7 +246,7 @@ NetworkEngine::requestStep(Sp<Request> sreq)
     auto now = scheduler.time();
     auto& node = *req.node;
     if (req.isExpired(now)) {
-        DHT_LOG.d(node.id, "[node %s] expired !", node.toString().c_str());
+        // DHT_LOG.d(node.id, "[node %s] expired !", node.toString().c_str());
         node.setExpired();
         if (not node.id)
             requests.erase(req.tid);
@@ -481,7 +481,8 @@ NetworkEngine::process(std::unique_ptr<ParsedMessage>&& msg, const SockAddr& fro
                 node->received(now, req);
                 if (not node->isClient())
                     onNewNode(node, 1);
-                throw DhtProtocolException {DhtProtocolException::UNKNOWN_TID, "Can't find transaction", msg->id};
+                DHT_LOG.d(node->id, "[node %s] can't find transaction with id %u", node->toString().c_str(), msg->tid);
+                return;
             }
         }
 
-- 
GitLab