expiration work

This commit is contained in:
John Smith 2023-12-10 14:55:44 -05:00 committed by Christien Rioux
parent b6f1e706f7
commit 064661f20d
2 changed files with 13 additions and 5 deletions

View File

@ -627,16 +627,24 @@ impl StorageManager {
opened_record.clear_active_watch(); opened_record.clear_active_watch();
// Get the minimum expiration timestamp we will accept // 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(); 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 cur_ts = get_timestamp();
let min_expiration_ts = cur_ts + rpc_timeout_us.as_u64(); 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 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 // Don't set the watch so we ignore any stray valuechanged messages
return Ok(Timestamp::new(0)); return Ok(Timestamp::new(0));

View File

@ -88,7 +88,7 @@ impl StorageManager {
if wva.answer.expiration_ts.as_u64() > 0 { if wva.answer.expiration_ts.as_u64() > 0 {
if count > 0 { if count > 0 {
// If we asked for a nonzero notification count, then this is an accepted watch // 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 { } else {
// If we asked for a zero notification count, then this is a cancelled watch // If we asked for a zero notification count, then this is a cancelled watch
log_stor!(debug "Watch cancelled"); log_stor!(debug "Watch cancelled");