Mercurial > dnsbl
diff src/dnsbl.cpp @ 138:9d0bc30b4576
add smtp auth rate limits
author | carl |
---|---|
date | Tue, 26 Sep 2006 15:09:46 -0700 |
parents | a6190f7798f4 |
children | 003026deaed1 |
line wrap: on
line diff
--- a/src/dnsbl.cpp Tue Sep 26 14:17:00 2006 -0700 +++ b/src/dnsbl.cpp Tue Sep 26 15:09:46 2006 -0700 @@ -149,8 +149,14 @@ int incr_rcpt_count(char *user) { pthread_mutex_lock(&rate_mutex); rcpt_rates::iterator i = rcpt_counts.find(user); - int c = (i == rcpt_counts.end()) ? 0 : (*i).second; - rcpt_counts[user] = c++; + int c = 1; + if (i == rcpt_counts.end()) { + user = strdup(user); + rcpt_counts[user] = c; + } + else { + c = (*i).second++; + } pthread_mutex_unlock(&rate_mutex); return c; } @@ -1173,6 +1179,10 @@ // three minutes thru each loop, 20 loops per hour // clear the recipient counts pthread_mutex_lock(&rate_mutex); + for (rcpt_rates::iterator i=rcpt_counts.begin(); i!=rcpt_counts.end(); i++) { + char *x = (*i).first; + free(x); + } rcpt_counts.clear(); pthread_mutex_unlock(&rate_mutex); loop = 0;