allow dead code on signals

This commit is contained in:
Rob Ede 2021-11-03 17:22:27 +00:00
parent 3ba69afe9f
commit a12871cebc
3 changed files with 17 additions and 16 deletions

View File

@ -7,16 +7,16 @@ use crate::server::ServerCommand;
/// Server handle.
#[derive(Debug, Clone)]
pub struct ServerHandle {
tx_cmd: UnboundedSender<ServerCommand>,
cmd_tx: UnboundedSender<ServerCommand>,
}
impl ServerHandle {
pub(crate) fn new(tx_cmd: UnboundedSender<ServerCommand>) -> Self {
ServerHandle { tx_cmd }
pub(crate) fn new(cmd_tx: UnboundedSender<ServerCommand>) -> Self {
ServerHandle { cmd_tx }
}
pub(crate) fn worker_faulted(&self, idx: usize) {
let _ = self.tx_cmd.send(ServerCommand::WorkerFaulted(idx));
let _ = self.cmd_tx.send(ServerCommand::WorkerFaulted(idx));
}
/// Pause accepting incoming connections.
@ -24,7 +24,7 @@ impl ServerHandle {
/// May drop socket pending connection. All open connections remain active.
pub fn pause(&self) -> impl Future<Output = ()> {
let (tx, rx) = oneshot::channel();
let _ = self.tx_cmd.send(ServerCommand::Pause(tx));
let _ = self.cmd_tx.send(ServerCommand::Pause(tx));
async {
let _ = rx.await;
}
@ -33,7 +33,7 @@ impl ServerHandle {
/// Resume accepting incoming connections.
pub fn resume(&self) -> impl Future<Output = ()> {
let (tx, rx) = oneshot::channel();
let _ = self.tx_cmd.send(ServerCommand::Resume(tx));
let _ = self.cmd_tx.send(ServerCommand::Resume(tx));
async {
let _ = rx.await;
}
@ -42,7 +42,7 @@ impl ServerHandle {
/// Stop incoming connection processing, stop all workers and exit.
pub fn stop(&self, graceful: bool) -> impl Future<Output = ()> {
let (tx, rx) = oneshot::channel();
let _ = self.tx_cmd.send(ServerCommand::Stop {
let _ = self.cmd_tx.send(ServerCommand::Stop {
graceful,
completion: Some(tx),
});

View File

@ -10,6 +10,7 @@ use log::trace;
/// Types of process signals.
// #[allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq)]
#[allow(dead_code)] // variants are never constructed on non-unix
pub(crate) enum Signal {
/// `SIGINT`
Int,

View File

@ -43,20 +43,20 @@ pub(crate) struct Conn {
pub token: usize,
}
///
/// Create accept and server worker handles.
fn handle_pair(
idx: usize,
tx_conn: UnboundedSender<Conn>,
tx_stop: UnboundedSender<Stop>,
conn_tx: UnboundedSender<Conn>,
stop_tx: UnboundedSender<Stop>,
counter: Counter,
) -> (WorkerHandleAccept, WorkerHandleServer) {
let accept = WorkerHandleAccept {
idx,
tx_conn,
conn_tx,
counter,
};
let server = WorkerHandleServer { idx, tx_stop };
let server = WorkerHandleServer { idx, stop_tx };
(accept, server)
}
@ -158,7 +158,7 @@ impl Drop for WorkerCounterGuard {
/// Held by [Accept](crate::accept::Accept).
pub(crate) struct WorkerHandleAccept {
idx: usize,
tx_conn: UnboundedSender<Conn>,
conn_tx: UnboundedSender<Conn>,
counter: Counter,
}
@ -170,7 +170,7 @@ impl WorkerHandleAccept {
#[inline(always)]
pub(crate) fn send(&self, conn: Conn) -> Result<(), Conn> {
self.tx_conn.send(conn).map_err(|msg| msg.0)
self.conn_tx.send(conn).map_err(|msg| msg.0)
}
#[inline(always)]
@ -185,13 +185,13 @@ impl WorkerHandleAccept {
#[derive(Debug)]
pub(crate) struct WorkerHandleServer {
pub(crate) idx: usize,
tx_stop: UnboundedSender<Stop>,
stop_tx: UnboundedSender<Stop>,
}
impl WorkerHandleServer {
pub(crate) fn stop(&self, graceful: bool) -> oneshot::Receiver<bool> {
let (tx, rx) = oneshot::channel();
let _ = self.tx_stop.send(Stop { graceful, tx });
let _ = self.stop_tx.send(Stop { graceful, tx });
rx
}
}