authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-13 19:23:08-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-15 10:48:15-07:00
log2b0929929d67e222ca6a9523a3a594ed456c4a51
tree27d50d65e7e55e07c609d42c7ce7db98170120a4
parentbde12930939c50fbfa344c3701a01885e6dd06d4

std.Build.Cache: handle ENOENT on createFile race

There are no dir components, so you would think that this was unreachable, however we have observed on macOS two processes racing to do openat() with O_CREAT manifest in ENOENT.

1 files changed, 4 insertions(+), 1 deletions(-)

lib/std/Build/Cache.zig+4-1
......@@ -439,7 +439,10 @@ pub const Manifest = struct {
439439 self.manifest_file = manifest_file;
440440 self.have_exclusive_lock = true;
441441 } else |err| switch (err) {
442 error.WouldBlock => {
442 // There are no dir components, so you would think that this was
443 // unreachable, however we have observed on macOS two processes racing
444 // to do openat() with O_CREAT manifest in ENOENT.
445 error.WouldBlock, error.FileNotFound => {
443446 self.manifest_file = try self.cache.manifest_dir.openFile(&manifest_file_path, .{
444447 .lock = .Shared,
445448 });