From 09015df5e93de837bdbe0ad87469762dbdda4e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 13 Nov 2021 22:14:54 +0100 Subject: Pairing: properly handle lingering threads after server stops --- include/erebos/pairing.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/erebos/pairing.h b/include/erebos/pairing.h index 4457426..b8b680a 100644 --- a/include/erebos/pairing.h +++ b/include/erebos/pairing.h @@ -29,6 +29,8 @@ using std::vector; class PairingServiceBase : public Service { public: + virtual ~PairingServiceBase(); + typedef function RequestInitHook; void onRequestInit(RequestInitHook); @@ -49,7 +51,6 @@ private: static vector nonceDigest(const Identity & id1, const Identity & id2, const vector & nonce1, const vector & nonce2); static string confirmationNumber(const vector &); - void waitForConfirmation(Peer peer, string confirm); RequestInitHook requestInitHook; ConfirmHook responseHook; @@ -70,14 +71,17 @@ private: }; struct State { + mutex lock; StatePhase phase; vector nonce; vector peerCheck; promise success; }; - map peerStates; + map> peerStates; mutex stateLock; + + void waitForConfirmation(Peer peer, weak_ptr state, string confirm, ConfirmHook hook); }; template -- cgit v1.2.3