From: Po Lu Date: Fri, 19 Jan 2024 12:51:24 +0000 (+0800) Subject: Fix another cause of superfluous inotify signals on Android X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c4b570f48921929974c3bbc79660127e68ac8bf0;p=emacs.git Fix another cause of superfluous inotify signals on Android * src/android.c (android_select): If the event queue isn't empty upon the initial check, clear all fdsets. (cherry picked from commit bd5bfc29137b6e452e1900a1fc3cf09e77959133) --- diff --git a/src/android.c b/src/android.c index 757f256c188..fb7703d84ab 100644 --- a/src/android.c +++ b/src/android.c @@ -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; }