Skip to content

Commit 98a21d1

Browse files
NattyNarwhalnikic
authored andcommitted
Fix bug #80728: Don't reset the timeout on ini deactivate
When the time limit for a script is changed, when the script ends, its INI value will be reset. This calls the event handler for the timeout change, which will unset then reset the timeout. However, this is done even if the script is done executing, and say, the CGI or CLI web server process is idle. This is probably incorrect, but isn't a problem on most platforms, because PHP uses a timer that only ticks when the process is active (that is, executing code). Since when it's idle, it's blocking on listen/read, it won't tick because nothing executes. However, on platforms where only the real-time timer is supported, (Cygwin/PASE) it ticks regardless of if PHP is even executing. This means that the idle processes are subject to timeouts from the INI reset on script end. This makes it so the timer is never set if the state is deactivating. Testing with the CLI web server indicates the timer no longer spuriously activates under PASE. Closes GH-6683.
1 parent 40332be commit 98a21d1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ PHP NEWS
77
(cmb, Nikita)
88
. Fixed bug #81163 (incorrect handling of indirect vars in __sleep).
99
(krakjoe)
10+
. Fixed bug #80728 (PHP built-in web server resets timeout when it can kill
11+
the process). (Calvin Buckley)
1012

1113
- Intl:
1214
. Fixed bug #72809 (Locale::lookup() wrong result with canonicalize option).

main/main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,15 @@ static PHP_INI_MH(OnUpdateTimeout)
479479
}
480480
zend_unset_timeout();
481481
ZEND_ATOL(EG(timeout_seconds), ZSTR_VAL(new_value));
482-
zend_set_timeout(EG(timeout_seconds), 0);
482+
if (stage != PHP_INI_STAGE_DEACTIVATE) {
483+
/*
484+
* If we're restoring INI values, we shouldn't reset the timer.
485+
* Otherwise, the timer is active when PHP is idle, such as the
486+
* the CLI web server or CGI. Running a script will re-activate
487+
* the timeout, so it's not needed to do so at script end.
488+
*/
489+
zend_set_timeout(EG(timeout_seconds), 0);
490+
}
483491
return SUCCESS;
484492
}
485493
/* }}} */

0 commit comments

Comments
 (0)