-
Notifications
You must be signed in to change notification settings - Fork 11
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
Lock likely being released on close of other FDs (Unix) #6
Comments
It seems like we could have some control over other |
Perhaps we could use The problem is that is seems to be non-POSIX. However, |
I'm likely publishing a new version of this library with Is 'flock` not-by-process in every platform? Or is it just Linux and MacOS? Does |
|
Yeah, but I intend to replace What makes me think twice about But yeah as I said earlier, |
I don't know this stuff too well to contribute much to the discussion, but while searching for Rust crates I did come across a resource on the topic that might be helpful for this issue/decision. Maybe you've already seen it? 😅 (EDIT: I'm only now looking over the earlier link (https://gavv.github.io/articles/file-locks/#lockf-function) and noticing it covers similar details pretty well, so the information below probably doesn't contribute much, apologies!) Expand for previous contentThis Dec 2010 article (with 2014 and 2015/2019 updates) details 3 types of locking and their pro/cons as well as cross-platform issues (some since resolved):
Those are the highlights that stood out to me, but there's plenty of info on gotchas the author experienced between C and Python versions of their code across platforms. Things may have improved since then however (eg: Python 3 and Windows 10 WSL). The SMB gotcha cited was specific to macOS IIRC. So while switching from It seems you might want to instead stick with The referenced LWN article also provided some good insights, and describes the OFD addition as blending the benefits of EDIT: The earlier comment providing a different detailed resource on the topic is also quite nice!
|
Test
other_process_but_curr_reads
fails.It attempts to read the locked file into a string (in the same process, with
std::fs::read_to_string
) and then spawns another process to make it try to lock the file. It would be expected that the process would fail to lock, but it actually succeeds.I've made other tests, and without opening the file again and reading it, the lock works. I believe the bug is not in reading nor opening, but closing the file.
Manual page for
lock
seems to specify that it is implemented on top offnctl
on Linux. Also, manual page forclose
seems to specify thatclose
will revoke any locks viafnctl
on the file, no matter if a different FD to that file was closed.The text was updated successfully, but these errors were encountered: