From f07f0dfaac980255bb30ff14aa02e38d67f24169 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 17 Jul 2020 12:04:35 +0200 Subject: [PATCH] Skip second termiantion if there is already a termination event in progress. This has been observed with clients clsoing their connection exactly at the same time when dnsmasq wants to close the connection itself due to a timeout (it thinks this client is stale). Signed-off-by: DL6ER --- src/dnsmasq_interface.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/dnsmasq_interface.c b/src/dnsmasq_interface.c index 8779860a..937de47a 100644 --- a/src/dnsmasq_interface.c +++ b/src/dnsmasq_interface.c @@ -1785,8 +1785,17 @@ static void prepare_blocking_metadata(void) // Called when a (forked) TCP worker is terminated by receiving SIGALRM // We close the dedicated database connection this client had opened // to avoid dangling database locks +static volatile bool worker_already_terminating = false; void FTL_TCP_worker_terminating(bool finished) { + if(worker_already_terminating) + { + logg("TCP worker already terminating!"); + return; + } + worker_already_terminating = true; + + // Possible debug logging if(config.debug != 0) { const char *reason = finished ? "client disconnected" : "timeout";