From 2291076f1924f7712dbd961700257db6f6b34dac Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Fri, 22 May 2015 19:48:03 +0200 Subject: [PATCH] Fix poll zero timeout not being instant wakeup. --- kernel/poll.cpp | 8 +++++--- trianglix/trianglix.cpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/poll.cpp b/kernel/poll.cpp index 3fd9ef8b..2f05dc2e 100644 --- a/kernel/poll.cpp +++ b/kernel/poll.cpp @@ -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) ) diff --git a/trianglix/trianglix.cpp b/trianglix/trianglix.cpp index 50faab65..9a3a16e6 100644 --- a/trianglix/trianglix.cpp +++ b/trianglix/trianglix.cpp @@ -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);