Skip to content

Commit

Permalink
Fix #182: Convert error codes before passing them to QUIC
Browse files Browse the repository at this point in the history
  • Loading branch information
barafael committed Sep 3, 2024
1 parent 209a6c9 commit 9cbcd80
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions wtransport/src/driver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl Driver {

stream
.into_stream()
.stop(ErrorCode::BufferedStreamRejected.to_code())
.stop(ErrorCode::BufferedStreamRejected.to_http3())
.expect("Stream not already stopped");
}
}
Expand All @@ -164,7 +164,7 @@ impl Driver {
stream
.into_stream()
.1
.stop(ErrorCode::BufferedStreamRejected.to_code())
.stop(ErrorCode::BufferedStreamRejected.to_http3())
.expect("Stream not already stopped");
}
}
Expand Down Expand Up @@ -308,7 +308,7 @@ mod worker {

if let DriverError::Proto(error_code) = &error {
self.quic_connection
.close(varint_w2q(error_code.to_code()), b"");
.close(varint_w2q(error_code.to_http3()), b"");
}

self.driver_result.set(error);
Expand Down Expand Up @@ -595,14 +595,14 @@ mod worker {
Ok(session_request) => stream.into_session(session_request),
Err(HeadersParseError::MethodNotConnect) => {
stream
.stop(ErrorCode::RequestRejected.to_code())
.stop(ErrorCode::RequestRejected.to_http3())
.expect("Stream not already stopped");
return Ok(());
}
// TODO(biagio): we might have more granularity with errors
Err(_) => {
stream
.stop(ErrorCode::Message.to_code())
.stop(ErrorCode::Message.to_http3())
.expect("Stream not already stopped");
return Ok(());
}
Expand All @@ -613,7 +613,7 @@ mod worker {
Err(TrySendError::Full(mut stream)) => {
debug!("Discarding session request: sessions queue is full");
stream
.stop(ErrorCode::RequestRejected.to_code())
.stop(ErrorCode::RequestRejected.to_http3())
.expect("Stream not already stopped");
}
Err(TrySendError::Closed(_)) => return Err(DriverError::NotConnected),
Expand Down
10 changes: 5 additions & 5 deletions wtransport/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ impl Endpoint<endpoint_side::Client> {
let frame = match stream_session.read_frame().await {
Ok(frame) => frame,
Err(ProtoReadError::H3(error_code)) => {
quic_connection.close(varint_w2q(error_code.to_code()), b"");
quic_connection.close(varint_w2q(error_code.to_http3()), b"");
return Err(ConnectingError::ConnectionError(
ConnectionError::local_h3_error(error_code),
));
Expand All @@ -404,7 +404,7 @@ impl Endpoint<endpoint_side::Client> {
};

if !matches!(frame.kind(), FrameKind::Headers) {
quic_connection.close(varint_w2q(ErrorCode::FrameUnexpected.to_code()), b"");
quic_connection.close(varint_w2q(ErrorCode::FrameUnexpected.to_http3()), b"");
return Err(ConnectingError::ConnectionError(
ConnectionError::local_h3_error(ErrorCode::FrameUnexpected),
));
Expand All @@ -413,7 +413,7 @@ impl Endpoint<endpoint_side::Client> {
let headers = match Headers::with_frame(&frame) {
Ok(headers) => headers,
Err(error_code) => {
quic_connection.close(varint_w2q(error_code.to_code()), b"");
quic_connection.close(varint_w2q(error_code.to_http3()), b"");
return Err(ConnectingError::ConnectionError(
ConnectionError::local_h3_error(error_code),
));
Expand All @@ -423,7 +423,7 @@ impl Endpoint<endpoint_side::Client> {
let session_response = match SessionResponseProto::try_from(headers) {
Ok(session_response) => session_response,
Err(_) => {
quic_connection.close(varint_w2q(ErrorCode::Message.to_code()), b"");
quic_connection.close(varint_w2q(ErrorCode::Message.to_http3()), b"");
return Err(ConnectingError::ConnectionError(
ConnectionError::local_h3_error(ErrorCode::Message),
));
Expand Down Expand Up @@ -759,7 +759,7 @@ impl SessionRequest {
}
Err(ProtoWriteError::Stopped) => {
self.quic_connection
.close(varint_w2q(ErrorCode::ClosedCriticalStream.to_code()), b"");
.close(varint_w2q(ErrorCode::ClosedCriticalStream.to_http3()), b"");

Err(ConnectionError::local_h3_error(
ErrorCode::ClosedCriticalStream,
Expand Down

0 comments on commit 9cbcd80

Please sign in to comment.