summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/libmilter/listener.c
diff options
context:
space:
mode:
authorgshapiro <gshapiro@FreeBSD.org>2007-04-09 01:38:51 +0000
committergshapiro <gshapiro@FreeBSD.org>2007-04-09 01:38:51 +0000
commit97853bac963c5d3bed1b2cc8456b52dc100a3a16 (patch)
tree2164c380c4cbce635871c28ad6025cf3001cedaa /contrib/sendmail/libmilter/listener.c
parenta26ee9422b3dd49a0146ab2eec3f21acf30e399c (diff)
parent14e22b52d4375b164f9fa21c0ab3abd9837e823f (diff)
downloadFreeBSD-src-97853bac963c5d3bed1b2cc8456b52dc100a3a16.zip
FreeBSD-src-97853bac963c5d3bed1b2cc8456b52dc100a3a16.tar.gz
This commit was generated by cvs2svn to compensate for changes in r168515,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/sendmail/libmilter/listener.c')
-rw-r--r--contrib/sendmail/libmilter/listener.c60
1 files changed, 39 insertions, 21 deletions
diff --git a/contrib/sendmail/libmilter/listener.c b/contrib/sendmail/libmilter/listener.c
index 4429edf..cf98361 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.115 2006/01/24 00:48:39 ca Exp $")
+SM_RCSID("@(#)$Id: listener.c,v 8.122 2006/11/02 17:54:44 ca Exp $")
/*
** listener.c -- threaded network listener
@@ -25,6 +25,10 @@ SM_RCSID("@(#)$Id: listener.c,v 8.115 2006/01/24 00:48:39 ca Exp $")
# if NETINET || NETINET6
# include <arpa/inet.h>
# endif /* NETINET || NETINET6 */
+# if SM_CONF_POLL
+# undef SM_FD_OK_SELECT
+# define SM_FD_OK_SELECT(fd) true
+# endif /* SM_CONF_POLL */
static smutex_t L_Mutex;
static int L_family;
@@ -32,7 +36,9 @@ static SOCKADDR_LEN_T L_socksize;
static socket_t listenfd = INVALID_SOCKET;
static socket_t mi_milteropen __P((char *, int, bool, char *));
+#if !_FFR_WORKERS_POOL
static void *mi_thread_handle_wrapper __P((void *));
+#endif /* !_FFR_WORKERS_POOL */
/*
** MI_OPENSOCKET -- create the socket where this filter and the MTA will meet
@@ -80,7 +86,6 @@ mi_opensocket(conn, backlog, dbg, rmsocket, smfi)
(void) smutex_unlock(&L_Mutex);
return MI_FAILURE;
}
-#if !SM_CONF_POLL
if (!SM_FD_OK_SELECT(listenfd))
{
smi_log(SMI_LOG_ERR, "%s: fd %d is larger than FD_SETSIZE %d",
@@ -88,7 +93,6 @@ mi_opensocket(conn, backlog, dbg, rmsocket, smfi)
(void) smutex_unlock(&L_Mutex);
return MI_FAILURE;
}
-#endif /* !SM_CONF_POLL */
(void) smutex_unlock(&L_Mutex);
return MI_SUCCESS;
}
@@ -549,6 +553,8 @@ mi_milteropen(conn, backlog, rmsocket, name)
L_family = addr.sa.sa_family;
return sock;
}
+
+#if !_FFR_WORKERS_POOL
/*
** MI_THREAD_HANDLE_WRAPPER -- small wrapper to handle session
**
@@ -563,8 +569,16 @@ static void *
mi_thread_handle_wrapper(arg)
void *arg;
{
+ /*
+ ** Note: on some systems this generates a compiler warning:
+ ** cast to pointer from integer of different size
+ ** You can safely ignore this warning as the result of this function
+ ** is not used anywhere.
+ */
+
return (void *) mi_handle_session(arg);
}
+#endif /* _FFR_WORKERS_POOL */
/*
** MI_CLOSENER -- close listen socket
@@ -714,7 +728,9 @@ mi_listener(conn, dbg, smfi, timeout, backlog)
int acnt = 0; /* error count for accept() failures */
int scnt = 0; /* error count for select() failures */
int save_errno = 0;
+#if !_FFR_WORKERS_POOL
sthread_t thread_id;
+#endif /* !_FFR_WORKERS_POOL */
_SOCK_ADDR cliaddr;
SOCKADDR_LEN_T clilen;
SMFICTX_PTR ctx;
@@ -724,6 +740,11 @@ mi_listener(conn, dbg, smfi, timeout, backlog)
if (mi_opensocket(conn, backlog, dbg, false, smfi) == MI_FAILURE)
return MI_FAILURE;
+#if _FFR_WORKERS_POOL
+ if (mi_pool_controller_init() == MI_FAILURE)
+ return MI_FAILURE;
+#endif /* _FFR_WORKERS_POOL */
+
clilen = L_socksize;
while ((mistop = mi_stop()) == MILTER_CONT)
{
@@ -786,9 +807,8 @@ mi_listener(conn, dbg, smfi, timeout, backlog)
(void) smutex_unlock(&L_Mutex);
/*
- ** If remote side closes before
- ** accept() finishes, sockaddr
- ** might not be fully filled in.
+ ** If remote side closes before accept() finishes,
+ ** sockaddr might not be fully filled in.
*/
if (ValidSocket(connfd) &&
@@ -803,7 +823,6 @@ mi_listener(conn, dbg, smfi, timeout, backlog)
save_errno = EINVAL;
}
-#if !SM_CONF_POLL
/* check if acceptable for select() */
if (ValidSocket(connfd) && !SM_FD_OK_SELECT(connfd))
{
@@ -811,7 +830,6 @@ mi_listener(conn, dbg, smfi, timeout, backlog)
connfd = INVALID_SOCKET;
save_errno = ERANGE;
}
-#endif /* !SM_CONF_POLL */
if (!ValidSocket(connfd))
{
@@ -858,11 +876,7 @@ mi_listener(conn, dbg, smfi, timeout, backlog)
acnt = 0; /* reset error counter for accept() */
#if _FFR_DUP_FD
dupfd = fcntl(connfd, F_DUPFD, 256);
- if (ValidSocket(dupfd)
-# if !SM_CONF_POLL
- && SM_FD_OK_SELECT(dupfd)
-# endif /* !SM_CONF_POLL */
- )
+ if (ValidSocket(dupfd) && SM_FD_OK_SELECT(dupfd))
{
close(connfd);
connfd = dupfd;
@@ -899,12 +913,6 @@ mi_listener(conn, dbg, smfi, timeout, backlog)
ctx->ctx_dbg = dbg;
ctx->ctx_timeout = timeout;
ctx->ctx_smfi = smfi;
-#if 0
- if (smfi->xxfi_eoh == NULL)
- if (smfi->xxfi_eom == NULL)
- if (smfi->xxfi_abort == NULL)
- if (smfi->xxfi_close == NULL)
-#endif /* 0 */
if (smfi->xxfi_connect == NULL)
ctx->ctx_pflags |= SMFIP_NOCONNECT;
if (smfi->xxfi_helo == NULL)
@@ -919,14 +927,24 @@ mi_listener(conn, dbg, smfi, timeout, backlog)
ctx->ctx_pflags |= SMFIP_NOEOH;
if (smfi->xxfi_body == NULL)
ctx->ctx_pflags |= SMFIP_NOBODY;
-
+ if (smfi->xxfi_data == NULL)
+ ctx->ctx_pflags |= SMFIP_NODATA;
+ if (smfi->xxfi_unknown == NULL)
+ ctx->ctx_pflags |= SMFIP_NOUNKNOWN;
+
+#if _FFR_WORKERS_POOL
+# define LOG_CRT_FAIL "%s: mi_start_session() failed: %d, %s"
+ if ((r = mi_start_session(ctx)) != MI_SUCCESS)
+#else /* _FFR_WORKERS_POOL */
+# define LOG_CRT_FAIL "%s: thread_create() failed: %d, %s"
if ((r = thread_create(&thread_id,
mi_thread_handle_wrapper,
(void *) ctx)) != 0)
+#endif /* _FFR_WORKERS_POOL */
{
tcnt++;
smi_log(SMI_LOG_ERR,
- "%s: thread_create() failed: %d, %s",
+ LOG_CRT_FAIL,
smfi->xxfi_name, r,
tcnt >= MAX_FAILS_T ? "abort" : "try again");
MI_SLEEP(tcnt);
OpenPOWER on IntegriCloud