Edit report at http://bugs.php.net/bug.php?id=51264&edit=1
ID: 51264 User updated by: bugs dot php dot net_2010 at forskernet dot dk Reported by: bugs dot php dot net_2010 at forskernet dot dk Summary: Unable to disable implicit session locking Status: Open Type: Feature/Change Request Package: Session related Operating System: Linux PHP Version: 5.2.13 New Comment: "You can call session_write_close() so the other process can access the session storage." Excellent - do you have any details on how I can accomplish this? Naively executing session_write_close(); as the first php line in the script apparently does not do any difference in allowing the second process to start executing. At least in my case the no. 2 process/tab still waits the full minute before it begins to execute. Previous Comments: ------------------------------------------------------------------------ [2010-03-10 18:28:49] johan...@php.net The session is locked to ensure no data is lost. You can call session_write_close() so the other process can access the session storage. Marking a feature request, maybe there's a better solution in future. ------------------------------------------------------------------------ [2010-03-10 17:52:12] bugs dot php dot net_2010 at forskernet dot dk Description: ------------ I would like to run to requests in parallel in the same session, i.e. have two instances of a php script run simultaneously. To demonstrate, please see the attached code (it will print 60 | chars with a second in between): Next, simply open two tabs in your browser and call the script from both tabs. If it is working as I hope, you will notice that they will not run in parallel (as I was hoping), but instead the script will start executing in one of the tabs, while the other will appear to hang. After the script in this tabs finishes (after one minute), the next tab will start executing. I have tried different approaches for achieving explicit locking, mainly using session_set_save_handler (http://theserverpages.com/php/manual/en/function.session-set-save-handler.php), but to no effect - the locking is effective no matter what I come up with. These are some pages that mention solutions for explicit locking, but none appear effective: - http://thwartedefforts.org/2006/11/11/race-conditions-with-ajax-and-php-sessions/ - http://www.tonymarston.co.uk/php-mysql/client-clones.html - http://blog.perplexedlabs.com/2009/10/05/php-custom-session-handler/ So, it appears to me that session_set_save_handler() is buggy - or am I just naively hoping it will work for me for a purpose it doesn't support? Test script: --------------- <?php print "["; for($i = 0; $i < 100; $i++){ $spaces.="<!-- bufferme -->"; } // for //and then for($i = 0; $i < 60; $i++){ for($ii = 0; $ii < 200000; $ii++){ //do something slow here } // for sleep(1); print "$spaces|"; flush(); } // for print "]"; ?> Expected result: ---------------- Both scripts running in parallel. Actual result: -------------- Scripts executing one at a time. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=51264&edit=1