mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
io: allow clear_readiness
after io driver shutdown (#6067)
This commit is contained in:
parent
d420d528f9
commit
0f296d2089
@ -210,8 +210,8 @@ impl ScheduledIo {
|
|||||||
pub(super) fn set_readiness(&self, tick: Tick, f: impl Fn(Ready) -> Ready) {
|
pub(super) fn set_readiness(&self, tick: Tick, f: impl Fn(Ready) -> Ready) {
|
||||||
let mut current = self.readiness.load(Acquire);
|
let mut current = self.readiness.load(Acquire);
|
||||||
|
|
||||||
// The shutdown bit should not be set
|
// If the io driver is shut down, then you are only allowed to clear readiness.
|
||||||
debug_assert_eq!(0, SHUTDOWN.unpack(current));
|
debug_assert!(SHUTDOWN.unpack(current) == 0 || matches!(tick, Tick::Clear(_)));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// Mask out the tick bits so that the modifying function doesn't see
|
// Mask out the tick bits so that the modifying function doesn't see
|
||||||
|
@ -578,6 +578,23 @@ fn driver_shutdown_wakes_poll() {
|
|||||||
assert_err!(futures::executor::block_on(poll_writable(&afd_a)));
|
assert_err!(futures::executor::block_on(poll_writable(&afd_a)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn driver_shutdown_then_clear_readiness() {
|
||||||
|
let rt = rt();
|
||||||
|
|
||||||
|
let (a, _b) = socketpair();
|
||||||
|
let afd_a = {
|
||||||
|
let _enter = rt.enter();
|
||||||
|
AsyncFd::new(a).unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut write_ready = rt.block_on(afd_a.writable()).unwrap();
|
||||||
|
|
||||||
|
std::mem::drop(rt);
|
||||||
|
|
||||||
|
write_ready.clear_ready();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn driver_shutdown_wakes_poll_race() {
|
fn driver_shutdown_wakes_poll_race() {
|
||||||
// TODO: make this a loom test
|
// TODO: make this a loom test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user