From 5620e271cb4ce0e534c87f68d218d599ca618612 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 26 Feb 2023 13:21:37 +0100 Subject: [PATCH] Destroy file_handle in fpm_main If it's not in the CG(open_files) list, we need to destroy the file handle ourselves. Co-authored-by: Jakub Zelenka --- sapi/fpm/fpm/fpm_main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index 7cb0a0a33b81..aae4fea80b43 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -1918,6 +1918,13 @@ consult the installation file that came with this distribution, or visit \n\ php_execute_script(&file_handle); + /* Without opcache, or the first time with opcache, the file handle will be placed + * in the CG(open_files) list by open_file_for_scanning(). Starting from the second + * request in opcache, the file handle won't be in the list and therefore won't be destroyed for us. */ + if (!file_handle.in_list) { + zend_destroy_file_handle(&file_handle); + } + fastcgi_request_done: if (EXPECTED(primary_script)) { efree(primary_script);