tidying
[exim.git] / src / src / transports / smtp.c
index e8a675750dced17ec8e867bf73c410d55e5d04a7..278349b4a419460f3a5c01af2c7ffb98b8f88ab0 100644 (file)
@@ -286,6 +286,7 @@ static uschar *smtp_command;   /* Points to last cmd for error messages */
 static uschar *mail_command;   /* Points to MAIL cmd for error messages */
 static BOOL    update_waiting; /* TRUE to update the "wait" database */
 static BOOL    pipelining_active; /* current transaction is in pipe mode */
+static int     off = 0;       /* for use by setsockopt */
 
 
 /*************************************************
@@ -1574,10 +1575,6 @@ lflags.send_quit = TRUE;
 lflags.setting_up = TRUE;
 lflags.esmtp = TRUE;
 lflags.esmtp_sent = FALSE;
-lflags.pending_MAIL;
-#ifndef DISABLE_PRDR
-lflags.prdr_active;
-#endif
 #ifdef SUPPORT_I18N
 lflags.utf8_needed = FALSE;
 #endif
@@ -1589,6 +1586,7 @@ lflags.dane_required = verify_check_given_host(&ob->hosts_require_dane, host) ==
 
 *message_defer = FALSE;
 smtp_command = US"initial connection";
+buffer[0] = '\0';
 if (max_rcpt == 0) max_rcpt = 999999;
 
 /* Set up the buffer for reading SMTP response packets. */
@@ -1709,7 +1707,12 @@ if (continue_hostname == NULL)
 
   if (!lflags.smtps)
     {
-    BOOL good_response = smtp_read_response(&inblock, buffer, sizeof(buffer),
+    BOOL good_response;
+
+#ifdef TCP_QUICKACK
+    (void) setsockopt(inblock.sock, IPPROTO_TCP, TCP_QUICKACK, US &off, sizeof(off));
+#endif
+    good_response = smtp_read_response(&inblock, buffer, sizeof(buffer),
       '2', ob->command_timeout);
 #ifdef EXPERIMENTAL_DSN_INFO
     smtp_greeting = string_copy(buffer);
@@ -1736,7 +1739,7 @@ if (continue_hostname == NULL)
     /* Now check if the helo_data expansion went well, and sign off cleanly if
     it didn't. */
 
-    if (helo_data == NULL)
+    if (!helo_data)
       {
       uschar *message = string_sprintf("failed to expand helo_data: %s",
         expand_string_message);
@@ -1949,12 +1952,9 @@ if (  smtp_peer_options & PEER_OFFERED_TLS
     if (rc != OK)
       {
 # ifdef EXPERIMENTAL_DANE
-      if (rc == DEFER && lflags.dane)
-       {
-       log_write(0, LOG_MAIN,
+      if (lflags.dane) log_write(0, LOG_MAIN,
          "DANE attempt failed; no TLS connection to %s [%s]",
          host->name, host->address);
-       }
 # endif
 
       save_errno = ERRNO_TLSFAILURE;
@@ -2172,10 +2172,10 @@ set it up. This cannot be done until the identify of the host is known. */
 if (tblock->filter_command != NULL)
   {
   BOOL rc;
-  uschar buffer[64];
-  sprintf(CS buffer, "%.50s transport", tblock->name);
+  uschar fbuf[64];
+  sprintf(CS fbuf, "%.50s transport", tblock->name);
   rc = transport_set_up_command(&transport_filter_argv, tblock->filter_command,
-    TRUE, DEFER, addrlist, buffer, NULL);
+    TRUE, DEFER, addrlist, fbuf, NULL);
   transport_filter_timeout = tblock->filter_timeout;
 
   /* On failure, copy the error to all addresses, abandon the SMTP call, and
@@ -3163,6 +3163,12 @@ specified in the transports, and therefore not visible at top level, in which
 case continue_more won't get set. */
 
 HDEBUG(D_transport|D_acl|D_v) debug_printf("  SMTP(close)>>\n");
+if (lflags.send_quit)
+  {
+  shutdown(outblock.sock, SHUT_WR);
+  for (rc = 16; read(inblock.sock, inbuffer, sizeof(inbuffer)) > 0 && rc > 0;)
+    rc--;                              /* drain socket */
+  }
 (void)close(inblock.sock);
 
 #ifndef DISABLE_EVENT