dnsmasq:dump cache on sigusr2 mine
authorKevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Sat, 13 Apr 2024 11:06:16 +0000 (12:06 +0100)
committerKevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Mon, 27 May 2024 17:33:49 +0000 (18:33 +0100)
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
package/network/services/dnsmasq/patches/400-dump-cache-on-sigusr2.patch [new file with mode: 0644]

diff --git a/package/network/services/dnsmasq/patches/400-dump-cache-on-sigusr2.patch b/package/network/services/dnsmasq/patches/400-dump-cache-on-sigusr2.patch
new file mode 100644 (file)
index 0000000..40558a9
--- /dev/null
@@ -0,0 +1,72 @@
+From bb7d39f44d8b2db69b4d6974abec7e85f6c689d1 Mon Sep 17 00:00:00 2001
+From: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
+Date: Sun, 17 Dec 2023 13:00:20 +0000
+Subject: [PATCH 1/2] dump cache on sigusr2
+
+---
+ src/cache.c   | 4 ++--
+ src/dnsmasq.c | 5 ++++-
+ src/dnsmasq.h | 2 +-
+ 3 files changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/src/cache.c b/src/cache.c
+index 0eacec9..c03bf6f 100644
+--- a/src/cache.c
++++ b/src/cache.c
+@@ -1905,7 +1905,7 @@ static void dump_cache_entry(struct crec *cache, time_t now)
+   my_syslog(LOG_INFO, "%s", buff);
+ }
+-void dump_cache(time_t now)
++void dump_cache(time_t now, unsigned int force_dump)
+ {
+   struct server *serv, *serv1;
+@@ -1959,7 +1959,7 @@ void dump_cache(time_t now)
+                 daemon->addrbuff, port, queries, retrys, failed_queries, nxdomain_replies, sigma_latency/count_latency);
+       }
+-  if (option_bool(OPT_DEBUG) || option_bool(OPT_LOG))
++  if (option_bool(OPT_DEBUG) || option_bool(OPT_LOG) || force_dump)
+     {
+       struct crec *cache;
+       int i;
+diff --git a/src/dnsmasq.c b/src/dnsmasq.c
+index a9f26ae..e1dbb6c 100644
+--- a/src/dnsmasq.c
++++ b/src/dnsmasq.c
+@@ -1509,7 +1509,7 @@ static void async_event(int pipe, time_t now)
+       
+       case EVENT_DUMP:
+       if (daemon->port != 0)
+-        dump_cache(now);
++        dump_cache(now, 0);
+       break;
+       
+       case EVENT_ALARM:
+@@ -1580,6 +1580,9 @@ static void async_event(int pipe, time_t now)
+          we leave them logging to the old file. */
+       if (daemon->log_file != NULL)
+         log_reopen(daemon->log_file);
++      else
++        if (daemon->port != 0)
++          dump_cache(now, 1);
+       break;
+       case EVENT_NEWADDR:
+diff --git a/src/dnsmasq.h b/src/dnsmasq.h
+index e455c3f..00eeb16 100644
+--- a/src/dnsmasq.h
++++ b/src/dnsmasq.h
+@@ -1355,7 +1355,7 @@ void cache_reload(void);
+ void cache_add_dhcp_entry(char *host_name, int prot, union all_addr *host_address, time_t ttd);
+ struct in_addr a_record_from_hosts(char *name, time_t now);
+ void cache_unhash_dhcp(void);
+-void dump_cache(time_t now);
++void dump_cache(time_t now, unsigned int force_dump);
+ #ifndef NO_ID
+ int cache_make_stat(struct txt_record *t);
+ #endif
+-- 
+2.39.2
+