From 064661f20d9ff6e7144638de0172a7c5937a54e3 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 10 Dec 2023 14:55:44 -0500 Subject: [PATCH] expiration work --- veilid-core/src/storage_manager/mod.rs | 16 ++++++++++++---- veilid-core/src/storage_manager/watch_value.rs | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/veilid-core/src/storage_manager/mod.rs b/veilid-core/src/storage_manager/mod.rs index 4abe128d..31b5e48f 100644 --- a/veilid-core/src/storage_manager/mod.rs +++ b/veilid-core/src/storage_manager/mod.rs @@ -627,16 +627,24 @@ impl StorageManager { opened_record.clear_active_watch(); // Get the minimum expiration timestamp we will accept - let rpc_timeout_us = { + let (rpc_timeout_us, max_watch_expiration_us) = { let c = self.unlocked_inner.config.get(); - TimestampDuration::from(ms_to_us(c.network.rpc.timeout_ms)) + ( + TimestampDuration::from(ms_to_us(c.network.rpc.timeout_ms)), + TimestampDuration::from(ms_to_us(c.network.dht.max_watch_expiration_ms)), + ) }; let cur_ts = get_timestamp(); let min_expiration_ts = cur_ts + rpc_timeout_us.as_u64(); + let max_expiration_ts = if expiration.as_u64() == 0 { + cur_ts + max_watch_expiration_us.as_u64() + } else { + expiration.as_u64() + }; - // If the expiration time is less than our minimum expiration time or greater than the requested time, consider this watch cancelled + // If the expiration time is less than our minimum expiration time or greater than the maximum time, consider this watch cancelled if owvresult.expiration_ts.as_u64() < min_expiration_ts - || owvresult.expiration_ts.as_u64() > expiration.as_u64() + || owvresult.expiration_ts.as_u64() > max_expiration_ts { // Don't set the watch so we ignore any stray valuechanged messages return Ok(Timestamp::new(0)); diff --git a/veilid-core/src/storage_manager/watch_value.rs b/veilid-core/src/storage_manager/watch_value.rs index c448ebc2..f945c781 100644 --- a/veilid-core/src/storage_manager/watch_value.rs +++ b/veilid-core/src/storage_manager/watch_value.rs @@ -88,7 +88,7 @@ impl StorageManager { if wva.answer.expiration_ts.as_u64() > 0 { if count > 0 { // If we asked for a nonzero notification count, then this is an accepted watch - log_stor!(debug "Watch accepted: expiration_ts={}", wva.answer.expiration_ts); + log_stor!(debug "Watch accepted: expiration_ts={}", debug_ts(wva.answer.expiration_ts.as_u64())); } else { // If we asked for a zero notification count, then this is a cancelled watch log_stor!(debug "Watch cancelled");