This article provides a detailed analysis of PHP's solution to session deadlock. For more information, see the difficult problem encountered during development today.
When the background of an asynchronous request is processing a large amount of data, no information is returned from other controllers .. At first, I thought it was caused by setting ajax synchronization in the Ext framework.
Later, it was found that the session deadlock caused other controllers to wait until the session is complete. (This mainly refers to the user login judgment that the session needs to be updated)
When PHP cannot complete operations on large data volumes in a timely manner, another controller or
Session deadlock occurs during asynchronous requests.
I discussed with my colleagues that session_write_close () can be used to solve this problem.
The code is as follows:
Description
Void session_write_close (void)
End the current session and store session data.
Session data is usually stored after your script terminated without the need to call session_write_close (), but as session data is locked to prevent concurrent writes only one script may operate on a session at any time. when using framesets together with sessions you will experience the frames loading one by one due to this locking. you can reduce the time needed to load all the frames by ending the session as soon as all changes to session variables are done.
Function: ends the current session operation and saves session data.
Clearly, when the script request does not call session_write_close (); the session data is stored. However, session Date (that is, the session file) is locked.
It is to avoid unnecessary consequences for other applications to operate sessions at this time. when the framework is used, different files may constantly operate sessions so as not to cause other operations to wait for deadlocks on the current session.
You can use this function...
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service