diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2012-01-12 22:00:22 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2012-01-12 22:00:22 +0000 |
commit | 54843fee6d2ccc1c42edae527d1092d8b1729b2c (patch) | |
tree | cee334e578ca032221195ae268068847b218fbe6 | |
parent | 2a37fb393f776fbe5b20aa19dc7fea868346d2ec (diff) |
now that we no longer do a stateful iteration on schedule queue, we need
to make ramqueue_next_envelope() aware of pauses in mda/mta. while at it
kill the pausing of bounces since they are reinjected in smtp and end up
paused by the mda/mta cases.
fixes an infinite loop observed by eric@ when pausing deliveries and
trying to interrupt smtpd while it attempts to fetch next envelope :)
tested by eric@ and I, ok eric@
-rw-r--r-- | usr.sbin/smtpd/ramqueue.c | 18 | ||||
-rw-r--r-- | usr.sbin/smtpd/runner.c | 17 |
2 files changed, 18 insertions, 17 deletions
diff --git a/usr.sbin/smtpd/ramqueue.c b/usr.sbin/smtpd/ramqueue.c index a2c586f6a29..8d21afb75f3 100644 --- a/usr.sbin/smtpd/ramqueue.c +++ b/usr.sbin/smtpd/ramqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ramqueue.c,v 1.28 2012/01/11 22:55:16 gilles Exp $ */ +/* $OpenBSD: ramqueue.c,v 1.29 2012/01/12 22:00:21 gilles Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org> @@ -95,7 +95,19 @@ ramqueue_first_envelope(struct ramqueue *rqueue) struct ramqueue_envelope * ramqueue_next_envelope(struct ramqueue *rqueue) { - return TAILQ_FIRST(&rqueue->queue); + struct ramqueue_envelope *rq_evp = NULL; + + TAILQ_FOREACH(rq_evp, &rqueue->queue, queue_entry) { + if (rq_evp->rq_batch->type == D_MDA) + if (env->sc_opts & SMTPD_MDA_PAUSED) + continue; + if (rq_evp->rq_batch->type == D_MTA) + if (env->sc_opts & SMTPD_MTA_PAUSED) + continue; + break; + } + + return rq_evp; } struct ramqueue_envelope * @@ -107,12 +119,10 @@ ramqueue_batch_first_envelope(struct ramqueue_batch *rq_batch) int ramqueue_load(struct ramqueue *rqueue, time_t *nsched) { -// char path[MAXPATHLEN]; time_t curtm; struct envelope envelope; static struct qwalk *q = NULL; struct ramqueue_envelope *rq_evp; -// u_int32_t msgid; u_int64_t evpid; log_debug("ramqueue: queue loading in progress"); diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c index 391a777ff05..7c41816d17e 100644 --- a/usr.sbin/smtpd/runner.c +++ b/usr.sbin/smtpd/runner.c @@ -1,4 +1,4 @@ -/* $OpenBSD: runner.c,v 1.127 2012/01/11 17:46:36 eric Exp $ */ +/* $OpenBSD: runner.c,v 1.128 2012/01/12 22:00:21 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -353,26 +353,17 @@ runner_process_envelope(struct ramqueue_envelope *rq_evp, time_t curtm) mda_av = env->sc_maxconn - stat_get(STATS_MDA_SESSION, STAT_ACTIVE); bnc_av = env->sc_maxconn - stat_get(STATS_RUNNER_BOUNCES, STAT_ACTIVE); - if (rq_evp->rq_batch->type == D_MDA) { - if (env->sc_opts & SMTPD_MDA_PAUSED) - return 0; + if (rq_evp->rq_batch->type == D_MDA) if (mda_av == 0) return 0; - } - if (rq_evp->rq_batch->type == D_MTA) { - if (env->sc_opts & SMTPD_MTA_PAUSED) - return 0; + if (rq_evp->rq_batch->type == D_MTA) if (mta_av == 0) return 0; - } - if (rq_evp->rq_batch->type == D_BOUNCE) { - if (env->sc_opts & (SMTPD_MDA_PAUSED|SMTPD_MTA_PAUSED)) - return 0; + if (rq_evp->rq_batch->type == D_BOUNCE) if (bnc_av == 0) return 0; - } if (! queue_envelope_load(Q_QUEUE, rq_evp->evpid, &envelope)) return 0; |