zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit d0f675827c28b1d50e8aea6a7d29cb45ad8d4e67 (tree)
parent b465dc12349dd24fe060e69ad6eb290ddbb3739e
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Wed,  1 Mar 2023 22:55:47 -0700

link: only write manifest if we have the exclusive lock

Fixes assertion tripping when racing multiple processes that will create
the same static archive.

Diffstat:
Msrc/link.zig | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/link.zig b/src/link.zig @@ -1078,9 +1078,11 @@ pub const File = struct { log.warn("failed to save archive hash digest file: {s}", .{@errorName(err)}); }; - man.writeManifest() catch |err| { - log.warn("failed to write cache manifest when archiving: {s}", .{@errorName(err)}); - }; + if (man.have_exclusive_lock) { + man.writeManifest() catch |err| { + log.warn("failed to write cache manifest when archiving: {s}", .{@errorName(err)}); + }; + } base.lock = man.toOwnedLock(); }