authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-07-09 20:26:16-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-07-12 00:14:08-07:00
log956f1ebc707f8a2530e49b80357768f3bf1235ac
treee465b4f2782cb39a5af3bd9be3e7a28994cd4ffb
parente712ca595f3ac2e25911fd0d647bfb8c97019ce8

std.Build.Watch: gracefully handle fanotify queue overflow


1 files changed, 16 insertions(+), 0 deletions(-)

lib/std/Build/Watch.zig+16
......@@ -135,6 +135,12 @@ pub fn markDirtySteps(w: *Watch, gpa: Allocator) !bool {
135135 meta = @ptrCast(@as([*]u8, @ptrCast(meta)) + meta[0].event_len);
136136 }) {
137137 assert(meta[0].vers == M.VERSION);
138 if (meta[0].mask.Q_OVERFLOW) {
139 any_dirty = true;
140 std.log.warn("file system watch queue overflowed; falling back to fstat", .{});
141 markAllFilesDirty(w, gpa);
142 return true;
143 }
138144 const fid: *align(1) fanotify.event_info_fid = @ptrCast(meta + 1);
139145 switch (fid.hdr.info_type) {
140146 .DFID_NAME => {
......@@ -171,3 +177,13 @@ pub fn markFailedStepsDirty(gpa: Allocator, all_steps: []const *Step) void {
171177 else => continue,
172178 };
173179}
180
181fn markAllFilesDirty(w: *Watch, gpa: Allocator) void {
182 for (w.handle_table.values()) |reaction_set| {
183 for (reaction_set.values()) |step_set| {
184 for (step_set.keys()) |step| {
185 step.recursiveReset(gpa);
186 }
187 }
188 }
189}