Skip to content
Open
Changes from all 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
28 changes: 28 additions & 0 deletions tokio-quiche/src/quic/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,34 @@ where
conn
}

/// Drives a QUIC connection from handshake to close in separate tokio
/// tasks but returns a result by awaiting the [`InitialQuicConnection::handshake`] call.
///
/// It combines [`InitialQuicConnection::handshake`] and
/// [`InitialQuicConnection::resume`] into a single call.
pub async fn start_with_result<A: ApplicationOverQuic>(self, app: A) -> io::Result<QuicConnection> {
let task_metrics = self.params.metrics.clone();
let result = self.handshake(app).await;

match result {
Ok((q_conn, handshake)) => {
crate::metrics::tokio_task::spawn_with_killswitch(
"quic_handshake_worker",
task_metrics,
async move {
Self::resume(handshake)
}
);

Ok(q_conn)
},
Err(err) => {
log::error!("QUIC handshake failed in IQC::start_with_result"; "error" => &err);
Err(err) // Pass it upward
}
}
}

fn generate_id() -> u64 {
let mut buf = [0; 8];

Expand Down