Skip to content

Deadlock when using session_start(array("read_and_close"=>true)); #18

Open
@huguesalary

Description

@huguesalary

In PHP 7, session_start() can take an $options array parameter (php doc)

Using this parameter with Cm_RedisSession will cause the read() function to increment the lock field of the redis hash structure, then close() will be immediately called.

Unfortunately, close() does not decrement the lock field, which means that any subsequent call to read() will wait until the configured timeout before taking the lock on the session.

    /**
     * Overridden to prevent calling getLifeTime at shutdown
     *
     * @return bool
     */
    public function close()
    {
        $this->_log("Closing connection");
        if ($this->_redis) $this->_redis->close();
        return true;
    }

Submitted PR #17, however, I'm not convinced this is the right way of handling this issue.

It might make more sense to add logic to read() to release the lock when being used with "read_and_close".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions