unix: retry on EINTR in uv_sleep()
Reception of a signal makes nanosleep() return prematurely. Restart the system call when that happens. PR-URL: https://github.com/libuv/libuv/pull/2552 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
664f9c0011
commit
7a914e7f3d
@ -1558,8 +1558,14 @@ int uv_gettimeofday(uv_timeval64_t* tv) {
|
||||
|
||||
void uv_sleep(unsigned int msec) {
|
||||
struct timespec timeout;
|
||||
int rc;
|
||||
|
||||
timeout.tv_sec = msec / 1000;
|
||||
timeout.tv_nsec = (msec % 1000) * 1000 * 1000;
|
||||
nanosleep(&timeout, NULL);
|
||||
|
||||
do
|
||||
rc = nanosleep(&timeout, &timeout);
|
||||
while (rc == -1 && errno == EINTR);
|
||||
|
||||
assert(rc == 0);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user