mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 01:37:39 +03:00
Kernel: Fix poll() with timeout
This commit is contained in:
parent
b33cc7f772
commit
123283d840
Notes:
sideshowbarker
2024-07-19 14:02:30 +09:00
Author: https://github.com/rburchell Commit: https://github.com/SerenityOS/serenity/commit/123283d840d Pull-request: https://github.com/SerenityOS/serenity/pull/57 Reviewed-by: https://github.com/awesomekling ✅
@ -1854,9 +1854,27 @@ int Process::sys$poll(pollfd* fds, int nfds, int timeout)
|
||||
current->m_select_write_fds.append(fds[i].fd);
|
||||
}
|
||||
|
||||
// FIXME: this should set m_select_timeout, right?
|
||||
if (timeout < 0)
|
||||
if (timeout >= 0) {
|
||||
// poll is in ms, we want s/us.
|
||||
struct timeval tvtimeout;
|
||||
tvtimeout.tv_sec = 0;
|
||||
while (timeout >= 1000) {
|
||||
tvtimeout.tv_sec += 1;
|
||||
timeout -= 1000;
|
||||
}
|
||||
tvtimeout.tv_usec = timeout * 1000;
|
||||
|
||||
struct timeval now;
|
||||
kgettimeofday(now);
|
||||
AK::timeval_add(&now, &tvtimeout, ¤t->m_select_timeout);
|
||||
current->m_select_has_timeout = true;
|
||||
} else {
|
||||
current->m_select_has_timeout = false;
|
||||
}
|
||||
|
||||
if (current->m_select_has_timeout || timeout < 0) {
|
||||
current->block(Thread::State::BlockedSelect);
|
||||
}
|
||||
|
||||
int fds_with_revents = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user