diff options
| author | Loris Cro <kappaloris@gmail.com> | 2025-03-14 19:16:13 +0100 |
|---|---|---|
| committer | Matthew Lugg <mlugg@mlugg.co.uk> | 2025-03-15 05:29:54 +0000 |
| commit | 11b49e90024da21e806a71a7ee62b23572836cee (patch) | |
| tree | 1f69e50db41e470e176d9a5362783a002320d7d6 /lib/std/Build | |
| parent | 1f92b394e97ce13e49cce8838968c0dc848d0abb (diff) | |
| download | zig-11b49e90024da21e806a71a7ee62b23572836cee.tar.gz zig-11b49e90024da21e806a71a7ee62b23572836cee.zip | |
std.Build.Watch: fix macos implementation
The code did one useless thing and two wrong things:
- ref counting was basically a noop
- last_dir_fd was chosen from the wrong index and also under the wrong
condition
This caused regular crashes on macOS which are now gone.
Diffstat (limited to 'lib/std/Build')
| -rw-r--r-- | lib/std/Build/Watch.zig | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/lib/std/Build/Watch.zig b/lib/std/Build/Watch.zig index 2ddb3ca4c2..068a50769f 100644 --- a/lib/std/Build/Watch.zig +++ b/lib/std/Build/Watch.zig @@ -612,8 +612,6 @@ const Os = switch (builtin.os.tag) { /// -1. Otherwise, it needs to be opened in update(), and will be /// stored here. dir_fd: i32, - /// Number of files being watched by this directory handle. - ref_count: u32, }), const dir_open_flags: posix.O = f: { @@ -673,11 +671,9 @@ const Os = switch (builtin.os.tag) { try handles.append(gpa, .{ .rs = .{}, .dir_fd = if (skip_open_dir) -1 else dir_fd, - .ref_count = 1, }); - } else { - handles.items(.ref_count)[gop.index] += 1; } + break :rs &handles.items(.rs)[gop.index]; }; for (files.items) |basename| { @@ -718,10 +714,6 @@ const Os = switch (builtin.os.tag) { } } - const ref_count_ptr = &handles.items(.ref_count)[i]; - ref_count_ptr.* -= 1; - if (ref_count_ptr.* > 0) continue; - // If the sub_path == "" then this patch has already the // dir fd that we need to use as the ident to remove the // event. If it was opened above with openat() then we need @@ -738,10 +730,10 @@ const Os = switch (builtin.os.tag) { // index in the udata field. const last_dir_fd = fd: { const last_path = w.dir_table.keys()[handles.len - 1]; - const last_dir_fd = if (last_path.sub_path.len != 0) + const last_dir_fd = if (last_path.sub_path.len == 0) last_path.root_dir.handle.fd else - handles.items(.dir_fd)[i]; + handles.items(.dir_fd)[handles.len - 1]; assert(last_dir_fd != -1); break :fd last_dir_fd; }; |
