Re: Session cache, lock and write
| From: | Stas Malyshev | Date: | Thu, 14 Nov 2013 21:19:37 +0000 |
| Subject: | Re: Session cache, lock and write | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70131@lists.php.net to get a copy of this message | ||
Hi!
> I think you've wrote this before I sent new mail. For files save handler,
> when session.lock=Off, it will be
>
> open-and-lock -> read session data -> close-and-unlock ->
> script executed
> -> open-and-lock -> write session data -> close-and-unlock
I don't think this is a very good idea, since what happens if somebody
else changed the state while script was executing? That change would be
killed by the write. The lock is not for writing, the lock is for data
consistency between reading in writing. If you gave up the lock, you
should not write afterwards because your data may be stale.
> would not be a problem with write short circuit, since unchanged session
> data is not written to session storage. User has to know what session
> module is doing well to avoid problems, though.
That's exactly the problem. Using this method would mean anything you
write to a session can magically vanish and you wouldn't have any idea
why, just because some other script was executing at the same time and
have overwritten your data. "Read and never write" is OK, but read and
then write without locking is very dangerous.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227