PHP-FPM fastcgi_finish_request() 未按预期工作

发布于 2024-12-09 00:34:06 字数 649 浏览 0 评论 0原文

我阅读了 @Dmitri 的原始 如何使用 fastcgi_finish_request() 问题的示例,并尝试按照我的 Kohana 中的答案中的示例进行操作3.1 在index.php 中设置:

echo Request::factory()
    ->execute()
    ->send_headers()
    ->body();

紧接着,我添加了:

fastcgi_finish_request();
sleep(5);

最初,我认为它有效。但后来我意识到它只能满足所有其他请求。示例:

  1. 导航到 localhost(有效,无暂停)
  2. 单击指向 localhost/controller 的链接(暂停 5 秒)
  3. 单击另一个指向 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:

  1. Navigate to localhost (works, no pause)
  2. Click link to localhost/controller (pause 5 seconds)
  3. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

帅气尐潴 2024-12-16 00:34:06

在调用 fastcgi_finish_request() 之前调用 session_write_close() 来解决此问题:

session_write_close();
fastcgi_finish_request();
sleep(5);

Call session_write_close() before you call fastcgi_finish_request() to resolve this issue:

session_write_close();
fastcgi_finish_request();
sleep(5);
满地尘埃落定 2024-12-16 00:34:06

除了服务器响应本身(您可以使用 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.

抚你发端 2024-12-16 00:34:06

是不是因为你的Web服务器一次只处理一个php实例并且它仍然令人兴奋之前的脚本?

Is it because your web server only handles one php instance at a time and it is still exciting the previous script?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文