session_start挂起同一会话的并行请求 [英] session_start hangs parallel requests for the same session

查看:89
本文介绍了session_start挂起同一会话的并行请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我有一个在php和两个浏览器窗口(IE)/标签开始的会话

(FF)打开。

在一个窗口中,我执行一个非常慢的报告,紧接着那个,我

在另一个页面执行一个快速简单的页面。


我已经设置了一个计时器,可以将时间记录到全局变量中

请求的开始,

它以秒为单位输出三个时间值 - 就在session_start之前,

紧跟在session_start之后,并且在请求的最后。

这里是它显示的内容

之前开始的慢速报告:

DEBUG:会话开始前:0.0115

DEBUG:会话开始时间:0.0133

DEBUG:结束请求:101.9878


快速之后开始的页面:

DEBUG:会话开始前:0.0114

DEBUG:会话开始时间:98.467

DEBUG:结束请求:99.084


对于任何请求计数都是如此,所有这些请求的加载速度都是最慢的。

什么'这是错误的w / session_start以及如何修复它?

Hi. I have a session started in php and two browser windows (IE)/tabs
(FF) open.
In one window, I execute a very slow report, immediately after that, I
execute a fast simple page in another.

I have set up a timer that records time into global variable at the
start of the request,
it outputs three time values in seconds - right before session_start,
right after session_start, and at the very end of the request.
here''s what it shows
Slow report that started a second earlier:
DEBUG: Before session start: 0.0115
DEBUG: Session start: 0.0133
DEBUG: End request: 101.9878

"Quick" page that started after it:
DEBUG: Before session start: 0.0114
DEBUG: Session start time: 98.467
DEBUG: End request: 99.084

The same is true for any request count, all of them load as fast as
the slowest one.
What''s wrong w/session_start and how do I fix it?

推荐答案

6月11日下午12:21,Sergei Shelukhin< ; realg ... @ gmail.comwrote:
On Jun 11, 12:21 pm, Sergei Shelukhin <realg...@gmail.comwrote:

嗨。我有一个在php和两个浏览器窗口(IE)/标签开始的会话

(FF)打开。

在一个窗口中,我执行一个非常慢的报告,紧接着那个,我

在另一个页面执行一个快速简单的页面。


我已经设置了一个计时器,可以将时间记录到全局变量中

请求的开始,

它以秒为单位输出三个时间值 - 就在session_start之前,

紧跟在session_start之后,并且在请求的最后。

这里是它显示的内容

之前开始的慢速报告:

DEBUG:会话开始前:0.0115

DEBUG:会话开始时间:0.0133

DEBUG:结束请求:101.9878


快速之后开始的页面:

DEBUG:会话开始前:0.0114

DEBUG:会话开始时间:98.467

DEBUG:结束请求:99.084


对于任何请求计数都是如此,所有这些请求的加载速度都是最慢的。

什么'错了w / session_start,我该如何解决?
Hi. I have a session started in php and two browser windows (IE)/tabs
(FF) open.
In one window, I execute a very slow report, immediately after that, I
execute a fast simple page in another.

I have set up a timer that records time into global variable at the
start of the request,
it outputs three time values in seconds - right before session_start,
right after session_start, and at the very end of the request.
here''s what it shows
Slow report that started a second earlier:
DEBUG: Before session start: 0.0115
DEBUG: Session start: 0.0133
DEBUG: End request: 101.9878

"Quick" page that started after it:
DEBUG: Before session start: 0.0114
DEBUG: Session start time: 98.467
DEBUG: End request: 99.084

The same is true for any request count, all of them load as fast as
the slowest one.
What''s wrong w/session_start and how do I fix it?



这是因为第一个请求锁定会话文件并且没有
释放锁定直到会话关闭(在

请求结束时)。所以,其他页面等待它完成。请参阅此说明:


< http://www.php.net/manual/en/ref.session.php#64525>

It''s because the first request locks the session file and doesn''t
release the lock until the session is closed (at the end of the
request). So, the other pages wait for it to finish. See this note:

<http://www.php.net/manual/en/ref.session.php#64525>


谢谢,就是这样!

但是,如果我有一个会议开始的标准模式和

然后关闭写入在一个地方开始每个请求,

如何重新打开它以便偶尔写一个变量?我有两个地方确实需要这样做,如果我在那里使用session_start它

显示警告(不能发送cookie)。我可以抑制它们但是它

看起来不正确

Thanks, that was it!
However, if I have a standard pattern where session is started and
then closed for writing at the start of every request in one place,
how do I reopen it to write a variable once in a while? I have exactly
two places where I need to do that and if I use session_start there it
shows warnings (cannot send cookie). I can suppress them but it
doesn''t seem right


Sergei Shelukhin写道:
Sergei Shelukhin wrote:

嗨。我有一个在php和两个浏览器窗口(IE)/标签开始的会话

(FF)打开。

在一个窗口中,我执行一个非常慢的报告,紧接着那个,我

在另一个页面执行一个快速简单的页面。


我已经设置了一个计时器,可以将时间记录到全局变量中

请求的开始,

它以秒为单位输出三个时间值 - 就在session_start之前,

紧跟在session_start之后,并且在请求的最后。

这里是它显示的内容

之前开始的慢速报告:

DEBUG:会话开始前:0.0115

DEBUG:会话开始时间:0.0133

DEBUG:结束请求:101.9878


快速之后开始的页面:

DEBUG:会话开始前:0.0114

DEBUG:会话开始时间:98.467

DEBUG:结束请求:99.084


对于任何请求计数都是如此,所有这些请求的加载速度都是最慢的。

什么'这是错误的w / session_start以及如何修复它?
Hi. I have a session started in php and two browser windows (IE)/tabs
(FF) open.
In one window, I execute a very slow report, immediately after that, I
execute a fast simple page in another.

I have set up a timer that records time into global variable at the
start of the request,
it outputs three time values in seconds - right before session_start,
right after session_start, and at the very end of the request.
here''s what it shows
Slow report that started a second earlier:
DEBUG: Before session start: 0.0115
DEBUG: Session start: 0.0133
DEBUG: End request: 101.9878

"Quick" page that started after it:
DEBUG: Before session start: 0.0114
DEBUG: Session start time: 98.467
DEBUG: End request: 99.084

The same is true for any request count, all of them load as fast as
the slowest one.
What''s wrong w/session_start and how do I fix it?



会话是单线程的。如果您已经在一个

会话中打开了该页面,PHP将保留同一会话的任何其他请求。


要解决此问题,您需要调用

长时间运行的任务中的session_write_close()。当然,在此之后你将无法获得

Sessions are single threaded. If you already have the page open in one
session, PHP will hold any other requests for that same session.

To resolve the problem you need to call session_write_close() in the
long-running task. Of course, after that you won''t have access to any
of the

的任何


这篇关于session_start挂起同一会话的并行请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆