Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Zend/zend_execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ ZEND_API bool zend_is_executing(void);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_cannot_pass_by_reference(uint32_t arg_num);

ZEND_API void zend_set_timeout(zend_long seconds, bool reset_signals);
ZEND_API void zend_set_input_timeout(zend_long seconds);
ZEND_API void zend_unset_timeout(void);
ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(void);
ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type);
Expand Down
13 changes: 11 additions & 2 deletions Zend/zend_execute_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,10 @@ ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(void) /* {{{ */
zend_set_timeout_ex(0, 1);
#endif

zend_error_noreturn(E_ERROR, "Maximum execution time of " ZEND_LONG_FMT " second%s exceeded", EG(timeout_seconds), EG(timeout_seconds) == 1 ? "" : "s");
zend_error_noreturn(E_ERROR, "Maximum %s time of " ZEND_LONG_FMT " second%s exceeded",
EG(timeout_type) == ZEND_TIMEOUT_TYPE_INPUT ? "input" : "execution",
EG(timeout_seconds),
EG(timeout_seconds) == 1 ? "" : "s");
}
/* }}} */

Expand Down Expand Up @@ -1493,13 +1496,19 @@ static void zend_set_timeout_ex(zend_long seconds, bool reset_signals) /* {{{ */

void zend_set_timeout(zend_long seconds, bool reset_signals) /* {{{ */
{

EG(timeout_seconds) = seconds;
EG(timeout_type) = ZEND_TIMEOUT_TYPE_DEFAULT;
zend_set_timeout_ex(seconds, reset_signals);
EG(timed_out) = 0;
}
/* }}} */

void zend_set_input_timeout(zend_long seconds)
{
zend_set_timeout(seconds, 1);
EG(timeout_type) = ZEND_TIMEOUT_TYPE_INPUT;
}

void zend_unset_timeout(void) /* {{{ */
{
#ifdef ZEND_WIN32
Expand Down
3 changes: 3 additions & 0 deletions Zend/zend_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ END_EXTERN_C()

#define SYMTABLE_CACHE_SIZE 32

#define ZEND_TIMEOUT_TYPE_DEFAULT 1
#define ZEND_TIMEOUT_TYPE_INPUT 2

#include "zend_compile.h"

Expand Down Expand Up @@ -212,6 +214,7 @@ struct _zend_executor_globals {

/* timeout support */
zend_long timeout_seconds;
zend_ulong timeout_type;

int capture_warnings_during_sccp;

Expand Down
2 changes: 1 addition & 1 deletion main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1737,7 +1737,7 @@ int php_request_startup(void)
if (PG(max_input_time) == -1) {
zend_set_timeout(EG(timeout_seconds), 1);
Copy link
Member

@kocsismate kocsismate Apr 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, this is also an input timeout: when max_input_time equals to -1 the value of max_execution_time is used (https://www.php.net/manual/en/info.configuration.php#ini.max-input-time)

} else {
zend_set_timeout(PG(max_input_time), 1);
zend_set_input_timeout(PG(max_input_time));
}

/* Disable realpath cache if an open_basedir is set */
Expand Down