From aa510b3fd0c25e2da7f561b3c0fadc32dd74843b Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Tue, 20 Jun 2023 13:25:40 -0700 Subject: [PATCH] Remove transient newClient Summary: This was a temporary variable which is not really needed, so remove. Reviewed By: passy Differential Revision: D46849864 fbshipit-source-id: 56fb52f9a80128fb746afcdc4d36225e6d596db2 --- .../Flipper/FlipperConnectionManagerImpl.cpp | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/xplat/Flipper/FlipperConnectionManagerImpl.cpp b/xplat/Flipper/FlipperConnectionManagerImpl.cpp index c7c08d74b..7404f0ec3 100644 --- a/xplat/Flipper/FlipperConnectionManagerImpl.cpp +++ b/xplat/Flipper/FlipperConnectionManagerImpl.cpp @@ -209,19 +209,20 @@ bool FlipperConnectionManagerImpl::connectAndExchangeCertificate() { payload->sdk_version = sdkVersion; payload->medium = medium; - auto newClient = FlipperSocketProvider::socketCreate( + client_ = FlipperSocketProvider::socketCreate( endpoint, std::move(payload), flipperScheduler_); - newClient->setEventHandler(ConnectionEvents(implWrapper_)); + client_->setEventHandler(ConnectionEvents(implWrapper_)); auto connectingInsecurely = flipperState_->start("Connect insecurely"); connectionIsTrusted_ = false; - if (!newClient->connect(this)) { + // Connect is just handled here, move this elsewhere. + if (!client_->connect(this)) { connectingInsecurely->fail("Failed to connect"); + client_ = nullptr; return false; } - client_ = std::move(newClient); connectingInsecurely->complete(); auto resettingState = flipperState_->start("Reset state"); @@ -258,10 +259,10 @@ bool FlipperConnectionManagerImpl::connectSecurely() { payload->csr = contextStore_->getCertificateSigningRequest().c_str(); payload->csr_path = contextStore_->getCertificateDirectoryPath().c_str(); - auto newClient = FlipperSocketProvider::socketCreate( + client_ = FlipperSocketProvider::socketCreate( endpoint, std::move(payload), connectionScheduler_, contextStore_.get()); - newClient->setEventHandler(ConnectionEvents(implWrapper_)); - newClient->setMessageHandler([this](const std::string& msg) { + client_->setEventHandler(ConnectionEvents(implWrapper_)); + client_->setMessageHandler([this](const std::string& msg) { std::unique_ptr responder; auto message = folly::parseJson(msg); auto idItr = message.find("id"); @@ -278,12 +279,13 @@ bool FlipperConnectionManagerImpl::connectSecurely() { auto connectingSecurely = flipperState_->start("Connect securely"); connectionIsTrusted_ = true; - if (!newClient->connect(this)) { + // Connect is just handled here, move this elsewhere. + if (!client_->connect(this)) { connectingSecurely->fail("Failed to connect"); + client_ = nullptr; return false; } - client_ = std::move(newClient); connectingSecurely->complete(); failedConnectionAttempts_ = 0; return true;