From 8eb4010a92bede550850e177d3dd7c4c76eb90ba Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 19 Oct 2023 15:06:49 +0200 Subject: [PATCH] Fix receiver and sender fd in pipe based waker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender and receiver fd where swapped resulting in: ``` ❯ RUSTFLAGS="--cfg mio_unsupported_force_waker_pipe" cargo test --test events events_all --all-features Compiling mio v0.8.8 (/home/harald/git/mio) Finished test [unoptimized + debuginfo] target(s) in 0.35s Running tests/events.rs (target/debug/deps/events-c745c521d9f052e3) running 1 test test events_all ... FAILED failures: ---- events_all stdout ---- thread 'events_all' panicked at 'unable to wake: Os { code: 9, kind: Uncategorized, message: "Bad file descriptor" }', tests/events.rs:30:18 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace failures: events_all test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.00s error: test failed, to rerun pass `--test events` ``` Fixed that and added a CI test. Signed-off-by: Harald Hoyer --- .github/workflows/ci.yml | 12 ++++++++++++ src/sys/unix/waker.rs | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 490e8fedd..8960dbc62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,18 @@ jobs: run: cargo test --all-features - name: Tests release build run: cargo test --release --all-features + TestWakerPipe: + runs-on: ubuntu-latest + timeout-minutes: 10 + env: + RUSTFLAGS: "--cfg mio_unsupported_force_waker_pipe" + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - name: Tests + run: cargo test --all-features + - name: Tests release build + run: cargo test --release --all-features MinimalVersions: runs-on: ${{ matrix.os }} timeout-minutes: 10 diff --git a/src/sys/unix/waker.rs b/src/sys/unix/waker.rs index 4b73df32d..ff6a4b506 100644 --- a/src/sys/unix/waker.rs +++ b/src/sys/unix/waker.rs @@ -224,7 +224,7 @@ mod pipe { impl WakerInternal { pub fn new() -> io::Result { - let [sender, receiver] = pipe::new_raw()?; + let [receiver, sender] = pipe::new_raw()?; let sender = unsafe { File::from_raw_fd(sender) }; let receiver = unsafe { File::from_raw_fd(receiver) }; Ok(WakerInternal { sender, receiver })