mirror of
https://github.com/ziglang/zig.git
synced 2026-02-01 12:13:44 +00:00
stage2: Bypass file locks in src/Cache.zig for WASI targets
This commit is contained in:
parent
922d8378e7
commit
089651716c
@ -762,18 +762,22 @@ pub const Manifest = struct {
|
||||
|
||||
fn downgradeToSharedLock(self: *Manifest) !void {
|
||||
if (!self.have_exclusive_lock) return;
|
||||
const manifest_file = self.manifest_file.?;
|
||||
try manifest_file.downgradeLock();
|
||||
if (std.process.can_spawn or !builtin.single_threaded) { // Some targets (WASI) do not support flock
|
||||
const manifest_file = self.manifest_file.?;
|
||||
try manifest_file.downgradeLock();
|
||||
}
|
||||
self.have_exclusive_lock = false;
|
||||
}
|
||||
|
||||
fn upgradeToExclusiveLock(self: *Manifest) !void {
|
||||
if (self.have_exclusive_lock) return;
|
||||
const manifest_file = self.manifest_file.?;
|
||||
// Here we intentionally have a period where the lock is released, in case there are
|
||||
// other processes holding a shared lock.
|
||||
manifest_file.unlock();
|
||||
try manifest_file.lock(.Exclusive);
|
||||
if (std.process.can_spawn or !builtin.single_threaded) { // Some targets (WASI) do not support flock
|
||||
const manifest_file = self.manifest_file.?;
|
||||
// Here we intentionally have a period where the lock is released, in case there are
|
||||
// other processes holding a shared lock.
|
||||
manifest_file.unlock();
|
||||
try manifest_file.lock(.Exclusive);
|
||||
}
|
||||
self.have_exclusive_lock = true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user