PHP-FPM fastcgi_finish_request() 未按预期工作
我阅读了 @Dmitri 的原始 如何使用 fastcgi_finish_request() 问题的示例,并尝试按照我的 Kohana 中的答案中的示例进行操作3.1 在index.php 中设置:
echo Request::factory()
->execute()
->send_headers()
->body();
紧接着,我添加了:
fastcgi_finish_request();
sleep(5);
最初,我认为它有效。但后来我意识到它只能满足所有其他请求。示例:
- 导航到 localhost(有效,无暂停)
- 单击指向 localhost/controller 的链接(暂停 5 秒)
- 单击另一个指向 localhost/controller 的链接(再次有效,无暂停)
然后就这样继续。我错过了什么吗?就像 php5-fpm 配置文件中的设置一样?
使用 Suhosin-Patch、Nginx 运行 PHP 5.3.5-1ubuntu7.2
I read @Dmitri 's original example of how to use fastcgi_finish_request() question and tried to follow the example in the answer in my Kohana 3.1 setup in index.php:
echo Request::factory()
->execute()
->send_headers()
->body();
Right after that, I added:
fastcgi_finish_request();
sleep(5);
Initially, I thought it worked. But then I realised in only worked for every other request. Example:
- Navigate to localhost (works, no pause)
- Click link to localhost/controller (pause 5 seconds)
- Click another link to localhost/controller (works again, no pause)
And it continues on like that. Am I missing something? Like maybe a setting in php5-fpm config file?
Running PHP 5.3.5-1ubuntu7.2 with Suhosin-Patch, Nginx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在调用
fastcgi_finish_request()
之前调用session_write_close()
来解决此问题:Call
session_write_close()
before you callfastcgi_finish_request()
to resolve this issue:除了服务器响应本身(您可以使用 fastcgi_finish_request 函数进行控制,并放心它会以这种方式工作)之外,可能还有其他资源阻止(下一个)脚本立即开始。
这可以是文件锁定(在会话中很流行)和其他东西。由于您没有共享太多代码,并且我们没有看到您的 Kohana 配置,您应该查看一下您使用了哪些组件以及它们获取了哪些资源。
Next to the server-response itself (which you can control with the
fastcgi_finish_request
function and rest assured it works that way), there can be other resources that is blocking the (next) script from starting right ahead.This can be file-lockings (popular for session) and other stuff. As you have not shared much code and we do not see your Kohana configuration you should take a look which components you use and which resources they acquire.
是不是因为你的Web服务器一次只处理一个php实例并且它仍然令人兴奋之前的脚本?
Is it because your web server only handles one php instance at a time and it is still exciting the previous script?