aboutsummaryrefslogtreecommitdiff
path: root/src/peering/fullmesh.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-10-13 17:12:13 +0200
committerAlex Auvolat <alex@adnab.me>2021-10-13 17:12:13 +0200
commit70839d70d86354232f168e63ce4062219acb85c7 (patch)
tree9c956af0339aa048f487c3a4e54c320be8d13647 /src/peering/fullmesh.rs
parent8dede69dee20b812ad1dcab5b374c60232409f4f (diff)
downloadnetapp-70839d70d86354232f168e63ce4062219acb85c7.tar.gz
netapp-70839d70d86354232f168e63ce4062219acb85c7.zip
Try to handle termination and closing of stuff properly
Diffstat (limited to 'src/peering/fullmesh.rs')
-rw-r--r--src/peering/fullmesh.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/peering/fullmesh.rs b/src/peering/fullmesh.rs
index b579654..793eeb2 100644
--- a/src/peering/fullmesh.rs
+++ b/src/peering/fullmesh.rs
@@ -8,6 +8,8 @@ use async_trait::async_trait;
use log::{debug, info, trace, warn};
use serde::{Deserialize, Serialize};
+use tokio::sync::watch;
+
use sodiumoxide::crypto::hash;
use crate::endpoint::*;
@@ -171,8 +173,8 @@ impl FullMeshPeeringStrategy {
strat
}
- pub async fn run(self: Arc<Self>) {
- loop {
+ pub async fn run(self: Arc<Self>, must_exit: watch::Receiver<bool>) {
+ while !*must_exit.borrow() {
// 1. Read current state: get list of connected peers (ping them)
let (to_ping, to_retry) = {
let known_hosts = self.known_hosts.read().unwrap();