Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
remove SHUTDOWN global
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma committed Feb 22, 2023
1 parent 84ac150 commit 886d92b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 3 additions & 5 deletions sqld/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ type Result<T> = std::result::Result<T, Error>;
///
/// /!\ use with caution.
pub(crate) static HARD_RESET: Lazy<Arc<Notify>> = Lazy::new(|| Arc::new(Notify::new()));
/// Clean shutdown of the server.
pub(crate) static SHUTDOWN: Lazy<Arc<Notify>> = Lazy::new(|| Arc::new(Notify::new()));

#[cfg(feature = "mwal_backend")]
pub(crate) static VWAL_METHODS: OnceCell<
Expand Down Expand Up @@ -239,9 +237,10 @@ pub async fn run_server(config: Config) -> anyhow::Result<()> {
}
let mut join_set = JoinSet::new();

let shutdown_notify: Arc<Notify> = Arc::new(Notify::new());
let idle_shutdown_layer = config
.idle_shutdown_timeout
.map(|d| IdleShutdownLayer::new(d, SHUTDOWN.clone()));
.map(|d| IdleShutdownLayer::new(d, shutdown_notify.clone()));

match config.writer_rpc_addr {
Some(ref addr) => {
Expand All @@ -251,14 +250,13 @@ pub async fn run_server(config: Config) -> anyhow::Result<()> {
}

let reset = HARD_RESET.clone();
let shutdown = SHUTDOWN.clone();
loop {
tokio::select! {
_ = reset.notified() => {
hard_reset(&config, join_set).await?;
break;
},
_ = shutdown.notified() => {
_ = shutdown_notify.notified() => {
return Ok(())
}
Some(res) = join_set.join_next() => {
Expand Down
1 change: 1 addition & 0 deletions sqld/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::utils::services::idle_shutdown::IdleShutdownLayer;
pub mod proxy;
pub mod replication_log;

#[allow(clippy::too_many_arguments)]
pub async fn run_rpc_server(
addr: SocketAddr,
tls: bool,
Expand Down

0 comments on commit 886d92b

Please sign in to comment.