aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCody Tapscott <topolarity@tapscott.me>2022-04-18 23:08:00 -0700
committerCody Tapscott <topolarity@tapscott.me>2022-04-18 23:08:00 -0700
commitf8dc6fc416d27bc6d93d79689823a4278aacd5b2 (patch)
tree719e723424d02372830f8339ae84b256a226058d /src
parentbb9cd6db1cab40d5d5fba7c2ea4fc979efdefa44 (diff)
downloadzig-f8dc6fc416d27bc6d93d79689823a4278aacd5b2.tar.gz
zig-f8dc6fc416d27bc6d93d79689823a4278aacd5b2.zip
stage2: Only bypass `flock` on WASI
Diffstat (limited to 'src')
-rw-r--r--src/Cache.zig12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Cache.zig b/src/Cache.zig
index 37cd7a7529..0d4b51492d 100644
--- a/src/Cache.zig
+++ b/src/Cache.zig
@@ -762,7 +762,11 @@ pub const Manifest = struct {
fn downgradeToSharedLock(self: *Manifest) !void {
if (!self.have_exclusive_lock) return;
- if (std.process.can_spawn or !builtin.single_threaded) { // Some targets (WASI) do not support flock
+
+ // WASI does not currently support flock, so we bypass it here.
+ // TODO: If/when flock is supported on WASI, this check should be removed.
+ // See https://github.com/WebAssembly/wasi-filesystem/issues/2
+ if (builtin.os.tag != .wasi or std.process.can_spawn or !builtin.single_threaded) {
const manifest_file = self.manifest_file.?;
try manifest_file.downgradeLock();
}
@@ -771,7 +775,11 @@ pub const Manifest = struct {
fn upgradeToExclusiveLock(self: *Manifest) !void {
if (self.have_exclusive_lock) return;
- if (std.process.can_spawn or !builtin.single_threaded) { // Some targets (WASI) do not support flock
+
+ // WASI does not currently support flock, so we bypass it here.
+ // TODO: If/when flock is supported on WASI, this check should be removed.
+ // See https://github.com/WebAssembly/wasi-filesystem/issues/2
+ if (builtin.os.tag != .wasi or std.process.can_spawn or !builtin.single_threaded) {
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.