From c4b570f48921929974c3bbc79660127e68ac8bf0 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Fri, 19 Jan 2024 20:51:24 +0800 Subject: [PATCH] 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) --- src/android.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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; } -- 2.39.5