From c78ed10a6d3227ff4587d70eae85a2b056a60893 Mon Sep 17 00:00:00 2001 From: Kees Monshouwer Date: Wed, 22 Dec 2021 13:18:57 +0100 Subject: [PATCH] auth: improve tcp exception handling --- pdns/tcpreceiver.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index b9c619eb2d..2b0127f8a1 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -359,11 +359,15 @@ void TCPNameserver::doConnection(int fd) } catch(std::exception &e) { - g_log< l(s_plock); + s_P.reset(); // on next call, backend will be recycled + g_log << Logger::Error << "TCP Connection Thread died because of STL error, cycling backend: " << e.what() << endl; } catch( ... ) { - g_log << Logger::Error << "TCP Connection Thread caught unknown exception." << endl; + std::lock_guard l(s_plock); + s_P.reset(); // on next call, backend will be recycled + g_log << Logger::Error << "TCP Connection Thread caught unknown exception, cycling backend." << endl; } d_connectionroom_sem->post(); -- 2.47.2