| ... | ... | @@ -442,7 +442,15 @@ pub const Node = struct { |
| 442 | 442 | global_progress.ipc_files[slot] = file; |
| 443 | 443 | storageByIndex(index).setIpcIndex(.{ .slot = slot, .generation = generation }); |
| 444 | 444 | break; |
| 445 | | } else file.close(io); |
| 445 | } else { |
| 446 | // There was no IPC slot available, so we'll drop this node's IPC info and just close |
| 447 | // the fd. To avoid an old `estimated_total_items` or `completed_count` value still |
| 448 | // being rendered for the node, we'll zero that field out (and the user is not allowed |
| 449 | // to change it because they think we're doing IPC). |
| 450 | file.close(io); |
| 451 | @atomicStore(u32, &storageByIndex(index).completed_count, 0, .monotonic); |
| 452 | @atomicStore(u32, &storageByIndex(index).estimated_total_count, 0, .monotonic); |
| 453 | } |
| 446 | 454 | } |
| 447 | 455 | |
| 448 | 456 | pub fn setIpcIndex(node: Node, ipc_index: Ipc.Index) void { |
| ... | ... | @@ -452,7 +460,11 @@ pub const Node = struct { |
| 452 | 460 | /// Not thread-safe. |
| 453 | 461 | pub fn takeIpcIndex(node: Node) ?Ipc.Index { |
| 454 | 462 | const storage = storageByIndex(node.index.unwrap() orelse return null); |
| 455 | | assert(storage.estimated_total_count == std.math.maxInt(u32)); |
| 463 | switch (storage.estimated_total_count) { |
| 464 | std.math.maxInt(u32) => {}, // indicates that there is an IPC index in `completed_count` |
| 465 | 0 => return null, // `setIpcFile` failed so we don't have an IPC index for this node |
| 466 | else => unreachable, // not an IPC node |
| 467 | } |
| 456 | 468 | @atomicStore(u32, &storage.estimated_total_count, 0, .monotonic); |
| 457 | 469 | return @bitCast(storage.completed_count); |
| 458 | 470 | } |