Skip to content

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

@voiteck

Description

@voiteck

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions