|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-06-25 18:40 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Feb 10 01:00:01 2026 UTC |
Description: ------------ If more than one process of the same session is created in the one time, this processes are executed simultaneously instead of being executed one after another. Reproduce code: --------------- <?php //For example this script is asked three times simultaneously from the one user, siting on the one session ID require_once('db_fns.php'); //requiring mysql functions and connecting to database require_once('session.php'); //creating session from MySQL storage $sessid = session_id(); $example = db_query_onerow("SELECT example FROM table WHERE id=1"); //etc the field `example` is "1" by default. So all three times every process has the value "1" echo "Example: $example"; //So every time we will get "1" $lock = db_query_onerow("SELECT GET_LOCK('database.lock_{$sessid}', 60);"); //Getting lock to test the bug of PHP $anotherexample = db_query_onerow("SELECT example FROM table WHERE id=1"); //This Select will be not executed at the one time because of MySQL locks and will give us the right values echo "Another Example: $anotherexample"; //At the first time it will be "1" and two other time "0" db_query_write("UPDATE table SET example=0 WHERE id=1"); //Setting the field `example` to 0 $lock = db_query_onerow("SELECT RELEASE_LOCK('database.lock_{$sessid}')"); //Getting lock to test the bug ?> Expected result: ---------------- Example: 1 Another Example: 1 Example: 0 Another Example: 0 Example: 0 Another Example: 0 Actual result: -------------- Example: 1 Example: 1 Example: 1 Another Example: 1 Another Example: 0 Another Example: 0