(Message /home/auspex/a/staff/eric/.mh/inbox:2575)
From: John Gardiner Myers <jgm+@cmu.edu>
Subject: contrib/rcpt-streaming
Date: Fri, 4 Jun 1993 13:54:06 -0400 (EDT)
To: sendmail@cs.berkeley.edu
This patch implements "RCPT streaming" in sendmail version 6. 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.orig/deliver.c src/deliver.c
*** src.orig/deliver.c Thu May 27 14:38:22 1993
--- src/deliver.c Fri Jun 4 13:50:02 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.orig/usersmtp.c src/usersmtp.c
*** src.orig/usersmtp.c Thu May 27 14:38:09 1993
--- src/usersmtp.c Fri Jun 4 13:48:24 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, ...);
smtpmessage("RCPT To:<%s>", m, mci, to->q_user);
SmtpPhase = mci->mci_phase = "RCPT wait";
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 (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 src: usersmtp.c.orig
diff -cr src.orig/util.c src/util.c
*** src.orig/util.c Thu May 27 14:38:20 1993
--- src/util.c Wed Jun 2 16:39:15 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