2
0
mirror of https://github.com/vdukhovni/postfix synced 2025-08-30 05:38:06 +00:00

snapshot-20010327

This commit is contained in:
Wietse Venema 2001-03-27 00:00:00 -05:00 committed by Viktor Dukhovni
parent 709dd6ee2a
commit c08f4e677f
11 changed files with 47 additions and 23 deletions

View File

@ -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.

View File

@ -130,6 +130,7 @@
#include <utime.h>
#include <errno.h>
#include <ctype.h>
#include <string.h>
/* Utility library. */
@ -139,7 +140,6 @@
#include <vstring.h>
#include <vstring_vstream.h>
#include <myflock.h>
#include <valid_hostname.h>
#include <htable.h>
#include <dict.h>
#include <scan_dir.h>
@ -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.

View File

@ -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

View File

@ -46,6 +46,7 @@
#include <sys_defs.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
/* Utility library. */

View File

@ -36,6 +36,7 @@
#include <sys_defs.h>
#include <unistd.h>
#include <string.h>
/* Utility library. */

View File

@ -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

View File

@ -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);
}

View File

@ -48,6 +48,7 @@
#include <stdarg.h>
#include <errno.h>
#include <syslog.h>
#include <string.h>
/* Application-specific. */

View File

@ -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

View File

@ -42,6 +42,7 @@
#include <sys/stat.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
/* Utility library. */

View File

@ -205,6 +205,7 @@
/* System library. */
#include <sys_defs.h>
#include <stdlib.h>
/* Utility library. */