aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-04-05 20:26:01 +0200
committerAlex Auvolat <alex@adnab.me>2021-04-05 20:26:01 +0200
commit595dc0ed0d6994cbe0f628b41df85f44c576dc64 (patch)
tree82194baf5dcde3fdd71d322a3d3eeb686f1222a9 /src
parent78eeaab5edc5c7e8682c2465e4df7c3fe4e9bd66 (diff)
downloadgarage-595dc0ed0d6994cbe0f628b41df85f44c576dc64.tar.gz
garage-595dc0ed0d6994cbe0f628b41df85f44c576dc64.zip
Persist directly and not in background
Diffstat (limited to 'src')
-rw-r--r--src/rpc/membership.rs23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/rpc/membership.rs b/src/rpc/membership.rs
index adef7c97..330c154f 100644
--- a/src/rpc/membership.rs
+++ b/src/rpc/membership.rs
@@ -410,7 +410,7 @@ impl System {
if has_changes {
status.recalculate_hash();
}
- self.update_status(&update_locked, status);
+ self.update_status(&update_locked, status).await;
drop(update_locked);
if to_advertise.len() > 0 {
@@ -434,7 +434,7 @@ impl System {
let status_hash = status.hash;
let config_version = self.ring.borrow().config.version;
- self.update_status(&update_locked, status);
+ self.update_status(&update_locked, status).await;
drop(update_locked);
if is_new || status_hash != ping.status_hash {
@@ -502,7 +502,7 @@ impl System {
if has_changed {
status.recalculate_hash();
}
- self.update_status(&update_lock, status);
+ self.update_status(&update_lock, status).await;
drop(update_lock);
if to_ping.len() > 0 {
@@ -650,19 +650,18 @@ impl System {
}
}
- fn update_status(self: &Arc<Self>, updaters: &Updaters, status: Status) {
+ async fn update_status(self: &Arc<Self>, updaters: &Updaters, status: Status) {
+ if status.hash != self.status.borrow().hash {
+ info!("Persisting new peer list");
+ let serializable_status = status.to_serializable_membership(&self);
+ self.persist_status.save_async(&serializable_status).await
+ .expect("Unable to persist peer list");
+ }
+
let status = Arc::new(status);
updaters
.update_status
.send(status.clone())
.expect("Could not update internal membership status");
- self.background
- .spawn_cancellable(self.clone().persist_status(status));
- }
-
- async fn persist_status(self: Arc<Self>, status: Arc<Status>) -> Result<(), Error> {
- let serializable_status = status.to_serializable_membership(&self);
- self.persist_status.save_async(&serializable_status).await?;
- Ok(())
}
}