From e04d618edeeb06dcddb7c3833c6ebc3aaaebfcb7 Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Thu, 8 Oct 2020 12:47:18 +0200 Subject: [PATCH] Catch exceptions in the thread running HandleConfigUpdate With dc3062a9b06fed69cdbb1508ace6eb2f77f87553, exceptions in this code path were no longer caught properly. This commit restores exception handling for this function. --- lib/remote/apilistener-filesync.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/remote/apilistener-filesync.cpp b/lib/remote/apilistener-filesync.cpp index 1feb13097..468c0038f 100644 --- a/lib/remote/apilistener-filesync.cpp +++ b/lib/remote/apilistener-filesync.cpp @@ -312,7 +312,16 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin::Ptr& origin, const D return Empty; } - std::thread([origin, params]() { HandleConfigUpdate(origin, params); }).detach(); + std::thread([origin, params, listener]() { + try { + HandleConfigUpdate(origin, params); + } catch (const std::exception& ex) { + auto msg ("Exception during config sync: " + DiagnosticInformation(ex)); + + Log(LogCritical, "ApiListener") << msg; + listener->UpdateLastFailedZonesStageValidation(msg); + } + }).detach(); return Empty; }