comparison src/context.cpp @ 318:e2dc882839f6 stable-6-0-47

better smtp verify logging
author Carl Byington <carl@five-ten-sg.com>
date Thu, 22 Sep 2016 08:43:02 -0700
parents f7c5cfb76e86
children e27c24c1974a
comparison
equal deleted inserted replaced
317:a20c59b88049 318:e2dc882839f6
314 conn = NULL; 314 conn = NULL;
315 } 315 }
316 else { 316 else {
317 conn->set_id(queueid); 317 conn->set_id(queueid);
318 connections.pop_front(); 318 connections.pop_front();
319 #ifdef VERIFY_DEBUG 319 conn->log("verify::get_connection(%d) from cache %s", "");
320 conn->log("verify::get_connection(%d) from cache %s", "");
321 #endif
322 break; 320 break;
323 } 321 }
324 } 322 }
325 pthread_mutex_unlock(&mutex); 323 pthread_mutex_unlock(&mutex);
326 if (conn) { 324 if (conn) {
327 int rc = conn->rset(); 325 int rc = conn->rset();
328 conn->log("verify::getconnection(%d) rset sees %d", rc); 326 conn->log("verify::getconnection(%d) rset sees %d", rc);
329 if (rc == 250) return conn; 327 if (rc == 250) return conn;
330 put_connection(conn); 328 delete conn;
331 return NULL; 329 // old connection from cache was unusable, fall thru and make a new one
332 } 330 }
333 int sock = NULL_SOCKET; 331 int sock = NULL_SOCKET;
334 if ((time(NULL) - last_err) > ERROR_SMTP_SOCKET_TIME) { 332 if ((time(NULL) - last_err) > ERROR_SMTP_SOCKET_TIME) {
335 // nothing recent, maybe this time it will work 333 // nothing recent, maybe this time it will work
336 hostent *h = gethostbyname(host); 334 hostent *h = gethostbyname(host);
359 tv.tv_usec = 0; 357 tv.tv_usec = 0;
360 setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct timeval)); 358 setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct timeval));
361 setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(struct timeval)); 359 setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(struct timeval));
362 conn = new SMTP(sock); 360 conn = new SMTP(sock);
363 conn->set_id(queueid); 361 conn->set_id(queueid);
364 #ifdef VERIFY_DEBUG 362 conn->log("get_connection(%d) new socket %s", "");
365 conn->log("get_connection(%d) new socket %s", "");
366 #endif
367 int rc = conn->helo(); 363 int rc = conn->helo();
368 conn->log("verify::get_connection(%d) helo sees %d", rc); 364 conn->log("verify::get_connection(%d) helo sees %d", rc);
369 if (rc == 250) return conn; 365 if (rc == 250) return conn;
370 delete conn; 366 delete conn;
371 } 367 }