diff options
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -3971,12 +3971,13 @@ ruby_ppoll(struct pollfd *fds, nfds_t nfds, int tmp, tmp2; if (ts->tv_sec > INT_MAX/1000) - timeout_ms = -1; + timeout_ms = INT_MAX; else { tmp = (int)(ts->tv_sec * 1000); - tmp2 = (int)(ts->tv_nsec / (1000 * 1000)); + /* round up 1ns to 1ms to avoid excessive wakeups for <1ms sleep */ + tmp2 = (int)((ts->tv_nsec + 999999L) / (1000L * 1000L)); if (INT_MAX - tmp < tmp2) - timeout_ms = -1; + timeout_ms = INT_MAX; else timeout_ms = (int)(tmp + tmp2); } |