Deleted Added
sdiff udiff text old ( 102528 ) new ( 110560 )
full compact
1/*
2 * Copyright (c) 1999-2002 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 *
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
8 *
9 */
10
11#include <sm/gen.h>
12SM_RCSID("@(#)$Id: listener.c,v 8.85.2.1 2002/08/09 22:13:36 gshapiro Exp $")
13
14/*
15** listener.c -- threaded network listener
16*/
17
18#include "libmilter.h"
19#include <sm/errstring.h>
20
21
22# if NETINET || NETINET6
23# include <arpa/inet.h>
24# endif /* NETINET || NETINET6 */
25
26static smutex_t L_Mutex;
27static int L_family;

--- 40 unchanged lines hidden (view full) ---

68 if (!ValidSocket(listenfd))
69 {
70 smi_log(SMI_LOG_FATAL,
71 "%s: Unable to create listening socket on conn %s",
72 smfi->xxfi_name, conn);
73 (void) smutex_unlock(&L_Mutex);
74 return MI_FAILURE;
75 }
76
77 return MI_SUCCESS;
78}
79
80/*
81** MI_MILTEROPEN -- setup socket to listen on
82**
83** Parameters:
84** conn -- connection description

--- 392 unchanged lines hidden (view full) ---

477
478 sockpath = (char *) malloc(len);
479 if (sockpath != NULL)
480 (void) sm_strlcpy(sockpath, colon, len);
481 else
482 {
483 smi_log(SMI_LOG_ERR,
484 "%s: can't malloc(%d) for sockpath: %s",
485 name, len, sm_errstring(errno));
486 (void) closesocket(sock);
487 return INVALID_SOCKET;
488 }
489 }
490#endif /* NETUNIX */
491 L_family = addr.sa.sa_family;
492 return sock;
493}

--- 131 unchanged lines hidden (view full) ---

625 for (;;) \
626 { \
627 rs = select(0, NULL, NULL, NULL, &st); \
628 if (rs < 0 && errno == EINTR) \
629 continue; \
630 if (rs != 0) \
631 { \
632 smi_log(SMI_LOG_ERR, \
633 "MI_SLEEP(): select() returned non-zero result %d, errno = %d", \
634 rs, errno); \
635 } \
636 } \
637 } \
638}
639#else /* BROKEN_PTHREAD_SLEEP */
640# define MI_SLEEP(s) sleep((s))
641#endif /* BROKEN_PTHREAD_SLEEP */
642
643int

--- 19 unchanged lines hidden (view full) ---

663 SMFICTX_PTR ctx;
664 fd_set readset, excset;
665 struct timeval chktime;
666
667 if (mi_opensocket(conn, backlog, dbg, smfi) == MI_FAILURE)
668 return MI_FAILURE;
669
670 clilen = L_socksize;
671
672 if (listenfd >= FD_SETSIZE)
673 {
674 smi_log(SMI_LOG_ERR, "%s: fd %d is larger than FD_SETSIZE %d",
675 smfi->xxfi_name, listenfd, FD_SETSIZE);
676 (void) smutex_unlock(&L_Mutex);
677 return MI_FAILURE;
678 }
679 (void) smutex_unlock(&L_Mutex);
680
681 while (mi_stop() == MILTER_CONT)
682 {
683 (void) smutex_lock(&L_Mutex);
684 if (!ValidSocket(listenfd))
685 {
686 (void) smutex_unlock(&L_Mutex);
687 break;
688 }

--- 61 unchanged lines hidden (view full) ---

750# endif /* BSD4_4_SOCKADDR */
751 cliaddr.sa.sa_family != L_family))
752 {
753 (void) closesocket(connfd);
754 connfd = INVALID_SOCKET;
755 save_errno = EINVAL;
756 }
757
758 if (!ValidSocket(connfd))
759 {
760 if (save_errno == EINTR)
761 continue;
762 acnt++;
763 smi_log(SMI_LOG_ERR,
764 "%s: accept() returned invalid socket (%s), %s",
765 smfi->xxfi_name, sm_errstring(save_errno),

--- 88 unchanged lines hidden ---