Skip to content

pcntl not available in webserver environments causing errors #6

Closed
@wuuti

Description

@wuuti

If the RedisSimpleLock is used in webserver environments, it will probably most of the time produce a fatal error, because the pctnl extension is not compiled in to webserver's php modules.

It is used just once to register a shutdown function for the SIGINT in the constructor, which makes sense if we want to catch a cli execution and a pressed CTRL-C for example. But that prevents usage when the pcntl extension is not available.

Better

public function __construct($identifier, Client $client, $ttl = 10000, LoggerInterface $logger = null)
    {
        $this->identifier = $identifier;
        $this->client     = $client;
        $this->ttl        = $ttl;
        $this->logger     = $logger ?: new NullLogger;
        $this->id         = mt_rand();
        register_shutdown_function($closure = $this->releaseClosure());
        if (function_exists('pcntl_signal')) {
            pcntl_signal(SIGINT, $closure);
        } 
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions