aboutsummaryrefslogtreecommitdiffstats
path: root/main/dnsmasq/0021-build_server_array.patch
blob: 2c70418dc94a1cec11375cbba5ded222e9292e3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Patch-Source: https://src.fedoraproject.org/rpms/dnsmasq/blob/f36/f/dnsmasq-2.86-build_server_array.patch
This patch replaces/enhances http://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=commit;h=d290630d31f4517ab26392d00753d1397f9a4114
--
From 068e849c713fa5e95eeb210792c061b7e212eab5 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
index 08f2785..3f82412 100644
--- a/src/dnsmasq.h
+++ b/src/dnsmasq.h
@@ -1757,7 +1757,6 @@ void dump_packet(int mask, void *packet, size_t len, union mysockaddr *src, unio
 #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
index 45528c1..e5b409e 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;
@@ -592,6 +592,12 @@ void cleanup_servers(void)
       else 
 	up = &serv->next;
    }
+
+  /* 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
index 3fc179d..0b68866 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1653,7 +1653,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.
-- 
2.31.1