Re: Proposal: Check if script has been aborted (for apache)
| From: | Rasmus Lerdorf | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: Proposal: Check if script has been aborted (for apache) | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-3613@lists.php.net to get a copy of this message | ||
> but what i want to get is:
> - be fully backward compatible (keep the script running - so nobody gets hurt by
> this "new" feature)
> - be able to set the behaviour:
> - just abort the script
> - call a user-level function (for user-level logging;-) and run the rest of the
> script
> - call a user-level function (for user-level logging;-) and stop the script
> (maybe based on the return value of the user-level function???)
>
> i've looked into the register_shutdown_function stuff - and i believe i could get
> something like this up for "died" requests (detection only takes place when the
> script actually writes to the HTTP stream - and only for apache)....
>
> i was dreaming of something like:
>
> <?
> function script_stopped()
> { mylogfunction("script has been aborted");
> return 0; // 0 -> please continue execution, 1 -> stop it NOW!!!
> }
>
> register_abort_function("script_stopped");
>
> while (1)
> printf "this is cool<BR>";
> ?>
>
> any suggestions????
Hrm.. How about just a simple function that returns that global variable
you created. You could then just check that in your shutdown function in
a script. That would avoid adding an extra register_abort_function()
call.
function abort_function() {
whatever;
}
function shutdown() {
if(connection_aborted()) {
abort_function();
}
}
register_shutdown_function("shutdown");
As for configuring whether to actually abort the script or not. Perhaps
that should be a php3.ini switch.
-Rasmus
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net