Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/backend/epoll.zig
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,15 @@ pub const Loop = struct {

const c: *Completion = @ptrFromInt(@as(usize, @intCast(ev.data.ptr)));

// Skip stale deliveries. A completion can be completed and
// retired (disarmed, cancelled, or already dispatched earlier
// in this same epoll_wait batch) while the kernel still
// reports an event for its former registration. Only an
// `.active` completion is legitimately outstanding; invoking
// any other callback again can hand it state it no longer
// owns (e.g. queueWrite's `head.?` on an empty write queue).
if (c.flags.state != .active) continue;

// We get the fd and mark this as in progress we can properly
// clean this up late.r
const fd = if (c.flags.dup) c.flags.dup_fd else c.fd();
Expand Down