authorgravatar for topolarity@tapscott.meCody Tapscott <topolarity@tapscott.me> 2022-04-18 23:08:00-07:00
committergravatar for topolarity@tapscott.meCody Tapscott <topolarity@tapscott.me> 2022-04-18 23:08:00-07:00
logf8dc6fc416d27bc6d93d79689823a4278aacd5b2
tree719e723424d02372830f8339ae84b256a226058d
parentbb9cd6db1cab40d5d5fba7c2ea4fc979efdefa44

stage2: Only bypass `flock` on WASI


1 files changed, 10 insertions(+), 2 deletions(-)

src/Cache.zig+10-2
......@@ -762,7 +762,11 @@ pub const Manifest = struct {
762762
763763 fn downgradeToSharedLock(self: *Manifest) !void {
764764 if (!self.have_exclusive_lock) return;
765 if (std.process.can_spawn or !builtin.single_threaded) { // Some targets (WASI) do not support flock
765
766 // WASI does not currently support flock, so we bypass it here.
767 // TODO: If/when flock is supported on WASI, this check should be removed.
768 // See https://github.com/WebAssembly/wasi-filesystem/issues/2
769 if (builtin.os.tag != .wasi or std.process.can_spawn or !builtin.single_threaded) {
766770 const manifest_file = self.manifest_file.?;
767771 try manifest_file.downgradeLock();
768772 }
......@@ -771,7 +775,11 @@ pub const Manifest = struct {
771775
772776 fn upgradeToExclusiveLock(self: *Manifest) !void {
773777 if (self.have_exclusive_lock) return;
774 if (std.process.can_spawn or !builtin.single_threaded) { // Some targets (WASI) do not support flock
778
779 // WASI does not currently support flock, so we bypass it here.
780 // TODO: If/when flock is supported on WASI, this check should be removed.
781 // See https://github.com/WebAssembly/wasi-filesystem/issues/2
782 if (builtin.os.tag != .wasi or std.process.can_spawn or !builtin.single_threaded) {
775783 const manifest_file = self.manifest_file.?;
776784 // Here we intentionally have a period where the lock is released, in case there are
777785 // other processes holding a shared lock.