1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Fix poll zero timeout not being instant wakeup.

This commit is contained in:
Jonas 'Sortie' Termansen 2015-05-22 19:48:03 +02:00
parent 40594eba1c
commit 2291076f19
2 changed files with 6 additions and 4 deletions

View file

@ -208,7 +208,7 @@ int sys_ppoll(struct pollfd* user_fds, nfds_t nfds,
volatile bool remote_woken = false;
bool unexpected_error = false;
nfds_t reqs = nfds;
nfds_t reqs;
for ( reqs = 0; !unexpected_error && reqs < nfds; )
{
PollNode* node = nodes + reqs;
@ -234,11 +234,13 @@ int sys_ppoll(struct pollfd* user_fds, nfds_t nfds,
// TODO: How should errors be handled?
if ( desc->poll(&ctx, node) == 0 )
self_woken = true;
else if ( errno != EAGAIN )
else if ( errno == EAGAIN )
errno = 0;
else
unexpected_error = self_woken = true;
}
if ( timeout_ts.tv_sec < 0 )
if ( timeout_ts.tv_sec == 0 )
self_woken = true;
while ( !(self_woken || remote_woken) )

View file

@ -1784,7 +1784,7 @@ static void HandleEvents(int kbfd, struct Desktop* desktop)
fds[0].fd = kbfd;
fds[0].events = POLLIN;
fds[0].revents = 0;
if ( 0 < poll(fds, NFDS, -1) )
if ( 0 < poll(fds, NFDS, 0) )
{
if ( fds[0].revents )
HandleKeyboardEvents(kbfd, desktop);