aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory Neil Shapiro <gshapiro@FreeBSD.org>2005-02-14 03:04:18 +0000
committerGregory Neil Shapiro <gshapiro@FreeBSD.org>2005-02-14 03:04:18 +0000
commit27bec48138ffa668d5c5d3b1e87f82e533befb5c (patch)
tree0d1e1e48f37b259b3d84394eb3ccc2ba9f5ee2cc
parentb37a166a402ac326a03b91fa7302ad3db6e29b3b (diff)
downloadsrc-27bec48138ffa668d5c5d3b1e87f82e533befb5c.tar.gz
src-27bec48138ffa668d5c5d3b1e87f82e533befb5c.zip
Commit patch from sendmail.org web site for socket close bug:
http://www.sendmail.org/patches/close_wait.p2 This is being put in the vendor branch as it is in the vendor's repo.
Notes
Notes: svn path=/vendor/sendmail/dist/; revision=141867
-rw-r--r--contrib/sendmail/src/mci.c51
-rw-r--r--contrib/sendmail/src/sendmail.h1
-rw-r--r--contrib/sendmail/src/usersmtp.c8
3 files changed, 58 insertions, 2 deletions
diff --git a/contrib/sendmail/src/mci.c b/contrib/sendmail/src/mci.c
index 4955197a6ebb..4ff75780bfbc 100644
--- a/contrib/sendmail/src/mci.c
+++ b/contrib/sendmail/src/mci.c
@@ -398,6 +398,57 @@ mci_get(host, m)
return mci;
}
+
+/*
+** MCI_CLOSE -- (forcefully) close files used for a connection.
+** Note: this is a last resort, usually smtpquit() or endmailer()
+** should be used to close a connection.
+**
+** Parameters:
+** mci -- the connection to close.
+** where -- where has this been called?
+**
+** Returns:
+** none.
+*/
+
+void
+mci_close(mci, where)
+ MCI *mci;
+ char *where;
+{
+ bool dumped;
+
+ if (mci == NULL)
+ return;
+ dumped = false;
+ if (mci->mci_out != NULL)
+ {
+ if (tTd(56, 1))
+ {
+ sm_dprintf("mci_close: mci_out!=NULL, where=%s\n",
+ where);
+ mci_dump(sm_debug_file(), mci, false);
+ dumped = true;
+ }
+ (void) sm_io_close(mci->mci_out, SM_TIME_DEFAULT);
+ mci->mci_out = NULL;
+ }
+ if (mci->mci_in != NULL)
+ {
+ if (tTd(56, 1))
+ {
+ sm_dprintf("mci_close: mci_in!=NULL, where=%s\n",
+ where);
+ if (!dumped)
+ mci_dump(sm_debug_file(), mci, false);
+ }
+ (void) sm_io_close(mci->mci_in, SM_TIME_DEFAULT);
+ mci->mci_in = NULL;
+ }
+ mci->mci_state = MCIS_CLOSED;
+}
+
/*
** MCI_NEW -- allocate new MCI structure
**
diff --git a/contrib/sendmail/src/sendmail.h b/contrib/sendmail/src/sendmail.h
index 673cee5cf073..370fae856b89 100644
--- a/contrib/sendmail/src/sendmail.h
+++ b/contrib/sendmail/src/sendmail.h
@@ -728,6 +728,7 @@ MCI
/* functions */
extern void mci_cache __P((MCI *));
+extern void mci_close __P((MCI *, char *where));
extern void mci_dump __P((SM_FILE_T *, MCI *, bool));
extern void mci_dump_all __P((SM_FILE_T *, bool));
extern void mci_flush __P((bool, MCI *));
diff --git a/contrib/sendmail/src/usersmtp.c b/contrib/sendmail/src/usersmtp.c
index 0bcbcf51bbf1..24b09549a12a 100644
--- a/contrib/sendmail/src/usersmtp.c
+++ b/contrib/sendmail/src/usersmtp.c
@@ -89,6 +89,7 @@ smtpinit(m, mci, e, onlyhelo)
*/
SmtpError[0] = '\0';
+ SmtpMsgBuffer[0] = '\0';
CurHostName = mci->mci_host; /* XXX UGLY XXX */
if (CurHostName == NULL)
CurHostName = MyHostName;
@@ -2899,7 +2900,10 @@ smtpquit(m, mci, e)
char *oldcurhost;
if (mci->mci_state == MCIS_CLOSED)
+ {
+ mci_close(mci, "smtpquit:1");
return;
+ }
oldcurhost = CurHostName;
CurHostName = mci->mci_host; /* XXX UGLY XXX */
@@ -3133,7 +3137,7 @@ reply(m, mci, e, timeout, pfunc, enhstat, rtype)
if (strncmp(SmtpMsgBuffer, "QUIT", 4) == 0)
{
errno = mci->mci_errno;
- mci->mci_state = MCIS_CLOSED;
+ mci_close(mci, "reply:1");
return -1;
}
mci->mci_state = MCIS_ERROR;
@@ -3158,7 +3162,7 @@ reply(m, mci, e, timeout, pfunc, enhstat, rtype)
/* errors on QUIT should be ignored */
if (strncmp(SmtpMsgBuffer, "QUIT", 4) == 0)
{
- mci->mci_state = MCIS_CLOSED;
+ mci_close(mci, "reply:2");
return -1;
}