parrot/parrot — Issue #714: Use of usleep in conflict with SUSv2 (fencepost error)
Author: he32
Created: 2012-02-09 09:44:34+00:00
State: open

SUSv2 says in http://pubs.opengroup.org/onlinepubs/7908799/xsh/usleep.html:

The useconds argument must be less than 1,000,000.
The NetBSD libc implementation enforces this limitation.

However, parrot will try to use that exact value, due to a fencepost error,
and this causes several of the timer tests to fail.

Fix for parrot 3.9.0:

--- src/scheduler.c.orig 2011-10-18 22:44:11.000000000 +0000
+++ src/scheduler.c
@@ -993,7 +993,7 @@ Parrot_cx_schedule_sleep(PARROT_INTERP,
Parrot_cx_runloop_wake(interp, interp->scheduler);

/* A more primitive, platform-specific, non-threaded form of sleep. */
- if (time > 1) {
+ if (time >= 1) {
/* prevent integer overflow when converting to microseconds
* and problems in platforms that doesn't allow usleep more
* than 1 second */