diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-04-18 23:53:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-18 23:53:41 +0200 |
| commit | b03345f32a5ba2849ddbeeae0e31e0e77ca01b01 (patch) | |
| tree | 4100326d0b400a38525d980739214feaf48508b8 /src/Cache.zig | |
| parent | 5195b87639a1dc56b90751d0aecc4fcf4f2a1bb0 (diff) | |
| parent | 3a63fa6b7f56a2f384ebd460e80c00e6bbd2efee (diff) | |
| download | zig-b03345f32a5ba2849ddbeeae0e31e0e77ca01b01.tar.gz zig-b03345f32a5ba2849ddbeeae0e31e0e77ca01b01.zip | |
Merge pull request #11024 from topolarity/wasi-stage2
stage2: Add limited WASI support for selfExePath and globalCacheDir
Diffstat (limited to 'src/Cache.zig')
| -rw-r--r-- | src/Cache.zig | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/Cache.zig b/src/Cache.zig index 993114905e..37cd7a7529 100644 --- a/src/Cache.zig +++ b/src/Cache.zig @@ -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; } |
