unix: expand range of values for usleep
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 <imran@imraniqbal.org> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
parent
404025721f
commit
e37f25d776
@ -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);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user