]> git.eshelyaron.com Git - emacs.git/commitdiff
Guarantee delivery of inotify special events
authorPo Lu <luangruo@yahoo.com>
Wed, 26 Feb 2025 01:56:46 +0000 (09:56 +0800)
committerEshel Yaron <me@eshelyaron.com>
Wed, 26 Feb 2025 09:41:33 +0000 (10:41 +0100)
* 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
test/src/inotify-tests.el

index ff842ddc58c3a2a874b6be414b6c4bc97ec23d7e..c29d940c984f76f8ed2b230adfda499aa70feb6d 100644 (file)
@@ -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)
index 23febef2c676ffb4a214dca506041e2aacc1c522..aa7801d1e2c1c56fd27b74e75f78f51dd8ede2ca 100644 (file)
           (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