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

Advisory lock on an open file using flock not working #11797

Closed
kjpou1 opened this issue Aug 3, 2020 · 5 comments
Closed

Advisory lock on an open file using flock not working #11797

kjpou1 opened this issue Aug 3, 2020 · 5 comments

Comments

@kjpou1
Copy link
Contributor

kjpou1 commented Aug 3, 2020

Using flock does not seem to work.

The API is implemented and it's used by some of emscripten internal tooling (https://github.com/emscripten-core/emscripten/blob/master/tools/filelock.py#L363).

In the tests there are tests for fnctl that reference struct flock: https://github.com/emscripten-core/emscripten/blob/master/tests/fcntl/test_fcntl.c#L57

But there do not seem to be any tests that use flock.

@kjpou1 kjpou1 changed the title Advisory lock on an open file using flock Advisory lock on an open file using flock not working Aug 3, 2020
@sbc100
Copy link
Collaborator

sbc100 commented Aug 3, 2020

The python locking implemented in tools/filelock.py is part of the compiler driver and nothing to do with the runtime.

It looks like flock is linux/bsd and not part of POSIX, which is probably why we have not gotten around to implementing it yet. I don't think anyone would object if somebody wanted to add it. It looks like we have a stub right here that can be filled in:

flock: function(fd, operation) {

@kjpou1
Copy link
Contributor Author

kjpou1 commented Aug 4, 2020

@sbc100 thank you for the information.

Are you saying that POSIX record locks (fcntl) is implemented and should work?

@sbc100
Copy link
Collaborator

sbc100 commented Aug 4, 2020

I looks from the test you linked to at hat least the F_GETLK and F_SETLK fcntls return errno 0.

It looks like they mostly stubbed out:

__sys_fcntl64__deps: ['$setErrNo'],

Remember that emscripten is not multi-process and the filesystem is basically local the running module, so the actually locking functionality I don't think make much sense.

What you are hoping to lock against in your application exactly?

@kjpou1
Copy link
Contributor Author

kjpou1 commented Aug 4, 2020

@sbc100 thank you for the information. We will need to discuss the locking and whether or not it makes sense as you have mentioned.

@stale
Copy link

stale bot commented Aug 4, 2021

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

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

No branches or pull requests

2 participants