From 8ca7b4c5486423976f73b26bd342d98daadccb0b Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Sat, 4 Jul 2020 19:23:52 +0200 Subject: [PATCH] safeguard --- callback_dispatcher.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/callback_dispatcher.cc b/callback_dispatcher.cc index 92d955a..2213dbe 100644 --- a/callback_dispatcher.cc +++ b/callback_dispatcher.cc @@ -30,9 +30,11 @@ namespace pEp { targets.push_back({messageToSend, notifyHandshake, on_startup, shutdown}); - // try_unlock() possibly waiting messageToSend - sync_mtx.try_lock(); - sync_mtx.unlock(); + if (!Adapter::on_sync_thread()) { + // try_unlock() possibly waiting messageToSend + sync_mtx.try_lock(); + sync_mtx.unlock(); + } } void CallbackDispatcher::remove(::messageToSend_t messageToSend)