From 80673f7832c4a2ce0ce4572c442f9ce32c3720ba Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Thu, 22 Jun 2023 04:01:42 -0700 Subject: [PATCH] Rework flipper state step for connect Summary: Create the step as an attempt. Remove conditionally marking it as success or failure as connect will not be done 'synchronously' moving forward. :::notes::: Documentation is for personal use and will be removed next. Reviewed By: passy Differential Revision: D46850048 fbshipit-source-id: d6dce961d5cbd767f428e58850d24a433d50ba14 --- .../Flipper/FlipperConnectionManagerImpl.cpp | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/xplat/Flipper/FlipperConnectionManagerImpl.cpp b/xplat/Flipper/FlipperConnectionManagerImpl.cpp index d326c31b5..d689c43ee 100644 --- a/xplat/Flipper/FlipperConnectionManagerImpl.cpp +++ b/xplat/Flipper/FlipperConnectionManagerImpl.cpp @@ -213,18 +213,23 @@ bool FlipperConnectionManagerImpl::connectAndExchangeCertificate() { endpoint, std::move(payload), flipperScheduler_); client_->setEventHandler(ConnectionEvents(implWrapper_)); - auto connectingInsecurely = flipperState_->start("Connect insecurely"); connectionIsTrusted_ = false; + auto step = + flipperState_->start("Attempt to connect for certificate exchange"); + + step->complete(); + + // NON-TLS: + // On failure: clear the client. + // On success: proceed to request the client certificate. + // Connect is just handled here, move this elsewhere. if (!client_->connect(this)) { - connectingInsecurely->fail("Failed to connect"); client_ = nullptr; return false; } - connectingInsecurely->complete(); - requestSignedCertificate(); return true; @@ -273,17 +278,23 @@ bool FlipperConnectionManagerImpl::connectSecurely() { this->onMessageReceived(folly::parseJson(msg), std::move(responder)); }); - auto connectingSecurely = flipperState_->start("Connect securely"); connectionIsTrusted_ = true; + auto step = flipperState_->start( + "Attempt to connect with existing client certificate"); + + step->complete(); + + // TLS: + // On failure: clear the client. + // On success: clear number of failed attempts. + // Connect is just handled here, move this elsewhere. if (!client_->connect(this)) { - connectingSecurely->fail("Failed to connect"); client_ = nullptr; return false; } - connectingSecurely->complete(); failedConnectionAttempts_ = 0; return true; }