Skip to content

Commit

Permalink
shouldn't deadlock now
Browse files Browse the repository at this point in the history
  • Loading branch information
tanneberger committed Mar 29, 2024
1 parent bb1e2c9 commit 813fb92
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::sync::atomic::Ordering;
use std::sync::Arc;
use time::{Duration, OffsetDateTime};
use tokio::sync::RwLock;
use tracing::error;

use url::Url;

Expand Down Expand Up @@ -127,7 +128,14 @@ impl NetworkService {
}
}

let new_values = self.fetch_values().await?;
let new_values = match self.fetch_values().await {
Ok(value) => value,
Err(e) => {
error!("couldn't fetch values! because of {e}");
self.updating.store(false, Ordering::Relaxed);
return Err(e);
}
};

*self.cached.write().await = (now + MAX_AGE, new_values.clone());
self.updating.store(false, Ordering::Relaxed);
Expand Down

0 comments on commit 813fb92

Please sign in to comment.