summaryrefslogtreecommitdiff
path: root/debian/patches/8.13/8.13.3/close_wait.p2
blob: 247fada76bd05fc431b711dc7c5160ba24c55dfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
--- mci.c.orig	Wed Aug  4 14:11:31 2004
+++ ./sendmail-8.13.3/sendmail/mci.c	Mon Jan 17 10:29:28 2005
@@ -398,6 +398,57 @@
 
 	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
 **
--- sendmail.h.orig	Tue Nov  9 11:45:46 2004
+++ ./sendmail-8.13.3/sendmail/sendmail.h	Mon Jan 17 09:39:56 2005
@@ -728,6 +728,7 @@
 
 /* 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 *));
--- usersmtp.c.orig	Fri Jan 14 07:34:00 2005
+++ ./sendmail-8.13.3/sendmail/usersmtp.c	Mon Jan 17 09:40:57 2005
@@ -89,6 +89,7 @@
 	*/
 
 	SmtpError[0] = '\0';
+	SmtpMsgBuffer[0] = '\0';
 	CurHostName = mci->mci_host;		/* XXX UGLY XXX */
 	if (CurHostName == NULL)
 		CurHostName = MyHostName;
@@ -2899,7 +2900,10 @@
 	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 @@
 			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 @@
 			/* errors on QUIT should be ignored */
 			if (strncmp(SmtpMsgBuffer, "QUIT", 4) == 0)
 			{
-				mci->mci_state = MCIS_CLOSED;
+				mci_close(mci, "reply:2");
 				return -1;
 			}