Skip to content

Commit

Permalink
fix(foundations): quic errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TroyKomodo committed Aug 28, 2024
1 parent 784a69a commit 24dccde
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions foundations/src/http/server/stream/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use axum::response::IntoResponse;
use bytes::{Buf, Bytes};
use futures::future::poll_fn;
use futures::Future;
use h3::error::{Code, ErrorLevel};
use h3::ext::Protocol;
use h3::server::{Builder, RequestStream};
use h3_quinn::{BidiStream, RecvStream, SendStream};
Expand Down Expand Up @@ -90,6 +91,14 @@ impl Backend for QuicBackend {
break;
};

if !connection.remote_address_validated() {
if let Err(err) = connection.retry() {
tracing::debug!(error = %err, "failed to retry quic connection");
}

continue;
}

let connection = match connection.accept() {
Ok(connection) => connection,
Err(e) => {
Expand Down Expand Up @@ -207,10 +216,23 @@ impl<S: ServiceHandler> Connection<S> {
},
// An error occurred.
Err(err) => {
tracing::debug!(err = %err, "error accepting request");
self.service.on_error(err.into()).await;
connection_handle.cancel();
break;
match err.get_error_level() {
ErrorLevel::ConnectionError => {
tracing::debug!(err = %err, "error accepting request");
self.service.on_error(err.into()).await;
connection_handle.cancel();
break;
}
ErrorLevel::StreamError => {
if let Some(Code::H3_NO_ERROR) = err.try_get_code() {
tracing::trace!("stream closed");
} else {
tracing::debug!(err = %err, "stream error");
self.service.on_error(err.into()).await;
}
continue;
}
}
}
}
},
Expand Down

0 comments on commit 24dccde

Please sign in to comment.