server: use select! for run

This commit is contained in:
Luna Yao
2026-04-06 11:54:02 +02:00
parent 0c8da66a74
commit 238858ebab
+13 -7
View File
@@ -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;