Fix callouts connection fallback from TLS to cleartext. Bug 1897
[exim.git] / src / src / transports / smtp.c
index e8a675750dced17ec8e867bf73c410d55e5d04a7..f506a75d65eb94736f5b5e755180b82a9cfb4b93 100644 (file)
@@ -1574,7 +1574,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
@@ -1949,12 +1948,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;
@@ -3163,6 +3159,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