Skip to content

Commit

Permalink
Fix GH-11336: php still tries to unlock the shared memory ZendSem wit…
Browse files Browse the repository at this point in the history
…h opcache.file_cache_only=1 but it was never locked

I chose to check for the value of lock_file instead of checking the
file_cache_only, because it is probably a little bit faster and we're
going to access the lock_file variable anyway. It's also more generic.

Closes GH-11341.
  • Loading branch information
nielsdos committed May 30, 2023
1 parent bce5360 commit 9c59d22
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS
Expand Up @@ -15,6 +15,8 @@ PHP NEWS
- Opcache:
. Fix allocation loop in zend_shared_alloc_startup(). (nielsdos)
. Access violation on smm_shared_globals with ALLOC_FALLBACK. (KoudelkaB)
. Fixed bug GH-11336 (php still tries to unlock the shared memory ZendSem
with opcache.file_cache_only=1 but it was never locked). (nielsdos)

- SPL:
. Fixed bug GH-11338 (SplFileInfo empty getBasename with more than one
Expand Down
4 changes: 4 additions & 0 deletions ext/opcache/ZendAccelerator.c
Expand Up @@ -354,6 +354,10 @@ static inline void accel_unlock_all(void)
#ifdef ZEND_WIN32
accel_deactivate_sub();
#else
if (lock_file == -1) {
return;
}

struct flock mem_usage_unlock_all;

mem_usage_unlock_all.l_type = F_UNLCK;
Expand Down
2 changes: 1 addition & 1 deletion ext/opcache/zend_shared_alloc.c
Expand Up @@ -52,7 +52,7 @@ zend_smm_shared_globals *smm_shared_globals;
#ifdef ZTS
static MUTEX_T zts_lock;
#endif
int lock_file;
int lock_file = -1;
static char lockfile_name[MAXPATHLEN];
#endif

Expand Down

0 comments on commit 9c59d22

Please sign in to comment.