Skip to content

Commit

Permalink
Check if restart is pending before trying to lock SHM
Browse files Browse the repository at this point in the history
This reduces lock contention when Opcache restart is scheduled
but not yet started.

Closes GH-11805
  • Loading branch information
mikhainin authored and iluuu1994 committed Jul 31, 2023
1 parent b5f8a72 commit 3e9792f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions ext/opcache/zend_file_cache.c
Expand Up @@ -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 */
Expand Down

0 comments on commit 3e9792f

Please sign in to comment.