diff src/context.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 d9d2f8699621
children f4746d8a12a3
line wrap: on
line diff
--- a/src/context.cpp	Thu Apr 27 10:05:43 2006 -0700
+++ b/src/context.cpp	Tue Jun 06 08:45:07 2006 -0700
@@ -67,7 +67,7 @@
 const int maxlen = 1000;	// used for snprintf buffers
 const int maxage = 120; 	// smtp verify sockets older than this are ancient
 extern int	  NULL_SOCKET;
-extern time_t ERROR_SOCKET_TIME;	// number of seconds between attempts to open a socket an smtp host for address verification
+const time_t  ERROR_SMTP_SOCKET_TIME = 600; // number of seconds between attempts to open a socket to an smtp server
 
 
 int SMTP::writer() {
@@ -293,9 +293,8 @@
 		}
 	pthread_mutex_unlock(&mutex);
 	if (conn) return conn;
-	time_t now = time(NULL);
 	int sock = NULL_SOCKET;
-	if ((now - last_err) > ERROR_SOCKET_TIME) {
+	if ((time(NULL) - last_err) > ERROR_SMTP_SOCKET_TIME) {
 		// nothing recent, maybe this time it will work
 		hostent *h = gethostbyname(host);
 		if (h) {
@@ -310,12 +309,12 @@
 					shutdown(sock, SHUT_RDWR);
 					close(sock);
 					sock = NULL_SOCKET;
-					last_err = now;
+					last_err = time(NULL);
 				}
 			}
-			else last_err = now;
+			else last_err = time(NULL);
 		}
-		else last_err = now;
+		else last_err = time(NULL);
 	}
 	if (sock != NULL_SOCKET) {
 		conn = new SMTP(sock);