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.
This commit is contained in:
Po Lu 2024-01-19 20:51:24 +08:00
parent dd2caf1a76
commit bd5bfc2913

View 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;
}