Skip to content

Commit e36d54e

Browse files
riberkdfaust
andauthored
fix: INotifyWatcher may raise events with no paths (#700)
* fix: INotifyWatcher may raise events with no paths INotifyWatcher hold inotify watch descriptors map `wd -> path` and after an `unwatch` call the descriptor is deleted from the map. In some cases, if a lot of events are raised, it may cause race condition when the descriptor has been deleted, but event with this descriptor has already been queued. In that case INotifyWatcher doesn't know the path and just ignore the event fixes #678 * chore: changelog for (#700) * fix: typo * fix: typo Co-authored-by: Daniel Faust <[email protected]> --------- Co-authored-by: Daniel Faust <[email protected]>
1 parent 394ef18 commit e36d54e

File tree

4 files changed

+199
-115
lines changed

4 files changed

+199
-115
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
## notify 8.2.0 (unreleased)
44
- FEATURE: notify a user if the `max_user_watches` has been reached implicitly (`INotifyWatcher`) [#698]
5+
- FIX: `INotifyWatcher` ignores events with unknown watch descriptors (instead of `EventMask::Q_OVERFLOW`) [#700]
56

67
[#698]: https://github.com/notify-rs/notify/pull/698
8+
[#700]: https://github.com/notify-rs/notify/pull/700
79

810
## notify 8.1.0 (2025-07-03)
911
- FEATURE: added support for the [`flume`](https://docs.rs/flume) crate

notify-debouncer-full/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,13 @@ impl<T: FileIdCache> DebounceDataInner<T> {
279279
return;
280280
}
281281

282-
let path = &event.paths[0];
282+
let path = match event.paths.first() {
283+
Some(path) => path,
284+
None => {
285+
log::info!("skipping event with no paths: {event:?}");
286+
return;
287+
}
288+
};
283289

284290
match &event.kind {
285291
EventKind::Create(_) => {
@@ -775,6 +781,7 @@ mod tests {
775781
"add_create_event",
776782
"add_create_event_after_remove_event",
777783
"add_create_dir_event_twice",
784+
"add_event_with_no_paths_is_ok",
778785
"add_modify_content_event_after_create_event",
779786
"add_rename_from_event",
780787
"add_rename_from_event_after_create_event",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// https://github.com/notify-rs/notify/issues/678
2+
//
3+
// There was a bug in INotifyWatcher that causes producing events with no paths.
4+
// Debouncer should ignore this kind of events
5+
{
6+
state: {}
7+
events: [
8+
{ kind: "create-folder", paths: [] }
9+
]
10+
expected: {
11+
queues: {}
12+
}
13+
}

0 commit comments

Comments
 (0)