Skip to content

Commit

Permalink
allow to pass Vec<Datagram> to neqo
Browse files Browse the repository at this point in the history
  • Loading branch information
KershawChang committed Dec 22, 2023
1 parent bdc183b commit e7d76a1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
6 changes: 4 additions & 2 deletions neqo-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ fn process_loop(
)?;

'read: loop {
let mut datagrams: Vec<Datagram> = Vec::new();
match socket.recv_from(&mut buf[..]) {
Err(ref err) => {
if err.kind() == ErrorKind::WouldBlock || err.kind() == ErrorKind::Interrupted {
Expand All @@ -427,11 +428,12 @@ fn process_loop(
}
if sz > 0 {
let d = Datagram::new(remote, *local_addr, &buf[..sz]);
client.process_input(d, Instant::now());
handler.maybe_key_update(client)?;
datagrams.push(d);
}
}
};
client.process_multiple_input(datagrams, Instant::now());
handler.maybe_key_update(client)?;
}

if let Http3State::Closed(..) = client.state() {
Expand Down
6 changes: 6 additions & 0 deletions neqo-http3/src/connection_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,12 @@ impl Http3Client {
self.process_http3(now);
}

pub fn process_multiple_input(&mut self, dgrams: Vec<Datagram>, now: Instant) {
qtrace!([self], "Process multiple datagrams, len={}", dgrams.len());
self.conn.process_multiple_input(dgrams, now);
self.process_http3(now);
}

/// This should not be used because it gives access to functionalities that may disrupt the
/// proper functioning of the HTTP/3 session.
/// Only used by `neqo-interop`.
Expand Down
13 changes: 13 additions & 0 deletions neqo-transport/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,13 @@ impl Connection {
self.streams.cleanup_closed_streams();
}

/// Process new input datagrams on the connection.
pub fn process_multiple_input(&mut self, dgrams: Vec<Datagram>, now: Instant) {
self.multiple_input(dgrams, now, now);
self.process_saved(now);
self.streams.cleanup_closed_streams();
}

/// Get the time that we next need to be called back, relative to `now`.
fn next_delay(&mut self, now: Instant, paced: bool) -> Duration {
qtrace!([self], "Get callback delay {:?}", now);
Expand Down Expand Up @@ -1369,6 +1376,12 @@ impl Connection {
self.capture_error(Some(path), now, 0, res).ok();
}

fn multiple_input(&mut self, datagrams: Vec<Datagram>, received: Instant, now: Instant) {
for d in datagrams {
self.input(d, received, now);
}
}

fn input_path(&mut self, path: &PathRef, d: Datagram, now: Instant) -> Res<()> {
let mut slc = &d[..];
let mut dcid = None;
Expand Down

0 comments on commit e7d76a1

Please sign in to comment.