From ad47ec1eeb8b886915ea232368f798df48ab734d Mon Sep 17 00:00:00 2001 From: Eric Faurot Date: Thu, 1 Sep 2011 19:56:50 +0000 Subject: Introduce a small set of functions to manage stat counters in a simpler and hopefully saner way. ok gilles@ chl@ --- usr.sbin/smtpd/control.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'usr.sbin/smtpd/control.c') 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 @@ -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); } -- cgit v1.2.3