X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=serialport.c;h=7af818e2d2574ca022b5a0cce57b55da8ffcabaf;hb=56fe6e320780ad3fdae6a059a0a8379d850c7e35;hp=da292ac650ffff5e1099733fe58271cf16b60248;hpb=e5c2630eeed1825889dfe7cf0aaeb734b047ea74;p=libserialport.git diff --git a/serialport.c b/serialport.c index da292ac..7af818e 100644 --- a/serialport.c +++ b/serialport.c @@ -1457,7 +1457,11 @@ SP_API enum sp_return sp_wait(struct sp_event_set *event_set, * to avoid any issues if a short timeout is reached before * poll() is even run. */ - if (timeout_ms && started) { + if (!timeout_ms) { + timeout_remaining_ms = -1; + } else if (!started) { + timeout_remaining_ms = timeout_ms; + } else { gettimeofday(&now, NULL); if (timercmp(&now, &end, >)) { DEBUG("Wait timed out"); @@ -1467,7 +1471,7 @@ SP_API enum sp_return sp_wait(struct sp_event_set *event_set, timeout_remaining_ms = delta.tv_sec * 1000 + delta.tv_usec / 1000; } - result = poll(pollfds, event_set->count, timeout_ms ? timeout_remaining_ms : -1); + result = poll(pollfds, event_set->count, timeout_remaining_ms); started = 1; if (result < 0) {