Skip to content

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

Closed

Description

@kjpou1

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.

Activity

  1. changed the title [-]Advisory lock on an open file using flock[/-] [+]Advisory lock on an open file using flock not working[/+] on Aug 3, 2020
  2. sbc100 commented on Aug 3, 2020

    @sbc100
    Collaborator

    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) {

  3. kjpou1 commented on Aug 4, 2020

    @kjpou1
    ContributorAuthor

    @sbc100 thank you for the information.

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

  4. sbc100 commented on Aug 4, 2020

    @sbc100
    Collaborator

    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?

  5. kjpou1 commented on Aug 4, 2020

    @kjpou1
    ContributorAuthor

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

  6. stale commented on Aug 4, 2021

    @stale

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions