Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(transport/server): always process each connection #1929

Merged
merged 14 commits into from
Jul 2, 2024
1 change: 0 additions & 1 deletion neqo-bin/src/server/http09.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ impl HttpServer {
.unwrap();
qdebug!("Wrote {}", sent);
*offset += sent;
self.server.add_to_waiting(conn);
if *offset == data.len() {
qinfo!("Sent {sent} on {stream_id}, closing");
conn.borrow_mut().stream_close_send(stream_id).unwrap();
Expand Down
27 changes: 7 additions & 20 deletions neqo-http3/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,27 +131,14 @@ impl Http3Server {
fn process_http3(&mut self, now: Instant) {
qtrace!([self], "Process http3 internal.");
let mut active_conns = self.server.active_connections();
active_conns.extend(
self.http3_handlers
.iter()
.filter(|(_, handler)| handler.borrow_mut().should_be_processed())
.map(|(c, _)| c)
.cloned(),
);

// We need to find connections that needs to be process on http3 level.
let mut http3_active: Vec<ActiveConnectionRef> = self
.http3_handlers
.iter()
.filter_map(|(conn, handler)| {
if handler.borrow_mut().should_be_processed() && !active_conns.contains(conn) {
Some(conn)
} else {
None
}
})
.cloned()
.collect();
// For http_active connection we need to put them in neqo-transport's server
// waiting queue.
active_conns.append(&mut http3_active);
active_conns.dedup();
active_conns
.iter()
.for_each(|conn| self.server.add_to_waiting(conn));
for mut conn in active_conns {
self.process_events(&mut conn, now);
}
Expand Down
11 changes: 11 additions & 0 deletions neqo-transport/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ impl Output {
_ => Duration::new(0, 0),
}
}

#[must_use]
pub fn or_else<F>(self, f: F) -> Self
where
F: FnOnce() -> Self,
{
match self {
x @ (Self::Datagram(_) | Self::Callback(_)) => x,
Self::None => f(),
}
}
}

/// Used by inner functions like `Connection::output`.
Expand Down
Loading
Loading