Skip to content

Commit d35dd7e

Browse files
committed
Fix behavior on platforms which already measure wall-clock time
1 parent 2845904 commit d35dd7e

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

main/main.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -385,32 +385,41 @@ static void php_binary_init(void)
385385
}
386386
/* }}} */
387387

388-
/* {{{ PHP_INI_MH */
389-
static PHP_INI_MH(OnUpdateTimeout)
388+
static void updateTimeout(zend_string * new_value, int stage)
390389
{
391-
if (stage==PHP_INI_STAGE_STARTUP) {
390+
if (stage == PHP_INI_STAGE_STARTUP) {
392391
/* Don't set a timeout on startup, only per-request */
393392
ZEND_ATOL(EG(timeout_seconds), ZSTR_VAL(new_value));
394-
return SUCCESS;
393+
return;
395394
}
396395
zend_unset_timeout();
397396
ZEND_ATOL(EG(timeout_seconds), ZSTR_VAL(new_value));
398397
zend_set_timeout(EG(timeout_seconds), 0);
398+
}
399+
400+
/* {{{ PHP_INI_MH */
401+
static PHP_INI_MH(OnUpdateTimeout)
402+
{
403+
updateTimeout(new_value, stage);
399404
return SUCCESS;
400405
}
401406
/* }}} */
402407

403408
/* {{{ PHP_INI_MH */
404409
static PHP_INI_MH(OnUpdateWallTimeout)
405410
{
406-
if (stage==PHP_INI_STAGE_STARTUP) {
411+
#if defined(WIN32) || defined(__CYGWIN__) || defined(__PASE__)
412+
updateTimeout();
413+
#else
414+
if (stage == PHP_INI_STAGE_STARTUP) {
407415
/* Don't set a timeout on startup, only per-request */
408416
ZEND_ATOL(EG(wall_timeout_seconds), ZSTR_VAL(new_value));
409417
return SUCCESS;
410418
}
411419
zend_unset_wall_timeout();
412420
ZEND_ATOL(EG(wall_timeout_seconds), ZSTR_VAL(new_value));
413421
zend_set_wall_timeout(EG(wall_timeout_seconds), 0);
422+
#endif
414423
return SUCCESS;
415424
}
416425
/* }}} */
@@ -1702,7 +1711,9 @@ int php_request_startup(void)
17021711
} else {
17031712
zend_set_timeout(PG(max_input_time), 1);
17041713
}
1714+
#if !defined(WIN32) && !defined(__CYGWIN__) && !defined(__PASE__)
17051715
zend_set_wall_timeout(EG(wall_timeout_seconds), 1);
1716+
#endif
17061717

17071718
/* Disable realpath cache if an open_basedir is set */
17081719
if (PG(open_basedir) && *PG(open_basedir)) {
@@ -1792,7 +1803,9 @@ void php_request_shutdown(void *dummy)
17921803
/* 4. Reset max_execution_time and max_execution_wall_time (no longer executing php code after response sent) */
17931804
zend_try {
17941805
zend_unset_timeout();
1806+
#if !defined(WIN32) && !defined(__CYGWIN__) && !defined(__PASE__)
17951807
zend_unset_wall_timeout();
1808+
#endif
17961809
} zend_end_try();
17971810

17981811
/* 5. Call all extensions RSHUTDOWN functions */

0 commit comments

Comments
 (0)