Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning: [PHP Warning] usleep(): Number of microseconds must be greater than or equal to 0 #7

Open
voiteck opened this issue Mar 12, 2012 · 0 comments

Comments

@voiteck
Copy link

voiteck commented Mar 12, 2012

When you set the interval time to more than 2147 you will get an error: warning: [PHP Warning] usleep(): Number of microseconds must be greater than or equal to 0. As well daemon will not wait between iterations.

Similar problem is posted here:
http://pear.php.net/bugs/bug.php?id=19121

Solution is to use sleep() instead of usleep(). So the iterate method at Daemon class will looks like:

static public function iterate($sleepSeconds = 0)
{
    self::_optionObjSetup();
    if ($sleepSeconds >= 1) {
        sleep($sleepSeconds);
    } else if (is_numeric($sleepSeconds)) {
        usleep($sleepSeconds * 1000000);
    }

    clearstatcache();

    // Garbage Collection (PHP >= 5.3)
    if (function_exists('gc_collect_cycles')) {
        gc_collect_cycles();
    }

    return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant