Mercurial > dnsbl
changeset 62:7ad7d8b100bf
only keep 20% of the open resolver sockets in the ready pool.
author | carl |
---|---|
date | Sun, 16 Jan 2005 08:25:36 -0800 |
parents | 7f44a4974bf6 |
children | 579dc5955cbe |
files | ChangeLog dnsbl.spec.in package.bash src/dnsbl.cpp xml/dnsbl.in |
diffstat | 5 files changed, 28 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sat Jan 08 12:26:30 2005 -0800 +++ b/ChangeLog Sun Jan 16 08:25:36 2005 -0800 @@ -1,5 +1,8 @@ $Id$ +4.3 2005-01-16 + Only keep 20% of the resolver sockets in the ready pool. + 4.2 2005-01-08 Use the separate resolver processes even if we don't have the resolver interfaces and need gethostbyname.
--- a/dnsbl.spec.in Sat Jan 08 12:26:30 2005 -0800 +++ b/dnsbl.spec.in Sun Jan 16 08:25:36 2005 -0800 @@ -1,6 +1,6 @@ Summary: DNSBL Sendmail Milter Name: dnsbl -Version: 4.2 +Version: 4.3 Release: 2 Copyright: GPL Group: System Environment/Daemons
--- a/package.bash Sat Jan 08 12:26:30 2005 -0800 +++ b/package.bash Sun Jan 16 08:25:36 2005 -0800 @@ -1,6 +1,6 @@ #!/bin/bash -VER=dnsbl-4.2 +VER=dnsbl-4.3 mkdir $VER target1=/home/httpd/html/510sg/util/dnsbl.tar.gz target2=/home/httpd/html/510sg/dnsbl.conf
--- a/src/dnsbl.cpp Sat Jan 08 12:26:30 2005 -0800 +++ b/src/dnsbl.cpp Sun Jan 16 08:25:36 2005 -0800 @@ -205,6 +205,8 @@ static int resolver_socket = NULL_SOCKET; // socket used to listen for resolver requests static time_t ERROR_SOCKET_TIME = 60; // number of seconds between attempts to open the spam filter socket static time_t last_error_time; +static int resolver_sock_count = 0; // protected with fd_pool_mutex +static int resolver_pool_size = 0; // protected with fd_pool_mutex // packed structure to allow a single socket write to dump the @@ -290,6 +292,9 @@ void my_disconnect(int sock) { if (sock != NULL_SOCKET) { + pthread_mutex_lock(&fd_pool_mutex); + resolver_sock_count--; + pthread_mutex_unlock(&fd_pool_mutex); shutdown(sock, SHUT_RDWR); close(sock); } @@ -316,13 +321,17 @@ if (sock != NULL_SOCKET) { bool rc = (connect(sock, (sockaddr *)&server, sizeof(server)) == 0); if (!rc) { - int er = errno; my_disconnect(sock); sock = NULL_SOCKET; last_error_time = now; } } else last_error_time = now; + if (sock != NULL_SOCKET) { + pthread_mutex_lock(&fd_pool_mutex); + resolver_sock_count++; + pthread_mutex_unlock(&fd_pool_mutex); + } return sock; } @@ -410,6 +419,7 @@ err = false; fd = *i; fd_pool.erase(fd); + resolver_pool_size--; } else { // pool is empty, get a new fd @@ -434,8 +444,16 @@ else { int result = pthread_mutex_lock(&fd_pool_mutex); if (!result) { + if (resolver_sock_count > resolver_pool_size*5) { // return the fd to the pool fd_pool.insert(fd); + resolver_pool_size++; + } + else { + // more than 20% of the open resolver sockets are in the pool + // that is enough, so just close this one. + my_disconnect(fd); + } pthread_mutex_unlock(&fd_pool_mutex); } else {
--- a/xml/dnsbl.in Sat Jan 08 12:26:30 2005 -0800 +++ b/xml/dnsbl.in Sun Jan 16 08:25:36 2005 -0800 @@ -2,7 +2,7 @@ <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> -<title>DNSBL Sendmail milter - Version 4.2</title> +<title>DNSBL Sendmail milter - Version 4.3</title> </head> <center>Introduction</center>