add some interruption points in recursive event handling to prevent shutdown hangs
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -5,7 +5,7 @@ use std::{
|
||||
|
||||
use tokio::{runtime, sync::broadcast};
|
||||
|
||||
use crate::{config::Config, log::Log, metrics::Metrics, Err, Result};
|
||||
use crate::{config::Config, err, log::Log, metrics::Metrics, Err, Result};
|
||||
|
||||
/// Server runtime state; public portion
|
||||
pub struct Server {
|
||||
@@ -107,6 +107,13 @@ impl Server {
|
||||
.expect("runtime handle available in Server")
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn check_running(&self) -> Result {
|
||||
self.running()
|
||||
.then_some(())
|
||||
.ok_or_else(|| err!(debug_warn!("Server is shutting down.")))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn running(&self) -> bool { !self.stopping.load(Ordering::Acquire) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user