diff --git a/xplat/Flipper/FlipperConnectionManagerImpl.cpp b/xplat/Flipper/FlipperConnectionManagerImpl.cpp index 55594368f..6d71c46d9 100644 --- a/xplat/Flipper/FlipperConnectionManagerImpl.cpp +++ b/xplat/Flipper/FlipperConnectionManagerImpl.cpp @@ -366,12 +366,13 @@ void FlipperConnectionManagerImpl::requestSignedCertFromFlipper() { "destination", contextStore_->getCertificateDirectoryPath().c_str())("medium", medium); auto gettingCert = flipperState_->start("Getting cert from desktop"); - bool handled = false; - flipperEventBase_->add([this, &handled, message, gettingCert]() { + certificateExchangeCompleted_ = false; + + flipperEventBase_->add([this, message, gettingCert]() { client_->sendExpectResponse( folly::toJson(message), - [this, &handled, message, gettingCert]( + [this, message, gettingCert]( const std::string& response, bool isError) { /** Need to keep track of whether the response has been handled. @@ -382,9 +383,9 @@ void FlipperConnectionManagerImpl::requestSignedCertFromFlipper() { interrupted because we are effectively still handing the response read. So, if already handled, ignore and return; */ - if (handled) + if (certificateExchangeCompleted_) return; - handled = true; + certificateExchangeCompleted_ = true; if (isError) { if (response.compare("not implemented")) { auto error = diff --git a/xplat/Flipper/FlipperConnectionManagerImpl.h b/xplat/Flipper/FlipperConnectionManagerImpl.h index 3e0cd240b..78807a6a7 100644 --- a/xplat/Flipper/FlipperConnectionManagerImpl.h +++ b/xplat/Flipper/FlipperConnectionManagerImpl.h @@ -68,6 +68,8 @@ class FlipperConnectionManagerImpl : public FlipperConnectionManager { std::unique_ptr client_; bool connectionIsTrusted_; + bool certificateExchangeCompleted_ = false; + int failedConnectionAttempts_ = 0; std::shared_ptr contextStore_; std::shared_ptr implWrapper_;