From 8a876e2da3e90e143594323842fed68356a86c61 Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Sat, 13 Apr 2024 10:54:41 +1000 Subject: [PATCH] review --- quinn-proto/src/tests/util.rs | 5 +---- quinn/src/incoming.rs | 18 ++++++++++++++---- quinn/src/tests.rs | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/quinn-proto/src/tests/util.rs b/quinn-proto/src/tests/util.rs index 9b75dfeb2f..d735fb8d8a 100644 --- a/quinn-proto/src/tests/util.rs +++ b/quinn-proto/src/tests/util.rs @@ -456,10 +456,7 @@ impl TestEndpoint { now: Instant, ) -> Result { let mut buf = BytesMut::new(); - match self - .endpoint - .accept(incoming, now, &mut buf, Default::default()) - { + match self.endpoint.accept(incoming, now, &mut buf, None) { Ok((ch, conn)) => { self.connections.insert(ch, conn); self.accepted = Some(Ok(ch)); diff --git a/quinn/src/incoming.rs b/quinn/src/incoming.rs index 76e6e0840a..c6a03bc170 100644 --- a/quinn/src/incoming.rs +++ b/quinn/src/incoming.rs @@ -24,12 +24,22 @@ impl Incoming { } /// Attempt to accept this incoming connection (an error may still occur) - pub fn accept( + pub fn accept(mut self) -> Result { + let state = self.0.take().unwrap(); + state.endpoint.accept(state.inner, None) + } + + /// Accept this incoming connection using a custom configuration. + /// + /// See [`accept()`] for more details. + /// + /// [`accept()`]: Incoming::accept + pub fn accept_with( mut self, - server_config: Option>, + server_config: Arc, ) -> Result { let state = self.0.take().unwrap(); - state.endpoint.accept(state.inner, server_config) + state.endpoint.accept(state.inner, Some(server_config)) } /// Reject this incoming connection attempt @@ -124,6 +134,6 @@ impl IntoFuture for Incoming { type IntoFuture = IncomingFuture; fn into_future(self) -> Self::IntoFuture { - IncomingFuture(self.accept(None)) + IncomingFuture(self.accept()) } } diff --git a/quinn/src/tests.rs b/quinn/src/tests.rs index 9d420092ba..afe4b2039e 100755 --- a/quinn/src/tests.rs +++ b/quinn/src/tests.rs @@ -293,7 +293,7 @@ async fn zero_rtt() { let endpoint2 = endpoint.clone(); tokio::spawn(async move { for _ in 0..2 { - let incoming = endpoint2.accept().await.unwrap().accept(None).unwrap(); + let incoming = endpoint2.accept().await.unwrap().accept().unwrap(); let (connection, established) = incoming.into_0rtt().unwrap_or_else(|_| unreachable!()); let c = connection.clone(); tokio::spawn(async move {