Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -224,6 +224,7 @@ ZEND_API uint zend_get_executed_lineno(void);
ZEND_API zend_bool zend_is_executing(void);

ZEND_API void zend_set_timeout(zend_long seconds, int reset_signals);
ZEND_API void zend_set_input_timeout(long seconds);
ZEND_API void zend_unset_timeout(void);
ZEND_API void zend_timeout(int dummy);
ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type);
Expand Down
14 changes: 13 additions & 1 deletion Zend/zend_execute_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,11 @@ ZEND_API void zend_timeout(int dummy) /* {{{ */
zend_on_timeout(EG(timeout_seconds));
}

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

Expand Down Expand Up @@ -1172,6 +1176,7 @@ void zend_set_timeout(zend_long seconds, int reset_signals) /* {{{ */
{

EG(timeout_seconds) = seconds;
EG(timeout_type) = ZEND_TIMEOUT_TYPE_DEFAULT;

#ifdef ZEND_WIN32
if(!seconds) {
Expand Down Expand Up @@ -1237,6 +1242,13 @@ void zend_set_timeout(zend_long seconds, int reset_signals) /* {{{ */
}
/* }}} */

void zend_set_input_timeout(long seconds) /* {{{ */
{
zend_set_timeout(seconds, 1);
EG(timeout_type) = ZEND_TIMEOUT_TYPE_INPUT;
}
/* }}} */

void zend_unset_timeout(void) /* {{{ */
{
#ifdef ZEND_WIN32
Expand Down
4 changes: 4 additions & 0 deletions Zend/zend_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ END_EXTERN_C()
#define ZEND_EARLY_BINDING_DELAYED 1
#define ZEND_EARLY_BINDING_DELAYED_ALL 2

#define ZEND_TIMEOUT_TYPE_DEFAULT 1
#define ZEND_TIMEOUT_TYPE_INPUT 2

typedef struct _zend_declarables {
zval ticks;
} zend_declarables;
Expand Down Expand Up @@ -208,6 +211,7 @@ struct _zend_executor_globals {

/* timeout support */
zend_long timeout_seconds;
int timeout_type;
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer using an unsigned char here. More appropriate storage size


int lambda_count;

Expand Down
2 changes: 1 addition & 1 deletion main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1621,7 +1621,7 @@ int php_request_startup(void)
if (PG(max_input_time) == -1) {
zend_set_timeout(EG(timeout_seconds), 1);
} 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