diff --git a/src/backend/kqueue.zig b/src/backend/kqueue.zig index c419e61..9930aab 100644 --- a/src/backend/kqueue.zig +++ b/src/backend/kqueue.zig @@ -201,6 +201,7 @@ pub const Loop = struct { const ecanceled = -1 * @as(i32, @intCast(@intFromEnum(posix.system.E.CANCELED))); c.result = c.syscall_result(ecanceled); c.flags.state = .dead; + c.next = null; self.completions.push(c); events[events_len] = ev; @@ -261,6 +262,7 @@ pub const Loop = struct { } assert(c.result != null); + c.next = null; self.completions.push(c); } } @@ -454,7 +456,10 @@ pub const Loop = struct { }, // Only resubmit if we aren't already active (in the queue) - .rearm => if (!c_active) self.submissions.push(c), + .rearm => if (!c_active) { + c.next = null; + self.submissions.push(c); + }, } // If we filled the events slice, we break to avoid overflow. diff --git a/src/watcher/file.zig b/src/watcher/file.zig index d916bd1..9903999 100644 --- a/src/watcher/file.zig +++ b/src/watcher/file.zig @@ -196,7 +196,10 @@ fn FileStream(comptime xev: type) type { // Rearm requeues this request, it doesn't return rearm // on the actual callback here... - if (action == .rearm) q_inner.push(req_inner); + if (action == .rearm) { + req_inner.next = null; + q_inner.push(req_inner); + } // If we have another request, add that completion next. if (q_inner.head) |req_next| l_inner.add(&req_next.completion); diff --git a/src/watcher/stream.zig b/src/watcher/stream.zig index 4b1ca38..17f7cb0 100644 --- a/src/watcher/stream.zig +++ b/src/watcher/stream.zig @@ -854,7 +854,10 @@ pub fn Writeable(comptime xev: type, comptime T: type, comptime options: Options // Rearm requeues this request, it doesn't return rearm // on the actual callback here... - if (action == .rearm) q_inner.push(req_inner); + if (action == .rearm) { + req_inner.next = null; + q_inner.push(req_inner); + } // If we have another request, add that completion next. if (q_inner.head) |req_next| l_inner.add(&req_next.completion);