Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
devsnek committed Apr 13, 2024
1 parent 8a6bcd2 commit 438e37d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
5 changes: 1 addition & 4 deletions quinn-proto/src/tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,7 @@ impl TestEndpoint {
now: Instant,
) -> Result<ConnectionHandle, ConnectionError> {
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));
Expand Down
18 changes: 14 additions & 4 deletions quinn/src/incoming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Connecting, ConnectionError> {
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<Arc<ServerConfig>>,
server_config: Arc<ServerConfig>,
) -> Result<Connecting, ConnectionError> {
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
Expand Down Expand Up @@ -124,6 +134,6 @@ impl IntoFuture for Incoming {
type IntoFuture = IncomingFuture;

fn into_future(self) -> Self::IntoFuture {
IncomingFuture(self.accept(None))
IncomingFuture(self.accept())
}
}
2 changes: 1 addition & 1 deletion quinn/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 438e37d

Please sign in to comment.