mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-03 01:25:37 +00:00
server: use select! for run
This commit is contained in:
@@ -225,8 +225,7 @@ impl DnsServer {
|
|||||||
let dirty = &self.mgr.dirty;
|
let dirty = &self.mgr.dirty;
|
||||||
let mut runtime = None;
|
let mut runtime = None;
|
||||||
|
|
||||||
tokio::join!(
|
let reload_catalog = async {
|
||||||
async {
|
|
||||||
loop {
|
loop {
|
||||||
dirty.catalog.notified().await;
|
dirty.catalog.notified().await;
|
||||||
if dirty.catalog.reset() {
|
if dirty.catalog.reset() {
|
||||||
@@ -234,8 +233,9 @@ impl DnsServer {
|
|||||||
}
|
}
|
||||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
async {
|
|
||||||
|
let reload_addresses = async {
|
||||||
loop {
|
loop {
|
||||||
dirty.addresses.notified().await;
|
dirty.addresses.notified().await;
|
||||||
if dirty.addresses.reset() {
|
if dirty.addresses.reset() {
|
||||||
@@ -243,8 +243,9 @@ impl DnsServer {
|
|||||||
}
|
}
|
||||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
async {
|
|
||||||
|
let reload_listeners = async {
|
||||||
loop {
|
loop {
|
||||||
dirty.listeners.notified().await;
|
dirty.listeners.notified().await;
|
||||||
if dirty.listeners.reset() {
|
if dirty.listeners.reset() {
|
||||||
@@ -258,7 +259,12 @@ impl DnsServer {
|
|||||||
}
|
}
|
||||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
|
|
||||||
|
tokio::select!(
|
||||||
|
_ = reload_catalog => {},
|
||||||
|
_ = reload_addresses => {},
|
||||||
|
_ = reload_listeners => {},
|
||||||
);
|
);
|
||||||
|
|
||||||
self.reload_addresses(iter::empty()).await;
|
self.reload_addresses(iter::empty()).await;
|
||||||
|
|||||||
Reference in New Issue
Block a user