From 3e9792f4a218ead9fdc88a6710c82f08780d256e Mon Sep 17 00:00:00 2001 From: Mikhail Galanin Date: Thu, 27 Jul 2023 12:54:29 +0100 Subject: [PATCH] Check if restart is pending before trying to lock SHM This reduces lock contention when Opcache restart is scheduled but not yet started. Closes GH-11805 --- NEWS | 2 ++ ext/opcache/zend_file_cache.c | 1 + 2 files changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 989e53f2850..87a478e4b4e 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,8 @@ PHP NEWS - Opcache: . Fixed bug GH-11715 (opcache.interned_strings_buffer either has no effect or opcache_get_status() / phpinfo() is wrong). (nielsdos) + . Avoid adding an unnecessary read-lock when loading script from shm if + restart is in progress. (mikhainin) - Standard: . Prevent int overflow on $decimals in number_format. (Marc Bennewitz) diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c index 22ccc4d8430..bcee38079b3 100644 --- a/ext/opcache/zend_file_cache.c +++ b/ext/opcache/zend_file_cache.c @@ -1786,6 +1786,7 @@ zend_persistent_script *zend_file_cache_script_load(zend_file_handle *file_handl if (!file_cache_only && !ZCSG(restart_in_progress) && + !ZCSG(restart_pending) && !ZSMMG(memory_exhausted) && accelerator_shm_read_lock() == SUCCESS) { /* exclusive lock */