Skip to content

Commit

Permalink
Fix locking when downloading RIS dump files (#1177)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Bruijnzeels committed Dec 21, 2023
1 parent 46feb1e commit ee74834
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/commons/bgp/analyser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ impl BgpAnalyser {

pub async fn update(&self) -> Result<bool, BgpAnalyserError> {
if let Some(loader) = &self.dump_loader {
let mut seen = self.seen.write().await;
if let Some(last_time) = seen.last_checked() {
if (last_time + Duration::minutes(BGP_RIS_REFRESH_MINUTES)) > Time::now() {
trace!("Will not check BGP Ris Dumps until the refresh interval has passed");
return Ok(false); // no need to update yet
{
let seen = self.seen.read().await;
if let Some(last_time) = seen.last_checked() {
if (last_time + Duration::minutes(BGP_RIS_REFRESH_MINUTES)) > Time::now() {
trace!("Will not check BGP Ris Dumps until the refresh interval has passed");
return Ok(false); // no need to update yet
}
}
}
let announcements = loader.download_updates().await?;
let mut seen = self.seen.write().await;
if seen.equivalent(&announcements) {
debug!("BGP Ris Dumps unchanged");
seen.update_checked();
Expand Down

0 comments on commit ee74834

Please sign in to comment.