poll: rework timeout

This commit is contained in:
Matheus
2025-11-02 21:32:04 -03:00
parent c9d401f488
commit 3b6b5363ad
5 changed files with 36 additions and 23 deletions
+5 -1
View File
@@ -75,11 +75,15 @@ syscallret_t syscall_poll(context_t *, pollfd_t *fds, size_t nfds, int timeoutms
if (eventcount == 0 && timeoutms != 0) {
ret.errno = poll_dowait(&desc, (timeoutms == -1 ? 0 : timeoutms) * 1000);
if (ret.errno == 0 && desc.event) {
if (ret.errno == 0) {
int fd = ((uintptr_t)desc.event - (uintptr_t)desc.data) / sizeof(polldata_t);
fdsbuff[fd].revents = desc.data[fd].revents;
eventcount = 1;
}
// timeout is not an error in poll()
if (ret.errno == ETIMEDOUT)
ret.errno = 0;
}
if (ret.errno == 0)