rust-pcap / pcap

Rust language pcap library
Apache License 2.0
610 stars 138 forks source link

Tell Tokio that pcap file descriptor is read-only #168

Closed jvns closed 3 years ago

jvns commented 3 years ago

Fixes #90, where the streamlisten example fails on Mac OS.

This fix comes from this comment on https://github.com/tokio-rs/tokio/issues/2413. It looks like the issue is that the pcap file descriptor is read-only, but PollEvented by default expects it to be read-write, so it raises an error.

I've tested that with this change, the streamlisten example works on Mac, and that without it I get an InvalidInput error when running that example.

Wojtek242 commented 3 years ago

Hi @jvns, thanks for the PR. I'd like to merge it, but it seems to be failing the pipeline on cargo fmt. Should be pretty straightforward to rectify.

Something for me to think of as a follow-up would be how to include tests for issues like the one you're fixing in the CI.

jvns commented 3 years ago

Fixed!

DanielRussell commented 3 years ago

Hi! This change worked well for me, and also inspired me to update Tokio from 0.2 to 1.0.

Submitted as #170, which conflicts with this PR (and overwrites the changes here -- they touch the same lines of code).

jvns commented 3 years ago

Awesome! Closing this then.