Skip to content

Commit 7855c4f

Browse files
authored
Merge pull request #1 from Corendos/fix/kqueue-too-many-events
Fix/kqueue too many events
2 parents 2fb2ecb + a2d9b31 commit 7855c4f

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/ThreadPool.zig

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,8 @@ fn unregister(noalias self: *ThreadPool, noalias maybe_thread: ?*Thread) void {
335335

336336
fn join(self: *ThreadPool) void {
337337
// Wait for the thread pool to be shutdown() then for all threads to enter a joinable state
338-
var sync: Sync = @bitCast(self.sync.load(.monotonic));
339-
if (!(sync.state == .shutdown and sync.spawned == 0)) {
340-
self.join_event.wait();
341-
sync = @bitCast(self.sync.load(.monotonic));
342-
}
343-
338+
self.join_event.wait();
339+
const sync: Sync = @bitCast(self.sync.load(.monotonic));
344340
assert(sync.state == .shutdown);
345341
assert(sync.spawned == 0);
346342

src/backend/kqueue.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ pub const Loop = struct {
437437
// Only resubmit if we aren't already active (in the queue)
438438
.rearm => if (!c_active) self.submissions.push(c),
439439
}
440+
441+
// If we filled the events slice, we break to avoid overflow.
442+
if (changes == events.len) break;
440443
}
441444

442445
// Determine our next timeout based on the timers

0 commit comments

Comments
 (0)