mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-12-25 15:29:32 -05:00
clamp instead of reject max expiration time
This commit is contained in:
parent
9c0c7cf0b2
commit
c33b00fe32
@ -642,14 +642,17 @@ impl StorageManager {
|
|||||||
expiration.as_u64()
|
expiration.as_u64()
|
||||||
};
|
};
|
||||||
|
|
||||||
// If the expiration time is less than our minimum expiration time or greater than the maximum time, consider this watch cancelled
|
// If the expiration time is less than our minimum expiration time consider this watch cancelled
|
||||||
if owvresult.expiration_ts.as_u64() < min_expiration_ts
|
let mut expiration_ts = owvresult.expiration_ts;
|
||||||
|| owvresult.expiration_ts.as_u64() > max_expiration_ts
|
if expiration_ts.as_u64() < min_expiration_ts {
|
||||||
{
|
|
||||||
// Don't set the watch so we ignore any stray valuechanged messages
|
|
||||||
return Ok(Timestamp::new(0));
|
return Ok(Timestamp::new(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the expiration time is greated than our maximum expiration time, clamp our local watch so we ignore extra valuechanged messages
|
||||||
|
if expiration_ts.as_u64() > max_expiration_ts {
|
||||||
|
expiration_ts = Timestamp::new(max_expiration_ts);
|
||||||
|
}
|
||||||
|
|
||||||
// If we requested a cancellation, then consider this watch cancelled
|
// If we requested a cancellation, then consider this watch cancelled
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
return Ok(Timestamp::new(0));
|
return Ok(Timestamp::new(0));
|
||||||
@ -657,7 +660,7 @@ impl StorageManager {
|
|||||||
|
|
||||||
// Keep a record of the watch
|
// Keep a record of the watch
|
||||||
opened_record.set_active_watch(ActiveWatch {
|
opened_record.set_active_watch(ActiveWatch {
|
||||||
expiration_ts: owvresult.expiration_ts,
|
expiration_ts,
|
||||||
watch_node: owvresult.watch_node,
|
watch_node: owvresult.watch_node,
|
||||||
opt_value_changed_route: owvresult.opt_value_changed_route,
|
opt_value_changed_route: owvresult.opt_value_changed_route,
|
||||||
subkeys,
|
subkeys,
|
||||||
|
@ -760,9 +760,12 @@ where
|
|||||||
let cur_ts = get_timestamp();
|
let cur_ts = get_timestamp();
|
||||||
let max_ts = cur_ts + self.limits.max_watch_expiration.as_u64();
|
let max_ts = cur_ts + self.limits.max_watch_expiration.as_u64();
|
||||||
let min_ts = cur_ts + self.limits.min_watch_expiration.as_u64();
|
let min_ts = cur_ts + self.limits.min_watch_expiration.as_u64();
|
||||||
if expiration.as_u64() == 0 {
|
|
||||||
|
if expiration.as_u64() == 0 || expiration.as_u64() > max_ts {
|
||||||
|
// Clamp expiration max time (or set zero expiration to max)
|
||||||
expiration = Timestamp::new(max_ts);
|
expiration = Timestamp::new(max_ts);
|
||||||
} else if expiration.as_u64() < min_ts || expiration.as_u64() > max_ts {
|
} else if expiration.as_u64() < min_ts {
|
||||||
|
// Don't add watches with too low of an expiration time
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user