diff --git a/app/active_calls/resources/classes/active_calls_service.php b/app/active_calls/resources/classes/active_calls_service.php index a216fdd5b..2fbc118e8 100644 --- a/app/active_calls/resources/classes/active_calls_service.php +++ b/app/active_calls/resources/classes/active_calls_service.php @@ -394,10 +394,18 @@ class active_calls_service extends service implements websocket_service_interfac if (!empty($read)) { $write = $except = []; // Wait for an event and timeout at 1/3 of a second so we can re-check all connections - if (false === stream_select($read, $write, $except, 0, 333333)) { - // severe error encountered so exit + $select_result = @stream_select($read, $write, $except, 0, 333333); + if ($select_result === false) { + // SIGUSR1/SIGHUP can interrupt stream_select during reload + $last_error = error_get_last(); + $last_error_message = $last_error['message'] ?? ''; + $error_message = strtolower((string)$last_error_message); + if (str_contains($error_message, 'interrupted system call')) { + continue; + } + + // real fatal select error $this->running = false; - // Exit with non-zero exit code return 1; } diff --git a/core/websockets/resources/classes/websocket_service.php b/core/websockets/resources/classes/websocket_service.php index c64a71c57..c0c45f5af 100644 --- a/core/websockets/resources/classes/websocket_service.php +++ b/core/websockets/resources/classes/websocket_service.php @@ -582,8 +582,15 @@ class websocket_service extends service { // // Wait for activity on the sockets and timeout about 3 times per second // - $result = stream_select($read, $write, $except, 0, 333333); + $result = @stream_select($read, $write, $except, 0, 333333); if ($result === false) { + // Reload signals (for example SIGUSR1) can interrupt stream_select. + // Do not treat as a fatal socket error without checking the error message for "interrupted system call" and retrying a few times. + $last_error = error_get_last(); + $error_message = strtolower((string)($last_error['message'] ?? '')); + if (str_contains($error_message, 'interrupted system call')) { + continue; + } // Check for error status 3 times in a row if (++$stream_select_tries > 3) { throw new \RuntimeException("Error occured reading socket");