aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/membership.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-03-15 23:14:12 +0100
committerAlex Auvolat <alex@adnab.me>2021-03-15 23:14:12 +0100
commit6a8439fd1345ecae7414386f76dda7a03eb14df2 (patch)
treea6306030d7f0cc41158512e600683b8874f7d85e /src/rpc/membership.rs
parent0cd5b2ae19965b8c1f3176afeb8f678c4d8366dd (diff)
downloadgarage-6a8439fd1345ecae7414386f76dda7a03eb14df2.tar.gz
garage-6a8439fd1345ecae7414386f76dda7a03eb14df2.zip
Some improvements in background worker but we terminate late
Diffstat (limited to 'src/rpc/membership.rs')
-rw-r--r--src/rpc/membership.rs25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/rpc/membership.rs b/src/rpc/membership.rs
index 6cc3ed2e..4e9822fa 100644
--- a/src/rpc/membership.rs
+++ b/src/rpc/membership.rs
@@ -11,9 +11,9 @@ use futures::future::join_all;
use futures::select;
use futures_util::future::*;
use serde::{Deserialize, Serialize};
+use tokio::io::AsyncWriteExt;
use tokio::sync::watch;
use tokio::sync::Mutex;
-use tokio::io::AsyncWriteExt;
use garage_util::background::BackgroundRunner;
use garage_util::data::*;
@@ -316,17 +316,16 @@ impl System {
self.clone().ping_nodes(bootstrap_peers).await;
let self2 = self.clone();
- self.clone()
- .background
- .spawn_worker(format!("ping loop"), |stop_signal| self2.ping_loop(stop_signal));
+ self.background
+ .spawn_worker(format!("ping loop"), |stop_signal| {
+ self2.ping_loop(stop_signal)
+ });
if let (Some(consul_host), Some(consul_service_name)) = (consul_host, consul_service_name) {
let self2 = self.clone();
- self.clone()
- .background
+ self.background
.spawn_worker(format!("Consul loop"), |stop_signal| {
- self2
- .consul_loop(stop_signal, consul_host, consul_service_name)
+ self2.consul_loop(stop_signal, consul_host, consul_service_name)
});
}
}
@@ -531,7 +530,7 @@ impl System {
.broadcast(Message::AdvertiseConfig(adv.clone()), PING_TIMEOUT)
.map(Ok),
);
- self.background.spawn(self.clone().save_network_config()).await;
+ self.background.spawn(self.clone().save_network_config());
}
Ok(Message::Ok)
@@ -568,7 +567,7 @@ impl System {
consul_host: String,
consul_service_name: String,
) {
- loop {
+ while !*stop_signal.borrow() {
let restart_at = tokio::time::sleep(CONSUL_INTERVAL);
match get_consul_nodes(&consul_host, &consul_service_name).await {
@@ -583,11 +582,7 @@ impl System {
select! {
_ = restart_at.fuse() => (),
- _ = stop_signal.changed().fuse() => {
- if *stop_signal.borrow() {
- return;
- }
- }
+ _ = stop_signal.changed().fuse() => (),
}
}
}