]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix another cause of superfluous inotify signals on Android
authorPo Lu <luangruo@yahoo.com>
Fri, 19 Jan 2024 12:51:24 +0000 (20:51 +0800)
committerEshel Yaron <me@eshelyaron.com>
Sat, 20 Jan 2024 09:07:03 +0000 (10:07 +0100)
* src/android.c (android_select): If the event queue isn't
empty upon the initial check, clear all fdsets.

(cherry picked from commit bd5bfc29137b6e452e1900a1fc3cf09e77959133)

src/android.c

index 757f256c188885959609c8485e45ce053f7c3213..fb7703d84ab02b8bc0f81b829590883eb2a344aa 100644 (file)
@@ -744,6 +744,19 @@ android_select (int nfds, fd_set *readfds, fd_set *writefds,
 
   if (event_queue.num_events)
     {
+      /* Zero READFDS, WRITEFDS and EXCEPTFDS, lest the caller
+        mistakenly interpret this return value as indicating that an
+        inotify file descriptor is readable, and try to poll an
+        unready one.  */
+
+      if (readfds)
+       FD_ZERO (readfds);
+
+      if (writefds)
+       FD_ZERO (writefds);
+
+      if (exceptfds)
+       FD_ZERO (exceptfds);
       pthread_mutex_unlock (&event_queue.mutex);
       return 1;
     }