unix: Fix calculation of poll() timeout in sp_wait().

This commit is contained in:
Martin Ling 2020-02-02 09:36:52 +00:00
parent 78c3db9bfb
commit d81a4dfdc6
1 changed files with 6 additions and 1 deletions

View File

@ -1448,6 +1448,7 @@ SP_API enum sp_return sp_wait(struct sp_event_set *event_set,
RETURN_OK(); RETURN_OK();
#else #else
struct timeout timeout; struct timeout timeout;
int poll_timeout;
int result; int result;
struct pollfd *pollfds; struct pollfd *pollfds;
unsigned int i; unsigned int i;
@ -1478,7 +1479,11 @@ SP_API enum sp_return sp_wait(struct sp_event_set *event_set,
break; break;
} }
result = poll(pollfds, event_set->count, timeout_remaining_ms(&timeout) || -1); poll_timeout = (int) timeout_remaining_ms(&timeout);
if (poll_timeout == 0)
poll_timeout = -1;
result = poll(pollfds, event_set->count, poll_timeout);
timeout_update(&timeout); timeout_update(&timeout);