Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions apps/src/bin/quiche-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ use std::cell::RefCell;

use ring::rand::*;

use quiche::EventLoopIteration;

use quiche_apps::args::*;

use quiche_apps::common::*;
Expand Down Expand Up @@ -198,6 +200,8 @@ fn main() {
}
}

let iteration = EventLoopIteration::new();

// Read incoming UDP packets from the socket and feed them to quiche,
// until there are no more packets to read.
'read: loop {
Expand All @@ -207,7 +211,9 @@ fn main() {
if events.is_empty() && !continue_write {
trace!("timed out");

clients.values_mut().for_each(|c| c.conn.on_timeout());
clients
.values_mut()
.for_each(|c| c.conn.on_timeout(&iteration));

break 'read;
}
Expand Down Expand Up @@ -425,7 +431,7 @@ fn main() {
};

// Process potentially coalesced packets.
let read = match client.conn.recv(pkt_buf, recv_info) {
let read = match client.conn.recv(&iteration, pkt_buf, recv_info) {
Ok(v) => v,

Err(e) => {
Expand Down Expand Up @@ -561,7 +567,7 @@ fn main() {
while total_write < max_send_burst {
let (write, send_info) = match client
.conn
.send(&mut out[total_write..max_send_burst])
.send(&iteration, &mut out[total_write..max_send_burst])
{
Ok(v) => v,

Expand Down
14 changes: 11 additions & 3 deletions apps/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
use crate::args::*;
use crate::common::*;

use quiche::EventLoopIteration;

use std::io::prelude::*;

use std::rc::Rc;
Expand Down Expand Up @@ -226,7 +228,9 @@ pub fn connect(
scid,
);

let (write, send_info) = conn.send(&mut out).expect("initial send failed");
let (write, send_info) = conn
.send(&EventLoopIteration::new(), &mut out)
.expect("initial send failed");

while let Err(e) = socket.send_to(&out[..write], send_info.to) {
if e.kind() == std::io::ErrorKind::WouldBlock {
Expand Down Expand Up @@ -256,13 +260,15 @@ pub fn connect(
poll.poll(&mut events, conn.timeout()).unwrap();
}

let iteration = EventLoopIteration::new();

// If the event loop reported no events, it means that the timeout
// has expired, so handle it without attempting to read packets. We
// will then proceed with the send loop.
if events.is_empty() {
trace!("timed out");

conn.on_timeout();
conn.on_timeout(&iteration);
}

// Read incoming UDP packets from the socket and feed them to quiche,
Expand Down Expand Up @@ -314,7 +320,8 @@ pub fn connect(
};

// Process potentially coalesced packets.
let read = match conn.recv(&mut buf[..len], recv_info) {
let read = match conn.recv(&iteration, &mut buf[..len], recv_info)
{
Ok(v) => v,

Err(e) => {
Expand Down Expand Up @@ -498,6 +505,7 @@ pub fn connect(
for peer_addr in conn.paths_iter(local_addr) {
loop {
let (write, send_info) = match conn.send_on_path(
&iteration,
&mut out,
Some(local_addr),
Some(peer_addr),
Expand Down
5 changes: 3 additions & 2 deletions fuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::path::Path;
use std::path::PathBuf;

use quiche::h3::NameValue;
use quiche::EventLoopIteration;

pub struct PktsData<'a> {
pub data: &'a [u8],
Expand Down Expand Up @@ -92,7 +93,7 @@ pub fn server_process(
h3_conn: &mut Option<quiche::h3::Connection>, info: quiche::RecvInfo,
) {
let mut buf = pkt.to_vec();
conn.recv(&mut buf, info).ok();
conn.recv(&EventLoopIteration::new(), &mut buf, info).ok();

if (conn.is_in_early_data() || conn.is_established()) && h3_conn.is_none() {
let h3_config = quiche::h3::Config::new().unwrap();
Expand Down Expand Up @@ -168,5 +169,5 @@ pub fn server_process(
}

let mut out_buf = [0; 1500];
while conn.send(&mut out_buf).is_ok() {}
while conn.send(&EventLoopIteration::new(), &mut out_buf).is_ok() {}
}
6 changes: 4 additions & 2 deletions fuzz/src/packet_recv_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ extern crate libfuzzer_sys;
use std::net::SocketAddr;

use std::sync::Mutex;

use quiche::EventLoopIteration;
use std::sync::Once;
use std::sync::OnceLock;

Expand Down Expand Up @@ -57,8 +59,8 @@ fuzz_target!(|data: &[u8]| {

let info = quiche::RecvInfo { from, to };

conn.recv(&mut buf, info).ok();
conn.recv(&EventLoopIteration::new(), &mut buf, info).ok();

let mut out_buf = [0; 1500];
while conn.send(&mut out_buf).is_ok() {}
while conn.send(&EventLoopIteration::new(), &mut out_buf).is_ok() {}
});
6 changes: 4 additions & 2 deletions fuzz/src/packet_recv_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ extern crate libfuzzer_sys;
use std::net::SocketAddr;

use std::sync::Mutex;

use quiche::EventLoopIteration;
use std::sync::Once;
use std::sync::OnceLock;

Expand Down Expand Up @@ -55,8 +57,8 @@ fuzz_target!(|data: &[u8]| {

let info = quiche::RecvInfo { from, to };

conn.recv(&mut buf, info).ok();
conn.recv(&EventLoopIteration::new(), &mut buf, info).ok();

let mut out_buf = [0; 1500];
while conn.send(&mut out_buf).is_ok() {}
while conn.send(&EventLoopIteration::new(), &mut out_buf).is_ok() {}
});
25 changes: 16 additions & 9 deletions h3i/src/client/sync_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use ring::rand::*;
use crate::client::QUIC_VERSION;
use crate::frame::H3iFrame;
use crate::quiche;
use crate::quiche::EventLoopIteration;

use crate::actions::h3::Action;
use crate::actions::h3::StreamEventType;
Expand Down Expand Up @@ -216,7 +217,9 @@ pub fn connect_with_early_data(
let mut app_proto_selected = false;

// Send ClientHello and initiate the handshake.
let (write, send_info) = conn.send(&mut out).expect("initial send failed");
let (write, send_info) = conn
.send(&EventLoopIteration::new(), &mut out)
.expect("initial send failed");

let mut client = SyncClient::new(close_trigger_frames);
// Send early data if connection is_in_early_data (resumption with 0-RTT was
Expand Down Expand Up @@ -285,12 +288,14 @@ pub fn connect_with_early_data(
log::debug!("actual sleep is {actual_sleep:?}");
poll.poll(&mut events, actual_sleep).unwrap();

let iteration = EventLoopIteration::new();

// If the event loop reported no events, run a belt and braces check on
// the quiche connection's timeouts.
if events.is_empty() {
log::debug!("timed out");

conn.on_timeout();
conn.on_timeout(&iteration);
}

// Read incoming UDP packets from the socket and feed them to quiche,
Expand Down Expand Up @@ -326,14 +331,15 @@ pub fn connect_with_early_data(
};

// Process potentially coalesced packets.
let _read = match conn.recv(&mut buf[..len], recv_info) {
Ok(v) => v,
let _read =
match conn.recv(&iteration, &mut buf[..len], recv_info) {
Ok(v) => v,

Err(e) => {
log::debug!("{local_addr}: recv failed: {e:?}");
continue 'read;
},
};
Err(e) => {
log::debug!("{local_addr}: recv failed: {e:?}");
continue 'read;
},
};
}
}

Expand Down Expand Up @@ -433,6 +439,7 @@ pub fn connect_with_early_data(
for peer_addr in conn.paths_iter(local_addr) {
loop {
let (write, send_info) = match conn.send_on_path(
&iteration,
&mut out,
Some(local_addr),
Some(peer_addr),
Expand Down
14 changes: 10 additions & 4 deletions quiche/examples/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#[macro_use]
extern crate log;

use quiche::EventLoopIteration;

use ring::rand::*;

const MAX_DATAGRAM_SIZE: usize = 1350;
Expand Down Expand Up @@ -119,7 +121,9 @@ fn main() {
hex_dump(&scid)
);

let (write, send_info) = conn.send(&mut out).expect("initial send failed");
let (write, send_info) = conn
.send(&EventLoopIteration::new(), &mut out)
.expect("initial send failed");

while let Err(e) = socket.send_to(&out[..write], send_info.to) {
if e.kind() == std::io::ErrorKind::WouldBlock {
Expand All @@ -139,6 +143,8 @@ fn main() {
loop {
poll.poll(&mut events, conn.timeout()).unwrap();

let iteration = EventLoopIteration::new();

// Read incoming UDP packets from the socket and feed them to quiche,
// until there are no more packets to read.
'read: loop {
Expand All @@ -148,7 +154,7 @@ fn main() {
if events.is_empty() {
debug!("timed out");

conn.on_timeout();
conn.on_timeout(&iteration);
break 'read;
}

Expand All @@ -175,7 +181,7 @@ fn main() {
};

// Process potentially coalesced packets.
let read = match conn.recv(&mut buf[..len], recv_info) {
let read = match conn.recv(&iteration, &mut buf[..len], recv_info) {
Ok(v) => v,

Err(e) => {
Expand Down Expand Up @@ -239,7 +245,7 @@ fn main() {
// Generate outgoing QUIC packets and send them on the UDP socket, until
// quiche reports that there are no more packets to be sent.
loop {
let (write, send_info) = match conn.send(&mut out) {
let (write, send_info) = match conn.send(&iteration, &mut out) {
Ok(v) => v,

Err(quiche::Error::Done) => {
Expand Down
13 changes: 9 additions & 4 deletions quiche/examples/http3-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
extern crate log;

use quiche::h3::NameValue;
use quiche::EventLoopIteration;

use ring::rand::*;

Expand Down Expand Up @@ -116,7 +117,9 @@ fn main() {
hex_dump(&scid)
);

let (write, send_info) = conn.send(&mut out).expect("initial send failed");
let (write, send_info) = conn
.send(&EventLoopIteration::new(), &mut out)
.expect("initial send failed");

while let Err(e) = socket.send_to(&out[..write], send_info.to) {
if e.kind() == std::io::ErrorKind::WouldBlock {
Expand Down Expand Up @@ -157,6 +160,8 @@ fn main() {
loop {
poll.poll(&mut events, conn.timeout()).unwrap();

let iteration = EventLoopIteration::new();

// Read incoming UDP packets from the socket and feed them to quiche,
// until there are no more packets to read.
'read: loop {
Expand All @@ -166,7 +171,7 @@ fn main() {
if events.is_empty() {
debug!("timed out");

conn.on_timeout();
conn.on_timeout(&iteration);

break 'read;
}
Expand Down Expand Up @@ -194,7 +199,7 @@ fn main() {
};

// Process potentially coalesced packets.
let read = match conn.recv(&mut buf[..len], recv_info) {
let read = match conn.recv(&iteration, &mut buf[..len], recv_info) {
Ok(v) => v,

Err(e) => {
Expand Down Expand Up @@ -296,7 +301,7 @@ fn main() {
// Generate outgoing QUIC packets and send them on the UDP socket, until
// quiche reports that there are no more packets to be sent.
loop {
let (write, send_info) = match conn.send(&mut out) {
let (write, send_info) = match conn.send(&iteration, &mut out) {
Ok(v) => v,

Err(quiche::Error::Done) => {
Expand Down
18 changes: 13 additions & 5 deletions quiche/examples/http3-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ use std::net;

use std::collections::HashMap;

use ring::rand::*;

use quiche::h3::NameValue;
use quiche::EventLoopIteration;

use ring::rand::*;

const MAX_DATAGRAM_SIZE: usize = 1350;

Expand Down Expand Up @@ -124,6 +125,8 @@ fn main() {

poll.poll(&mut events, timeout).unwrap();

let iteration = EventLoopIteration::new();

// Read incoming UDP packets from the socket and feed them to quiche,
// until there are no more packets to read.
'read: loop {
Expand All @@ -133,7 +136,9 @@ fn main() {
if events.is_empty() {
debug!("timed out");

clients.values_mut().for_each(|c| c.conn.on_timeout());
clients
.values_mut()
.for_each(|c| c.conn.on_timeout(&iteration));

break 'read;
}
Expand Down Expand Up @@ -295,7 +300,7 @@ fn main() {
};

// Process potentially coalesced packets.
let read = match client.conn.recv(pkt_buf, recv_info) {
let read = match client.conn.recv(&iteration, pkt_buf, recv_info) {
Ok(v) => v,

Err(e) => {
Expand Down Expand Up @@ -399,7 +404,10 @@ fn main() {
// packets to be sent.
for client in clients.values_mut() {
loop {
let (write, send_info) = match client.conn.send(&mut out) {
let (write, send_info) = match client
.conn
.send(&iteration, &mut out)
{
Ok(v) => v,

Err(quiche::Error::Done) => {
Expand Down
Loading
Loading