summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/smtp.c
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2011-09-01 19:56:50 +0000
committerEric Faurot <eric@cvs.openbsd.org>2011-09-01 19:56:50 +0000
commitad47ec1eeb8b886915ea232368f798df48ab734d (patch)
treeb82ac55260162a3f1cdc3b009a94233126a1ecfc /usr.sbin/smtpd/smtp.c
parent9541d1e9935ed1f995936e6a2abd46c1ee30eaed (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/smtp.c')
-rw-r--r--usr.sbin/smtpd/smtp.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c
index 7614ca1344b..0718ce5b8f9 100644
--- a/usr.sbin/smtpd/smtp.c
+++ b/usr.sbin/smtpd/smtp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp.c,v 1.89 2011/08/31 18:56:30 gilles Exp $ */
+/* $OpenBSD: smtp.c,v 1.90 2011/09/01 19:56:49 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -533,12 +533,6 @@ smtp_new(struct listener *l)
if (env->sc_opts & SMTPD_SMTP_PAUSED)
fatalx("smtp_new: unexpected client");
- if (env->stats->smtp.sessions_active >= env->sc_maxconn) {
- log_warnx("client limit hit, disabling incoming connections");
- smtp_pause();
- return (NULL);
- }
-
if ((s = calloc(1, sizeof(*s))) == NULL)
fatal(NULL);
s->s_id = generate_uid();
@@ -546,17 +540,15 @@ smtp_new(struct listener *l)
strlcpy(s->s_msg.tag, l->tag, sizeof(s->s_msg.tag));
SPLAY_INSERT(sessiontree, &env->sc_sessions, s);
- env->stats->smtp.sessions++;
- env->stats->smtp.sessions_active++;
+ if (stat_increment(STATS_SMTP_SESSION) >= env->sc_maxconn) {
+ log_warnx("client limit hit, disabling incoming connections");
+ smtp_pause();
+ }
if (s->s_l->ss.ss_family == AF_INET)
- env->stats->smtp.sessions_inet4++;
+ stat_increment(STATS_SMTP_SESSION_INET4);
if (s->s_l->ss.ss_family == AF_INET6)
- env->stats->smtp.sessions_inet6++;
-
- SET_IF_GREATER(env->stats->smtp.sessions_active,
- env->stats->smtp.sessions_maxactive);
-
+ stat_increment(STATS_SMTP_SESSION_INET6);
return (s);
}