From 723b6b18295d365136fe05fc08f630c1760378d2 Mon Sep 17 00:00:00 2001 From: heck Date: Wed, 15 Jan 2020 20:45:00 +0100 Subject: [PATCH] Possible fix for "shutdown problem". Tests added in last commit (startup/shutdown repeatedly) now seem to work better, but still fail on iteration 61, with a different problem. --- Adapter.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Adapter.cc b/Adapter.cc index 2a96092..cd213f9 100644 --- a/Adapter.cc +++ b/Adapter.cc @@ -55,8 +55,17 @@ namespace pEp { } if (ev == nullptr) { if (!on_sync_thread()) { - _sync_thread->join(); - q.clear(); + if(_sync_thread->joinable()) { + pEpLog("Waiting for Sync thread to join..."); + _sync_thread->join(); + delete _sync_thread; + _sync_thread = nullptr; + pEpLog("...thread joined"); + q.clear(); + } else { + //FATAL + pEpLog("FATAL: sync thread not joinable/detached"); + } } } return 0;