Clear event handler on deallocation

Summary:
It's just bad that we give a naked pointer of the connection manager to other instances. If the connection manager gets deallocated, the instances keeping a pointer to it are doomed to crash.

This change creates a wrapper on top of the pointer that can be freely shared. On deallocation, the shared wrapper gets invalidated.

Reviewed By: timur-valiev

Differential Revision: D30398466

fbshipit-source-id: 8f228e7fbaebc0ea28921409de071b58bbb69f1e
This commit is contained in:
Lorenzo Blasa
2021-08-19 04:41:35 -07:00
committed by Facebook GitHub Bot
parent ebe5e7f9ff
commit 8e2a839f9d
3 changed files with 49 additions and 29 deletions

View File

@@ -21,7 +21,7 @@ namespace flipper {
class ConnectionEvents;
class ConnectionContextStore;
class FlipperRSocketResponder;
class FlipperConnectionManagerWrapper;
class FlipperConnectionManagerImpl : public FlipperConnectionManager {
friend ConnectionEvents;
@@ -70,6 +70,7 @@ class FlipperConnectionManagerImpl : public FlipperConnectionManager {
bool connectionIsTrusted_;
int failedConnectionAttempts_ = 0;
std::shared_ptr<ConnectionContextStore> contextStore_;
std::shared_ptr<FlipperConnectionManagerWrapper> implWrapper_;
void startSync();
bool connectAndExchangeCertificate();