mirror of
https://github.com/vdukhovni/postfix
synced 2025-08-31 14:17:41 +00:00
snapshot-20010327
This commit is contained in:
committed by
Viktor Dukhovni
parent
709dd6ee2a
commit
c08f4e677f
@@ -4988,3 +4988,8 @@ Apologies for any names omitted.
|
|||||||
Bugfix: the fast ETRN flush server could not handle [ipaddr]
|
Bugfix: the fast ETRN flush server could not handle [ipaddr]
|
||||||
or domain names with one-character hostname part. It should
|
or domain names with one-character hostname part. It should
|
||||||
be OK now. File: flush/flush.c.
|
be OK now. File: flush/flush.c.
|
||||||
|
|
||||||
|
20010327
|
||||||
|
|
||||||
|
Speed up mailq (sendmail -bp) display by flushing output
|
||||||
|
after each file. File: showq/showq.c.
|
||||||
|
@@ -130,6 +130,7 @@
|
|||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/* Utility library. */
|
/* Utility library. */
|
||||||
|
|
||||||
@@ -139,7 +140,6 @@
|
|||||||
#include <vstring.h>
|
#include <vstring.h>
|
||||||
#include <vstring_vstream.h>
|
#include <vstring_vstream.h>
|
||||||
#include <myflock.h>
|
#include <myflock.h>
|
||||||
#include <valid_hostname.h>
|
|
||||||
#include <htable.h>
|
#include <htable.h>
|
||||||
#include <dict.h>
|
#include <dict.h>
|
||||||
#include <scan_dir.h>
|
#include <scan_dir.h>
|
||||||
@@ -164,7 +164,9 @@
|
|||||||
/* Application-specific. */
|
/* 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_refresh;
|
||||||
int var_fflush_purge;
|
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
|
* 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 */
|
#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)
|
#define STREQ(x,y) (strcmp(x,y) == 0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Forward declarations for where we broke routines along their name space
|
* Forward declarations resulting from breaking up routines according to
|
||||||
* domain boundaries (actually, hostnames versus safe-to-use pathnames).
|
* name space: domain names versus safe-to-use pathnames.
|
||||||
*/
|
*/
|
||||||
static int flush_add_path(const char *, const char *);
|
static int flush_add_path(const char *, const char *);
|
||||||
static int flush_send_path(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);
|
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)
|
while ((ch = *(unsigned const char *) site++) != 0)
|
||||||
if (ISALNUM(ch))
|
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.
|
* Map site to path and update log.
|
||||||
*/
|
*/
|
||||||
site_path = flush_site_to_path((VSTRING *) 0, site);
|
site_path = flush_site_to_path((VSTRING *) 0, site);
|
||||||
status = valid_hostname(STR(site_path), DONT_GRIPE) ?
|
status = flush_add_path(STR(site_path), queue_id);
|
||||||
flush_add_path(STR(site_path), queue_id) : FLUSH_STAT_BAD;
|
|
||||||
vstring_free(site_path);
|
vstring_free(site_path);
|
||||||
|
|
||||||
return (status);
|
return (status);
|
||||||
@@ -263,6 +265,12 @@ static int flush_add_path(const char *path, const char *queue_id)
|
|||||||
char *myname = "flush_add_path";
|
char *myname = "flush_add_path";
|
||||||
VSTREAM *log;
|
VSTREAM *log;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sanity check.
|
||||||
|
*/
|
||||||
|
if (!mail_queue_id_ok(path))
|
||||||
|
return (FLUSH_STAT_BAD);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open the logfile or bust.
|
* 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);
|
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,
|
* 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
|
* then we could add other signature information, such as the file size
|
||||||
* in bytes.
|
* in bytes.
|
||||||
*/
|
*/
|
||||||
vstream_fprintf(log, "%s\n", queue_id);
|
vstream_fprintf(log, "%s\n", queue_id);
|
||||||
|
if (vstream_fflush(log))
|
||||||
|
msg_warn("write fast flush logfile %s: %m", path);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clean up.
|
* Clean up.
|
||||||
@@ -318,8 +328,7 @@ static int flush_send_service(const char *site)
|
|||||||
* Map site name to path name and flush the log.
|
* Map site name to path name and flush the log.
|
||||||
*/
|
*/
|
||||||
site_path = flush_site_to_path((VSTRING *) 0, site);
|
site_path = flush_site_to_path((VSTRING *) 0, site);
|
||||||
status = valid_hostname(STR(site_path), DONT_GRIPE) ?
|
status = flush_send_path(STR(site_path));
|
||||||
flush_send_path(STR(site_path)) : FLUSH_STAT_BAD;
|
|
||||||
vstring_free(site_path);
|
vstring_free(site_path);
|
||||||
|
|
||||||
return (status);
|
return (status);
|
||||||
@@ -341,6 +350,12 @@ static int flush_send_path(const char *path)
|
|||||||
HTABLE *dup_filter;
|
HTABLE *dup_filter;
|
||||||
int count;
|
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
|
* Open the logfile. If the file does not exist, then there is no queued
|
||||||
* mail for this destination.
|
* mail for this destination.
|
||||||
@@ -470,7 +485,7 @@ static int flush_refresh_service(int max_age)
|
|||||||
if (st.st_size == 0) {
|
if (st.st_size == 0) {
|
||||||
if (st.st_mtime + var_fflush_purge < event_time()) {
|
if (st.st_mtime + var_fflush_purge < event_time()) {
|
||||||
if (unlink(STR(path)) < 0)
|
if (unlink(STR(path)) < 0)
|
||||||
msg_warn("remove %s: %m", STR(path));
|
msg_warn("remove logfile %s: %m", STR(path));
|
||||||
else if (msg_verbose)
|
else if (msg_verbose)
|
||||||
msg_info("%s: unlink %s, empty and unchanged for %d days",
|
msg_info("%s: unlink %s, empty and unchanged for %d days",
|
||||||
myname, STR(path), var_fflush_purge / 86400);
|
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
|
* 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
|
* 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)
|
* 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
|
* and (2) acknowledge that we have received the request.
|
||||||
* name maps onto the file system, make sure the site name is a valid
|
|
||||||
* SMTP hostname.
|
|
||||||
*
|
*
|
||||||
* All connection-management stuff is handled by the common code in
|
* All connection-management stuff is handled by the common code in
|
||||||
* single_server.c.
|
* single_server.c.
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* Version of this program.
|
* Version of this program.
|
||||||
*/
|
*/
|
||||||
#define VAR_MAIL_VERSION "mail_version"
|
#define VAR_MAIL_VERSION "mail_version"
|
||||||
#define DEF_MAIL_VERSION "Snapshot-20010324"
|
#define DEF_MAIL_VERSION "Snapshot-20010327"
|
||||||
extern char *var_mail_version;
|
extern char *var_mail_version;
|
||||||
|
|
||||||
/* LICENSE
|
/* LICENSE
|
||||||
|
@@ -46,6 +46,7 @@
|
|||||||
#include <sys_defs.h>
|
#include <sys_defs.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/* Utility library. */
|
/* Utility library. */
|
||||||
|
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include <sys_defs.h>
|
#include <sys_defs.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/* Utility library. */
|
/* Utility library. */
|
||||||
|
|
||||||
|
@@ -113,7 +113,7 @@ static void master_status_event(int event, char *context)
|
|||||||
}
|
}
|
||||||
if (proc->serv != serv)
|
if (proc->serv != serv)
|
||||||
msg_panic("%s: pointer corruption: %p != %p",
|
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
|
* Update our idea of the child process status. Allow redundant status
|
||||||
|
@@ -273,6 +273,7 @@ static void showq_service(VSTREAM *client, char *unused_service, char **argv)
|
|||||||
} else if (errno != ENOENT)
|
} else if (errno != ENOENT)
|
||||||
msg_fatal("open %s %s: %m", *queue, id);
|
msg_fatal("open %s %s: %m", *queue, id);
|
||||||
file_count++;
|
file_count++;
|
||||||
|
vstream_fflush(client);
|
||||||
}
|
}
|
||||||
vstream_fflush(client);
|
vstream_fflush(client);
|
||||||
}
|
}
|
||||||
|
@@ -48,6 +48,7 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/* Application-specific. */
|
/* Application-specific. */
|
||||||
|
|
||||||
|
@@ -133,7 +133,7 @@ static void watchdog_event(int unused_sig)
|
|||||||
if ((wp = watchdog_curr) == 0)
|
if ((wp = watchdog_curr) == 0)
|
||||||
msg_panic("%s: no instance", myname);
|
msg_panic("%s: no instance", myname);
|
||||||
if (msg_verbose)
|
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) {
|
if (++(wp->trip_run) < WATCHDOG_STEPS) {
|
||||||
alarm(wp->timeout);
|
alarm(wp->timeout);
|
||||||
} else {
|
} else {
|
||||||
@@ -169,7 +169,7 @@ WATCHDOG *watchdog_create(unsigned timeout, WATCHDOG_FN action, char *context)
|
|||||||
if (sigaction(SIGALRM, &sig_action, &wp->saved_action) < 0)
|
if (sigaction(SIGALRM, &sig_action, &wp->saved_action) < 0)
|
||||||
msg_fatal("%s: sigaction(SIGALRM): %m", myname);
|
msg_fatal("%s: sigaction(SIGALRM): %m", myname);
|
||||||
if (msg_verbose)
|
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);
|
return (watchdog_curr = wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ void watchdog_destroy(WATCHDOG *wp)
|
|||||||
alarm(wp->saved_time);
|
alarm(wp->saved_time);
|
||||||
myfree((char *) wp);
|
myfree((char *) wp);
|
||||||
if (msg_verbose)
|
if (msg_verbose)
|
||||||
msg_info("%s: %p", myname, (char *) wp);
|
msg_info("%s: %p", myname, (void *) wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* watchdog_start - enable watchdog timer */
|
/* watchdog_start - enable watchdog timer */
|
||||||
@@ -201,7 +201,7 @@ void watchdog_start(WATCHDOG *wp)
|
|||||||
wp->trip_run = 0;
|
wp->trip_run = 0;
|
||||||
alarm(wp->timeout);
|
alarm(wp->timeout);
|
||||||
if (msg_verbose)
|
if (msg_verbose)
|
||||||
msg_info("%s: %p", myname, (char *) wp);
|
msg_info("%s: %p", myname, (void *) wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* watchdog_stop - disable watchdog timer */
|
/* watchdog_stop - disable watchdog timer */
|
||||||
@@ -214,7 +214,7 @@ void watchdog_stop(WATCHDOG *wp)
|
|||||||
msg_panic("%s: wrong watchdog instance", myname);
|
msg_panic("%s: wrong watchdog instance", myname);
|
||||||
alarm(0);
|
alarm(0);
|
||||||
if (msg_verbose)
|
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 */
|
/* watchdog_pat - pat the dog so it stays quiet */
|
||||||
@@ -226,7 +226,7 @@ void watchdog_pat(void)
|
|||||||
if (watchdog_curr)
|
if (watchdog_curr)
|
||||||
watchdog_curr->trip_run = 0;
|
watchdog_curr->trip_run = 0;
|
||||||
if (msg_verbose)
|
if (msg_verbose)
|
||||||
msg_info("%s: %p", myname, (char *) watchdog_curr);
|
msg_info("%s: %p", myname, (void *) watchdog_curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
|
@@ -42,6 +42,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/* Utility library. */
|
/* Utility library. */
|
||||||
|
|
||||||
|
@@ -205,6 +205,7 @@
|
|||||||
/* System library. */
|
/* System library. */
|
||||||
|
|
||||||
#include <sys_defs.h>
|
#include <sys_defs.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* Utility library. */
|
/* Utility library. */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user