From: Martin Ling Date: Sun, 2 Feb 2020 09:36:52 +0000 (+0000) Subject: unix: Fix calculation of poll() timeout in sp_wait(). X-Git-Tag: libserialport-0.1.2~27 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d81a4dfdc6f9779c13c6dd10b342e9d4c5a7ff97;p=libserialport.git unix: Fix calculation of poll() timeout in sp_wait(). --- diff --git a/serialport.c b/serialport.c index eda2d19..7201091 100644 --- a/serialport.c +++ b/serialport.c @@ -1448,6 +1448,7 @@ SP_API enum sp_return sp_wait(struct sp_event_set *event_set, RETURN_OK(); #else struct timeout timeout; + int poll_timeout; int result; struct pollfd *pollfds; unsigned int i; @@ -1478,7 +1479,11 @@ SP_API enum sp_return sp_wait(struct sp_event_set *event_set, 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);