Skip to content

Flock compat dead fallback - #25659

Open
jorgsowa wants to merge 3 commits into
php:masterfrom
jorgsowa:flock-compat-dead-fallback
Open

jorgsowa wants to merge 3 commits into
php:masterfrom
jorgsowa:flock-compat-dead-fallback

Conversation

@jorgsowa

Copy link
Copy Markdown
Contributor

Remove dead no-lock flock fallbacks.

php_flock() and the opcache file cache each had a fallback that silently skipped locking. It was only compiled on platforms without struct flock or flock(), and no supported platform lacks them. On non-Windows, struct flock is already required by opcache.

  • main/flock_compat: drop the HAVE_STRUCT_FLOCK check and the no-op stub. Use the fcntl implementation on all non-Windows platforms.
  • opcache: use flock() from flock_compat.h (which wraps fcntl when flock() is missing) instead of the no-op stub.

@shivammathur

Copy link
Copy Markdown
Member

@jorgsowa

LGTM. Could you also check the LOCK_EX failure path on platforms without native flock(), such as Solaris?

When opcache.file_cache is set, I think it can leave an empty .bin file if fcntl() fails.

struct flock is POSIX and every supported non-Windows platform has it, so
drop the HAVE_STRUCT_FLOCK check and the stub that silently skipped
locking.
On non-Windows platforms without flock(), flock_compat.h provides one
backed by fcntl, so the stub that skipped locking is not needed.
Otherwise the freshly created empty .bin blocks later stores until a load
removes it.
@jorgsowa
jorgsowa force-pushed the flock-compat-dead-fallback branch from fd65a1b to 61365c1 Compare November 24, 2026 10:36
@jorgsowa

Copy link
Copy Markdown
Contributor Author

When opcache.file_cache is set, I think it can leave an empty .bin file if fcntl() fails.

That's true. I added removal of it in last commit.

I need to check Solaris still, because Solaris CI job doesn't work on this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants