Skip to content

Clear AsyncFd readiness in read_event - #7

Open
RoastVeg wants to merge 1 commit into
katyo:masterfrom
ecog-gmbh:master
Open

Clear AsyncFd readiness in read_event#7
RoastVeg wants to merge 1 commit into
katyo:masterfrom
ecog-gmbh:master

Conversation

@RoastVeg

@RoastVeg RoastVeg commented Dec 3, 2024

Copy link
Copy Markdown

@seimonw correctly identified in #6 that tokio-gpiod fails in repeated calls to read_event with EWOULDBLOCK/EAGAIN, but mistakenly assumes it's due to NONBLOCK having been set. This is actually due to the fact that the readiness flag in AsyncFd is not cleared after the first call to readable.

The easiest way to solve the problem is by following the example given in the AsyncFd docs

@nsabovic

nsabovic commented Mar 3, 2025

Copy link
Copy Markdown

Just a ping to see if we can have this merged?

I've verified that it works in my code, but it can also be tested with the CLI—without this commit tgpio mon fails after the first state change. With this change the CLI works and doesn't have spurious wakeups.

@de-vri-es

Copy link
Copy Markdown

Polite ping! This is a very important fix. Without it, read_event() is basically broken.

AlonaSolntseva-Nanit added a commit to nanit/gpiod-rs that referenced this pull request Apr 7, 2026
Use guard.try_io() instead of discarding the AsyncFd ready guard.
Without this, the second call to read_event() gets a spurious
readiness notification and fails with EAGAIN (os error 11).

Port of katyo#7

Co-Authored-By: Louis Hampton <louis@ecog.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants