mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-06 20:58:33 +01: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
1 changed files with 3 additions and 0 deletions
|
@ -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…
Add table
Reference in a new issue