1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-11-24 04:01:07 +03:00
Files
mvfst/quic/client/state/ClientStateMachine.h
Amaury Séchet e6e6196c86 Move the delayed destruction from Handshake to QuicConnectionStateBase
Summary: Pull Request resolved: https://github.com/facebookincubator/mvfst/pull/88

Test Plan:
Imported from GitHub, without a `Test Plan:` line.

 ---
## Proxygen Canary
Traffic Canary: https://our.intern.facebook.com/intern/traffic/canary?fbid=224323975233396
* elb.prod.ham3c01 - binary_asan - 2020-02-05 02:00 - https://fburl.com/dyndash/u2q12hwq
* elb.prod.mia3c02 - binary - 2020-01-31 09:40 - https://fburl.com/dyndash/vmv34rpa
* elb.prod.otp1c01 - binary - 2020-02-05 02:26 - https://fburl.com/dyndash/0zttm61b
* flb.prod.fath4c02 - binary - 2020-02-05 02:26 - https://fburl.com/dyndash/6o1nqsti
* flb.prod.fgye3c01 - binary - 2020-01-31 09:40 - https://fburl.com/dyndash/nu3i5ahw
* olb.prod.rfrc0c01.p2 - binary - 2020-01-31 09:40 - https://fburl.com/dyndash/c1o6hpqw
* olb.prod.rftw0c01.p2 - binary - 2020-02-05 02:26 - https://fburl.com/dyndash/xg6qbyru
* slb.prod_regional.rcln0c00 - binary - 2020-02-05 02:26 - https://fburl.com/dyndash/e4qkbzcz
* slb.prod_regional.rfrc0c00 - binary - 2020-01-31 09:40 - https://fburl.com/dyndash/j0yxofty
* slb.prod_regional.rrva0c00 - binary_asan - 2020-02-05 02:00 - https://fburl.com/dyndash/4hsg02uj
* slb.regional.rfrc0c01.p2 - binary - 2020-01-31 09:40 - https://fburl.com/dyndash/1njxzbgf
* slb.regional.rvll0c01.p2 - binary - 2020-02-05 02:26 - https://fburl.com/dyndash/056xdmzn
 ---

Reviewed By: lnicco

Differential Revision: D19551142

Pulled By: mjoras

fbshipit-source-id: b0d14146d14384b8c37887b3e9d8fed7d6181d88
2020-02-05 06:13:33 -08:00

93 lines
3.5 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
#pragma once
#include <folly/io/async/AsyncSocketException.h>
#include <quic/client/handshake/CachedServerTransportParameters.h>
#include <quic/client/handshake/ClientHandshake.h>
#include <quic/client/handshake/ClientHandshakeFactory.h>
#include <quic/congestion_control/QuicCubic.h>
#include <quic/flowcontrol/QuicFlowController.h>
#include <quic/handshake/TransportParameters.h>
#include <quic/state/QuicStateFunctions.h>
#include <quic/state/StateData.h>
namespace quic {
struct QuicClientConnectionState : public QuicConnectionStateBase {
~QuicClientConnectionState() override = default;
// The stateless reset token sent by the server.
folly::Optional<StatelessResetToken> statelessResetToken;
// The retry token sent by the server.
std::string retryToken;
// Initial destination connection id.
folly::Optional<ConnectionId> initialDestinationConnectionId;
std::shared_ptr<ClientHandshakeFactory> handshakeFactory;
ClientHandshake* clientHandshakeLayer;
// Save the server transport params here so that client can access the value
// when it wants to write the values to psk cache
// TODO Save TicketTransportParams here instead of in QuicClientTransport
uint64_t peerAdvertisedInitialMaxStreamsBidi{0};
uint64_t peerAdvertisedInitialMaxStreamsUni{0};
// Packet number in which client initial was sent. Receipt of data on the
// crypto stream from the server can implicitly ack the client initial packet.
// TODO: use this to get rid of the data in the crypto stream.
// folly::Optional<PacketNum> clientInitialPacketNum;
explicit QuicClientConnectionState(
std::shared_ptr<ClientHandshakeFactory> handshakeFactoryIn)
: QuicConnectionStateBase(QuicNodeType::Client),
handshakeFactory(std::move(handshakeFactoryIn)) {
cryptoState = std::make_unique<QuicCryptoState>();
congestionController = std::make_unique<Cubic>(*this);
// TODO: this is wrong, it should be the handshake finish time. But i need
// a relatively sane time now to make the timestamps all sane.
connectionTime = Clock::now();
originalVersion = QuicVersion::MVFST;
DCHECK(handshakeFactory);
auto tmpClientHandshake =
handshakeFactory->makeClientHandshake(*cryptoState);
clientHandshakeLayer = tmpClientHandshake.get();
handshakeLayer = std::move(tmpClientHandshake);
// We shouldn't normally need to set this until we're starting the
// transport, however writing unit tests is much easier if we set this here.
updateFlowControlStateWithSettings(flowControlState, transportSettings);
streamManager = std::make_unique<QuicStreamManager>(
*this, this->nodeType, transportSettings);
transportSettings.selfActiveConnectionIdLimit =
kDefaultActiveConnectionIdLimit;
}
};
/**
* Undos the clients state to be the original state of the client.
*/
std::unique_ptr<QuicClientConnectionState> undoAllClientStateCommon(
std::unique_ptr<QuicClientConnectionState> conn);
std::unique_ptr<QuicClientConnectionState> undoAllClientStateForRetry(
std::unique_ptr<QuicClientConnectionState> conn);
void processServerInitialParams(
QuicClientConnectionState& conn,
ServerTransportParameters serverParams,
PacketNum packetNum);
void updateTransportParamsFromCachedEarlyParams(
QuicClientConnectionState& conn,
const CachedServerTransportParameters& transportParams);
} // namespace quic