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
This commit is contained in:
Mikhail Galanin 2023-07-27 12:54:29 +01:00 committed by Ilija Tovilo
parent b5f8a7270a
commit 3e9792f4a2
No known key found for this signature in database
GPG key ID: A4F5D403F118200A
2 changed files with 3 additions and 0 deletions

2
NEWS
View file

@ -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)

View file

@ -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 */