From: Fred Morcos Date: Thu, 11 Aug 2022 13:35:29 +0000 (+0200) Subject: Rec: Asynchronously destroy old connections to dnstap servers X-Git-Tag: rec-4.8.0-alpha1~59^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e0757d5c661c124b58ac69e91da440ad9705c62;p=thirdparty%2Fpdns.git Rec: Asynchronously destroy old connections to dnstap servers With @omoerbeek Closes #11795 --- diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index d91cb080c6..de718753b2 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -625,12 +625,20 @@ static std::shared_ptr>> startFra return result; } +static void asyncFrameStreamLoggersCleanup(std::shared_ptr>>&& servers) +{ + auto thread = std::thread([&] { + servers.reset(); + }); + thread.detach(); +} + bool checkFrameStreamExport(LocalStateHolder& luaconfsLocal) { if (!luaconfsLocal->frameStreamExportConfig.enabled) { if (t_frameStreamServersInfo.servers) { // dt's take care of cleanup - t_frameStreamServersInfo.servers.reset(); + asyncFrameStreamLoggersCleanup(std::move(t_frameStreamServersInfo.servers)); t_frameStreamServersInfo.config = luaconfsLocal->frameStreamExportConfig; } @@ -643,7 +651,7 @@ bool checkFrameStreamExport(LocalStateHolder& luaconfsLocal) if (t_frameStreamServersInfo.generation < luaconfsLocal->generation && t_frameStreamServersInfo.config != luaconfsLocal->frameStreamExportConfig) { if (t_frameStreamServersInfo.servers) { // dt's take care of cleanup - t_frameStreamServersInfo.servers.reset(); + asyncFrameStreamLoggersCleanup(std::move(t_frameStreamServersInfo.servers)); } auto dnsTapLog = g_slog->withName("dnstap");