-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
add flock API to fs module #122
Comments
Sorry, but that is unlikely to happen for the reasons outlined here and elsewhere. To summarize, it's not possible to implement flock() cross-platform in a consistent manner. |
Could you keep this issue open a bit longer please? This is purportedly a community-driven project. Let's give the community a chance to weigh in.
How about: drop support for platforms that don't support a locking mechanism. Or less radically: have fs.flock throw an error on platforms that do not support it. I just implemented this in C in Windows and POSIX. It works fine, and that covers every operating system that anyone cares about. This "lowest common denominator" excuse is not satisfying. |
Here's rust's flock implementation: https://github.com/rust-lang/rust/blob/master/src/librustdoc/flock.rs Looks like it works on:
Is this list really too small to bother implementing it at all? |
Note that rust uses
In other words, it's completely unsafe to use in a concurrent program. That's probably why that If you want a flock() in your node, see this npm module. |
Well, fs-ext's flock does not work on windows: baudehlo/node-fs-ext#30 |
for anyone reaching this page debugging strange deadlocks with fs-ext: fs-ext calls flock() using uv's thread pool, which has a default size of 4. That means if a single node process has 4 blocking fs-ext flock calls running, all other uv threadpool based calls (i.e. nearly all fs.* functions) hang. https://github.com/joyent/node-lockfd solves that using a dedicated thread (not uv threadpool) |
https://www.freebsd.org/cgi/man.cgi?query=flock&sektion=2
The text was updated successfully, but these errors were encountered: