summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/libmilter
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/sendmail/libmilter')
-rw-r--r--contrib/sendmail/libmilter/Makefile.m42
-rw-r--r--contrib/sendmail/libmilter/comm.c17
-rw-r--r--contrib/sendmail/libmilter/docs/api.html8
-rw-r--r--contrib/sendmail/libmilter/docs/overview.html6
-rw-r--r--contrib/sendmail/libmilter/docs/smfi_addheader.html10
-rw-r--r--contrib/sendmail/libmilter/docs/smfi_chgheader.html9
-rw-r--r--contrib/sendmail/libmilter/docs/smfi_insheader.html9
-rw-r--r--contrib/sendmail/libmilter/engine.c143
-rw-r--r--contrib/sendmail/libmilter/example.c4
-rw-r--r--contrib/sendmail/libmilter/handler.c21
-rw-r--r--contrib/sendmail/libmilter/libmilter.h3
-rw-r--r--contrib/sendmail/libmilter/listener.c7
-rw-r--r--contrib/sendmail/libmilter/main.c2
-rw-r--r--contrib/sendmail/libmilter/worker.c47
14 files changed, 205 insertions, 83 deletions
diff --git a/contrib/sendmail/libmilter/Makefile.m4 b/contrib/sendmail/libmilter/Makefile.m4
index 929ec75..bc9bc66 100644
--- a/contrib/sendmail/libmilter/Makefile.m4
+++ b/contrib/sendmail/libmilter/Makefile.m4
@@ -1,4 +1,4 @@
-dnl $Id: Makefile.m4,v 8.80 2008/04/08 05:23:44 ca Exp $
+dnl $Id: Makefile.m4,v 8.85 2009/11/24 21:59:33 ca Exp $
include(confBUILDTOOLSDIR`/M4/switch.m4')
dnl only required for compilation of EXTRAS
diff --git a/contrib/sendmail/libmilter/comm.c b/contrib/sendmail/libmilter/comm.c
index a7a44df..e04681c 100644
--- a/contrib/sendmail/libmilter/comm.c
+++ b/contrib/sendmail/libmilter/comm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2004 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1999-2004, 2009 Sendmail, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
@@ -9,7 +9,7 @@
*/
#include <sm/gen.h>
-SM_RCSID("@(#)$Id: comm.c,v 8.67 2006/11/02 17:54:44 ca Exp $")
+SM_RCSID("@(#)$Id: comm.c,v 8.70 2009/12/16 16:33:48 ca Exp $")
#include "libmilter.h"
#include <sm/errstring.h>
@@ -18,7 +18,6 @@ SM_RCSID("@(#)$Id: comm.c,v 8.67 2006/11/02 17:54:44 ca Exp $")
static ssize_t retry_writev __P((socket_t, struct iovec *, int, struct timeval *));
static size_t Maxdatasize = MILTER_MAX_DATA_SIZE;
-#if _FFR_MAXDATASIZE
/*
** SMFI_SETMAXDATASIZE -- set limit for milter data read/write.
**
@@ -39,7 +38,6 @@ smfi_setmaxdatasize(sz)
Maxdatasize = sz;
return old;
}
-#endif /* _FFR_MAXDATASIZE */
/*
** MI_RD_CMD -- read a command
@@ -122,8 +120,8 @@ mi_rd_cmd(sd, timeout, cmd, rlen, name)
else if (ret < 0)
{
smi_log(SMI_LOG_ERR,
- "%s: mi_rd_cmd: select returned %d: %s",
- name, ret, sm_errstring(errno));
+ "%s: mi_rd_cmd: %s() returned %d: %s",
+ name, MI_POLLSELECT, ret, sm_errstring(errno));
*cmd = SMFIC_RECVERR;
return NULL;
}
@@ -214,8 +212,8 @@ mi_rd_cmd(sd, timeout, cmd, rlen, name)
if (ret < 0)
{
smi_log(SMI_LOG_ERR,
- "%s: mi_rd_cmd: select returned %d: %s",
- name, ret, sm_errstring(save_errno));
+ "%s: mi_rd_cmd: %s() returned %d: %s",
+ name, MI_POLLSELECT, ret, sm_errstring(save_errno));
*cmd = SMFIC_RECVERR;
return NULL;
}
@@ -326,7 +324,7 @@ mi_wr_cmd(sd, timeout, cmd, buf, len)
char *buf;
size_t len;
{
- size_t sl, i;
+ size_t sl;
ssize_t l;
mi_int32 nl;
int iovcnt;
@@ -339,7 +337,6 @@ mi_wr_cmd(sd, timeout, cmd, buf, len)
nl = htonl(len + 1); /* add 1 for the cmd char */
(void) memcpy(data, (void *) &nl, MILTER_LEN_BYTES);
data[MILTER_LEN_BYTES] = (char) cmd;
- i = 0;
sl = MILTER_LEN_BYTES + 1;
/* set up the vector for the size / command */
diff --git a/contrib/sendmail/libmilter/docs/api.html b/contrib/sendmail/libmilter/docs/api.html
index 4214df4..578e0ca 100644
--- a/contrib/sendmail/libmilter/docs/api.html
+++ b/contrib/sendmail/libmilter/docs/api.html
@@ -2,7 +2,7 @@
<HEAD><TITLE>Milter API</TITLE></HEAD>
<BODY>
<!--
-$Id: api.html,v 1.35 2006/11/30 23:09:23 ca Exp $
+$Id: api.html,v 1.37 2009/05/19 00:40:52 ca Exp $
-->
<H1>Milter API</H1>
@@ -80,7 +80,9 @@ The following functions change a message's contents and attributes.
<EM>They may only be called in <A HREF="xxfi_eom.html">xxfi_eom</A></EM>.
All of these functions may invoke additional communication with the MTA.
They will return either MI_SUCCESS or MI_FAILURE to indicate the status of
-the operation.
+the operation. Message data (senders, recipients, headers, body chunks)
+passed to these functions via parameters is copied and does not need to be
+preserved (i.e., allocated memory can be freed).
<P>
A filter must have set the appropriate flag (listed below) in the
@@ -310,7 +312,7 @@ for a protocol stage.
<HR SIZE="1">
<FONT SIZE="-1">
-Copyright (c) 2000, 2003, 2006 Sendmail, Inc. and its suppliers.
+Copyright (c) 2000, 2003, 2006, 2009 Sendmail, Inc. and its suppliers.
All rights reserved.
<BR>
By using this file, you agree to the terms and conditions set
diff --git a/contrib/sendmail/libmilter/docs/overview.html b/contrib/sendmail/libmilter/docs/overview.html
index b7e80df..5c6f21c 100644
--- a/contrib/sendmail/libmilter/docs/overview.html
+++ b/contrib/sendmail/libmilter/docs/overview.html
@@ -4,7 +4,7 @@
</HEAD>
<BODY>
<!--
-$Id: overview.html,v 1.19 2006/12/21 18:23:47 ca Exp $
+$Id: overview.html,v 1.20 2009/11/13 18:15:05 ca Exp $
-->
<H1>Technical Overview</H1>
@@ -60,7 +60,9 @@ returns to <CODE>MESSAGE</CODE>.
For each of N connections
{
For each filter
- process connection/helo (<A HREF="xxfi_connect.html">xxfi_connect</A>, <A HREF="xxfi_helo.html">xxfi_helo</A>)
+ process connection (<A HREF="xxfi_connect.html">xxfi_connect</A>)
+ For each filter
+ process helo/ehlo (<A HREF="xxfi_helo.html">xxfi_helo</A>)
MESSAGE:For each message in this connection (sequentially)
{
For each filter
diff --git a/contrib/sendmail/libmilter/docs/smfi_addheader.html b/contrib/sendmail/libmilter/docs/smfi_addheader.html
index d068f9f..460b4ca 100644
--- a/contrib/sendmail/libmilter/docs/smfi_addheader.html
+++ b/contrib/sendmail/libmilter/docs/smfi_addheader.html
@@ -2,7 +2,7 @@
<HEAD><TITLE>smfi_addheader</TITLE></HEAD>
<BODY>
<!--
-$Id: smfi_addheader.html,v 1.19 2006/12/21 18:30:35 ca Exp $
+$Id: smfi_addheader.html,v 1.20 2009/05/18 23:51:23 ca Exp $
-->
<H1>smfi_addheader</H1>
@@ -90,7 +90,11 @@ To change a header's current value, use
the MTA will add this automatically.
<B>It is the filter writer's responsibility to ensure that no standards
are violated.</B>
- <LI>The MTA adds a leading space to an added header value.
+ <LI>The MTA adds a leading space to an added header value unless
+ the flag
+<A HREF="xxfi_negotiate.html#SMFIP_HDR_LEADSPC"><CODE>SMFIP_HDR_LEADSPC</CODE></A>
+ is set, in which case the milter
+ must include any desired leading spaces itself.
</UL>
</TD>
</TR>
@@ -116,7 +120,7 @@ To change a header's current value, use
<HR size="1">
<FONT size="-1">
-Copyright (c) 2000-2003, 2006 Sendmail, Inc. and its suppliers.
+Copyright (c) 2000-2003, 2006, 2009 Sendmail, Inc. and its suppliers.
All rights reserved.
<BR>
By using this file, you agree to the terms and conditions set
diff --git a/contrib/sendmail/libmilter/docs/smfi_chgheader.html b/contrib/sendmail/libmilter/docs/smfi_chgheader.html
index 0701a36..517b5ba 100644
--- a/contrib/sendmail/libmilter/docs/smfi_chgheader.html
+++ b/contrib/sendmail/libmilter/docs/smfi_chgheader.html
@@ -2,7 +2,7 @@
<HEAD><TITLE>smfi_chgheader</TITLE></HEAD>
<BODY>
<!--
-$Id: smfi_chgheader.html,v 1.17 2006/12/21 18:30:35 ca Exp $
+$Id: smfi_chgheader.html,v 1.18 2009/05/18 23:51:23 ca Exp $
-->
<H1>smfi_chgheader</H1>
@@ -85,6 +85,11 @@ Otherwise, it returns MI_SUCCESS.
carriage return (ASCII 0x0d); the MTA will add this automatically.
<B>It is the filter writer's responsibility to ensure that no standards
are violated.</B>
+ <LI>The MTA adds a leading space to a header value unless
+ the flag
+<A HREF="xxfi_negotiate.html#SMFIP_HDR_LEADSPC"><CODE>SMFIP_HDR_LEADSPC</CODE></A>
+ is set, in which case the milter
+ must include any desired leading spaces itself.
</UL>
</TD>
</TR>
@@ -110,7 +115,7 @@ Otherwise, it returns MI_SUCCESS.
<HR size="1">
<FONT size="-1">
-Copyright (c) 2000-2003 Sendmail, Inc. and its suppliers.
+Copyright (c) 2000-2003, 2009 Sendmail, Inc. and its suppliers.
All rights reserved.
<BR>
By using this file, you agree to the terms and conditions set
diff --git a/contrib/sendmail/libmilter/docs/smfi_insheader.html b/contrib/sendmail/libmilter/docs/smfi_insheader.html
index a4ba77f..5962e61 100644
--- a/contrib/sendmail/libmilter/docs/smfi_insheader.html
+++ b/contrib/sendmail/libmilter/docs/smfi_insheader.html
@@ -2,7 +2,7 @@
<HEAD><TITLE>smfi_insheader</TITLE></HEAD>
<BODY>
<!--
-$Id: smfi_insheader.html,v 1.9 2006/12/21 18:30:35 ca Exp $
+$Id: smfi_insheader.html,v 1.10 2009/05/18 23:51:23 ca Exp $
-->
<H1>smfi_insheader</H1>
@@ -111,6 +111,11 @@ Otherwise, it returns MI_SUCCESS.
the MTA will add this automatically.
<B>It is the filter writer's responsibility to ensure that no standards
are violated.</B>
+ <LI>The MTA adds a leading space to an inserted header value unless
+ the flag
+<A HREF="xxfi_negotiate.html#SMFIP_HDR_LEADSPC"><CODE>SMFIP_HDR_LEADSPC</CODE></A>
+ is set, in which case the milter
+ must include any desired leading spaces itself.
</UL>
</TD>
</TR>
@@ -135,7 +140,7 @@ Otherwise, it returns MI_SUCCESS.
<HR size="1">
<FONT size="-1">
-Copyright (c) 2004, 2006 Sendmail, Inc. and its suppliers.
+Copyright (c) 2004, 2006, 2009 Sendmail, Inc. and its suppliers.
All rights reserved.
<BR>
By using this file, you agree to the terms and conditions set
diff --git a/contrib/sendmail/libmilter/engine.c b/contrib/sendmail/libmilter/engine.c
index 9002a0b..a2d3e1e 100644
--- a/contrib/sendmail/libmilter/engine.c
+++ b/contrib/sendmail/libmilter/engine.c
@@ -9,7 +9,7 @@
*/
#include <sm/gen.h>
-SM_RCSID("@(#)$Id: engine.c,v 8.162 2008/02/27 01:34:14 ca Exp $")
+SM_RCSID("@(#)$Id: engine.c,v 8.166 2009/11/06 00:57:07 ca Exp $")
#include "libmilter.h"
@@ -113,6 +113,7 @@ static void fix_stm __P((SMFICTX_PTR));
static bool trans_ok __P((int, int));
static char **dec_argv __P((char *, size_t));
static int dec_arg2 __P((char *, size_t, char **, char **));
+static void mi_clr_symlist __P((SMFICTX_PTR));
#if _FFR_WORKERS_POOL
static bool mi_rd_socket_ready __P((int));
@@ -758,6 +759,69 @@ mi_clr_macros(ctx, m)
}
/*
+** MI_CLR_SYMLIST -- clear list of macros
+**
+** Parameters:
+** ctx -- context structure
+**
+** Returns:
+** None.
+*/
+
+static void
+mi_clr_symlist(ctx)
+ SMFICTX *ctx;
+{
+ int i;
+
+ SM_ASSERT(ctx != NULL);
+ for (i = SMFIM_FIRST; i <= SMFIM_LAST; i++)
+ {
+ if (ctx->ctx_mac_list[i] != NULL)
+ {
+ free(ctx->ctx_mac_list[i]);
+ ctx->ctx_mac_list[i] = NULL;
+ }
+ }
+}
+
+/*
+** MI_CLR_CTX -- clear context
+**
+** Parameters:
+** ctx -- context structure
+**
+** Returns:
+** None.
+*/
+
+void
+mi_clr_ctx(ctx)
+ SMFICTX *ctx;
+{
+ SM_ASSERT(ctx != NULL);
+ if (ValidSocket(ctx->ctx_sd))
+ {
+ (void) closesocket(ctx->ctx_sd);
+ ctx->ctx_sd = INVALID_SOCKET;
+ }
+ if (ctx->ctx_reply != NULL)
+ {
+ free(ctx->ctx_reply);
+ ctx->ctx_reply = NULL;
+ }
+ if (ctx->ctx_privdata != NULL)
+ {
+ smi_log(SMI_LOG_WARN,
+ "%s: private data not NULL",
+ ctx->ctx_smfi->xxfi_name);
+ }
+ mi_clr_macros(ctx, 0);
+ mi_clr_symlist(ctx);
+ free(ctx);
+}
+
+/*
** ST_OPTIONNEG -- negotiate options
**
** Parameters:
@@ -771,8 +835,11 @@ static int
st_optionneg(g)
genarg *g;
{
- mi_int32 i, v, fake_pflags;
+ mi_int32 i, v, fake_pflags, internal_pflags;
SMFICTX_PTR ctx;
+#if _FFR_MILTER_CHECK
+ bool testmode = false;
+#endif /* _FFR_MILTER_CHECK */
int (*fi_negotiate) __P((SMFICTX *,
unsigned long, unsigned long,
unsigned long, unsigned long,
@@ -826,6 +893,7 @@ st_optionneg(g)
v = SMFI_V1_ACTS;
ctx->ctx_mta_aflags = v; /* MTA action flags */
+ internal_pflags = 0;
(void) memcpy((void *) &i, (void *) &(g->a_buf[MILTER_LEN_BYTES * 2]),
MILTER_LEN_BYTES);
v = ntohl(i);
@@ -833,7 +901,51 @@ st_optionneg(g)
/* no flags? set to default value for V1 protocol */
if (v == 0)
v = SMFI_V1_PROT;
- ctx->ctx_mta_pflags = v; /* MTA protocol flags */
+#if _FFR_MDS_NEGOTIATE
+ else if (ctx->ctx_smfi->xxfi_version >= SMFI_VERSION_MDS)
+ {
+ /*
+ ** Allow changing the size only if milter is compiled
+ ** against a version that supports this.
+ ** If a milter is dynamically linked against a newer
+ ** libmilter version, we don't want to "surprise"
+ ** it with a larger buffer as it may rely on it
+ ** even though it is not documented as a limit.
+ */
+
+ if (bitset(SMFIP_MDS_1M, v))
+ {
+ internal_pflags |= SMFIP_MDS_1M;
+ (void) smfi_setmaxdatasize(MILTER_MDS_1M);
+ }
+ else if (bitset(SMFIP_MDS_256K, v))
+ {
+ internal_pflags |= SMFIP_MDS_256K;
+ (void) smfi_setmaxdatasize(MILTER_MDS_256K);
+ }
+ }
+# if 0
+ /* don't log this for now... */
+ else if (ctx->ctx_smfi->xxfi_version < SMFI_VERSION_MDS &&
+ bitset(SMFIP_MDS_1M|SMFIP_MDS_256K, v))
+ {
+ smi_log(SMI_LOG_WARN,
+ "%s: st_optionneg[%ld]: milter version=%X, trying flags=%X",
+ ctx->ctx_smfi->xxfi_name,
+ (long) ctx->ctx_id, ctx->ctx_smfi->xxfi_version, v);
+ }
+# endif /* 0 */
+#endif /* _FFR_MDS_NEGOTIATE */
+
+ /*
+ ** MTA protocol flags.
+ ** We pass the internal flags to the milter as "read only",
+ ** i.e., a milter can read them so it knows which size
+ ** will be used, but any changes by a milter will be ignored
+ ** (see below, search for SMFI_INTERNAL).
+ */
+
+ ctx->ctx_mta_pflags = (v & ~SMFI_INTERNAL) | internal_pflags;
/*
** Copy flags from milter struct into libmilter context;
@@ -880,6 +992,12 @@ st_optionneg(g)
0, 0,
&m_aflags, &m_pflags, &m_f2, &m_f3);
+#if _FFR_MILTER_CHECK
+ testmode = bitset(SMFIP_TEST, m_pflags);
+ if (testmode)
+ m_pflags &= ~SMFIP_TEST;
+#endif /* _FFR_MILTER_CHECK */
+
/*
** Types of protocol flags (pflags):
** 1. do NOT send protocol step X
@@ -1011,6 +1129,25 @@ st_optionneg(g)
, ctx->ctx_mta_aflags, ctx->ctx_mta_pflags
, ctx->ctx_aflags, ctx->ctx_pflags);
+#if _FFR_MILTER_CHECK
+ if (ctx->ctx_dbg > 3)
+ sm_dprintf("[%ld] milter_negotiate:"
+ " testmode=%d, pflags2mta=%X, internal_pflags=%X\n"
+ , (long) ctx->ctx_id, testmode
+ , ctx->ctx_pflags2mta, internal_pflags);
+
+ /* in test mode: take flags without further modifications */
+ if (!testmode)
+ /* Warning: check statement below! */
+#endif /* _FFR_MILTER_CHECK */
+
+ /*
+ ** Remove the internal flags that might have been set by a milter
+ ** and set only those determined above.
+ */
+
+ ctx->ctx_pflags2mta = (ctx->ctx_pflags2mta & ~SMFI_INTERNAL)
+ | internal_pflags;
return _SMFIS_OPTIONS;
}
diff --git a/contrib/sendmail/libmilter/example.c b/contrib/sendmail/libmilter/example.c
index 5a09f1d..cef4b0f 100644
--- a/contrib/sendmail/libmilter/example.c
+++ b/contrib/sendmail/libmilter/example.c
@@ -6,7 +6,7 @@
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
- * $Id: example.c,v 8.3 2006/12/20 21:22:34 ca Exp $
+ * $Id: example.c,v 8.4 2008/07/22 15:12:47 ca Exp $
*/
/*
@@ -252,7 +252,7 @@ struct smfiDesc smfilter =
mlfi_close, /* connection cleanup */
mlfi_unknown, /* unknown/unimplemented SMTP commands */
mlfi_data, /* DATA command filter */
- mlfi_negotiate /* option negotation at connection startup */
+ mlfi_negotiate /* option negotiation at connection startup */
};
int
diff --git a/contrib/sendmail/libmilter/handler.c b/contrib/sendmail/libmilter/handler.c
index 5fd4b26..2c34f1f 100644
--- a/contrib/sendmail/libmilter/handler.c
+++ b/contrib/sendmail/libmilter/handler.c
@@ -9,7 +9,7 @@
*/
#include <sm/gen.h>
-SM_RCSID("@(#)$Id: handler.c,v 8.38 2006/11/02 02:38:22 ca Exp $")
+SM_RCSID("@(#)$Id: handler.c,v 8.39 2008/11/25 01:14:16 ca Exp $")
#include "libmilter.h"
@@ -43,24 +43,7 @@ mi_handle_session(ctx)
ret = MI_FAILURE;
else
ret = mi_engine(ctx);
- if (ValidSocket(ctx->ctx_sd))
- {
- (void) closesocket(ctx->ctx_sd);
- ctx->ctx_sd = INVALID_SOCKET;
- }
- if (ctx->ctx_reply != NULL)
- {
- free(ctx->ctx_reply);
- ctx->ctx_reply = NULL;
- }
- if (ctx->ctx_privdata != NULL)
- {
- smi_log(SMI_LOG_WARN,
- "%s: private data not NULL",
- ctx->ctx_smfi->xxfi_name);
- }
- mi_clr_macros(ctx, 0);
- free(ctx);
+ mi_clr_ctx(ctx);
ctx = NULL;
return ret;
}
diff --git a/contrib/sendmail/libmilter/libmilter.h b/contrib/sendmail/libmilter/libmilter.h
index 5a12409..5824151 100644
--- a/contrib/sendmail/libmilter/libmilter.h
+++ b/contrib/sendmail/libmilter/libmilter.h
@@ -19,7 +19,7 @@
#ifdef _DEFINE
# define EXTERN
# define INIT(x) = x
-SM_IDSTR(MilterlId, "@(#)$Id: libmilter.h,v 8.74 2006/12/19 18:19:52 ca Exp $")
+SM_IDSTR(MilterlId, "@(#)$Id: libmilter.h,v 8.77 2008/11/25 18:28:18 ca Exp $")
#else /* _DEFINE */
# define EXTERN extern
# define INIT(x)
@@ -282,6 +282,7 @@ extern int mi_handle_session __P((SMFICTX_PTR));
extern int mi_engine __P((SMFICTX_PTR));
extern int mi_listener __P((char *, int, smfiDesc_ptr, time_t, int));
extern void mi_clr_macros __P((SMFICTX_PTR, int));
+extern void mi_clr_ctx __P((SMFICTX_PTR));
extern int mi_stop __P((void));
extern int mi_control_startup __P((char *));
extern void mi_stop_milters __P((int));
diff --git a/contrib/sendmail/libmilter/listener.c b/contrib/sendmail/libmilter/listener.c
index 6e68ae5..48c552f 100644
--- a/contrib/sendmail/libmilter/listener.c
+++ b/contrib/sendmail/libmilter/listener.c
@@ -9,7 +9,7 @@
*/
#include <sm/gen.h>
-SM_RCSID("@(#)$Id: listener.c,v 8.124 2007/04/23 22:22:50 ca Exp $")
+SM_RCSID("@(#)$Id: listener.c,v 8.126 2009/12/16 16:40:23 ca Exp $")
/*
** listener.c -- threaded network listener
@@ -777,8 +777,9 @@ mi_listener(conn, dbg, smfi, timeout, backlog)
continue;
scnt++;
smi_log(SMI_LOG_ERR,
- "%s: select() failed (%s), %s",
- smfi->xxfi_name, sm_errstring(save_errno),
+ "%s: %s() failed (%s), %s",
+ smfi->xxfi_name, MI_POLLSELECT,
+ sm_errstring(save_errno),
scnt >= MAX_FAILS_S ? "abort" : "try again");
MI_SLEEP(scnt);
if (scnt >= MAX_FAILS_S)
diff --git a/contrib/sendmail/libmilter/main.c b/contrib/sendmail/libmilter/main.c
index 2da9a82..d6e7279 100644
--- a/contrib/sendmail/libmilter/main.c
+++ b/contrib/sendmail/libmilter/main.c
@@ -9,7 +9,7 @@
*/
#include <sm/gen.h>
-SM_RCSID("@(#)$Id: main.c,v 8.83 2007/04/23 22:22:50 ca Exp $")
+SM_RCSID("@(#)$Id: main.c,v 8.84 2008/09/02 05:37:06 ca Exp $")
#define _DEFINE 1
#include "libmilter.h"
diff --git a/contrib/sendmail/libmilter/worker.c b/contrib/sendmail/libmilter/worker.c
index fd4b66e..28d404f 100644
--- a/contrib/sendmail/libmilter/worker.c
+++ b/contrib/sendmail/libmilter/worker.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2004, 2007 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 2003-2004, 2007, 2009 Sendmail, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
@@ -11,7 +11,7 @@
*/
#include <sm/gen.h>
-SM_RCSID("@(#)$Id: worker.c,v 8.10 2007/12/03 22:06:05 ca Exp $")
+SM_RCSID("@(#)$Id: worker.c,v 8.17 2009/06/15 15:34:54 ca Exp $")
#include "libmilter.h"
@@ -210,23 +210,7 @@ mi_close_session(ctx)
SM_ASSERT(ctx != NULL);
(void) mi_list_del_ctx(ctx);
- if (ValidSocket(ctx->ctx_sd))
- {
- (void) closesocket(ctx->ctx_sd);
- ctx->ctx_sd = INVALID_SOCKET;
- }
- if (ctx->ctx_reply != NULL)
- {
- free(ctx->ctx_reply);
- ctx->ctx_reply = NULL;
- }
- if (ctx->ctx_privdata != NULL)
- {
- smi_log(SMI_LOG_WARN, "%s: private data not NULL",
- ctx->ctx_smfi->xxfi_name);
- }
- mi_clr_macros(ctx, 0);
- free(ctx);
+ mi_clr_ctx(ctx);
return MI_SUCCESS;
}
@@ -259,7 +243,7 @@ mi_pool_controller_init()
if (pipe(Tskmgr.tm_p) != 0)
{
smi_log(SMI_LOG_ERR, "can't create event pipe: %s",
- sm_errstring(r));
+ sm_errstring(errno));
return MI_FAILURE;
}
@@ -328,6 +312,7 @@ mi_pool_controller(arg)
int dim_pfd = 0;
bool rebuild_set = true;
int pcnt = 0; /* error count for poll() failures */
+ time_t lastcheck;
Tskmgr.tm_tid = sthread_get_id();
if (pthread_detach(Tskmgr.tm_tid) != 0)
@@ -345,12 +330,12 @@ mi_pool_controller(arg)
}
dim_pfd = PFD_STEP;
+ lastcheck = time(NULL);
for (;;)
{
SMFICTX_PTR ctx;
int nfd, rfd, i;
time_t now;
- time_t lastcheck;
POOL_LEV_DPRINTF(4, ("Let's %s again...", WAITFN));
@@ -364,20 +349,20 @@ mi_pool_controller(arg)
/* check for timed out sessions? */
if (lastcheck + DT_CHECK_OLD_SESSIONS < now)
{
- SM_TAILQ_FOREACH(ctx, &WRK_CTX_HEAD, ctx_link)
+ ctx = SM_TAILQ_FIRST(&WRK_CTX_HEAD);
+ while (ctx != SM_TAILQ_END(&WRK_CTX_HEAD))
{
+ SMFICTX_PTR ctx_nxt;
+
+ ctx_nxt = SM_TAILQ_NEXT(ctx, ctx_link);
if (ctx->ctx_wstate == WKST_WAITING)
{
if (ctx->ctx_wait == 0)
- {
ctx->ctx_wait = now;
- continue;
- }
-
- /* if session timed out, close it */
- if (ctx->ctx_wait + OLD_SESSION_TIMEOUT
- < now)
+ else if (ctx->ctx_wait + OLD_SESSION_TIMEOUT
+ < now)
{
+ /* if session timed out, close it */
sfsistat (*fi_close) __P((SMFICTX *));
POOL_LEV_DPRINTF(4,
@@ -389,10 +374,9 @@ mi_pool_controller(arg)
(void) (*fi_close)(ctx);
mi_close_session(ctx);
- ctx = SM_TAILQ_FIRST(&WRK_CTX_HEAD);
- continue;
}
}
+ ctx = ctx_nxt;
}
lastcheck = now;
}
@@ -465,6 +449,7 @@ mi_pool_controller(arg)
}
}
}
+ rebuild_set = false;
}
TASKMGR_UNLOCK();
OpenPOWER on IntegriCloud