-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zlib streams should support locking #17668
Comments
Thanks for the response! |
No, that issue still persists. From a quick look at the implementation, the actual file stream is an "inner stream". Workaround: use PS: probably better anyway: use a separate lock file (.lck). |
Thanks. The old code in use has already created a lot of data, fear rewriting the old code may unexpectly corrupt the old data. Hope if can have something like gz_lock to patch to the old code. Regards, |
This cannot be implemented for PHP < 8.5, and I would assume that upgrading to PHP 8 already requires quite some changes to your code base, so possibly tough luck. Anyway, let's turn this into a proper feature request, since it generally makes sense to be able to lock zlib streams. |
Implementation would need to start at php-src/ext/zlib/zlib_fopen_wrapper.c Line 105 in ff80ec7
|
Thanks for moderating the title. |
Well, you would rather be able to use |
Added an external file lock as below if(file_exists($cachefileb."-lock") and time()-filemtime($cachefileb."-lock")<3){@set_time_limit(10);sleep(rand(0,8));} |
No, I've meant just $lock = fopen($gz . ".lck", "w+");
flock($lock, LOCK_EX);
$gz = gzopen($cachefileb,'w9');
gzwrite($gz, $towrite);
gzclose($gz);
flock($lock, LOCK_UN); |
Thanks! $lock = fopen($gz . ".lck", "w+"); |
Implemented in PHP 8.5 via 5acff0e |
I found the problem perhaps can be solved by gz witing the file to tmp file then rename it back to the disk. |
Description
The following code:
The text was updated successfully, but these errors were encountered: