From 5bd88533feca9057db79ae9ea3860cd4dca8b41e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Tue, 12 Jun 2018 16:49:42 -0400 Subject: [PATCH] SearchNode: refresh token in Query, Listen answers --- src/dht.cpp | 7 +++---- src/search.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/dht.cpp b/src/dht.cpp index 5c07d4c6..17866cc6 100644 --- a/src/dht.cpp +++ b/src/dht.cpp @@ -410,10 +410,11 @@ void Dht::searchSendAnnounceValue(const Sp<Search>& sr) { { /* on probing done */ auto sr = ws.lock(); if (not sr) return; + const auto& now = scheduler.time(); + sr->insertNode(req.node, scheduler.time(), answer.ntoken); auto sn = sr->getNode(req.node); if (not sn) return; - const auto& now = scheduler.time(); if (not sn->isSynced(now)) { /* Search is now unsynced. Let's call searchStep to sync again. */ scheduler.edit(sr->nextSearchStep, now); @@ -539,6 +540,7 @@ Dht::searchSynchedNodeListen(const Sp<Search>& sr, SearchNode& n) { /* on new values */ if (auto sr = ws.lock()) { scheduler.edit(sr->nextSearchStep, scheduler.time()); + sr->insertNode(req.node, scheduler.time(), answer.ntoken); if (auto sn = sr->getNode(node)) { sn->onValues(query, std::move(answer), types, scheduler); } @@ -2361,9 +2363,6 @@ Dht::onAnnounceDone(const Sp<Node>& node, net::RequestAnswer& answer, Sp<Search> DHT_LOG.d(sr->id, node->id, "[search %s] [node %s] got reply to put!", sr->id.toString().c_str(), node->toString().c_str()); searchSendGetValues(sr); - /* if (auto sn = sr->getNode(req->node)) { */ - /* sn->setRefreshTime(answer.vid, now + answer) */ - /* } */ sr->checkAnnounced(answer.vid); } diff --git a/src/search.h b/src/search.h index 7244981f..ec48f642 100644 --- a/src/search.h +++ b/src/search.h @@ -302,7 +302,7 @@ struct Dht::SearchNode { return isListening(now, ls); } bool isListening(time_point now, NodeListenerStatus::const_iterator listen_status) const { - if (listen_status == listenStatus.end()) + if (listen_status == listenStatus.end() or not listen_status->second.req) return false; return listen_status->second.req->reply_time + LISTEN_EXPIRE_TIME > now; } -- GitLab