You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Indicates to tokio that the file descriptor is no longer ready. All internal readiness flags will be cleared, and tokio will wait for the next edge-triggered readiness notification from the OS.
To me, this means that it clear the state and wait for the next notification after the time calling this method. But this implies that the it's incorrect to read to EAGAIN and then clear_ready (as said in docs of clear_ready_matching or try_io implementation), because there could be an edge-notification between the last read and clear_ready, and it would be cleared and lost. Thus clear_ready should be called before calling read to catch all potential notifications.
But after a quick glance to the code, clear_ready seems to only clear readiness flags before the triggered event.
That's to clear readiness before the readiness().await returns, but not notifications happen between readiness() and the next clear_ready(). So the read then clear_ready pattern will not lose any notification.
It's better to address this timing issue in clear_ready and maybe also AsyncFd to be compatible with existing examples and implementations.
The text was updated successfully, but these errors were encountered:
Version
tokio 1.35.1
Platform
N/A, documentation only
Description
The documentation of
AsyncFdReadyGuard::clear_ready
says:To me, this means that it clear the state and wait for the next notification after the time calling this method. But this implies that the it's incorrect to
read
toEAGAIN
and thenclear_ready
(as said in docs ofclear_ready_matching
ortry_io
implementation), because there could be an edge-notification between the lastread
andclear_ready
, and it would be cleared and lost. Thusclear_ready
should be called before callingread
to catch all potential notifications.But after a quick glance to the code,
clear_ready
seems to only clear readiness flags before the triggered event.tokio/tokio/src/runtime/io/scheduled_io.rs
Lines 228 to 231 in 46ff363
That's to clear readiness before the
readiness().await
returns, but not notifications happen betweenreadiness()
and the nextclear_ready()
. So theread
thenclear_ready
pattern will not lose any notification.It's better to address this timing issue in
clear_ready
and maybe alsoAsyncFd
to be compatible with existing examples and implementations.The text was updated successfully, but these errors were encountered: