1

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

Community
  • 1
  • 1
Jason J. Nathan
  • 7,422
  • 2
  • 26
  • 37
  • 1
    Sorry guys, I asked this almost exactly a year ago. I can't find the relevant code anymore but will update update this question as soon as I have time to get back to it. Thanks for your replies! – Jason J. Nathan Nov 10 '12 at 07:54

3 Answers3

2

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

session_write_close();
fastcgi_finish_request();
sleep(5);
Sebass van Boxel
  • 2,514
  • 1
  • 22
  • 37
gold
  • 21
  • 2
1

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.

hakre
  • 193,403
  • 52
  • 435
  • 836
-1

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

nbransby
  • 359
  • 4
  • 12