| ... | ... | @@ -3231,6 +3231,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE |
| 3231 | 3231 | } |
| 3232 | 3232 | } |
| 3233 | 3233 | |
| 3234 | /// Thread-safe. Assumes that `comp.mutex` is *not* already held by the caller. |
| 3234 | 3235 | pub fn appendFileSystemInput(comp: *Compilation, path: Compilation.Path) Allocator.Error!void { |
| 3235 | 3236 | const gpa = comp.gpa; |
| 3236 | 3237 | const fsi = comp.file_system_inputs orelse return; |
| ... | ... | @@ -3251,6 +3252,10 @@ pub fn appendFileSystemInput(comp: *Compilation, path: Compilation.Path) Allocat |
| 3251 | 3252 | .{ @tagName(path.root), want_prefix_dir, path.sub_path }, |
| 3252 | 3253 | ); |
| 3253 | 3254 | |
| 3255 | // There may be concurrent calls to this function from C object workers and/or the main thread. |
| 3256 | comp.mutex.lock(); |
| 3257 | defer comp.mutex.unlock(); |
| 3258 | |
| 3254 | 3259 | try fsi.ensureUnusedCapacity(gpa, path.sub_path.len + 3); |
| 3255 | 3260 | if (fsi.items.len > 0) fsi.appendAssumeCapacity(0); |
| 3256 | 3261 | fsi.appendAssumeCapacity(prefix); |
| ... | ... | @@ -6443,10 +6448,6 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr |
| 6443 | 6448 | return error.InvalidDepFile; |
| 6444 | 6449 | }, |
| 6445 | 6450 | }; |
| 6446 | | |
| 6447 | | // There may be concurrent calls to `appendFileSystemInput` from other C objects. |
| 6448 | | comp.mutex.lock(); |
| 6449 | | defer comp.mutex.unlock(); |
| 6450 | 6451 | try comp.appendFileSystemInput(input_path); |
| 6451 | 6452 | } |
| 6452 | 6453 | } |