Flipper | Fix potential for deadlock when stopping Flipper

Summary:
There was an interesting problem in Flipper which I encountered. On closing our app we would deadlock. This was happening when joining the Flipper thread.

Upon investigation I found that it happened only when Flipper was not connected to the app. And digging in I found that it's because we are continually trying to connect the `FlipperClient` to the Flipper app when there is no connection. This works great, but it continues even if you have asked Flipper to terminate. So this meant that the `EventBase` never gets chance to shutdown, as it keeps getting new work to do.

The fix is to add a flag to `FlipperConnectionManagerImpl` to say if the conection is started or not. Then, if it's not started and we get a request to retry connection, then we will fail it.

Reviewed By: jknoxville

Differential Revision: D18780622

fbshipit-source-id: cce82cbb5c54e6d92ea16644c8a247bd2578ae26
This commit is contained in:
Matt Galloway
2019-12-04 07:31:41 -08:00
committed by Facebook Github Bot
parent 15e1b25098
commit d37c64c329
2 changed files with 21 additions and 0 deletions

View File

@@ -53,6 +53,7 @@ class FlipperConnectionManagerImpl : public FlipperConnectionManager {
private:
bool isOpen_ = false;
bool isStarted_ = false;
Callbacks* callbacks_;
DeviceData deviceData_;
std::shared_ptr<FlipperState> flipperState_;