-
-
Save zhouye/adfd509f51645d314f53992331449c45 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/dnsmasq.h b/src/dnsmasq.h | |
index 90dc986..5aaffcc 100644 | |
--- a/src/dnsmasq.h | |
+++ b/src/dnsmasq.h | |
@@ -1144,6 +1144,7 @@ extern struct daemon { | |
struct iname *if_names, *if_addrs, *if_except, *dhcp_except, *auth_peers, *tftp_interfaces; | |
struct bogus_addr *bogus_addr, *ignore_addr; | |
struct server *servers, *servers_tail, *local_domains, **serverarray; | |
+ int servers_flag; | |
struct rebind_domain *no_rebind; | |
int server_has_wildcard; | |
int serverarraysz, serverarrayhwm; | |
diff --git a/src/domain-match.c b/src/domain-match.c | |
index 76a1109..56ae015 100644 | |
--- a/src/domain-match.c | |
+++ b/src/domain-match.c | |
@@ -552,6 +552,7 @@ void mark_servers(int flag) | |
struct server *serv, **up; | |
daemon->servers_tail = NULL; | |
+ daemon->servers_flag = flag; | |
/* mark everything with argument flag */ | |
for (serv = daemon->servers; serv; serv = serv->next) | |
@@ -602,6 +603,8 @@ void cleanup_servers(void) | |
daemon->servers_tail = serv; | |
} | |
} | |
+ | |
+ daemon->servers_flag = 0; | |
} | |
int add_update_server(int flags, | |
@@ -663,29 +666,32 @@ int add_update_server(int flags, | |
} | |
else | |
{ | |
- /* Upstream servers. See if there is a suitable candidate, if so unmark | |
- and move to the end of the list, for order. The entry found may already | |
- be at the end. */ | |
- struct server **up, *tmp; | |
- | |
- for (serv = daemon->servers, up = &daemon->servers; serv; serv = tmp) | |
+ if (daemon->servers_flag) | |
{ | |
- tmp = serv->next; | |
- if ((serv->flags & SERV_MARK) && | |
- hostname_isequal(alloc_domain, serv->domain)) | |
+ /* Upstream servers. See if there is a suitable candidate, if so unmark | |
+ and move to the end of the list, for order. The entry found may already | |
+ be at the end. */ | |
+ struct server **up, *tmp; | |
+ | |
+ for (serv = daemon->servers, up = &daemon->servers; serv; serv = tmp) | |
{ | |
- /* Need to move down? */ | |
- if (serv->next) | |
+ tmp = serv->next; | |
+ if ((serv->flags & SERV_MARK) && | |
+ hostname_isequal(alloc_domain, serv->domain)) | |
{ | |
- *up = serv->next; | |
- daemon->servers_tail->next = serv; | |
- daemon->servers_tail = serv; | |
- serv->next = NULL; | |
+ /* Need to move down? */ | |
+ if (serv->next) | |
+ { | |
+ *up = serv->next; | |
+ daemon->servers_tail->next = serv; | |
+ daemon->servers_tail = serv; | |
+ serv->next = NULL; | |
+ } | |
+ break; | |
} | |
- break; | |
+ else | |
+ up = &serv->next; | |
} | |
- else | |
- up = &serv->next; | |
} | |
if (serv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment