mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 20:40:05 +00:00
mach: Fix bogus negative return
One can be very unlucky to call time_now first just before a second switch, and mach_msg sleep just a bit more enough for the second time_now call to count one second too many (or even more if scheduling is really unlucky). So we have to protect against returning a bogus negative value in such case.
This commit is contained in:
parent
82b5340ebd
commit
f071795d80
@ -43,6 +43,9 @@ __sleep (unsigned int seconds)
|
||||
after = time_now ();
|
||||
__mach_port_destroy (__mach_task_self (), recv);
|
||||
|
||||
if (after - before > seconds)
|
||||
return 0;
|
||||
|
||||
return seconds - (after - before);
|
||||
}
|
||||
weak_alias (__sleep, sleep)
|
||||
|
Loading…
Reference in New Issue
Block a user