From e37f25d7762ca7f5cc71bf661bc06f405beb7309 Mon Sep 17 00:00:00 2001 From: John Barboza Date: Tue, 19 Jul 2016 08:11:30 -0400 Subject: [PATCH] unix: expand range of values for usleep MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit uv_sleep uses only usleep which can only take integers in the range [0,1000000]. Avoid using boundary parameters such as 1000000 for portability reasons. Use sleep and usleep together to expand the acceptable range of values for uv_sleep. PR-URL: https://github.com/libuv/libuv/pull/950 Reviewed-By: Imran Iqbal Reviewed-By: Saúl Ibarra Corretgé --- test/runner-unix.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/runner-unix.c b/test/runner-unix.c index 63f801b5..2ff18ce7 100644 --- a/test/runner-unix.c +++ b/test/runner-unix.c @@ -386,5 +386,13 @@ void rewind_cursor(void) { /* Pause the calling thread for a number of milliseconds. */ void uv_sleep(int msec) { - usleep(msec * 1000); + int sec; + int usec; + + sec = msec / 1000; + usec = (msec % 1000) * 1000; + if (sec > 0) + sleep(sec); + if (usec > 0) + usleep(usec); }