summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/smtp_session.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/smtpd/smtp_session.c')
-rw-r--r--usr.sbin/smtpd/smtp_session.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index 396f3ef3fb1..d173fef7599 100644
--- a/usr.sbin/smtpd/smtp_session.c
+++ b/usr.sbin/smtpd/smtp_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp_session.c,v 1.164 2012/08/18 16:05:54 chl Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.165 2012/08/18 18:18:23 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -610,9 +610,9 @@ session_io(struct io *io, int evt)
case IO_TLSREADY:
s->s_flags |= F_SECURE;
if (s->s_l->flags & F_SMTPS)
- stat_increment(STATS_SMTP_SMTPS);
+ stat_increment("smtp.smtps");
if (s->s_l->flags & F_STARTTLS)
- stat_increment(STATS_SMTP_STARTTLS);
+ stat_increment("smtp.tls");
if (s->s_state == S_INIT) {
io_set_write(&s->s_io);
session_respond(s, SMTPD_BANNER, env->sc_hostname);
@@ -694,7 +694,7 @@ session_pickup(struct session *s, struct submit_status *ss)
if ((ss != NULL && ss->code == 421) ||
(s->s_dstatus & DS_TEMPFAILURE)) {
- env->stats->smtp.tempfail++;
+ stat_increment("smtp.tempfail");
session_respond(s, "421 Service temporarily unavailable");
session_enter_state(s, S_QUIT);
io_reload(&s->s_io);
@@ -924,7 +924,7 @@ session_line(struct session *s, char *line, size_t len)
tempfail:
session_respond(s, "421 4.0.0 Service temporarily unavailable");
- env->stats->smtp.tempfail++;
+ stat_increment("smtp.tempfail");
session_enter_state(s, S_QUIT);
}
@@ -947,7 +947,7 @@ session_read_data(struct session *s, char *line)
} else if (s->s_dstatus & DS_TEMPFAILURE) {
session_respond(s, "421 4.0.0 Temporary failure");
session_enter_state(s, S_QUIT);
- env->stats->smtp.tempfail++;
+ stat_increment("smtp.tempfail");
} else {
session_imsg(s, PROC_QUEUE, IMSG_QUEUE_COMMIT_MESSAGE,
0, 0, -1, &s->s_msg, sizeof(s->s_msg));
@@ -991,8 +991,6 @@ session_read_data(struct session *s, char *line)
void
session_destroy(struct session *s, const char * reason)
{
- size_t resume;
-
log_debug("smtp: %p: deleting session: %s", s, reason);
if (s->s_flags & F_ZOMBIE)
@@ -1009,10 +1007,10 @@ session_destroy(struct session *s, const char * reason)
if (s->s_ssl) {
if (s->s_l->flags & F_SMTPS)
if (s->s_flags & F_SECURE)
- stat_decrement(STATS_SMTP_SMTPS);
+ stat_decrement("smtp.smtps");
if (s->s_l->flags & F_STARTTLS)
if (s->s_flags & F_SECURE)
- stat_decrement(STATS_SMTP_STARTTLS);
+ stat_decrement("smtp.tls");
}
event_del(&s->s_ev); /* in case something was scheduled */
@@ -1020,11 +1018,7 @@ session_destroy(struct session *s, const char * reason)
iobuf_clear(&s->s_iobuf);
/* resume when session count decreases to 95% */
- resume = env->sc_maxconn * 95 / 100;
- if (stat_decrement(STATS_SMTP_SESSION) == resume) {
- log_warnx("re-enabling incoming connections");
- smtp_resume();
- }
+ stat_decrement("smtp.session");
/* If the session is waiting for an imsg, do not kill it now, since
* the id must still be valid.
@@ -1035,6 +1029,9 @@ session_destroy(struct session *s, const char * reason)
}
finalize:
+
+ smtp_destroy(s);
+
SPLAY_REMOVE(sessiontree, &env->sc_sessions, s);
bzero(s, sizeof(*s));
free(s);
@@ -1130,7 +1127,7 @@ session_respond(struct session *s, char *fmt, ...)
struct timeval tv = { delay, 0 };
io_pause(&s->s_io, IO_PAUSE_OUT);
- env->stats->smtp.delays++;
+ stat_increment("smtp.delays");
/* in case session_respond is called multiple times */
evtimer_del(&s->s_ev);