mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 12:28:42 +00:00
dht: fix persisted permanent values never expiring
When values are exported and re-imported, permanent values retain their time_point::max() expiration but lose their permanent flag. This caused them to be stored as non-permanent with an effectively infinite expiration, so they would never expire. Cap the expiration of non-permanent values to created + type.expiration, ensuring that imported permanent values get a finite expiration matching their value type.
This commit is contained in:
1 parent
3ff9338980
commit
a363d573e3
1 file changed
+2
@@ -1432,6 +1432,8 @@ Dht::storageStore(const InfoHash& id,
|
||||
created = std::min(created, now);
|
||||
if (expiration == time_point::min())
|
||||
expiration = permanent ? time_point::max() : created + getType(value->type).expiration;
|
||||
else if (not permanent)
|
||||
expiration = std::min(expiration, created + getType(value->type).expiration);
|
||||
if (expiration < now)
|
||||
return false;
|
||||
|
||||
|
||||
Reference in new issue
Block a user