diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2011-09-01 19:56:50 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2011-09-01 19:56:50 +0000 |
commit | ad47ec1eeb8b886915ea232368f798df48ab734d (patch) | |
tree | b82ac55260162a3f1cdc3b009a94233126a1ecfc /usr.sbin/smtpd/control.c | |
parent | 9541d1e9935ed1f995936e6a2abd46c1ee30eaed (diff) |
Introduce a small set of functions to manage stat counters in a
simpler and hopefully saner way.
ok gilles@ chl@
Diffstat (limited to 'usr.sbin/smtpd/control.c')
-rw-r--r-- | usr.sbin/smtpd/control.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c index 52749cfc2a7..3be91e81407 100644 --- a/usr.sbin/smtpd/control.c +++ b/usr.sbin/smtpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.59 2011/07/21 23:29:24 gilles Exp $ */ +/* $OpenBSD: control.c,v 1.60 2011/09/01 19:56:49 eric Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -267,12 +267,7 @@ control_accept(int listenfd, short event, void *arg) event_add(&c->iev.ev, NULL); TAILQ_INSERT_TAIL(&ctl_conns, c, entry); - env->stats->control.sessions++; - env->stats->control.sessions_active++; - SET_IF_GREATER(env->stats->control.sessions_active, - env->stats->control.sessions_maxactive); - - if (env->stats->control.sessions_active >= env->sc_maxconn) { + if (stat_increment(STATS_CONTROL_SESSION) >= env->sc_maxconn) { log_warnx("ctl client limit hit, disabling new connections"); event_del(&control_state.ev); } @@ -305,10 +300,8 @@ control_close(int fd) close(fd); free(c); - env->stats->control.sessions_active--; - - if (!event_pending(&control_state.ev, EV_READ, NULL) && - env->stats->control.sessions_active < env->sc_maxconn) { + if (stat_decrement(STATS_CONTROL_SESSION) < env->sc_maxconn && + !event_pending(&control_state.ev, EV_READ, NULL)) { log_warnx("re-enabling ctl connections"); event_add(&control_state.ev, NULL); } |