Skip to content

Commit

Permalink
Update the current snapshot even if there is no delta. (#940)
Browse files Browse the repository at this point in the history
This PR fixes an issue with calculating the refresh time under certain
conditions by updating the current internal payload snapshot even if the
delta to the previous snapshot is empty.

Because this snapshot also contains the expiry time of certificate first to
expire and this time is used as the refresh time if it is closer than the
configure refresh time (so the date derived from the expired certificate is
removed as soon as possible), not updating the snapshot can lead to a
refresh time in the past (effectively: an immediate refresh) if there is a
second, longer living object for an expiring object.
  • Loading branch information
partim committed Mar 21, 2024
1 parent f1e85a7 commit 7774129
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/payload/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,28 @@ impl SharedHistory {

let mut history = self.write();
history.metrics = Some(metrics.into());
if let Some(delta) = delta {
let res = if let Some(delta) = delta {
// Data has changed.
info!(
"Delta with {} announced and {} withdrawn items.",
delta.announce_len(),
delta.withdraw_len(),
);
history.current = Some(snapshot.into());
history.push_delta(delta);
true
}
else if current.is_none() {
// This is the first snapshot ever.
history.current = Some(snapshot.into());
true
}
else {
// Nothing has changed.
false
}
};
// Update the snapshot. The refresh time and object information may
// have changed.
history.current = Some(snapshot.into());
res
}

/// Marks the beginning of an update cycle.
Expand Down

0 comments on commit 7774129

Please sign in to comment.