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
This commit is contained in:
Lorenzo Blasa
2023-06-22 04:01:42 -07:00
committed by Facebook GitHub Bot
parent 1b5c9e627a
commit 80673f7832

View File

@@ -213,18 +213,23 @@ bool FlipperConnectionManagerImpl::connectAndExchangeCertificate() {
endpoint, std::move(payload), flipperScheduler_); endpoint, std::move(payload), flipperScheduler_);
client_->setEventHandler(ConnectionEvents(implWrapper_)); client_->setEventHandler(ConnectionEvents(implWrapper_));
auto connectingInsecurely = flipperState_->start("Connect insecurely");
connectionIsTrusted_ = false; 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. // Connect is just handled here, move this elsewhere.
if (!client_->connect(this)) { if (!client_->connect(this)) {
connectingInsecurely->fail("Failed to connect");
client_ = nullptr; client_ = nullptr;
return false; return false;
} }
connectingInsecurely->complete();
requestSignedCertificate(); requestSignedCertificate();
return true; return true;
@@ -273,17 +278,23 @@ bool FlipperConnectionManagerImpl::connectSecurely() {
this->onMessageReceived(folly::parseJson(msg), std::move(responder)); this->onMessageReceived(folly::parseJson(msg), std::move(responder));
}); });
auto connectingSecurely = flipperState_->start("Connect securely");
connectionIsTrusted_ = true; 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. // Connect is just handled here, move this elsewhere.
if (!client_->connect(this)) { if (!client_->connect(this)) {
connectingSecurely->fail("Failed to connect");
client_ = nullptr; client_ = nullptr;
return false; return false;
} }
connectingSecurely->complete();
failedConnectionAttempts_ = 0; failedConnectionAttempts_ = 0;
return true; return true;
} }