authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-01 22:55:47-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-15 10:48:13-07:00
logd0f675827c28b1d50e8aea6a7d29cb45ad8d4e67
tree7082febc976cdfc9f7149fbe5bbeab3c16a16690
parentb465dc12349dd24fe060e69ad6eb290ddbb3739e

link: only write manifest if we have the exclusive lock

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

1 files changed, 5 insertions(+), 3 deletions(-)

src/link.zig+5-3
...@@ -1078,9 +1078,11 @@ pub const File = struct {...@@ -1078,9 +1078,11 @@ pub const File = struct {
1078 log.warn("failed to save archive hash digest file: {s}", .{@errorName(err)});1078 log.warn("failed to save archive hash digest file: {s}", .{@errorName(err)});
1079 };1079 };
10801080
1081 man.writeManifest() catch |err| {1081 if (man.have_exclusive_lock) {
1082 log.warn("failed to write cache manifest when archiving: {s}", .{@errorName(err)});1082 man.writeManifest() catch |err| {
1083 };1083 log.warn("failed to write cache manifest when archiving: {s}", .{@errorName(err)});
1084 };
1085 }
10841086
1085 base.lock = man.toOwnedLock();1087 base.lock = man.toOwnedLock();
1086 }1088 }