Skip to content
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

Can't open file while locked. #1

Open
yusufkhan07 opened this issue Jul 19, 2018 · 1 comment
Open

Can't open file while locked. #1

yusufkhan07 opened this issue Jul 19, 2018 · 1 comment

Comments

@yusufkhan07
Copy link

yusufkhan07 commented Jul 19, 2018

Hello, when I acquire a lock using lock->acquire on a file, I can't open/read the file even in the same php script. How can I read the file while I have acquired a lock on it?

@dorantor
Copy link
Owner

Sorry for late reply - for some reason didn't received notification to my mailbox.

What you're saying is very strange, because this lib uses flock which provides, quoting:

advisory file locking which means all accessing programs have to use the same way of locking or it will not work

and also it means that lock is informative, not restrictive. So even if it's "locked" it could be read/written by anybody who doesn't want to respect locking. As you can see, you should always be able to read "locked" file same way as if it's not "locked". Basically "lock" is a way to communicate between separate and independent processes and share resources(files in this case) which can be used only in "single-threaded" mode. Most common case is you want to allow only one script/process to be able to write to the file at a time, and any amount of scripts/processes to be able to read from the file.

If you can reproduce it on a stable basis, could you please provide context(OS, PHP version, file system and so on), so I could reproduce it and investigate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants