diff --git a/FTL.h b/FTL.h index 4a25638f..a3e145ed 100644 --- a/FTL.h +++ b/FTL.h @@ -109,6 +109,7 @@ typedef struct { int overTime_MAX; int wildcarddomains_MAX; int gravity; + int gravity_conf; int overTime; int querytype[7]; int wildcarddomains; diff --git a/dnsmasq_interface.c b/dnsmasq_interface.c index e4d53759..38e877fe 100644 --- a/dnsmasq_interface.c +++ b/dnsmasq_interface.c @@ -250,24 +250,25 @@ void FTL_read_hosts(char * filename, int addr_count) { // Interpret hosts files that have been read by dnsmasq // We ignore other read lists like /etc/hosts - enable_thread_lock(); + if(counters.gravity == 0 && counters.gravity_conf > 0) + counters.gravity += counters.gravity_conf; + if(filename != NULL && (strstr(filename, "/gravity.list") != NULL || strstr(filename, "/black.list") != NULL)) { counters.gravity += addr_count; } - disable_thread_lock(); } void FTL_read_config(int flags) { // Interpret blocking configuration that have been read by dnsmasq - enable_thread_lock(); + // No need for thread locks here as this happens while the resolver + // is not yet ready if((flags & SERV_HAS_DOMAIN) && (flags & SERV_NO_ADDR)) - counters.gravity++; // Blacklist - else if((flags & SERV_USE_RESOLV) && counters.gravity > 0) - counters.gravity--; // Whitelist - disable_thread_lock(); + counters.gravity_conf++; // Blacklist + else if((flags & SERV_USE_RESOLV) && counters.gravity_conf > 0) + counters.gravity_conf--; // Whitelist } void FTL_reply(unsigned short flags, char *name, struct all_addr *addr, unsigned long ttl, int id)