diff src/dnsbl.cpp @ 129:c5cd1261394d

ignore smtp connection attempts for 10 minutes when getting connection errors on verify hosts
author carl
date Tue, 06 Jun 2006 08:45:07 -0700
parents 9ab51896447f
children df355d117199
line wrap: on
line diff
--- a/src/dnsbl.cpp	Thu Apr 27 10:05:43 2006 -0700
+++ b/src/dnsbl.cpp	Tue Jun 06 08:45:07 2006 -0700
@@ -88,10 +88,10 @@
 pthread_mutex_t  fd_pool_mutex;
 
 std::set<int>	 fd_pool;
-int    NULL_SOCKET		 = -1;
+const int	 NULL_SOCKET	   = -1;
+const time_t ERROR_SOCKET_TIME = 60;			// number of seconds between attempts to open a socket to the dns resolver process
 char  *resolver_port	 = NULL;		 // unix domain socket to talk to the dns resolver process
 int    resolver_socket	 = NULL_SOCKET;  // socket used to listen for resolver requests
-time_t ERROR_SOCKET_TIME = 60;			 // number of seconds between attempts to open a socket to the dns resolver process
 time_t last_error_time;
 int    resolver_sock_count = 0; 		 // protected with fd_pool_mutex
 int    resolver_pool_size  = 0; 		 // protected with fd_pool_mutex
@@ -188,8 +188,7 @@
 int my_connect();
 int my_connect() {
 	// if we have had recent errors, don't even try to open the socket
-	time_t now = time(NULL);
-	if ((now - last_error_time) < ERROR_SOCKET_TIME) return NULL_SOCKET;
+	if ((time(NULL) - last_error_time) < ERROR_SOCKET_TIME) return NULL_SOCKET;
 
 	// nothing recent, maybe this time it will work
 	int sock = NULL_SOCKET;
@@ -203,10 +202,10 @@
 		if (!rc) {
 			my_disconnect(sock, false);
 			sock = NULL_SOCKET;
-			last_error_time = now;
+			last_error_time = time(NULL);
 		}
 	}
-	else last_error_time = now;
+	else last_error_time = time(NULL);
 	if (sock != NULL_SOCKET) {
 		pthread_mutex_lock(&fd_pool_mutex);
 			resolver_sock_count++;