2018-07-28 12:30:46 -07:00
|
|
|
#![cfg(unix)]
|
2019-08-17 13:43:55 -07:00
|
|
|
#![cfg(feature = "signal")]
|
2019-08-10 00:07:57 +09:00
|
|
|
#![warn(rust_2018_idioms)]
|
2018-07-28 12:30:46 -07:00
|
|
|
|
2019-08-19 19:42:54 -07:00
|
|
|
pub mod support;
|
|
|
|
|
use support::*;
|
2018-07-28 12:30:46 -07:00
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn dropping_loops_does_not_cause_starvation() {
|
|
|
|
|
let (mut rt, signal) = {
|
2019-08-15 21:09:09 -07:00
|
|
|
let kind = SignalKind::user_defined1();
|
2019-08-13 21:07:22 -07:00
|
|
|
|
2019-02-21 11:56:15 -08:00
|
|
|
let mut first_rt = CurrentThreadRuntime::new().expect("failed to init first runtime");
|
2019-08-18 14:22:09 -07:00
|
|
|
let mut first_signal = signal(kind).expect("failed to register first signal");
|
2018-07-28 12:30:46 -07:00
|
|
|
|
2019-02-21 11:56:15 -08:00
|
|
|
let mut second_rt = CurrentThreadRuntime::new().expect("failed to init second runtime");
|
2019-08-18 14:22:09 -07:00
|
|
|
let mut second_signal = signal(kind).expect("failed to register second signal");
|
2019-07-30 18:23:26 -07:00
|
|
|
|
2019-08-13 21:07:22 -07:00
|
|
|
send_signal(libc::SIGUSR1);
|
2019-07-30 18:23:26 -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
|
|
|
|
2019-07-30 18:23:26 -07:00
|
|
|
let _ = run_with_timeout(&mut second_rt, second_signal.next())
|
|
|
|
|
.expect("failed to await second signal");
|
2018-07-28 12:30:46 -07:00
|
|
|
|
|
|
|
|
drop(first_rt);
|
|
|
|
|
drop(first_signal);
|
|
|
|
|
|
|
|
|
|
(second_rt, second_signal)
|
|
|
|
|
};
|
|
|
|
|
|
2019-08-13 21:07:22 -07:00
|
|
|
send_signal(libc::SIGUSR1);
|
2018-07-28 12:30:46 -07:00
|
|
|
|
2019-07-09 08:48:46 -07:00
|
|
|
let _ = run_with_timeout(&mut rt, signal.into_future());
|
2018-07-28 12:30:46 -07:00
|
|
|
}
|