Message-ID: <wgKo1lW00WBw46OU8k@andrew.cmu.edu>
Date: Sun, 1 Aug 1993 00:02:57 -0400 (EDT)
From: John Gardiner Myers <jgm+@CMU.EDU>
To: sendmail@cs.berkeley.edu
Subject: contrib/rcpt-streaming
This patch implements "RCPT streaming" in sendmail version 8. This
patch is not an official part of sendmail. Please report all problems
with this patch to jgm+@cmu.edu.
RCPT streming avoids network round trips by sending all RCPT commands
for a single SMTP transaction together. Sendmail then waits for all
the replies, matching them up with the apropriate addresses.
Apply to the sendmail src directory (your line numbers may vary) and
compile with -DRCPTSTREAM
diff -cr ./src/deliver.c /afs/andrew.cmu.edu/system/src/local/../host/oldsmail/016/src/deliver.c
*** ./src/deliver.c Thu Jul 22 14:28:19 1993
--- /afs/andrew.cmu.edu/system/src/local/../host/oldsmail/016/src/deliver.c Fri Jul 30 21:11:16 1993
/* send the recipient list */
+ /***********************************************************************
+ * RCPT streaming code by John G Myers, jgm+@cmu.edu
+ * This is not supported by the maintainer of sendmail.
+ * Report all bugs concerning RCPT streaming to jgm+@cmu.edu
+ ***********************************************************************
+ for (to = tochain; to != NULL; to = to->q_tchain)
+ smtpstreammessage("RCPT To:<%s>", m, mci,
for (to = tochain; to != NULL; to = to->q_tchain)
diff -cr ./src/usersmtp.c /afs/andrew.cmu.edu/system/src/local/../host/oldsmail/016/src/usersmtp.c
*** ./src/usersmtp.c Mon Jul 19 23:50:43 1993
--- /afs/andrew.cmu.edu/system/src/local/../host/oldsmail/016/src/usersmtp.c Fri Jul 30 21:12:00 1993
+ /***********************************************************************
+ * RCPT streaming code by John G Myers, jgm+@cmu.edu
+ * This is not supported by the maintainer of sendmail.
+ * Report all bugs concerning RCPT streaming to jgm+@cmu.edu
+ ***********************************************************************
+ # include <sys/types.h>
char SmtpError[MAXLINE] = ""; /* save failure error messages */
int SmtpPid; /* pid of mailer */
+ char *SmtpStreamBuf; /* buffer for streaming output */
+ int SmtpStreamBufSize = 0; /* allocated size of buffer */
+ char *SmtpStreamStart; /* pointer to text not yet written */
+ int SmtpStreamLen = 0; /* # chars not yet written */
extern smtpmessage(char *f, MAILER *m, MCI *mci, ...);
+ sprintf(SmtpMsgBuffer, "RCPT To:<%s>", to->q_user);
smtpmessage("RCPT To:<%s>", m, mci, to->q_user);
SmtpPhase = mci->mci_phase = "client RCPT";
setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase);
+ extern char MsgBuf[]; /* err.c */
if (mci->mci_out != NULL)
(void) fflush(mci->mci_out);
+ if (SmtpStreamLen > 0) {
+ outfd = fileno(mci->mci_out);
+ r = write(outfd, SmtpStreamStart, SmtpStreamLen);
+ nonblock(outfd, FALSE);
+ if (r == -1 && errno != EAGAIN
+ && errno != EWOULDBLOCK
+ mci->mci_errno = errno;
+ message("451 streamreply: write error to %s",
+ /* if debugging, pause so we can see state */
+ syslog(LOG_INFO, "%s", &MsgBuf[4]);
+ /* stop trying to write output */
+ #endif /* RCPTSTREAM */
/* actually do the read */
(void) fflush(e->e_xfp); /* for debugging */
+ ** SMTPSTREAMMESSAGE -- buffer message to be streamed to server
+ ** m -- the mailer to control formatting.
+ ** a, b, c -- parameters
+ ** stores message in SmtpStreamBuf
+ smtpstreammessage(char *f, MAILER *m, MCI *mci, ...)
+ smtpstreammessage(f, m, mci, va_alist)
+ (void) vsprintf(SmtpMsgBuffer, f, ap);
+ if (tTd(18, 1) || Verbose)
+ nmessage(">>> %s", SmtpMsgBuffer);
+ if (TrafficLogFile != NULL)
+ fprintf(TrafficLogFile, "%05d >>> %s\n", getpid(), SmtpMsgBuffer);
+ if (mci->mci_out == NULL) {
+ if (tTd(18, 1)) printf("smtpstreammessage: NULL mci_out\n");
+ strcat(SmtpMsgBuffer, m == NULL ? "\r\n" : m->m_eol);
+ len = strlen(SmtpMsgBuffer);
+ if (SmtpStreamLen == 0) {
+ if (SmtpStreamBufSize == 0) {
+ SmtpStreamBufSize = MAXLINE;
+ SmtpStreamBuf = xalloc(SmtpStreamBufSize);
+ SmtpStreamStart = SmtpStreamBuf;
+ if (SmtpStreamBufSize - SmtpStreamLen < len + 1) {
+ int start = SmtpStreamStart - SmtpStreamBuf;
+ SmtpStreamBufSize += MAXLINE;
+ SmtpStreamBuf = realloc(SmtpStreamBuf, SmtpStreamBufSize);
+ syserr("Out of memory!!");
+ /* exit(EX_UNAVAILABLE); */
+ SmtpStreamStart = SmtpStreamBuf + start;
+ strcpy(SmtpStreamBuf + SmtpStreamLen, SmtpMsgBuffer);
+ #endif /* RCPTSTREAM */
** SMTPMESSAGE -- send message to server
Only in /afs/andrew.cmu.edu/system/src/local/../host/oldsmail/016/src: usersmtp.c~
diff -cr ./src/util.c /afs/andrew.cmu.edu/system/src/local/../host/oldsmail/016/src/util.c
*** ./src/util.c Mon Jul 19 23:50:45 1993
--- /afs/andrew.cmu.edu/system/src/local/../host/oldsmail/016/src/util.c Mon Jul 26 17:17:10 1993
+ /***********************************************************************
+ * RCPT streaming code by John G Myers, jgm+@cmu.edu
+ * This is not supported by the maintainer of sendmail.
+ * Report all bugs concerning RCPT streaming to jgm+@cmu.edu
+ ***********************************************************************
+ ** NONBLOCK -- set or clear non-blocking mode on file descriptor
+ ** fd -- the file descriptor
+ ** mode -- TRUE to set non-blocking mode
+ ** FALSE to clear non-blocking mode
+ ** modifies nonblocking status of fd
+ flags = fcntl(fd, F_GETFL, 0);
+ fcntl(fd, F_SETFL, flags);
** STRCONTAINEDIN -- tell if one string is contained in another