From 8c04ddc66b6272bc0bec57ab67fd5c04f7357962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Sun, 23 Oct 2016 14:58:15 -0400 Subject: [PATCH] dht use proper value type to compute expiration --- src/dht.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dht.cpp b/src/dht.cpp index 765cc039..09bc3eef 100644 --- a/src/dht.cpp +++ b/src/dht.cpp @@ -2207,8 +2207,14 @@ Dht::storageStore(const InfoHash& id, const std::shared_ptr<Value>& value, time_ const auto& now = scheduler.time(); created = std::min(created, now); - if (created + getType(value->id).expiration < clock::now()) + auto expiration = created + getType(value->type).expiration; + if (expiration < now) { + using namespace std::chrono; + DHT_LOG_WARN("[store %s] won't store already expired value (created %lld s ago, expired %lld s ago)", + id.toString().c_str(), duration_cast<seconds>(now - created).count(), + duration_cast<seconds>(now - expiration).count()); return false; + } auto st = store.find(id); if (st == store.end()) { -- GitLab