Files
tokio/tokio-net/tests/signal_drop_multi_loop.rs
T

32 lines
929 B
Rust
Raw Normal View History

2018-07-28 12:30:46 -07:00
#![cfg(unix)]
2019-08-17 13:43:55 -07:00
#![cfg(feature = "signal")]
#![warn(rust_2018_idioms)]
2018-07-28 12:30:46 -07:00
pub mod support;
use support::*;
2018-07-28 12:30:46 -07:00
#[test]
fn dropping_loops_does_not_cause_starvation() {
let kind = SignalKind::user_defined1();
let mut first_rt = CurrentThreadRuntime::new().expect("failed to init first runtime");
let mut first_signal =
first_rt.block_on(async { signal(kind).expect("failed to register first signal") });
2018-07-28 12:30:46 -07:00
let mut second_rt = CurrentThreadRuntime::new().expect("failed to init second runtime");
let mut second_signal =
second_rt.block_on(async { signal(kind).expect("failed to register second signal") });
send_signal(libc::SIGUSR1);
2018-07-28 12:30:46 -07:00
let _ =
run_with_timeout(&mut first_rt, first_signal.next()).expect("failed to await first signal");
2018-07-28 12:30:46 -07:00
drop(first_rt);
drop(first_signal);
2018-07-28 12:30:46 -07:00
send_signal(libc::SIGUSR1);
2018-07-28 12:30:46 -07:00
let _ = run_with_timeout(&mut second_rt, second_signal.next());
2018-07-28 12:30:46 -07:00
}