Skip to content

Commit

Permalink
Fix receiver and sender fd in pipe based waker
Browse files Browse the repository at this point in the history
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 <harald@matterlabs.dev>
  • Loading branch information
haraldh committed Oct 19, 2023
1 parent 9f21ce1 commit 8eb4010
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/sys/unix/waker.rs
Expand Up @@ -224,7 +224,7 @@ mod pipe {

impl WakerInternal {
pub fn new() -> io::Result<WakerInternal> {
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 })
Expand Down

0 comments on commit 8eb4010

Please sign in to comment.