]> granicus.if.org Git - php/commitdiff
Add apache_reset_timeout() function for Apache1. This is needed because
authorRasmus Lerdorf <rasmus@php.net>
Sat, 4 Dec 2004 07:16:44 +0000 (07:16 +0000)
committerRasmus Lerdorf <rasmus@php.net>
Sat, 4 Dec 2004 07:16:44 +0000 (07:16 +0000)
Apache1 only resets the write timer, which defaults to 300 seconds, on
a successful write.  That is, if the client has gone away and Apache
attempts a write which fails it will set the conn->aborted flag but not
reset the timeout.  Assuming the PHP script is running in ignore_user_abort
mode we ignore the aborted flag, but we'll still get blown out of the water
300 seconds after the failed write unless we periodically reset the timer.
With set_time_limit(0), ignore_user_abort(true) and periodic
apache_reset_timeout() calls we can theoretically run forever which is
why I disabled this call in safe mode.

NEWS
sapi/apache/php_apache.c

diff --git a/NEWS b/NEWS
index ce8123ee22f3d35e7a16dfbc79d7c5f24c6b3200..e282067b11de5b251f883de743f1b2ea81e58440 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2004, PHP 5.1.0
+- Add apache_reset_timeout() Apache1 function. (Rasmus)
 - Make request start time be available via $_SERVER['REQUEST_TIME']. (Ilia)
 - Allow gettimeofday() return a float if optional argument is specified. (Ilia)
 - Added sqlite_fetch_column_types() 3rd argument for arrays. (Ilia)
index a52e95d19b023ae444feaf757420ca0a74837e69..6f98f3ecc9cdc8503bf21f5f15392c8c31b2793a 100644 (file)
@@ -47,6 +47,7 @@ PHP_FUNCTION(apache_child_terminate);
 PHP_FUNCTION(apache_setenv);
 PHP_FUNCTION(apache_get_version);
 PHP_FUNCTION(apache_get_modules);
+PHP_FUNCTION(apache_reset_timeout);
 
 PHP_MINFO_FUNCTION(apache);
 
@@ -536,6 +537,20 @@ PHP_FUNCTION(apache_get_modules)
 }
 /* }}} */
 
+/* {{{ proto array apache_reset_timeout(void)
+   Reset the Apache write timer */
+PHP_FUNCTION(apache_reset_timeout)
+{
+       if (PG(safe_mode)) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot reset the Apache timeout in safe mode");
+               RETURN_FALSE;
+       }
+
+       ap_reset_timeout((request_rec *)SG(server_context));
+       RETURN_TRUE;
+}
+/* }}} */
+
 /*
  * Local variables:
  * tab-width: 4