1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:38:11 +00:00

Support polling with select() by using a zero timeout.

Use this in WindowServer to avoid getting blocked in select() when
there are pending injected events.
This commit is contained in:
Andreas Kling 2019-01-18 05:26:45 +01:00
parent a01e119e05
commit dff5051905
4 changed files with 24 additions and 7 deletions

View file

@ -1939,7 +1939,7 @@ int Process::sys$select(const Syscall::SC_select_params* params)
ASSERT(!exceptfds);
// FIXME: Implement timeout support.
ASSERT(!timeout);
ASSERT(!timeout || (!timeout->tv_sec && !timeout->tv_usec));
if (nfds < 0)
return -EINVAL;
@ -1963,10 +1963,10 @@ int Process::sys$select(const Syscall::SC_select_params* params)
transfer_fds(readfds, m_select_read_fds);
#ifdef DEBUG_IO
dbgprintf("%s<%u> selecting on (read:%u, write:%u)\n", name().characters(), pid(), m_select_read_fds.size(), m_select_write_fds.size());
dbgprintf("%s<%u> selecting on (read:%u, write:%u), wakeup_req:%u, timeout=%p\n", name().characters(), pid(), m_select_read_fds.size(), m_select_write_fds.size(), m_wakeup_requested, timeout);
#endif
if (!m_wakeup_requested) {
if (!m_wakeup_requested && (!timeout || (timeout->tv_sec || timeout->tv_usec))) {
block(BlockedSelect);
Scheduler::yield();
}