Skip to content

Commit

Permalink
Do not wait unfinished tokio task if they does not exit after 30 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Nov 27, 2023
1 parent 3d674d5 commit 77b40bb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ckb-bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod subcommand;
use ckb_app_config::{cli, ExitCode, Setup};
use ckb_async_runtime::new_global_runtime;
use ckb_build_info::Version;
use ckb_channel::select;
use ckb_logger::info;
use ckb_network::tokio;
use helper::raise_fd_limit;
Expand Down Expand Up @@ -81,8 +82,14 @@ pub fn run_app(version: Version) -> Result<(), ExitCode> {

tokio::task::block_in_place(|| {
info!("waiting all tokio tasks exit...");
handle_stop_rx.blocking_recv();
info!("all tokio tasks and threads have exited, ckb shutdown");
select! {
handle_stop_rx.blocking_recv() -> _ => {
info!("all tokio tasks and threads have exited, ckb shutdown");
},
default(std::time::Duration::from_seconds(30)) => {
info!("waiting tokio tasks exit timeout, ckb shutdown");
}
}
});
}

Expand Down

0 comments on commit 77b40bb

Please sign in to comment.