Skip to content

Commit

Permalink
restore signaling functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
feschber committed Dec 23, 2023
1 parent db816a8 commit e07854d
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{
rc::Rc,
time::{Duration, Instant},
};
use tokio::{io::ReadHalf, net::UdpSocket, signal, sync::mpsc::Sender};
use tokio::{io::ReadHalf, net::UdpSocket, signal, sync::mpsc::Sender, task};

#[cfg(unix)]
use tokio::net::UnixStream;
Expand Down Expand Up @@ -291,13 +291,19 @@ impl Server {
}
});

_ = signal::ctrl_c().await;
let reaper = task::spawn_local(async move {
tokio::select! {
_ = signal::ctrl_c() => {
producer_task.abort();
receiver_task.abort();
frontend_task.abort();
resolver_task.abort();
udp_task.abort();
},
}
});

producer_task.await??;
receiver_task.await??;
frontend_task.await??;
resolver_task.await?;
udp_task.await?;
reaper.await?;

Ok(())
}
Expand Down Expand Up @@ -692,8 +698,6 @@ impl Server {
let _ = sender_tx.send((Event::Enter(), addr)).await;
}
let _ = sender_tx.send((e, addr)).await;
} else {
log::warn!("no address to send to for client {c}");
}
if let Some(addrs) = ping_addrs {
for addr in addrs {
Expand Down

0 comments on commit e07854d

Please sign in to comment.