diff options
Diffstat (limited to 'usr.sbin/smtpd/runner.c')
-rw-r--r-- | usr.sbin/smtpd/runner.c | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c index 1592cbe19d1..c08f8d220ff 100644 --- a/usr.sbin/smtpd/runner.c +++ b/usr.sbin/smtpd/runner.c @@ -1,4 +1,4 @@ -/* $OpenBSD: runner.c,v 1.74 2009/12/14 16:44:14 jacekm Exp $ */ +/* $OpenBSD: runner.c,v 1.75 2009/12/14 18:21:53 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -632,8 +632,13 @@ runner_process_queue(struct smtpd *env) char rqpath[MAXPATHLEN]; struct message message; time_t now; + size_t mta_av, mda_av, bnc_av; struct qwalk *q; + mta_av = env->sc_maxconn - env->stats->mta.sessions_active; + mda_av = env->sc_maxconn - env->stats->mda.sessions_active; + bnc_av = env->sc_maxconn - env->stats->runner.bounces_active; + now = time(NULL); q = qwalk_new(PATH_QUEUE); @@ -644,14 +649,21 @@ runner_process_queue(struct smtpd *env) if (message.type & T_MDA_MESSAGE) { if (env->sc_opts & SMTPD_MDA_PAUSED) continue; - if (env->stats->mda.sessions_active >= env->sc_maxconn) + if (mda_av == 0) continue; } if (message.type & T_MTA_MESSAGE) { if (env->sc_opts & SMTPD_MTA_PAUSED) continue; - if (env->stats->mta.sessions_active >= env->sc_maxconn) + if (mta_av == 0) + continue; + } + + if (message.type & T_BOUNCE_MESSAGE) { + if (env->sc_opts & (SMTPD_MDA_PAUSED|SMTPD_MTA_PAUSED)) + continue; + if (bnc_av == 0) continue; } @@ -681,15 +693,12 @@ runner_process_queue(struct smtpd *env) fatal("runner_process_queue: symlink"); } - if (message.type & T_MDA_MESSAGE) { - env->stats->mda.sessions_active++; - env->stats->mda.sessions++; - } - - if (message.type & T_MTA_MESSAGE) { - env->stats->mta.sessions_active++; - env->stats->mta.sessions++; - } + if (message.type & T_MDA_MESSAGE) + mda_av--; + if (message.type & T_MTA_MESSAGE) + mta_av--; + if (message.type & T_BOUNCE_MESSAGE) + bnc_av--; } qwalk_close(q); @@ -780,13 +789,20 @@ runner_batch_dispatch(struct smtpd *env, struct batch *batchp, time_t curtime) bzero(messagep, sizeof(*messagep)); free(messagep); } + env->stats->runner.bounces_active++; + env->stats->runner.bounces++; return; } - if (batchp->type & T_MDA_BATCH) + if (batchp->type & T_MDA_BATCH) { proctype = PROC_MDA; - else if (batchp->type & T_MTA_BATCH) + env->stats->mda.sessions_active++; + env->stats->mda.sessions++; + } else if (batchp->type & T_MTA_BATCH) { proctype = PROC_MTA; + env->stats->mta.sessions_active++; + env->stats->mta.sessions++; + } imsg_compose_event(env->sc_ievs[proctype], IMSG_BATCH_CREATE, 0, 0, -1, batchp, sizeof (struct batch)); |