Skip to content

Commit 52ebd56

Browse files
committed
fix hard_timeout support in shutdown functions
1 parent db68121 commit 52ebd56

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Zend/zend_execute_API.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,8 +1157,22 @@ static void zend_set_timeout_ex(zend_long seconds, int reset_signals);
11571157

11581158
ZEND_API ZEND_NORETURN void zend_timeout(int dummy) /* {{{ */
11591159
{
1160+
#if defined(PHP_WIN32)
1161+
/* No action is needed if we're timed out because zero seconds are
1162+
just ignored. Also, the hard timeout needs to be respected. If the
1163+
timer is not restarted properly, it could hang in the shutdown
1164+
function. */
1165+
if (EG(hard_timeout) > 0) {
1166+
EG(timed_out) = 0;
1167+
zend_set_timeout_ex(EG(hard_timeout), 1);
1168+
/* XXX Abused, introduce an additional flag if the value needs to be kept. */
1169+
EG(hard_timeout) = 0;
1170+
}
1171+
#else
11601172
EG(timed_out) = 0;
11611173
zend_set_timeout_ex(0, 1);
1174+
#endif
1175+
11621176
zend_error_noreturn(E_ERROR, "Maximum execution time of %pd second%s exceeded", EG(timeout_seconds), EG(timeout_seconds) == 1 ? "" : "s");
11631177
}
11641178
/* }}} */

0 commit comments

Comments
 (0)