Skip to content

Commit be2d4d7

Browse files
committed
queue: clear next before re-enqueue
1 parent 5647630 commit be2d4d7

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/backend/kqueue.zig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ pub const Loop = struct {
194194
const ecanceled = -1 * @as(i32, @intCast(@intFromEnum(posix.system.E.CANCELED)));
195195
c.result = c.syscall_result(ecanceled);
196196
c.flags.state = .dead;
197+
c.next = null;
197198
self.completions.push(c);
198199

199200
events[events_len] = ev;
@@ -254,6 +255,7 @@ pub const Loop = struct {
254255
}
255256

256257
assert(c.result != null);
258+
c.next = null;
257259
self.completions.push(c);
258260
}
259261
}
@@ -447,7 +449,10 @@ pub const Loop = struct {
447449
},
448450

449451
// Only resubmit if we aren't already active (in the queue)
450-
.rearm => if (!c_active) self.submissions.push(c),
452+
.rearm => if (!c_active) {
453+
c.next = null;
454+
self.submissions.push(c);
455+
},
451456
}
452457

453458
// If we filled the events slice, we break to avoid overflow.

src/watcher/file.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ fn FileStream(comptime xev: type) type {
190190

191191
// Rearm requeues this request, it doesn't return rearm
192192
// on the actual callback here...
193-
if (action == .rearm) q_inner.push(req_inner);
193+
if (action == .rearm) {
194+
req_inner.next = null;
195+
q_inner.push(req_inner);
196+
}
194197

195198
// If we have another request, add that completion next.
196199
if (q_inner.head) |req_next| l_inner.add(&req_next.completion);

src/watcher/stream.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,10 @@ pub fn Writeable(comptime xev: type, comptime T: type, comptime options: Options
840840

841841
// Rearm requeues this request, it doesn't return rearm
842842
// on the actual callback here...
843-
if (action == .rearm) q_inner.push(req_inner);
843+
if (action == .rearm) {
844+
req_inner.next = null;
845+
q_inner.push(req_inner);
846+
}
844847

845848
// If we have another request, add that completion next.
846849
if (q_inner.head) |req_next| l_inner.add(&req_next.completion);

0 commit comments

Comments
 (0)