Skip to content

Commit b403bb9

Browse files
dunglasclaude
andcommitted
fix: prevent worker starvation after max_execution_time restarts
Disable the execution timer in frankenphp_worker_request_shutdown() to prevent stale timers from firing between requests. Also fix evaluation order in frankenphp_handle_request() to check for shutdown before calling frankenphp_worker_request_startup(). Fixes #2205 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b02d99a commit b403bb9

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

frankenphp.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,12 @@ static void frankenphp_cleanup_worker_state(void) {
385385

386386
/* Adapted from php_request_shutdown */
387387
static void frankenphp_worker_request_shutdown() {
388+
#ifdef ZEND_MAX_EXECUTION_TIMERS
389+
/* Disable any execution timer set during the request callback to prevent
390+
* stale timers from firing between requests */
391+
zend_unset_timeout();
392+
#endif
393+
388394
/* Flush all output buffers */
389395
zend_try { php_output_end_all(); }
390396
zend_end_try();
@@ -667,9 +673,7 @@ PHP_FUNCTION(frankenphp_handle_request) {
667673

668674
struct go_frankenphp_worker_handle_request_start_return result =
669675
go_frankenphp_worker_handle_request_start(thread_index);
670-
if (frankenphp_worker_request_startup() == FAILURE
671-
/* Shutting down */
672-
|| !result.r0) {
676+
if (!result.r0 || frankenphp_worker_request_startup() == FAILURE) {
673677
RETURN_FALSE;
674678
}
675679

0 commit comments

Comments
 (0)