From c5f5edae52d33abe89c39c39a230cf9d2529623f Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 26 Feb 2025 09:56:46 +0800 Subject: [PATCH] Guarantee delivery of inotify special events * src/inotify.c (inotifyevent_to_event): Always match events that are not encompassed by IN_ALL_EVENTS and which the documentation implies are always delivered to callbacks. * test/src/inotify-tests.el (inotify-file-watch-stop-delivery): New test. (cherry picked from commit 928dc34e05fc04a9b8394df477beca2ef6d9fd1b) --- src/inotify.c | 5 ++++- test/src/inotify-tests.el | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/inotify.c b/src/inotify.c index ff842ddc58c..c29d940c984 100644 --- a/src/inotify.c +++ b/src/inotify.c @@ -187,7 +187,10 @@ inotifyevent_to_event (Lisp_Object watch, struct inotify_event const *ev) uint32_t mask; CONS_TO_INTEGER (Fnth (make_fixnum (3), watch), uint32_t, mask); - if (! (mask & ev->mask)) + if (! (mask & ev->mask) + /* These event types are supposed to be reported whether or not + they appeared in the ASPECT list when monitoring commenced. */ + && !(ev->mask & (IN_IGNORED | IN_Q_OVERFLOW | IN_ISDIR | IN_UNMOUNT))) return Qnil; if (ev->len > 0) diff --git a/test/src/inotify-tests.el b/test/src/inotify-tests.el index 23febef2c67..aa7801d1e2c 100644 --- a/test/src/inotify-tests.el +++ b/test/src/inotify-tests.el @@ -67,6 +67,17 @@ (inotify-rm-watch wd) (should-not (inotify-valid-p wd))))))) +(ert-deftest inotify-file-watch-stop-delivery () + "Test whether IN_IGNORE events are delivered." + (skip-unless (featurep 'inotify)) + (progn + (ert-with-temp-file temp-file + (inotify-add-watch + temp-file t (lambda (event) + (when (memq 'ignored (cadr event)) + (throw 'success t))))) + (should (catch 'success (recursive-edit) nil)))) + (provide 'inotify-tests) ;;; inotify-tests.el ends here -- 2.39.5