From 5f61b60a6b0e894f17c28cac99a3482809e5c91c Mon Sep 17 00:00:00 2001 From: Gilles Chehade Date: Sun, 4 Jan 2009 19:37:42 +0000 Subject: - 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@ --- usr.sbin/smtpd/control.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'usr.sbin/smtpd/control.c') diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c index 04370e980fc..a1905876d4d 100644 --- a/usr.sbin/smtpd/control.c +++ b/usr.sbin/smtpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.5 2009/01/01 16:15:47 jacekm Exp $ */ +/* $OpenBSD: control.c,v 1.6 2009/01/04 19:37:41 gilles Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -311,6 +311,51 @@ control_dispatch_ext(int fd, short event, void *arg) env->sc_flags |= SMTPD_EXITING; imsg_compose(&c->ibuf, IMSG_CTL_OK, 0, 0, -1, NULL, 0); break; + case IMSG_RUNNER_PAUSE_MDA: + if (env->sc_flags & SMTPD_MDA_PAUSED) { + imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1, + NULL, 0); + break; + } + env->sc_flags |= SMTPD_MDA_PAUSED; + imsg_compose(env->sc_ibufs[PROC_RUNNER], IMSG_RUNNER_PAUSE_MDA, + 0, 0, -1, NULL, 0); + imsg_compose(&c->ibuf, IMSG_CTL_OK, 0, 0, -1, NULL, 0); + break; + case IMSG_RUNNER_PAUSE_MTA: + if (env->sc_flags & SMTPD_MTA_PAUSED) { + imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1, + NULL, 0); + break; + } + env->sc_flags |= SMTPD_MTA_PAUSED; + imsg_compose(env->sc_ibufs[PROC_RUNNER], IMSG_RUNNER_PAUSE_MTA, + 0, 0, -1, NULL, 0); + imsg_compose(&c->ibuf, IMSG_CTL_OK, 0, 0, -1, NULL, 0); + break; + case IMSG_RUNNER_RESUME_MDA: + if (! (env->sc_flags & SMTPD_MDA_PAUSED)) { + imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1, + NULL, 0); + break; + } + env->sc_flags &= ~SMTPD_MDA_PAUSED; + imsg_compose(env->sc_ibufs[PROC_RUNNER], IMSG_RUNNER_RESUME_MDA, + 0, 0, -1, NULL, 0); + imsg_compose(&c->ibuf, IMSG_CTL_OK, 0, 0, -1, NULL, 0); + break; + case IMSG_RUNNER_RESUME_MTA: + if (!(env->sc_flags & SMTPD_MTA_PAUSED)) { + imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1, + NULL, 0); + break; + } + env->sc_flags &= ~SMTPD_MTA_PAUSED; + imsg_compose(env->sc_ibufs[PROC_RUNNER], IMSG_RUNNER_RESUME_MTA, + 0, 0, -1, NULL, 0); + imsg_compose(&c->ibuf, IMSG_CTL_OK, 0, 0, -1, NULL, 0); + break; + default: log_debug("control_dispatch_ext: " "error handling imsg %d", imsg.hdr.type); -- cgit v1.2.3