dnsmasq/dnsmasq-2.86-build_server_array.patch

68 lines
2.3 KiB
Diff
Raw Normal View History

2022-09-27 13:35:46 +00:00
From 3ae3f53359a6e40535dac1cfd4887e80331a48fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
Date: Wed, 13 Oct 2021 16:58:39 +0200
Subject: [PATCH] Ensure serverarray is rebuilt once server can be removed
Because cleanup_servers is called from each place which can remove
server, use that function to refresh serverarray after changes. Make it
static, since it does not have to be called from other places.
---
src/dnsmasq.h | 1 -
src/domain-match.c | 8 +++++++-
src/network.c | 1 -
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/dnsmasq.h b/src/dnsmasq.h
2022-09-27 13:35:46 +00:00
index 36d17fe..e46dba2 100644
--- a/src/dnsmasq.h
+++ b/src/dnsmasq.h
2022-09-27 13:35:46 +00:00
@@ -1810,7 +1810,6 @@ void dump_packet_icmp(int mask, void *packet, size_t len, union mysockaddr *src,
#endif
/* domain-match.c */
-void build_server_array(void);
int lookup_domain(char *qdomain, int flags, int *lowout, int *highout);
int filter_servers(int seed, int flags, int *lowout, int *highout);
int is_local_answer(time_t now, int first, char *name);
diff --git a/src/domain-match.c b/src/domain-match.c
2022-09-27 13:35:46 +00:00
index f7db0fe..d5840d9 100644
--- a/src/domain-match.c
+++ b/src/domain-match.c
@@ -23,7 +23,7 @@ static int order_servers(struct server *s, struct server *s2);
/* If the server is USE_RESOLV or LITERAL_ADDRES, it lives on the local_domains chain. */
#define SERV_IS_LOCAL (SERV_USE_RESOLV | SERV_LITERAL_ADDRESS)
-void build_server_array(void)
+static void build_server_array(void)
{
struct server *serv;
int count = 0;
2022-09-27 13:35:46 +00:00
@@ -602,6 +602,12 @@ void cleanup_servers(void)
daemon->servers_tail = serv;
}
}
+
+ /* If we're delaying things, we don't call check_servers(), but
+ reload_servers() may have deleted some servers, rendering the server_array
+ invalid, so just rebuild that here. Once reload_servers() succeeds,
+ we call check_servers() above, which calls build_server_array itself. */
+ build_server_array();
}
int add_update_server(int flags,
diff --git a/src/network.c b/src/network.c
2022-09-27 13:35:46 +00:00
index 6166484..f9dbcd8 100644
--- a/src/network.c
+++ b/src/network.c
2022-09-27 13:35:46 +00:00
@@ -1701,7 +1701,6 @@ void check_servers(int no_loop_check)
}
cleanup_servers(); /* remove servers we just deleted. */
- build_server_array();
}
/* Return zero if no servers found, in that case we keep polling.
--
2022-09-27 13:35:46 +00:00
2.37.3