mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-04-18 17:24:03 +03:00
Remove throws from ClientStateMachine.
Summary: These were all in processing the server initial params. Reviewed By: hanidamlaj Differential Revision: D72259115 fbshipit-source-id: 1a4eb31709b6e5e438f2c552f8b7d975eeffb82f
This commit is contained in:
parent
b86c100bd8
commit
ff9e833c4c
@ -100,7 +100,7 @@ std::unique_ptr<QuicClientConnectionState> undoAllClientStateForRetry(
|
||||
return newConn;
|
||||
}
|
||||
|
||||
void processServerInitialParams(
|
||||
folly::Expected<folly::Unit, QuicError> processServerInitialParams(
|
||||
QuicClientConnectionState& conn,
|
||||
const ServerTransportParameters& serverParams,
|
||||
PacketNum packetNum) {
|
||||
@ -163,9 +163,9 @@ void processServerInitialParams(
|
||||
TransportParameterId::reliable_stream_reset));
|
||||
if (reliableResetTpIter != serverParams.parameters.end()) {
|
||||
if (!reliableResetTpIter->value->empty()) {
|
||||
throw QuicTransportException(
|
||||
"Reliable reset transport parameter must be empty",
|
||||
TransportErrorCode::TRANSPORT_PARAMETER_ERROR);
|
||||
return folly::makeUnexpected(QuicError(
|
||||
TransportErrorCode::TRANSPORT_PARAMETER_ERROR,
|
||||
"Reliable reset transport parameter must be empty"));
|
||||
}
|
||||
conn.peerAdvertisedReliableStreamResetSupport = true;
|
||||
} else {
|
||||
@ -185,9 +185,9 @@ void processServerInitialParams(
|
||||
conn.readCodec->getServerConnectionId() ||
|
||||
originalDestinationConnId.value() !=
|
||||
conn.originalDestinationConnectionId) {
|
||||
throw QuicTransportException(
|
||||
"Initial CID does not match.",
|
||||
TransportErrorCode::TRANSPORT_PARAMETER_ERROR);
|
||||
return folly::makeUnexpected(QuicError(
|
||||
TransportErrorCode::TRANSPORT_PARAMETER_ERROR,
|
||||
"Initial CID does not match."));
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,11 +197,11 @@ void processServerInitialParams(
|
||||
packetSize = kDefaultUDPSendPacketLen;
|
||||
}
|
||||
if (*packetSize < kMinMaxUDPPayload) {
|
||||
throw QuicTransportException(
|
||||
return folly::makeUnexpected(QuicError(
|
||||
TransportErrorCode::TRANSPORT_PARAMETER_ERROR,
|
||||
folly::to<std::string>(
|
||||
"Max packet size too small. received max_packetSize = ",
|
||||
*packetSize),
|
||||
TransportErrorCode::TRANSPORT_PARAMETER_ERROR);
|
||||
*packetSize)));
|
||||
}
|
||||
|
||||
VLOG(10) << "Client advertised flow control ";
|
||||
@ -228,9 +228,9 @@ void processServerInitialParams(
|
||||
conn.peerIdleTimeout = std::chrono::milliseconds(idleTimeout.value_or(0));
|
||||
conn.peerIdleTimeout = timeMin(conn.peerIdleTimeout, kMaxIdleTimeout);
|
||||
if (ackDelayExponent && *ackDelayExponent > kMaxAckDelayExponent) {
|
||||
throw QuicTransportException(
|
||||
"ack_delay_exponent too large",
|
||||
TransportErrorCode::TRANSPORT_PARAMETER_ERROR);
|
||||
return folly::makeUnexpected(QuicError(
|
||||
TransportErrorCode::TRANSPORT_PARAMETER_ERROR,
|
||||
"ack_delay_exponent too large"));
|
||||
}
|
||||
conn.peerAckDelayExponent =
|
||||
ackDelayExponent.value_or(kDefaultAckDelayExponent);
|
||||
@ -264,9 +264,9 @@ void processServerInitialParams(
|
||||
if (maxDatagramFrameSize.has_value()) {
|
||||
if (maxDatagramFrameSize.value() > 0 &&
|
||||
maxDatagramFrameSize.value() <= kMaxDatagramPacketOverhead) {
|
||||
throw QuicTransportException(
|
||||
"max_datagram_frame_size too small",
|
||||
TransportErrorCode::TRANSPORT_PARAMETER_ERROR);
|
||||
return folly::makeUnexpected(QuicError(
|
||||
TransportErrorCode::TRANSPORT_PARAMETER_ERROR,
|
||||
"max_datagram_frame_size too small"));
|
||||
}
|
||||
conn.datagramState.maxWriteFrameSize = maxDatagramFrameSize.value();
|
||||
}
|
||||
@ -292,6 +292,8 @@ void processServerInitialParams(
|
||||
|
||||
conn.peerAdvertisedKnobFrameSupport = knobFrameSupported.value_or(0) > 0;
|
||||
conn.peerAdvertisedExtendedAckFeatures = extendedAckFeatures.value_or(0);
|
||||
|
||||
return folly::unit;
|
||||
}
|
||||
|
||||
void cacheServerInitialParams(
|
||||
|
@ -141,7 +141,7 @@ struct QuicClientConnectionState : public QuicConnectionStateBase {
|
||||
std::unique_ptr<QuicClientConnectionState> undoAllClientStateForRetry(
|
||||
std::unique_ptr<QuicClientConnectionState> conn);
|
||||
|
||||
void processServerInitialParams(
|
||||
folly::Expected<folly::Unit, QuicError> processServerInitialParams(
|
||||
QuicClientConnectionState& conn,
|
||||
const ServerTransportParameters& serverParams,
|
||||
PacketNum packetNum);
|
||||
|
@ -178,13 +178,11 @@ TEST_F(ClientStateMachineTest, TestProcessMaxDatagramSizeBelowMin) {
|
||||
kMaxDatagramPacketOverhead - 1));
|
||||
ServerTransportParameters serverTransportParams = {
|
||||
std::move(transportParams)};
|
||||
try {
|
||||
processServerInitialParams(clientConn, serverTransportParams, 0);
|
||||
FAIL()
|
||||
<< "Expect transport exception due to max datagram frame size too small";
|
||||
} catch (QuicTransportException& e) {
|
||||
EXPECT_EQ(e.errorCode(), TransportErrorCode::TRANSPORT_PARAMETER_ERROR);
|
||||
}
|
||||
|
||||
auto result =
|
||||
processServerInitialParams(clientConn, serverTransportParams, 0);
|
||||
EXPECT_TRUE(result.hasError());
|
||||
EXPECT_EQ(result.error().code, TransportErrorCode::TRANSPORT_PARAMETER_ERROR);
|
||||
}
|
||||
|
||||
TEST_F(ClientStateMachineTest, TestProcessMaxDatagramSizeZeroOk) {
|
||||
@ -285,7 +283,6 @@ TEST_F(
|
||||
processServerInitialParams(clientConn, serverTransportParams, 0);
|
||||
EXPECT_FALSE(clientConn.peerAdvertisedReliableStreamResetSupport);
|
||||
}
|
||||
|
||||
TEST_F(ClientStateMachineTest, TestProcessReliableStreamResetNonEmptyParam) {
|
||||
QuicClientConnectionState clientConn(
|
||||
FizzClientQuicHandshakeContext::Builder().build());
|
||||
@ -294,9 +291,10 @@ TEST_F(ClientStateMachineTest, TestProcessReliableStreamResetNonEmptyParam) {
|
||||
encodeIntegerParameter(TransportParameterId::reliable_stream_reset, 0));
|
||||
ServerTransportParameters serverTransportParams = {
|
||||
std::move(transportParams)};
|
||||
EXPECT_THROW(
|
||||
processServerInitialParams(clientConn, serverTransportParams, 0),
|
||||
QuicTransportException);
|
||||
auto result =
|
||||
processServerInitialParams(clientConn, serverTransportParams, 0);
|
||||
EXPECT_TRUE(result.hasError());
|
||||
EXPECT_EQ(result.error().code, TransportErrorCode::TRANSPORT_PARAMETER_ERROR);
|
||||
}
|
||||
|
||||
TEST_F(
|
||||
|
Loading…
x
Reference in New Issue
Block a user