changeset 316:f7c5cfb76e86

better smtp verify logging
author Carl Byington <carl@five-ten-sg.com>
date Wed, 21 Sep 2016 16:47:20 -0700
parents 6fbe3c81376b
children a20c59b88049
files ChangeLog NEWS configure.in dnsbl.spec.in src/context.cpp src/includes.h
diffstat 6 files changed, 24 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Sep 19 13:22:53 2016 -0700
+++ b/ChangeLog	Wed Sep 21 16:47:20 2016 -0700
@@ -1,3 +1,6 @@
+6.47 2016-09-21
+    Better smtp verify logging
+
 6.46 2016-09-19
     Enable smtp verify logging
 
--- a/NEWS	Mon Sep 19 13:22:53 2016 -0700
+++ b/NEWS	Wed Sep 21 16:47:20 2016 -0700
@@ -1,3 +1,4 @@
+6.47 2016-09-21 Better smtp verify logging
 6.46 2016-09-19 Enable smtp verify logging
 6.45 2015-04-09 Add bitcoin donation address
 6.44 2014-10-13 Generic regex now matches against the reverse dns PTR value
--- a/configure.in	Mon Sep 19 13:22:53 2016 -0700
+++ b/configure.in	Wed Sep 21 16:47:20 2016 -0700
@@ -1,6 +1,6 @@
 
 AC_PREREQ(2.59)
-AC_INIT(dnsbl,6.46,carl@five-ten-sg.com)
+AC_INIT(dnsbl,6.47,carl@five-ten-sg.com)
 AC_CONFIG_SRCDIR([config.h.in])
 AC_CONFIG_HEADER([config.h])
 AC_CONFIG_MACRO_DIR([m4])
--- a/dnsbl.spec.in	Mon Sep 19 13:22:53 2016 -0700
+++ b/dnsbl.spec.in	Wed Sep 21 16:47:20 2016 -0700
@@ -103,6 +103,9 @@
 
 
 %changelog
+* Wed Sep 21 2016 Carl Byington <carl@five-ten-sg.com> - 6.47-1
+- Better smtp verify logging
+
 * Mon Sep 19 2016 Carl Byington <carl@five-ten-sg.com> - 6.46-1
 - Enable smtp verify logging
 
--- a/src/context.cpp	Mon Sep 19 13:22:53 2016 -0700
+++ b/src/context.cpp	Wed Sep 21 16:47:20 2016 -0700
@@ -92,8 +92,7 @@
 
 int SMTP::writer() {
     #ifdef VERIFY_DEBUG
-        log("writer(%d) sees buffer with %s", buffer);
-        log("writer(%d) sees error %d", (int)error);
+        log("writer(%d) sees buffer with '%s'", buffer);
     #endif
     int rs = 0;
     if (!error) {
@@ -111,6 +110,9 @@
             }
         }
     }
+    #ifdef VERIFY_DEBUG
+        log("writer(%d) sees error %d", (int)error);
+    #endif
     return rs;
 }
 
@@ -138,7 +140,7 @@
     }
     buffer[pending] = '\0';
     #ifdef VERIFY_DEBUG
-        log("reader(%d) sees buffer with %s", buffer);
+        log("reader(%d) sees buffer with '%s'", buffer);
     #endif
     return pending;
 }
@@ -166,16 +168,12 @@
     buffer[pending] = '\0';
     while (true) {
         int r = read_line();
-        #ifdef VERIFY_DEBUG
-            log("read_response(%d) sees line with %s", buffer);
-            log("read_response(%d) sees line length %d", r);
-        #endif
+        log("verify::read_response(%d) sees line with '%s'", buffer);
         if (r == 0) return 0;   // failed to read any bytes
         if ((r > 4) && (buffer[3] == '-')) {
             flush_line(r);
             continue;
         }
-        log("verify::read_response(%d) sees line with %s", buffer);
         return atoi(buffer);
     }
     return 0;
@@ -203,9 +201,8 @@
 
 
 int SMTP::rset() {
-    int rc = cmd("RSET");
     efrom[0] = '\0';
-    return rc;
+    return cmd("RSET");
 }
 
 
@@ -215,7 +212,6 @@
     // except in the case of an empty return path, which was left as the two
     // character string <>.
     if (strncmp(efrom, f, maxlen)) {
-        rset();
         strncpy(efrom, f, maxlen);
         efrom[maxlen-1] = '\0';     // ensure null termination
         init();
@@ -327,7 +323,13 @@
             }
         }
     pthread_mutex_unlock(&mutex);
-    if (conn) return conn;
+    if (conn) {
+        int rc = conn->rset();
+        conn->log("verify::getconnection(%d) rset sees %d", rc);
+        if (rc == 250) return conn;
+        put_connection(conn);
+        return NULL;
+    }
     int sock = NULL_SOCKET;
     if ((time(NULL) - last_err) > ERROR_SMTP_SOCKET_TIME) {
         // nothing recent, maybe this time it will work
@@ -356,6 +358,7 @@
         tv.tv_sec = 15;
         tv.tv_usec = 0;
         setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct timeval));
+        setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(struct timeval));
         conn = new SMTP(sock);
         conn->set_id(queueid);
         #ifdef VERIFY_DEBUG
--- a/src/includes.h	Mon Sep 19 13:22:53 2016 -0700
+++ b/src/includes.h	Wed Sep 21 16:47:20 2016 -0700
@@ -8,7 +8,7 @@
 
 #define VERIFY_DEBUG   1
 #define RESOLVER_DEBUG 1
-//#undef  VERIFY_DEBUG
+#undef  VERIFY_DEBUG
 #undef	RESOLVER_DEBUG
 
 #ifdef HAVE_CONFIG_H