Skip to content

Commit

Permalink
EventLoop::new: Use level-triggered events for inotify fd.
Browse files Browse the repository at this point in the history
The `inotify` crate's `Inotify::read_events` method does not read all available
events from inotify (see hannobraun/inotify-rs#156), only one buffer's worth. Using
level-triggered events tells Mio to report events on the inotify fd until all
events have been read.

Fixes #267.
  • Loading branch information
jimblandy committed Nov 5, 2020
1 parent 84e7b0c commit c5a1046
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
- CHANGE: Remove `Sender`s from watcher API in favour of `EventFn` [#214]
- META: The project maintainers have changed from @passcod to notify-rs.
- CHANGE: Avoid stating the watched path for non-recursive watches with inotify [#256]
- CHANGE: Report events promptly on Linux, even when many occur in rapid succession. [#268]

[#268]: https://github.com/notify-rs/notify/pull/268

## 5.0.0-pre.4 (2020-10-31)

Expand Down
5 changes: 4 additions & 1 deletion src/inotify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ impl EventLoop {
&evented_inotify,
INOTIFY,
mio::Ready::readable(),
mio::PollOpt::edge(),
// Use level-sensitive polling, since `Inotify::read_events` only
// consumes one buffer's worth of events at a time, so there may be
// events remaining in the queue after calling handle_inotify.
mio::PollOpt::level(),
)?;

let event_loop = EventLoop {
Expand Down

0 comments on commit c5a1046

Please sign in to comment.