diff options
Diffstat (limited to 'usr.sbin/smtpd/queue.c')
-rw-r--r-- | usr.sbin/smtpd/queue.c | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index bc6635827c6..239d31f4731 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.140 2012/10/25 09:51:08 eric Exp $ */ +/* $OpenBSD: queue.c,v 1.141 2012/11/12 14:58:53 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -146,7 +146,8 @@ queue_imsg(struct imsgev *iev, struct imsg *imsg) id = *(uint64_t*)(imsg->data); if (queue_envelope_load(id, &evp) == 0) errx(1, "cannot load evp:%016" PRIx64, id); - log_envelope(&evp, NULL, "Removed by administrator"); + log_envelope(&evp, NULL, "Remove", + "Removed by administrator"); queue_envelope_delete(&evp); return; @@ -156,7 +157,7 @@ queue_imsg(struct imsgev *iev, struct imsg *imsg) errx(1, "cannot load evp:%016" PRIx64, id); envelope_set_errormsg(&evp, "Envelope expired"); queue_bounce(&evp); - log_envelope(&evp, NULL, evp.errorline); + log_envelope(&evp, NULL, "Expire", evp.errorline); queue_envelope_delete(&evp); return; @@ -290,19 +291,20 @@ queue_bounce(struct envelope *e) b.expire = 3600 * 24 * 7; if (e->type == D_BOUNCE) { - log_warnx("queue: double bounce!"); + log_warnx("warn: queue: double bounce!"); } else if (e->sender.user[0] == '\0') { - log_warnx("queue: no return path!"); + log_warnx("warn: queue: no return path!"); } else if (!queue_envelope_create(&b)) { - log_warnx("queue: cannot bounce!"); + log_warnx("warn: queue: cannot bounce!"); } else { - log_debug("queue: bouncing evp:%016" PRIx64 + log_debug("debug: queue: bouncing evp:%016" PRIx64 " as evp:%016" PRIx64, e->id, b.id); imsg_compose_event(env->sc_ievs[PROC_SCHEDULER], IMSG_QUEUE_SUBMIT_ENVELOPE, 0, 0, -1, &b, sizeof b); msgid = evpid_to_msgid(b.id); imsg_compose_event(env->sc_ievs[PROC_SCHEDULER], IMSG_QUEUE_COMMIT_MESSAGE, 0, 0, -1, &msgid, sizeof msgid); + stat_increment("queue.bounce", 1); } } @@ -322,7 +324,7 @@ queue_sig_handler(int sig, short event, void *p) static void queue_shutdown(void) { - log_info("queue handler exiting"); + log_info("info: queue handler exiting"); _exit(0); } @@ -404,41 +406,49 @@ static void queue_timeout(int fd, short event, void *p) { static struct qwalk *q = NULL; - static uint32_t last_msgid = 0; + static uint32_t msgid = 0; + static size_t evpcount = 0; struct event *ev = p; struct envelope envelope; struct timeval tv; uint64_t evpid; if (q == NULL) { - log_debug("queue: loading queue into scheduler"); + log_debug("debug: queue: loading queue into scheduler"); q = qwalk_new(0); } while (qwalk(q, &evpid)) { - if (queue_envelope_load(evpid, &envelope)) + if (! queue_envelope_load(evpid, &envelope)) + log_warnx("warn: Failed to load envelope %016"PRIx64, + evpid); + else { imsg_compose_event(env->sc_ievs[PROC_SCHEDULER], IMSG_QUEUE_SUBMIT_ENVELOPE, 0, 0, -1, &envelope, sizeof envelope); + evpcount++; + } - if (last_msgid && evpid_to_msgid(evpid) != last_msgid) + if (msgid && evpid_to_msgid(evpid) != msgid && evpcount) { imsg_compose_event(env->sc_ievs[PROC_SCHEDULER], - IMSG_QUEUE_COMMIT_MESSAGE, 0, 0, -1, &last_msgid, - sizeof last_msgid); + IMSG_QUEUE_COMMIT_MESSAGE, 0, 0, -1, &msgid, + sizeof msgid); + evpcount = 0; + } - last_msgid = evpid_to_msgid(evpid); + msgid = evpid_to_msgid(evpid); tv.tv_sec = 0; tv.tv_usec = 0; evtimer_add(ev, &tv); return; } - if (last_msgid) { + if (msgid && evpcount) { imsg_compose_event(env->sc_ievs[PROC_SCHEDULER], - IMSG_QUEUE_COMMIT_MESSAGE, 0, 0, -1, &last_msgid, - sizeof last_msgid); + IMSG_QUEUE_COMMIT_MESSAGE, 0, 0, -1, &msgid, sizeof msgid); + evpcount = 0; } - log_debug("queue: done loading queue into scheduler"); + log_debug("debug: queue: done loading queue into scheduler"); qwalk_close(q); } |