Skip to content

File.downgradeLock says it's atomic, but uses flock which is not atomic #9836

@xackus

Description

@xackus

File.downgradeLock says:

Atomically modifies the lock to be in shared mode, without releasing it.

From flock(2) Linux man page:

Converting a lock (shared to exclusive, or vice versa) is not
guaranteed to be atomic: the existing lock is first removed, and
then a new lock is established. Between these two steps, a
pending lock request by another process may be granted, with the
result that the conversion either blocks, or fails if LOCK_NB was
specified. (This is the original BSD behavior, and occurs on
many other implementations.)

downgradeLock is used in src/Cache.zig.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions