summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/runner.c
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2009-01-04 19:37:42 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2009-01-04 19:37:42 +0000
commit5f61b60a6b0e894f17c28cac99a3482809e5c91c (patch)
tree3e4780b60352ac89371bc06211486df130824e86 /usr.sbin/smtpd/runner.c
parent199a745fdcd9bc8c19dce443d37061a3fc8dc147 (diff)
- runner is now capable of pausing/resuming the scheduling of deliveries
for both mda and mta batches. - smtpctl can be used to disable/enable deliveries at runtime using the pause/resume commands. ok jacekm@
Diffstat (limited to 'usr.sbin/smtpd/runner.c')
-rw-r--r--usr.sbin/smtpd/runner.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c
index 31996f7b898..3d22e04550c 100644
--- a/usr.sbin/smtpd/runner.c
+++ b/usr.sbin/smtpd/runner.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: runner.c,v 1.15 2009/01/04 19:26:30 jacekm Exp $ */
+/* $OpenBSD: runner.c,v 1.16 2009/01/04 19:37:41 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -72,6 +72,10 @@ void runner_purge_message(char *);
struct batch *batch_record(struct smtpd *, struct message *);
struct batch *batch_lookup(struct smtpd *, struct message *);
+#define RUNNER_MDA 0x1
+#define RUNNER_MTA 0x2
+u_int8_t runstates = RUNNER_MDA|RUNNER_MTA;
+
void
runner_sig_handler(int sig, short event, void *p)
{
@@ -121,6 +125,18 @@ runner_dispatch_control(int sig, short event, void *p)
break;
switch (imsg.hdr.type) {
+ case IMSG_RUNNER_PAUSE_MDA:
+ runstates &= ~RUNNER_MDA;
+ break;
+ case IMSG_RUNNER_PAUSE_MTA:
+ runstates &= ~RUNNER_MTA;
+ break;
+ case IMSG_RUNNER_RESUME_MDA:
+ runstates |= RUNNER_MDA;
+ break;
+ case IMSG_RUNNER_RESUME_MTA:
+ runstates |= RUNNER_MTA;
+ break;
default:
log_debug("queue_dispatch_control: unexpected imsg %d",
imsg.hdr.type);
@@ -719,6 +735,10 @@ runner_message_schedule(struct message *messagep, time_t tm)
if (messagep->flags & (F_MESSAGE_SCHEDULED|F_MESSAGE_PROCESSING))
return 0;
+ if (((messagep->type & T_MDA_MESSAGE) && !(runstates & RUNNER_MDA)) ||
+ ((messagep->type & T_MTA_MESSAGE) && !(runstates & RUNNER_MTA)))
+ return 0;
+
/* Batch has been in the queue for too long and expired */
if (tm - messagep->creation >= SMTPD_QUEUE_EXPIRY) {
queue_remove_envelope(messagep);