Skip to content

Commit

Permalink
fix(s2n-quic-dc): handle spurious TCP acceptor worker wakeups (#2434)
Browse files Browse the repository at this point in the history
  • Loading branch information
camshaft authored Jan 2, 2025
1 parent 8d9b09e commit ac52a48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 7 additions & 0 deletions dc/s2n-quic-dc/src/stream/server/tokio/tcp/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,13 @@ where
let mut cf = ControlFlow::Continue(());

let entry = &mut self.workers[idx];

// Only poll the worker if it's active. We can end up here if we've pruned a worker right before
// the tokio runtime notifies us the stream is ready.
if !entry.worker.is_active() {
return cf;
}

let mut task_cx = task::Context::from_waker(&entry.waker);
let Poll::Ready(res) = entry.worker.poll(&mut task_cx, cx, publisher, clock) else {
debug_assert!(entry.worker.is_active());
Expand Down
5 changes: 2 additions & 3 deletions dc/s2n-quic-dc/src/stream/server/tokio/tcp/manager/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,8 @@ impl Harness {
let Entry { worker, waker, .. } = &mut self.manager.inner.workers[idx];
let is_active = worker.is_active();

if is_active {
waker.wake_by_ref();
}
// wake the worker even if it's not active so we can test more paths
waker.wake_by_ref();

is_active
}
Expand Down

0 comments on commit ac52a48

Please sign in to comment.