From ba49bcdc8dd5224a12467be5c08e74cbbcac783f Mon Sep 17 00:00:00 2001
From: Wietse Venema
Date: Wed, 14 Feb 2007 00:00:00 -0500
Subject: [PATCH] postfix-2.4-20070214
---
postfix/HISTORY | 15 ++++++++++++--
postfix/README_FILES/LMTP_README | 5 -----
postfix/README_FILES/OVERVIEW | 3 +--
postfix/conf/postfix-files | 2 --
postfix/html/LMTP_README.html | 24 ----------------------
postfix/html/OVERVIEW.html | 3 +--
postfix/makedefs | 6 +++++-
postfix/proto/LMTP_README.html | 24 ----------------------
postfix/proto/Makefile.in | 10 ++--------
postfix/proto/OVERVIEW.html | 3 +--
postfix/src/global/mail_version.h | 2 +-
postfix/src/oqmgr/qmgr_transport.c | 13 ++++++++++++
postfix/src/qmgr/qmgr_transport.c | 13 ++++++++++++
postfix/src/util/events.c | 12 +++++++----
postfix/src/util/sys_defs.h | 6 ++++--
postfix/src/util/vstream.c | 32 ++++++++++++++++++++++++++++++
postfix/src/util/vstream.h | 3 +++
17 files changed, 97 insertions(+), 79 deletions(-)
delete mode 100644 postfix/README_FILES/LMTP_README
delete mode 100644 postfix/html/LMTP_README.html
delete mode 100644 postfix/proto/LMTP_README.html
diff --git a/postfix/HISTORY b/postfix/HISTORY
index 613550be2..14cb15f59 100644
--- a/postfix/HISTORY
+++ b/postfix/HISTORY
@@ -13225,8 +13225,19 @@ Apologies for any names omitted.
events.c handler, undid some unnecessary changes to the
{read,write}{_wait,able}.c modules, and addressed Victor's
paranoia for multi-client servers with a thousand clients
- while linked with third-party libraries that can't handle
- file descriptors >= FD_SETSIZE.
+ while linked with library routines that can't handle file
+ descriptors >= FD_SETSIZE.
+
+ Cleanup: while debugging the new events.c handler, removed
+ an unnecessary "write after connect" call-back event. File:
+ global/post_mail.c.
+
+20070214
+
+ Robustness: in the queue manager keep a number of free file
+ descriptor slots at the low end, to work around library
+ routines that can't handle file descriptors >= FD_SETSIZE.
+ Files: *qmgr/qmgr_transport.c, util/vstream.[hc]
Wish list:
diff --git a/postfix/README_FILES/LMTP_README b/postfix/README_FILES/LMTP_README
deleted file mode 100644
index 256bf4667..000000000
--- a/postfix/README_FILES/LMTP_README
+++ /dev/null
@@ -1,5 +0,0 @@
-PPoossttffiixx LLMMTTPP HHoowwttoo
-
--------------------------------------------------------------------------------
-This document will be made available via http://www.postfix.org/.
-
diff --git a/postfix/README_FILES/OVERVIEW b/postfix/README_FILES/OVERVIEW
index 1d9ae180f..7331c2b1b 100644
--- a/postfix/README_FILES/OVERVIEW
+++ b/postfix/README_FILES/OVERVIEW
@@ -136,8 +136,7 @@ unnumbered names inside shaded areas represent Postfix queues.
delivery to mailbox servers such as Cyrus. The advantage of this setup is
that one Postfix machine can feed multiple mailbox servers over LMTP. The
opposite is true as well: one mailbox server can be fed over LMTP by
- multiple Postfix machines. The LMTP_README document gives examples of how
- to use the lmtp(8) client.
+ multiple Postfix machines.
* The local(8) delivery agent understands UNIX-style mailboxes, qmail-
compatible maildir files, Sendmail-style system-wide aliases(5) databases,
diff --git a/postfix/conf/postfix-files b/postfix/conf/postfix-files
index b0a0bfe68..b483b9146 100644
--- a/postfix/conf/postfix-files
+++ b/postfix/conf/postfix-files
@@ -242,7 +242,6 @@ $readme_directory/INSTALL:f:root:-:644
$readme_directory/IPV6_README:f:root:-:644
$readme_directory/LDAP_README:f:root:-:644
$readme_directory/LINUX_README:f:root:-:644
-$readme_directory/LMTP_README:f:root:-:644
$readme_directory/LOCAL_RECIPIENT_README:f:root:-:644
$readme_directory/MACOSX_README:f:root:-:644:o
$readme_directory/MAILDROP_README:f:root:-:644
@@ -292,7 +291,6 @@ $html_directory/INSTALL.html:f:root:-:644
$html_directory/IPV6_README.html:f:root:-:644
$html_directory/LDAP_README.html:f:root:-:644
$html_directory/LINUX_README.html:f:root:-:644
-$html_directory/LMTP_README.html:f:root:-:644
$html_directory/LOCAL_RECIPIENT_README.html:f:root:-:644
$html_directory/MAILDROP_README.html:f:root:-:644
$html_directory/MILTER_README.html:f:root:-:644
diff --git a/postfix/html/LMTP_README.html b/postfix/html/LMTP_README.html
deleted file mode 100644
index 715c216e5..000000000
--- a/postfix/html/LMTP_README.html
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-Postfix LMTP Howto
-
-
-
-
-
-
-
-
Postfix LMTP Howto
-
-
-
- This document will be made available via http://www.postfix.org/.
-
-
-
-
diff --git a/postfix/html/OVERVIEW.html b/postfix/html/OVERVIEW.html
index 9bdf973e6..015f6e940 100644
--- a/postfix/html/OVERVIEW.html
+++ b/postfix/html/OVERVIEW.html
@@ -359,8 +359,7 @@ is optimized for delivery to mailbox servers such as Cyrus. The
advantage of this setup is that one Postfix machine can feed multiple
mailbox servers over LMTP. The opposite is true as well: one
mailbox server can be fed over LMTP by multiple Postfix machines.
-The LMTP_README document gives examples of how to use the lmtp(8)
-client.
+
The local(8) delivery agent understands UNIX-style mailboxes,
qmail-compatible maildir files, Sendmail-style system-wide aliases(5)
diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h
index 8742a07dd..4a9f60a5d 100644
--- a/postfix/src/global/mail_version.h
+++ b/postfix/src/global/mail_version.h
@@ -20,7 +20,7 @@
* Patches change both the patchlevel and the release date. Snapshots have no
* patchlevel; they change the release date only.
*/
-#define MAIL_RELEASE_DATE "20070212"
+#define MAIL_RELEASE_DATE "20070214"
#define MAIL_VERSION_NUMBER "2.4"
#ifdef SNAPSHOT
diff --git a/postfix/src/oqmgr/qmgr_transport.c b/postfix/src/oqmgr/qmgr_transport.c
index 7ff31c57f..768c39bfe 100644
--- a/postfix/src/oqmgr/qmgr_transport.c
+++ b/postfix/src/oqmgr/qmgr_transport.c
@@ -71,6 +71,14 @@
#include
#include
+#include /* FD_SETSIZE */
+#include /* FD_SETSIZE */
+#include /* FD_SETSIZE */
+
+#ifdef USE_SYS_SELECT_H
+#include /* FD_SETSIZE */
+#endif
+
/* Utility library. */
#include
@@ -333,6 +341,11 @@ void qmgr_transport_alloc(QMGR_TRANSPORT *transport, QMGR_TRANSPORT_ALLOC_NOT
event_request_timer(qmgr_transport_event, (char *) alloc, 0);
return;
}
+#if !defined(USE_SELECT_EVENTS) && defined(VSTREAM_CTL_DUPFD)
+ vstream_control(alloc->stream,
+ VSTREAM_CTL_DUPFD, FD_SETSIZE / 8,
+ VSTREAM_CTL_END);
+#endif
event_enable_read(vstream_fileno(alloc->stream), qmgr_transport_event,
(char *) alloc);
diff --git a/postfix/src/qmgr/qmgr_transport.c b/postfix/src/qmgr/qmgr_transport.c
index de04bd192..862979dd2 100644
--- a/postfix/src/qmgr/qmgr_transport.c
+++ b/postfix/src/qmgr/qmgr_transport.c
@@ -76,6 +76,14 @@
#include
#include
+#include /* FD_SETSIZE */
+#include /* FD_SETSIZE */
+#include /* FD_SETSIZE */
+
+#ifdef USE_SYS_SELECT_H
+#include /* FD_SETSIZE */
+#endif
+
/* Utility library. */
#include
@@ -338,6 +346,11 @@ void qmgr_transport_alloc(QMGR_TRANSPORT *transport, QMGR_TRANSPORT_ALLOC_NOT
event_request_timer(qmgr_transport_event, (char *) alloc, 0);
return;
}
+#if !defined(USE_SELECT_EVENTS) && defined(VSTREAM_CTL_DUPFD)
+ vstream_control(alloc->stream,
+ VSTREAM_CTL_DUPFD, FD_SETSIZE / 8,
+ VSTREAM_CTL_END);
+#endif
event_enable_read(vstream_fileno(alloc->stream), qmgr_transport_event,
(char *) alloc);
diff --git a/postfix/src/util/events.c b/postfix/src/util/events.c
index e12f4bcda..81f2e6b80 100644
--- a/postfix/src/util/events.c
+++ b/postfix/src/util/events.c
@@ -328,6 +328,7 @@ typedef struct kevent EVENT_BUFFER;
(event_count) = kevent(event_kq, (struct kevent *) 0, 0, (event_buf), \
(buflen), (tsp)); \
} while (0)
+#define EVENT_BUFFER_READ_TEXT "kevent"
/*
* Macros to process event buffers from the kernel; see event_loop().
@@ -396,6 +397,7 @@ typedef struct pollfd EVENT_BUFFER;
dvpoll.dp_timeout = (delay) < 0 ? -1 : (delay) * 1000; \
(event_count) = ioctl(event_pollfd, DP_POLL, &dvpoll); \
} while (0)
+#define EVENT_BUFFER_READ_TEXT "ioctl DP_POLL"
/*
* Macros to process event buffers from the kernel; see event_loop().
@@ -465,6 +467,7 @@ typedef struct epoll_event EVENT_BUFFER;
(event_count) = epoll_wait(event_epollfd, (event_buf), (buflen), \
(delay) < 0 ? -1 : (delay) * 1000); \
} while (0)
+#define EVENT_BUFFER_READ_TEXT "epoll_wait"
/*
* Macros to process event buffers from the kernel; see event_loop().
@@ -918,9 +921,9 @@ void event_loop(int delay)
#else
EVENT_BUFFER event_buf[100];
EVENT_BUFFER *bp;
- int event_count;
#endif
+ int event_count;
EVENT_TIMER *timer;
int fd;
EVENT_FDTABLE *fdp;
@@ -982,7 +985,8 @@ void event_loop(int delay)
wmask = event_wmask;
xmask = event_xmask;
- if (select(event_max_fd + 1, &rmask, &wmask, &xmask, tvp) < 0) {
+ event_count = select(event_max_fd + 1, &rmask, &wmask, &xmask, tvp);
+ if (event_count < 0) {
if (errno != EINTR)
msg_fatal("event_loop: select: %m");
return;
@@ -993,7 +997,7 @@ void event_loop(int delay)
select_delay);
if (event_count < 0) {
if (errno != EINTR)
- msg_fatal("event_loop: kevent: %m");
+ msg_fatal("event_loop: " EVENT_BUFFER_READ_TEXT ": %m");
return;
}
#endif
@@ -1034,7 +1038,7 @@ void event_loop(int delay)
* application to determine when a read or write is complete.
*/
#ifdef USE_SELECT_EVENTS
- for (fd = 0; fd <= event_max_fd; fd++) {
+ for (fd = 0; event_count > 0 && fd <= event_max_fd; fd++) {
if (FD_ISSET(fd, &event_xmask)) {
/* In case event_fdtable is updated. */
fdp = event_fdtable + fd;
diff --git a/postfix/src/util/sys_defs.h b/postfix/src/util/sys_defs.h
index 6d4b8e4c2..e4e5af3a4 100644
--- a/postfix/src/util/sys_defs.h
+++ b/postfix/src/util/sys_defs.h
@@ -157,10 +157,12 @@
# define USE_SYSV_POLL
#endif
-#if (defined(__FreeBSD_version) && __FreeBSD_version >= 410000) \
+#ifndef NO_KQUEUE
+# if (defined(__FreeBSD_version) && __FreeBSD_version >= 410000) \
|| (defined(__NetBSD_Version__) && __NetBSD_Version__ >= 200000000) \
|| (defined(OpenBSD) && OpenBSD >= 200105) /* OpenBSD 2.9 */
-# define USE_KQUEUE_EVENTS
+# define USE_KQUEUE_EVENTS
+# endif
#endif
#endif
diff --git a/postfix/src/util/vstream.c b/postfix/src/util/vstream.c
index 602d659d3..90d3ab2ed 100644
--- a/postfix/src/util/vstream.c
+++ b/postfix/src/util/vstream.c
@@ -260,6 +260,12 @@
/* The argument specifies the file descriptor to be used for writing.
/* This feature is limited to double-buffered streams, and makes the
/* stream non-seekable.
+/* .IP "VSTREAM_CTL_DUPFD (int)"
+/* The argument specifies a minimum file descriptor value. If
+/* the actual stream's file descriptors are below the minimum,
+/* reallocate the descriptors to the first free value greater
+/* than or equal to the minimum. The VSTREAM_CTL_DUPFD macro
+/* is defined only on systems with fcntl() F_DUPFD support.
/* .IP "VSTREAM_CTL_WAITPID_FN (int (*)(pid_t, WAIT_STATUS_T *, int))"
/* A pointer to function that behaves like waitpid(). This information
/* is used by the vstream_pclose() routine.
@@ -1163,6 +1169,8 @@ void vstream_control(VSTREAM *stream, int name,...)
{
const char *myname = "vstream_control";
va_list ap;
+ int floor;
+ int old_fd;
for (va_start(ap, name); name != VSTREAM_CTL_END; name = va_arg(ap, int)) {
switch (name) {
@@ -1216,6 +1224,30 @@ void vstream_control(VSTREAM *stream, int name,...)
if (stream->jbuf == 0)
stream->jbuf = (jmp_buf *) mymalloc(sizeof(jmp_buf));
break;
+
+#ifdef VSTREAM_CTL_DUPFD
+
+#define VSTREAM_TRY_DUPFD(backup, fd, floor) do { \
+ if (((backup) = (fd)) < floor) { \
+ if (((fd) = fcntl((backup), F_DUPFD, (floor))) < 0) \
+ msg_fatal("fcntl F_DUPFD %d: %m", (floor)); \
+ (void) close(backup); \
+ } \
+ } while (0)
+
+ case VSTREAM_CTL_DUPFD:
+ floor = va_arg(ap, int);
+ if (stream->buf.flags & VSTREAM_FLAG_DOUBLE) {
+ VSTREAM_TRY_DUPFD(old_fd, stream->read_fd, floor);
+ if (stream->write_fd == old_fd)
+ stream->write_fd = stream->read_fd;
+ else
+ VSTREAM_TRY_DUPFD(old_fd, stream->write_fd, floor);
+ } else {
+ VSTREAM_TRY_DUPFD(old_fd, stream->fd, floor);
+ }
+ break;
+#endif
default:
msg_panic("%s: bad name %d", myname, name);
}
diff --git a/postfix/src/util/vstream.h b/postfix/src/util/vstream.h
index 625309298..dc2ebb9f8 100644
--- a/postfix/src/util/vstream.h
+++ b/postfix/src/util/vstream.h
@@ -120,6 +120,9 @@ extern void vstream_control(VSTREAM *, int,...);
#define VSTREAM_CTL_TIMEOUT 8
#define VSTREAM_CTL_EXCEPT 9
#define VSTREAM_CTL_CONTEXT 10
+#ifdef F_DUPFD
+#define VSTREAM_CTL_DUPFD 11
+#endif
extern VSTREAM *PRINTFLIKE(1, 2) vstream_printf(const char *,...);
extern VSTREAM *PRINTFLIKE(2, 3) vstream_fprintf(VSTREAM *, const char *,...);
--
2.47.3