diff --git a/quic/client/QuicClientTransport.cpp b/quic/client/QuicClientTransport.cpp index d6af049cb..f2bb11b8f 100644 --- a/quic/client/QuicClientTransport.cpp +++ b/quic/client/QuicClientTransport.cpp @@ -684,7 +684,7 @@ void QuicClientTransport::processPacketData( // was rejected, or we have derived 1-rtt keys and 0-rtt was never // attempted. if (oneRttKeyDerivationTriggered) { - auto serverParams = handshakeLayer->getServerTransportParams(); + const auto& serverParams = handshakeLayer->getServerTransportParams(); if (!serverParams) { throw QuicTransportException( "No server transport params", @@ -711,7 +711,7 @@ void QuicClientTransport::processPacketData( TransportParameterId::initial_max_streams_uni, serverParams->parameters); processServerInitialParams( - *clientConn_, std::move(*serverParams), packetNum); + *clientConn_, serverParams.value(), packetNum); cacheServerInitialParams( *clientConn_, diff --git a/quic/client/handshake/ClientHandshake.cpp b/quic/client/handshake/ClientHandshake.cpp index d7da1bd2e..8fe3e24c1 100644 --- a/quic/client/handshake/ClientHandshake.cpp +++ b/quic/client/handshake/ClientHandshake.cpp @@ -109,7 +109,7 @@ ClientHandshake::Phase ClientHandshake::getPhase() const { return phase_; } -folly::Optional +const folly::Optional& ClientHandshake::getServerTransportParams() { return transportParams_->getServerTransportParams(); } diff --git a/quic/client/handshake/ClientHandshake.h b/quic/client/handshake/ClientHandshake.h index 06d8deb3b..7f51a06f9 100644 --- a/quic/client/handshake/ClientHandshake.h +++ b/quic/client/handshake/ClientHandshake.h @@ -87,7 +87,8 @@ class ClientHandshake : public Handshake { /** * Returns the negotiated transport parameters chosen by the server */ - virtual folly::Optional getServerTransportParams(); + virtual const folly::Optional& + getServerTransportParams(); ~ClientHandshake() override = default; diff --git a/quic/client/handshake/ClientTransportParametersExtension.h b/quic/client/handshake/ClientTransportParametersExtension.h index 54769c077..787bbb76e 100644 --- a/quic/client/handshake/ClientTransportParametersExtension.h +++ b/quic/client/handshake/ClientTransportParametersExtension.h @@ -41,8 +41,8 @@ struct ClientTransportParametersExtension { initialSourceCid_(initialSourceCid), customTransportParameters_(std::move(customTransportParameters)) {} - folly::Optional getServerTransportParams() { - return std::move(serverTransportParameters_); + const folly::Optional& getServerTransportParams() { + return serverTransportParameters_; } QuicVersion encodingVersion_; diff --git a/quic/client/state/ClientStateMachine.cpp b/quic/client/state/ClientStateMachine.cpp index e69fac4c5..bb1fc46bd 100644 --- a/quic/client/state/ClientStateMachine.cpp +++ b/quic/client/state/ClientStateMachine.cpp @@ -101,7 +101,7 @@ std::unique_ptr undoAllClientStateForRetry( void processServerInitialParams( QuicClientConnectionState& conn, - ServerTransportParameters serverParams, + const ServerTransportParameters& serverParams, PacketNum packetNum) { auto maxData = getIntegerParameter( TransportParameterId::initial_max_data, serverParams.parameters); diff --git a/quic/client/state/ClientStateMachine.h b/quic/client/state/ClientStateMachine.h index ecc642f9b..227edaf02 100644 --- a/quic/client/state/ClientStateMachine.h +++ b/quic/client/state/ClientStateMachine.h @@ -144,7 +144,7 @@ std::unique_ptr undoAllClientStateForRetry( void processServerInitialParams( QuicClientConnectionState& conn, - ServerTransportParameters serverParams, + const ServerTransportParameters& serverParams, PacketNum packetNum); void cacheServerInitialParams( diff --git a/quic/client/test/Mocks.h b/quic/client/test/Mocks.h index 0b72a866d..b8cb5db63 100644 --- a/quic/client/test/Mocks.h +++ b/quic/client/test/Mocks.h @@ -56,7 +56,7 @@ class MockClientHandshake : public ClientHandshake { MOCK_METHOD(bool, isTLSResumed, (), (const)); MOCK_METHOD(folly::Optional, getZeroRttRejected, ()); MOCK_METHOD( - folly::Optional, + const folly::Optional&, getServerTransportParams, ()); MOCK_METHOD(void, destroy, ()); diff --git a/quic/fizz/client/test/QuicClientTransportTestUtil.h b/quic/fizz/client/test/QuicClientTransportTestUtil.h index fba74bbb0..3ce7844db 100644 --- a/quic/fizz/client/test/QuicClientTransportTestUtil.h +++ b/quic/fizz/client/test/QuicClientTransportTestUtil.h @@ -316,7 +316,7 @@ class FakeOneRttHandshakeLayer : public FizzClientHandshake { return connected_; } - folly::Optional getServerTransportParams() + const folly::Optional& getServerTransportParams() override { return params_; }