From 2f8774c921ffe2bc389dd99b5d2775cd5d9b62f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20S=C3=A9chet?= Date: Wed, 12 Feb 2020 09:40:52 -0800 Subject: [PATCH] Only take a QuicServerConnectionState when constructing ServerHandshake (#90) Summary: The cryptoState can be derrived from it, so it is redundant to pass it. This PR depends on https://github.com/facebookincubator/mvfst/issues/88 Pull Request resolved: https://github.com/facebookincubator/mvfst/pull/90 Reviewed By: mjoras Differential Revision: D19622581 Pulled By: yangchi fbshipit-source-id: b3c88999199673f69c4422b96fbe7f2b0656bf6c --- quic/server/handshake/ServerHandshake.cpp | 6 ++---- quic/server/handshake/ServerHandshake.h | 4 +--- quic/server/state/ServerStateMachine.h | 2 +- quic/server/test/QuicServerTransportTest.cpp | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/quic/server/handshake/ServerHandshake.cpp b/quic/server/handshake/ServerHandshake.cpp index e38be3d33..8954f4e64 100644 --- a/quic/server/handshake/ServerHandshake.cpp +++ b/quic/server/handshake/ServerHandshake.cpp @@ -15,12 +15,10 @@ #include namespace quic { -ServerHandshake::ServerHandshake( - QuicConnectionStateBase* conn, - QuicCryptoState& cryptoState) +ServerHandshake::ServerHandshake(QuicConnectionStateBase* conn) : conn_(conn), actionGuard_(nullptr), - cryptoState_(cryptoState), + cryptoState_(*conn->cryptoState), visitor_(*this) {} void ServerHandshake::accept( diff --git a/quic/server/handshake/ServerHandshake.h b/quic/server/handshake/ServerHandshake.h index 2fb78bdbb..8a5b4b71b 100644 --- a/quic/server/handshake/ServerHandshake.h +++ b/quic/server/handshake/ServerHandshake.h @@ -71,9 +71,7 @@ class ServerHandshake : public Handshake { */ enum class Phase { Handshake, KeysDerived, Established }; - explicit ServerHandshake( - QuicConnectionStateBase* conn, - QuicCryptoState& cryptoState); + explicit ServerHandshake(QuicConnectionStateBase* conn); /** * Starts accepting the TLS connection. diff --git a/quic/server/state/ServerStateMachine.h b/quic/server/state/ServerStateMachine.h index 13c33c23d..10a02c308 100644 --- a/quic/server/state/ServerStateMachine.h +++ b/quic/server/state/ServerStateMachine.h @@ -133,7 +133,7 @@ struct QuicServerConnectionState : public QuicConnectionStateBase { QuicVersion::QUIC_DRAFT, QuicVersion::QUIC_DRAFT_23}}; originalVersion = QuicVersion::MVFST; - serverHandshakeLayer = new ServerHandshake(this, *cryptoState); + serverHandshakeLayer = new ServerHandshake(this); handshakeLayer.reset(serverHandshakeLayer); // 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. diff --git a/quic/server/test/QuicServerTransportTest.cpp b/quic/server/test/QuicServerTransportTest.cpp index 5497a5165..f3e4b9b4b 100644 --- a/quic/server/test/QuicServerTransportTest.cpp +++ b/quic/server/test/QuicServerTransportTest.cpp @@ -44,7 +44,7 @@ class FakeServerHandshake : public ServerHandshake { bool chloSync = false, bool cfinSync = false, folly::Optional clientActiveConnectionIdLimit = folly::none) - : ServerHandshake(&conn, *conn.cryptoState), + : ServerHandshake(&conn), conn_(conn), chloSync_(chloSync), cfinSync_(cfinSync),