diff options
Diffstat (limited to 'usr.sbin/smtpd/scheduler.c')
-rw-r--r-- | usr.sbin/smtpd/scheduler.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/usr.sbin/smtpd/scheduler.c b/usr.sbin/smtpd/scheduler.c index 7971ae3be24..efe2cbf7622 100644 --- a/usr.sbin/smtpd/scheduler.c +++ b/usr.sbin/smtpd/scheduler.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scheduler.c,v 1.35 2013/10/27 17:47:53 eric Exp $ */ +/* $OpenBSD: scheduler.c,v 1.36 2013/11/19 10:01:20 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -57,6 +57,7 @@ static void scheduler_process_mta(struct scheduler_batch *); static struct scheduler_backend *backend = NULL; static struct event ev; +static size_t ninflight; extern const char *backend_scheduler; @@ -128,8 +129,11 @@ scheduler_imsg(struct mproc *p, struct imsg *imsg) stat_decrement("scheduler.envelope", 1); if (! inflight) backend->remove(evpid); - else + else { backend->delete(evpid); + ninflight -= 1; + stat_decrement("scheduler.envelope.inflight", 1); + } scheduler_reset_events(); return; @@ -141,6 +145,7 @@ scheduler_imsg(struct mproc *p, struct imsg *imsg) log_trace(TRACE_SCHEDULER, "scheduler: deleting evp:%016" PRIx64 " (ok)", evpid); backend->delete(evpid); + ninflight -= 1; stat_increment("scheduler.delivery.ok", 1); stat_decrement("scheduler.envelope.inflight", 1); stat_decrement("scheduler.envelope", 1); @@ -156,6 +161,7 @@ scheduler_imsg(struct mproc *p, struct imsg *imsg) "scheduler: updating evp:%016" PRIx64, evp.id); scheduler_info(&si, &evp, penalty); backend->update(&si); + ninflight -= 1; stat_increment("scheduler.delivery.tempfail", 1); stat_decrement("scheduler.envelope.inflight", 1); @@ -185,6 +191,7 @@ scheduler_imsg(struct mproc *p, struct imsg *imsg) log_trace(TRACE_SCHEDULER, "scheduler: deleting evp:%016" PRIx64 " (fail)", evpid); backend->delete(evpid); + ninflight -= 1; stat_increment("scheduler.delivery.permfail", 1); stat_decrement("scheduler.envelope.inflight", 1); stat_decrement("scheduler.envelope", 1); @@ -198,6 +205,7 @@ scheduler_imsg(struct mproc *p, struct imsg *imsg) log_trace(TRACE_SCHEDULER, "scheduler: deleting evp:%016" PRIx64 " (loop)", evpid); backend->delete(evpid); + ninflight -= 1; stat_increment("scheduler.delivery.loop", 1); stat_decrement("scheduler.envelope.inflight", 1); stat_decrement("scheduler.envelope", 1); @@ -213,6 +221,7 @@ scheduler_imsg(struct mproc *p, struct imsg *imsg) "scheduler: holding evp:%016" PRIx64 " on %016" PRIx64, evpid, holdq); backend->hold(evpid, holdq); + ninflight -= 1; stat_decrement("scheduler.envelope.inflight", 1); scheduler_reset_events(); return; @@ -458,9 +467,11 @@ scheduler_timeout(int fd, short event, void *p) tv.tv_usec = 0; typemask = SCHED_REMOVE | SCHED_EXPIRE | SCHED_BOUNCE; - if (!(env->sc_flags & SMTPD_MDA_PAUSED)) + if (ninflight < env->sc_scheduler_max_inflight && + !(env->sc_flags & SMTPD_MDA_PAUSED)) typemask |= SCHED_MDA; - if (!(env->sc_flags & SMTPD_MTA_PAUSED)) + if (ninflight < env->sc_scheduler_max_inflight && + !(env->sc_flags & SMTPD_MTA_PAUSED)) typemask |= SCHED_MTA; bzero(&batch, sizeof (batch)); @@ -564,6 +575,7 @@ scheduler_process_bounce(struct scheduler_batch *batch) m_close(p_queue); } + ninflight += batch->evpcount; stat_increment("scheduler.envelope.inflight", batch->evpcount); } @@ -580,6 +592,7 @@ scheduler_process_mda(struct scheduler_batch *batch) m_close(p_queue); } + ninflight += batch->evpcount; stat_increment("scheduler.envelope.inflight", batch->evpcount); } @@ -596,5 +609,6 @@ scheduler_process_mta(struct scheduler_batch *batch) m_close(p_queue); } + ninflight += batch->evpcount; stat_increment("scheduler.envelope.inflight", batch->evpcount); } |