diff options
author | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2009-12-14 18:21:54 +0000 |
---|---|---|
committer | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2009-12-14 18:21:54 +0000 |
commit | 13791bc79521b97c43818ba91b5638d84ad295c8 (patch) | |
tree | 90caae43dfc82beb698accde04551ad47e2b33e4 | |
parent | 6aaee87619dad173d0bf1228cee7ee184a118ec5 (diff) |
Control maximum number of bounce sessions similarly to how the mta and mda
are now controlled.
-rw-r--r-- | usr.sbin/smtpd/bounce.c | 6 | ||||
-rw-r--r-- | usr.sbin/smtpd/runner.c | 44 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpctl.c | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 4 |
4 files changed, 41 insertions, 17 deletions
diff --git a/usr.sbin/smtpd/bounce.c b/usr.sbin/smtpd/bounce.c index a313b8503a5..95813eea19c 100644 --- a/usr.sbin/smtpd/bounce.c +++ b/usr.sbin/smtpd/bounce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bounce.c,v 1.14 2009/12/12 14:03:59 jacekm Exp $ */ +/* $OpenBSD: bounce.c,v 1.15 2009/12/14 18:21:53 jacekm Exp $ */ /* * Copyright (c) 2009 Gilles Chehade <gilles@openbsd.org> @@ -40,6 +40,7 @@ struct client_ctx { struct event ev; struct message m; struct smtp_client *pcb; + struct smtpd *env; }; void bounce_event(int, short, void *); @@ -66,6 +67,7 @@ bounce_session(struct smtpd *env, int fd, struct message *messagep) if ((cc = calloc(1, sizeof(*cc))) == NULL) goto fail; cc->pcb = client_init(fd, msgfd, env->sc_hostname, 1); + cc->env = env; cc->m = *messagep; client_ssl_optional(cc->pcb); @@ -156,6 +158,8 @@ out: queue_message_update(&cc->m); } + cc->env->stats->runner.active--; + cc->env->stats->runner.bounces_active--; client_close(cc->pcb); free(cc); return; 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)); diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c index 6316de3e4b2..99137c99de6 100644 --- a/usr.sbin/smtpd/smtpctl.c +++ b/usr.sbin/smtpd/smtpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpctl.c,v 1.43 2009/12/14 16:44:14 jacekm Exp $ */ +/* $OpenBSD: smtpctl.c,v 1.44 2009/12/14 18:21:53 jacekm Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -288,6 +288,8 @@ show_stats_output(struct imsg *imsg) printf("queue.inserts.remote=%zd\n", stats->queue.inserts_remote); printf("runner.active=%zd\n", stats->runner.active); + printf("runner.bounces=%zd\n", stats->runner.bounces); + printf("runner.bounces.active=%zd\n", stats->runner.bounces_active); printf("smtp.errors.delays=%zd\n", stats->smtp.delays); printf("smtp.errors.linetoolong=%zd\n", stats->smtp.linetoolong); diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 54b1719f99c..2b319e0bba5 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.163 2009/12/14 16:44:14 jacekm Exp $ */ +/* $OpenBSD: smtpd.h,v 1.164 2009/12/14 18:21:53 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -649,6 +649,8 @@ struct s_queue { struct s_runner { size_t active; + size_t bounces_active; + size_t bounces; }; struct s_session { |