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 19334d0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
8 changes: 6 additions & 2 deletions neqo-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ fn process_loop(
},
)?;

let mut datagrams: Vec<Datagram> = Vec::new();
'read: loop {
match socket.recv_from(&mut buf[..]) {
Err(ref err) => {
Expand All @@ -427,12 +428,15 @@ 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);
}
}
};
}
if !datagrams.is_empty() {
client.process_multiple_input(datagrams, Instant::now());
handler.maybe_key_update(client)?;
}

if let Http3State::Closed(..) = client.state() {
return Ok(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 19334d0

Please sign in to comment.