Schedule close on the scheduler
Summary: ^ If Flipper stops, we cannot freely access the client outside of the scheduler. There may be an scheduled operation that depends on it. Instead, schedule the stop and wait until it finishes. Reviewed By: cekkaewnumchai Differential Revision: D37814820 fbshipit-source-id: 44217b5f623a8d92211a3d72a4a204d674b4bb76
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e7591b2a81
commit
039b647666
@@ -305,10 +305,18 @@ void FlipperConnectionManagerImpl::stop() {
|
||||
}
|
||||
isStarted_ = false;
|
||||
|
||||
if (client_) {
|
||||
client_->disconnect();
|
||||
}
|
||||
client_ = nullptr;
|
||||
std::shared_ptr<std::promise<void>> joinPromise =
|
||||
std::make_shared<std::promise<void>>();
|
||||
std::future<void> join = joinPromise->get_future();
|
||||
flipperScheduler_->schedule([this, joinPromise]() {
|
||||
if (client_) {
|
||||
client_->disconnect();
|
||||
}
|
||||
client_ = nullptr;
|
||||
joinPromise->set_value();
|
||||
});
|
||||
|
||||
join.wait();
|
||||
}
|
||||
|
||||
bool FlipperConnectionManagerImpl::isOpen() const {
|
||||
@@ -453,6 +461,9 @@ void FlipperConnectionManagerImpl::requestSignedCertificate() {
|
||||
|
||||
certificateExchangeCompleted_ = false;
|
||||
flipperScheduler_->schedule([this, message, gettingCert]() {
|
||||
if (!client_) {
|
||||
return;
|
||||
}
|
||||
client_->sendExpectResponse(
|
||||
folly::toJson(message),
|
||||
[this, gettingCert](const std::string& response, bool isError) {
|
||||
|
||||
Reference in New Issue
Block a user