# HG changeset patch # User carl # Date 1085699868 25200 # Node ID 4dfdf33f1db0eb58b0a49e26f6bbe20af4087442 # Parent 33e1e3910506412b6dba89256b8dfba24d295c6c add syslog msg freeing memory, use bare tld names without leading period diff -r 33e1e3910506 -r 4dfdf33f1db0 sendmail.st Binary file sendmail.st has changed diff -r 33e1e3910506 -r 4dfdf33f1db0 src/dnsbl.cpp --- a/src/dnsbl.cpp Thu May 27 10:08:51 2004 -0700 +++ b/src/dnsbl.cpp Thu May 27 16:17:48 2004 -0700 @@ -118,6 +118,7 @@ // the only mutable stuff once it has been loaded from the config file int reference_count; // protected by the global config_mutex // all the rest is constant after loading from the config file + int generation; time_t load_time; string_list config_files; dnsblp_map dnsbls; @@ -138,6 +139,7 @@ }; CONFIG::CONFIG() { reference_count = 0; + generation = 0; load_time = 0; content_suffix = NULL; content_message = NULL; @@ -168,6 +170,7 @@ static bool loader_run = true; // used to stop the config loader thread static string_set all_strings; // owns all the strings, only modified by the config loader thread static CONFIG * config = NULL; // protected by the config_mutex +static int generation = 0; // protected by the config_mutex static pthread_mutex_t config_mutex; static pthread_mutex_t syslog_mutex; @@ -493,21 +496,21 @@ int lim = priv.pc->host_limit; if ((count > lim) && (lim > 0)) return reject_host; host = *i; + ip = protected_dns_interface(host, true); if (debug_syslog) { char buf[200]; - snprintf(buf, sizeof(buf), "looking for host %s", host); + if (ip) { + char adr[sizeof "255.255.255.255"]; + adr[0] = '\0'; + inet_ntop(AF_INET, (const u_char *)&ip, adr, sizeof(adr)); + snprintf(buf, sizeof(buf), "host %s found at %s", host, adr); + } + else { + snprintf(buf, sizeof(buf), "host %s not found", host); + } my_syslog(buf); } - ip = protected_dns_interface(host, true); if (ip) { - // if (debug_syslog) { - // char adr[sizeof "255.255.255.255"]; - // adr[0] = '\0'; - // inet_ntop(AF_INET, (const u_char *)&ip, adr, sizeof(adr)); - // char buf[200]; - // snprintf(buf, sizeof(buf), "found host %s at %s", host, adr); - // my_syslog(buf); - // } status st = check_single(ip, dc.content_suffix); if (st == reject) return st; } @@ -877,11 +880,9 @@ bool processed = false; switch (commands[cmd]) { case tld: { - char *tld = strtok(NULL, delim); + char *tld = next_token(delim); if (!tld) break; // no tld value - char buf[200]; - snprintf(buf, sizeof(buf), ".%s", tld); - dc.tlds.insert(register_string(buf)); // leading . + dc.tlds.insert(tld); processed = true; } break; @@ -1066,8 +1067,13 @@ // static CONFIG* new_conf(); static CONFIG* new_conf() { - my_syslog("loading new configuration"); CONFIG *newc = new CONFIG; + pthread_mutex_lock(&config_mutex); + newc->generation = generation++; + pthread_mutex_unlock(&config_mutex); + char buf[200]; + snprintf(buf, sizeof(buf), "loading configuration generation %d", newc->generation); + my_syslog(buf); load_conf(*newc, "dnsbl.conf"); newc->load_time = time(NULL); return newc; @@ -1109,6 +1115,9 @@ for (configp_set::iterator i=old_configs.begin(); i!=old_configs.end(); ) { CONFIG *old = *i; if (!old->reference_count) { + char buf[200]; + snprintf(buf, sizeof(buf), "freeing memory for old configuration generation %d", old->generation); + my_syslog(buf); delete old; // destructor does all the work old_configs.erase(i++); } diff -r 33e1e3910506 -r 4dfdf33f1db0 src/scanner.cpp --- a/src/scanner.cpp Thu May 27 10:08:51 2004 -0700 +++ b/src/scanner.cpp Thu May 27 16:17:48 2004 -0700 @@ -953,7 +953,7 @@ // have two periods, so three components for (int i=1; itlds->find(p2); + string_set::iterator i = memory->tlds->find(p2+1); if (i != memory->tlds->end()) memory->new_url((char*)pending); } }