Skip to content

Commit

Permalink
Introduce struct for poll_socket's return value
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith committed Apr 23, 2024
1 parent 257fa01 commit 18a5e2d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions quinn/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ impl State {
now,
);
self.recv_state.recv_limiter.finish_cycle();
poll_res
poll_res.map(|x| x.keep_going)
}

fn drive_send(&mut self, cx: &mut Context) -> Result<bool, io::Error> {
Expand Down Expand Up @@ -766,7 +766,7 @@ impl RecvState {
transmit_state: &mut TransmitState,
socket: &dyn AsyncUdpSocket,
now: Instant,
) -> Result<bool, io::Error> {
) -> Result<PollProgress, io::Error> {
let mut metas = [RecvMeta::default(); BATCH_SIZE];
let mut iovs: [IoSliceMut; BATCH_SIZE] = {
let mut bufs = self
Expand Down Expand Up @@ -823,7 +823,7 @@ impl RecvState {
}
}
Poll::Pending => {
break;
return Ok(PollProgress { keep_going: false });
}
// Ignore ECONNRESET as it's undefined in QUIC and may be injected by an
// attacker
Expand All @@ -835,10 +835,14 @@ impl RecvState {
}
}
if !self.recv_limiter.allow_work() {
return Ok(true);
return Ok(PollProgress { keep_going: true });
}
}

Ok(false)
}
}

#[derive(Default)]
struct PollProgress {
/// Whether datagram handling was interrupted early by the work limiter for fairness
keep_going: bool,
}

0 comments on commit 18a5e2d

Please sign in to comment.