Re: On register_shutdown_function: What might be the problem?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I want the http client see the page ( here y.html) immediately after I call header function, and then close the connectiion, and the function f running in the background. But trying many many times, the result seems that I have to either set the time limit to small to send the the html page sooner but also terminate the background running function which was registered as a shutdown function, or set the time to long enough for the shutdown function to finish while keeping the http client waiting until function return.

I doubt that register_shutdown_function meant to behave this way by its design. I would like to find out what could be wrong of my code, configuration of php or apache?

My Question is:
What is the correct way to keep the function running after I redirect an existing page to http client (which I want the client get immediately) and then immediately close the connection?

Thank you very much.


Given it's a fatal error, it's as bad as a syntax error. It cancels
everything it's doing and leaves.

Remember that, even the shutdown function has to obey the time limit.

On 7/22/05, Liang ZHONG <little00wofl@xxxxxxxxxxx> wrote:
> <?php
>
> set_time_limit(0);
> function f(){
>         $count=10000000;
>         for($i=0; $i<$count; $i++){ }
>
>         exec("touch  /tmp/ccc");
> }
>
>
> register_shutdown_function('f');
>
> header("Content-type: text/plain");
> header("Location: y.html");
> ?>
>
>
> When the time_limit is set to 0, the redirect page will be shown in 20
> second after the file ccc is created.
> When the time_limit is set to 5, the redirect page will be shown in 5 second > and the ccc file is not created. The error from curl command line tool is
> as:
> ---------------------------------------
> <br />
> <b>Fatal error</b>:  Maximum execution time of 5 seconds exceeded
> in<b>/...../y.php</b> on line <b>6</b><br />
> ----------------------------------------
>
> What might be the problem that my register shudown function can not
> continuously run after the main program end?
> What is the correct way to keep the function running after I redirect a
> existing page to http client and then  immediately close the connection?
>
> Thank you very much for your help.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux