Mercurial > dnsbl
diff src/context.cpp @ 316:f7c5cfb76e86
better smtp verify logging
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 21 Sep 2016 16:47:20 -0700 |
parents | ef5a6099cbe7 |
children | e2dc882839f6 |
line wrap: on
line diff
--- 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