From c08f4e677f08edb91706335e91e1edcd295166af Mon Sep 17 00:00:00 2001 From: Wietse Venema Date: Tue, 27 Mar 2001 00:00:00 -0500 Subject: [PATCH] snapshot-20010327 --- postfix/HISTORY | 5 ++++ postfix/src/flush/flush.c | 43 +++++++++++++++++++----------- postfix/src/global/mail_version.h | 2 +- postfix/src/global/rewrite_clnt.c | 1 + postfix/src/master/master_conf.c | 1 + postfix/src/master/master_status.c | 2 +- postfix/src/showq/showq.c | 1 + postfix/src/util/msg_syslog.c | 1 + postfix/src/util/watchdog.c | 12 ++++----- postfix/src/virtual/mailbox.c | 1 + postfix/src/virtual/virtual.c | 1 + 11 files changed, 47 insertions(+), 23 deletions(-) diff --git a/postfix/HISTORY b/postfix/HISTORY index 5e509c65c..e50e741fe 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -4988,3 +4988,8 @@ Apologies for any names omitted. Bugfix: the fast ETRN flush server could not handle [ipaddr] or domain names with one-character hostname part. It should be OK now. File: flush/flush.c. + +20010327 + + Speed up mailq (sendmail -bp) display by flushing output + after each file. File: showq/showq.c. diff --git a/postfix/src/flush/flush.c b/postfix/src/flush/flush.c index 29e2a3a50..c8c76c0d0 100644 --- a/postfix/src/flush/flush.c +++ b/postfix/src/flush/flush.c @@ -130,6 +130,7 @@ #include #include #include +#include /* Utility library. */ @@ -139,7 +140,6 @@ #include #include #include -#include #include #include #include @@ -164,7 +164,9 @@ /* Application-specific. */ /* - * Tunable parameters. + * Tunable parameters. The fast_flush_domains parameter is not defined here, + * because it is also used by the global library, and therefore is owned by + * the library. */ int var_fflush_refresh; int var_fflush_purge; @@ -176,7 +178,8 @@ static DOMAIN_LIST *flush_domains; /* * Some hard-wired policy: how many queue IDs we remember while we're - * flushing a logfile. + * flushing a logfile (duplicate elimination). Sites with 1000+ emails + * queued should arrange for permanent connectivity. */ #define FLUSH_DUP_FILTER_SIZE 10000 /* graceful degradation */ @@ -187,8 +190,8 @@ static DOMAIN_LIST *flush_domains; #define STREQ(x,y) (strcmp(x,y) == 0) /* - * Forward declarations for where we broke routines along their name space - * domain boundaries (actually, hostnames versus safe-to-use pathnames). + * Forward declarations resulting from breaking up routines according to + * name space: domain names versus safe-to-use pathnames. */ static int flush_add_path(const char *, const char *); static int flush_send_path(const char *); @@ -206,7 +209,7 @@ static VSTRING *flush_site_to_path(VSTRING *path, const char *site) path = vstring_alloc(10); /* - * Convert character values to hexadecimal. + * Mask characters that could upset the name-to-queue-file mapping code. */ while ((ch = *(unsigned const char *) site++) != 0) if (ISALNUM(ch)) @@ -249,8 +252,7 @@ static int flush_add_service(const char *site, const char *queue_id) * Map site to path and update log. */ site_path = flush_site_to_path((VSTRING *) 0, site); - status = valid_hostname(STR(site_path), DONT_GRIPE) ? - flush_add_path(STR(site_path), queue_id) : FLUSH_STAT_BAD; + status = flush_add_path(STR(site_path), queue_id); vstring_free(site_path); return (status); @@ -263,6 +265,12 @@ static int flush_add_path(const char *path, const char *queue_id) char *myname = "flush_add_path"; VSTREAM *log; + /* + * Sanity check. + */ + if (!mail_queue_id_ok(path)) + return (FLUSH_STAT_BAD); + /* * Open the logfile or bust. */ @@ -279,12 +287,14 @@ static int flush_add_path(const char *path, const char *queue_id) msg_fatal("%s: lock fast flush logfile %s: %m", myname, path); /* - * Append the queue ID. With 15 bits if microsecond time, a queue ID is + * Append the queue ID. With 15 bits of microsecond time, a queue ID is * not recycled often enough for false hits to be a problem. If it does, * then we could add other signature information, such as the file size * in bytes. */ vstream_fprintf(log, "%s\n", queue_id); + if (vstream_fflush(log)) + msg_warn("write fast flush logfile %s: %m", path); /* * Clean up. @@ -318,8 +328,7 @@ static int flush_send_service(const char *site) * Map site name to path name and flush the log. */ site_path = flush_site_to_path((VSTRING *) 0, site); - status = valid_hostname(STR(site_path), DONT_GRIPE) ? - flush_send_path(STR(site_path)) : FLUSH_STAT_BAD; + status = flush_send_path(STR(site_path)); vstring_free(site_path); return (status); @@ -341,6 +350,12 @@ static int flush_send_path(const char *path) HTABLE *dup_filter; int count; + /* + * Sanity check. + */ + if (!mail_queue_id_ok(path)) + return (FLUSH_STAT_BAD); + /* * Open the logfile. If the file does not exist, then there is no queued * mail for this destination. @@ -470,7 +485,7 @@ static int flush_refresh_service(int max_age) if (st.st_size == 0) { if (st.st_mtime + var_fflush_purge < event_time()) { if (unlink(STR(path)) < 0) - msg_warn("remove %s: %m", STR(path)); + msg_warn("remove logfile %s: %m", STR(path)); else if (msg_verbose) msg_info("%s: unlink %s, empty and unchanged for %d days", myname, STR(path), var_fflush_purge / 86400); @@ -516,9 +531,7 @@ static void flush_service(VSTREAM *client_stream, char *unused_service, * This routine runs whenever a client connects to the UNIX-domain socket * dedicated to the fast flush service. What we see below is a little * protocol to (1) read a request from the client (the name of the site) - * and (2) acknowledge that we have received the request. Since the site - * name maps onto the file system, make sure the site name is a valid - * SMTP hostname. + * and (2) acknowledge that we have received the request. * * All connection-management stuff is handled by the common code in * single_server.c. diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index b11e3b085..45bad947d 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -15,7 +15,7 @@ * Version of this program. */ #define VAR_MAIL_VERSION "mail_version" -#define DEF_MAIL_VERSION "Snapshot-20010324" +#define DEF_MAIL_VERSION "Snapshot-20010327" extern char *var_mail_version; /* LICENSE diff --git a/postfix/src/global/rewrite_clnt.c b/postfix/src/global/rewrite_clnt.c index dfb4cbce5..ba9049ad3 100644 --- a/postfix/src/global/rewrite_clnt.c +++ b/postfix/src/global/rewrite_clnt.c @@ -46,6 +46,7 @@ #include #include #include +#include /* Utility library. */ diff --git a/postfix/src/master/master_conf.c b/postfix/src/master/master_conf.c index 1bb8ba100..2c24cdb9c 100644 --- a/postfix/src/master/master_conf.c +++ b/postfix/src/master/master_conf.c @@ -36,6 +36,7 @@ #include #include +#include /* Utility library. */ diff --git a/postfix/src/master/master_status.c b/postfix/src/master/master_status.c index 40ad1508a..de0cc4d28 100644 --- a/postfix/src/master/master_status.c +++ b/postfix/src/master/master_status.c @@ -113,7 +113,7 @@ static void master_status_event(int event, char *context) } if (proc->serv != serv) msg_panic("%s: pointer corruption: %p != %p", - myname, (char *) proc->serv, (char *) serv); + myname, (void *) proc->serv, (void *) serv); /* * Update our idea of the child process status. Allow redundant status diff --git a/postfix/src/showq/showq.c b/postfix/src/showq/showq.c index 06fdb1c25..55cab747a 100644 --- a/postfix/src/showq/showq.c +++ b/postfix/src/showq/showq.c @@ -273,6 +273,7 @@ static void showq_service(VSTREAM *client, char *unused_service, char **argv) } else if (errno != ENOENT) msg_fatal("open %s %s: %m", *queue, id); file_count++; + vstream_fflush(client); } vstream_fflush(client); } diff --git a/postfix/src/util/msg_syslog.c b/postfix/src/util/msg_syslog.c index c2892d628..fb9301457 100644 --- a/postfix/src/util/msg_syslog.c +++ b/postfix/src/util/msg_syslog.c @@ -48,6 +48,7 @@ #include #include #include +#include /* Application-specific. */ diff --git a/postfix/src/util/watchdog.c b/postfix/src/util/watchdog.c index 011b2fcb6..14504e90d 100644 --- a/postfix/src/util/watchdog.c +++ b/postfix/src/util/watchdog.c @@ -133,7 +133,7 @@ static void watchdog_event(int unused_sig) if ((wp = watchdog_curr) == 0) msg_panic("%s: no instance", myname); if (msg_verbose) - msg_info("%s: %p %d", myname, (char *) wp, wp->trip_run); + msg_info("%s: %p %d", myname, (void *) wp, wp->trip_run); if (++(wp->trip_run) < WATCHDOG_STEPS) { alarm(wp->timeout); } else { @@ -169,7 +169,7 @@ WATCHDOG *watchdog_create(unsigned timeout, WATCHDOG_FN action, char *context) if (sigaction(SIGALRM, &sig_action, &wp->saved_action) < 0) msg_fatal("%s: sigaction(SIGALRM): %m", myname); if (msg_verbose) - msg_info("%s: %p %d", myname, (char *) wp, timeout); + msg_info("%s: %p %d", myname, (void *) wp, timeout); return (watchdog_curr = wp); } @@ -187,7 +187,7 @@ void watchdog_destroy(WATCHDOG *wp) alarm(wp->saved_time); myfree((char *) wp); if (msg_verbose) - msg_info("%s: %p", myname, (char *) wp); + msg_info("%s: %p", myname, (void *) wp); } /* watchdog_start - enable watchdog timer */ @@ -201,7 +201,7 @@ void watchdog_start(WATCHDOG *wp) wp->trip_run = 0; alarm(wp->timeout); if (msg_verbose) - msg_info("%s: %p", myname, (char *) wp); + msg_info("%s: %p", myname, (void *) wp); } /* watchdog_stop - disable watchdog timer */ @@ -214,7 +214,7 @@ void watchdog_stop(WATCHDOG *wp) msg_panic("%s: wrong watchdog instance", myname); alarm(0); if (msg_verbose) - msg_info("%s: %p", myname, (char *) wp); + msg_info("%s: %p", myname, (void *) wp); } /* watchdog_pat - pat the dog so it stays quiet */ @@ -226,7 +226,7 @@ void watchdog_pat(void) if (watchdog_curr) watchdog_curr->trip_run = 0; if (msg_verbose) - msg_info("%s: %p", myname, (char *) watchdog_curr); + msg_info("%s: %p", myname, (void *) watchdog_curr); } #ifdef TEST diff --git a/postfix/src/virtual/mailbox.c b/postfix/src/virtual/mailbox.c index 68f8c4f52..58894538e 100644 --- a/postfix/src/virtual/mailbox.c +++ b/postfix/src/virtual/mailbox.c @@ -42,6 +42,7 @@ #include #include #include +#include /* Utility library. */ diff --git a/postfix/src/virtual/virtual.c b/postfix/src/virtual/virtual.c index 86809ace5..14c388e8a 100644 --- a/postfix/src/virtual/virtual.c +++ b/postfix/src/virtual/virtual.c @@ -205,6 +205,7 @@ /* System library. */ #include +#include /* Utility library. */