| ... | @@ -762,18 +762,22 @@ pub const Manifest = struct { | ... | @@ -762,18 +762,22 @@ pub const Manifest = struct { |
| 762 | | 762 | |
| 763 | fn downgradeToSharedLock(self: *Manifest) !void { | 763 | fn downgradeToSharedLock(self: *Manifest) !void { |
| 764 | if (!self.have_exclusive_lock) return; | 764 | if (!self.have_exclusive_lock) return; |
| 765 | const manifest_file = self.manifest_file.?; | 765 | if (std.process.can_spawn or !builtin.single_threaded) { // Some targets (WASI) do not support flock |
| 766 | try manifest_file.downgradeLock(); | 766 | const manifest_file = self.manifest_file.?; |
| | 767 | try manifest_file.downgradeLock(); |
| | 768 | } |
| 767 | self.have_exclusive_lock = false; | 769 | self.have_exclusive_lock = false; |
| 768 | } | 770 | } |
| 769 | | 771 | |
| 770 | fn upgradeToExclusiveLock(self: *Manifest) !void { | 772 | fn upgradeToExclusiveLock(self: *Manifest) !void { |
| 771 | if (self.have_exclusive_lock) return; | 773 | if (self.have_exclusive_lock) return; |
| 772 | const manifest_file = self.manifest_file.?; | 774 | if (std.process.can_spawn or !builtin.single_threaded) { // Some targets (WASI) do not support flock |
| 773 | // Here we intentionally have a period where the lock is released, in case there are | 775 | const manifest_file = self.manifest_file.?; |
| 774 | // other processes holding a shared lock. | 776 | // Here we intentionally have a period where the lock is released, in case there are |
| 775 | manifest_file.unlock(); | 777 | // other processes holding a shared lock. |
| 776 | try manifest_file.lock(.Exclusive); | 778 | manifest_file.unlock(); |
| | 779 | try manifest_file.lock(.Exclusive); |
| | 780 | } |
| 777 | self.have_exclusive_lock = true; | 781 | self.have_exclusive_lock = true; |
| 778 | } | 782 | } |
| 779 | | 783 | |