[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: smtp(8) question re hotmail.com



Hello,

I dug into the source code and found my answer (which is "no,
there's no way to configure it").

So I changed the source (smtp.c) a bit so that there's a way to
configure it.  Please check if this patch looks ok or not.  (It
seems to be okay, & it seems that sending keep-alives as often
as 60 seconds once is useless for hotmail.) The patch is against
the CVS version as of 2002-04-20.

Of course this doesn't get to the root of the problem, which
seems to be ZMailer being confused by the unsolicited response;
I don't think I know the internals good enough to figure out
what really should be fixed.

BTW, does anyone know which variable controls how long a
reusable connection is kept alive?


------------- cut here ------------- 8< ----------------------
--- transports/smtp/smtp.c.dist	Fri Apr 19 19:26:38 2002
+++ transports/smtp/smtp.c	Wed May  8 11:59:35 2002
@@ -22,6 +22,7 @@
 int timeout_tcpw =  5*60;	/* All tcp writes ?? */
 int timeout_dot  = 20*60;
 int timeout_conn =  3*60;	/* connect() timeout */
+int timeout_noop =  3*60;	/* Another 'keepalive' in 3 minutes */
 
 int sockwbufsize =  0;
 
@@ -61,6 +62,7 @@
 				   "nobody", in which case use "daemon"      */
 
 int D_alloc = 0;		/* Memory usage debug */
+int always_close_after_data = 0;	/* In case the remote system doesn't like keepalives */
 int no_pipelining = 0;		/* In case the system just doesn't cope with it */
 #if defined(AF_INET6) && defined(INET6)
 int use_ipv6 = 1;
@@ -167,7 +169,7 @@
 	time(&now);
 
 	
-	tmout = now + 3*60;
+	tmout = now + timeout_noop;
 
 
 	s = *bufp;
@@ -235,7 +237,7 @@
 	    }
 	  }
 	  if (now >= tmout)
-	    tmout = now + 3*60; /* Another 'keepalive' in 3 minutes */
+	    tmout = now + timeout_noop; /* Another 'keepalive' in 3 minutes or whatever -t noop=# says */
 
 	  if (rc == 1) { /* We have only ONE descriptor readable.. */
 	    /* Got something to read on 'infd' (or EOF)
@@ -472,7 +474,7 @@
 	SS.remotemsg[0] = '\0';
 	SS.remotehost[0] = '\0';
 	while (1) {
-	  c = getopt(argc, argv, "c:deh:l:p:rsvw:xDEF:L:HMPS:T:VWZ:678");
+	  c = getopt(argc, argv, "c:deh:l:p:rsvw:xDEF:L:HKMPS:T:VWZ:678");
 	  if (c == EOF)
 	    break;
 	  switch (c) {
@@ -528,6 +530,10 @@
 	  case 'H':
 	    keep_header8 = 1;
 	    break;
+	  case 'K':		/* close the connection after sending */
+	    always_close_after_data = 1;
+	    close_after_data = 1;	/* actual flag used by delivery code */
+	    break;
 	  case 'L':		/* Specify which local identity to use */
 	    localidentity = strdup(optarg);
 	    break;
@@ -559,6 +565,14 @@
 		++errflg;
 	      }
 	      break;
+	    } else if (CISTREQN(optarg,"noop=",5)) {
+	      timeout_noop = parse_interval(optarg+5,NULL);
+	      if (timeout_noop < 10) {
+		fprintf(stderr, "%s: bad noop (send-keep-alive) timeout: %s\n",
+			argv[0], optarg+5);
+		++errflg;
+	      }
+	      break;
 	    } else if (CISTREQN(optarg,"tcpw=",5)) {
 	      timeout_tcpw = parse_interval(optarg+5,NULL);
 	      if (timeout_tcpw < 10) {
@@ -625,7 +639,7 @@
 
 	if (errflg || optind > argc) {
 	  fprintf(stderr,
-		  "Usage: %s [-8|-8H|-7][-e][-r][-x][-E][-P][-W][-T timeout][-h myhostname][-l logfile][-p portnum][-c channel][-F forcedest][-L localidentity][-S /path/to/SmtpSSL.conf] [host]\n", argv[0]);
+		  "Usage: %s [-8|-8H|-7][-e][-r][-x][-E][-K][-P][-W][-T timeout][-h myhostname][-l logfile][-p portnum][-c channel][-F forcedest][-L localidentity][-S /path/to/SmtpSSL.conf] [host]\n", argv[0]);
 	  exit(EX_USAGE);
 	}
 
@@ -783,7 +797,7 @@
 		if (statusreport)
 		  report(&SS, "NewDomain: %s", host);
 	      }
-	      close_after_data = 0;
+	      close_after_data = always_close_after_data;
 	    }
 	    if (host) free((void*)host);
 	    host = strdup(s);
@@ -1879,7 +1893,7 @@
 	  smtpwrite(SS, 0, "QUIT", -1, NULL);
 	  smtpclose(SS,1);
 	  if (logfp)
-	    fprintf(logfp, "%s#\t(closed SMTP channel - ``close_after_data'' mode.", logtag());
+	    fprintf(logfp, "%s#\t(closed SMTP channel - ``close_after_data'' mode.)\n", logtag());
 	  retryat_time = 0;
 	}
 
--- man/smtp.8.dist	Mon Dec 10 17:35:27 2001
+++ man/smtp.8	Wed May  8 11:26:03 2002
@@ -7,7 +7,7 @@
 \- zmailer SMTP client transport agent
 .SH SYNOPSIS
 .IP \fBsmtp\fR 5em
-[\fB\-678deEHMrPsVxW\fR]
+[\fB\-678deEHKMrPsVxW\fR]
 [\fB\-c\fR\ \fIchannel\fR]
 [\fB\-h\fR\ \fIheloname\fR]
 [\fB\-l\fR\ \fIlogfile\fR]
@@ -130,6 +130,9 @@
 turns off MX lookups on delivery connections.  This may be used ignore
 public MX knowledge and do exactly what the router says in cases where
 delivering to an explicit IP address is inappropriate.
+.IP \-K
+force \(lqclose_after_data\(rq mode:
+disable keep-alives; do not reuse SMTP connections
 .IP \-P
 disable SMTP-PIPELINING usage (ESMTP keyword: PIPELINING)
 .IP \-S\ \fI/path/to/smtp-tls.conf\fR
@@ -157,12 +160,15 @@
 Waiting for command replies (e.g. MAIL FROM, et.al.)
 The default is 5 minutes.
 .IP data=\fI2m\fR
-From "DATA" verb issuance until "354" responce.
+From "DATA" verb issuance until "354" response.
 The default is 2 minutes.
 .IP dot=\fI10m\fR
 From "DATA" phase ending "." issuance until "250 OK" report
 reception (this is \fBafter\fR the TCP write pipeline has completed).
 The default is 20 minutes. (RFC 1123 gives 10 minutes.)
+.IP noop=\fI3m\fR
+Time between keep-alives (NOOP).
+The default is 3 minutes.
 .RE
 .IP \-V
 prints a version message and exits.
------------- cut here ------------- 8< ----------------------

[The patch contains two unrelated typo corrections.)

-- 
Ambrose Li

``A good style should show no sign of effort;
  what is written should seem a happy accident.'' ~ Somerset Maugham
-
To unsubscribe from this list: send the line "unsubscribe zmailer" in
the body of a message to majordomo@nic.funet.fi