summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/SAPI.c6
-rw-r--r--main/SAPI.h2
-rw-r--r--main/main.c14
-rw-r--r--main/php_globals.h1
4 files changed, 17 insertions, 6 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
index a5699252b1..feabcef549 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -1002,6 +1002,12 @@ SAPI_API time_t sapi_get_request_time(TSRMLS_D)
return SG(global_request_time);
}
+SAPI_API void sapi_terminate_process(TSRMLS_D) {
+ if (sapi_module.terminate_process) {
+ sapi_module.terminate_process(TSRMLS_C);
+ }
+}
+
/*
* Local variables:
* tab-width: 4
diff --git a/main/SAPI.h b/main/SAPI.h
index 39a9a85b26..d4a558e3e7 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -207,6 +207,7 @@ SAPI_API int sapi_force_http_10(TSRMLS_D);
SAPI_API int sapi_get_target_uid(uid_t * TSRMLS_DC);
SAPI_API int sapi_get_target_gid(gid_t * TSRMLS_DC);
SAPI_API time_t sapi_get_request_time(TSRMLS_D);
+SAPI_API void sapi_terminate_process(TSRMLS_D);
END_EXTERN_C()
struct _sapi_module_struct {
@@ -236,6 +237,7 @@ struct _sapi_module_struct {
void (*register_server_variables)(zval *track_vars_array TSRMLS_DC);
void (*log_message)(char *message);
time_t (*get_request_time)(TSRMLS_D);
+ void (*terminate_process)(TSRMLS_D);
char *php_ini_path_override;
diff --git a/main/main.c b/main/main.c
index 5b8e334ed8..e86ca796b3 100644
--- a/main/main.c
+++ b/main/main.c
@@ -209,7 +209,7 @@ static PHP_INI_MH(OnUpdateTimeout)
return SUCCESS;
}
zend_unset_timeout(TSRMLS_C);
- zend_set_timeout(EG(timeout_seconds));
+ zend_set_timeout(EG(timeout_seconds), 0);
return SUCCESS;
}
/* }}} */
@@ -461,6 +461,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("user_ini.filename", ".user.ini", PHP_INI_SYSTEM, OnUpdateString, user_ini_filename, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("user_ini.cache_ttl", "300", PHP_INI_SYSTEM, OnUpdateLong, user_ini_cache_ttl, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("exit_on_timeout", "0", PHP_INI_ALL, OnUpdateBool, exit_on_timeout, php_core_globals, core_globals)
PHP_INI_END()
/* }}} */
@@ -1229,7 +1230,8 @@ static void php_message_handler_for_zend(long message, void *data)
void php_on_timeout(int seconds TSRMLS_DC)
{
PG(connection_status) |= PHP_CONNECTION_TIMEOUT;
- zend_set_timeout(EG(timeout_seconds));
+ zend_set_timeout(EG(timeout_seconds), 0);
+ if(PG(exit_on_timeout)) sapi_terminate_process(TSRMLS_C);
}
#if PHP_SIGCHILD
@@ -1259,7 +1261,7 @@ static int php_start_sapi(TSRMLS_D)
PG(connection_status) = PHP_CONNECTION_NORMAL;
zend_activate(TSRMLS_C);
- zend_set_timeout(EG(timeout_seconds));
+ zend_set_timeout(EG(timeout_seconds), 1);
zend_activate_modules(TSRMLS_C);
PG(modules_activated)=1;
} zend_catch {
@@ -1303,9 +1305,9 @@ int php_request_startup(TSRMLS_D)
sapi_activate(TSRMLS_C);
if (PG(max_input_time) == -1) {
- zend_set_timeout(EG(timeout_seconds));
+ zend_set_timeout(EG(timeout_seconds), 1);
} else {
- zend_set_timeout(PG(max_input_time));
+ zend_set_timeout(PG(max_input_time), 1);
}
/* Disable realpath cache if safe_mode or open_basedir are set */
@@ -2070,7 +2072,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
#ifdef PHP_WIN32
zend_unset_timeout(TSRMLS_C);
#endif
- zend_set_timeout(INI_INT("max_execution_time"));
+ zend_set_timeout(EG(timeout_seconds), 0);
}
retval = (zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 3, prepend_file_p, primary_file, append_file_p) == SUCCESS);
diff --git a/main/php_globals.h b/main/php_globals.h
index 0c9ccff5df..53863104c6 100644
--- a/main/php_globals.h
+++ b/main/php_globals.h
@@ -154,6 +154,7 @@ struct _php_core_globals {
char *disable_functions;
char *disable_classes;
zend_bool allow_url_include;
+ zend_bool exit_on_timeout;
#ifdef PHP_WIN32
zend_bool com_initialized;
#endif