summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2009-01-30 21:22:34 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2009-01-30 21:22:34 +0000
commit5328220112c6a2ede4995eb893b771f763c4dc4f (patch)
tree3022196b45d93c50a8d6f6d0fed2ffec17e1ad9a /usr.sbin
parent02bfd51be8dc8fa6a4b9f1fd9d040b5f937310b7 (diff)
clear the F_EVLOCK flag earlier to prevent the error event handler from
being called again with F_EVLOCK set. this fixes a bug where disconnect after smtpd sends greeting and before entering any command failed to go into session_destroy(). while at it, rename the "smtp.clients" statistic to "smtp.sessions" and add counters to struct s_smtp so that I can add ssmtp and starttls with my next commit ;)
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/smtp.c14
-rw-r--r--usr.sbin/smtpd/smtp_session.c8
-rw-r--r--usr.sbin/smtpd/smtpctl.c4
-rw-r--r--usr.sbin/smtpd/smtpd.h6
4 files changed, 19 insertions, 13 deletions
diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c
index a2338ab4353..6693aee04ef 100644
--- a/usr.sbin/smtpd/smtp.c
+++ b/usr.sbin/smtpd/smtp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp.c,v 1.20 2009/01/30 17:34:58 gilles Exp $ */
+/* $OpenBSD: smtp.c,v 1.21 2009/01/30 21:22:33 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -180,6 +180,7 @@ smtp_dispatch_parent(int sig, short event, void *p)
session_destroy(s);
break;
}
+ s->s_flags &= ~F_EVLOCKED;
if (reply->value)
s->s_flags |= F_AUTHENTICATED;
@@ -253,6 +254,7 @@ smtp_dispatch_mfa(int sig, short event, void *p)
session_destroy(s);
break;
}
+ s->s_flags &= ~F_EVLOCKED;
session_pickup(s, ss);
break;
@@ -319,6 +321,7 @@ smtp_dispatch_lka(int sig, short event, void *p)
session_destroy(s);
break;
}
+ ss->s_flags &= ~F_EVLOCKED;
strlcpy(ss->s_hostname, s->s_hostname, MAXHOSTNAMELEN);
strlcpy(ss->s_msg.session_hostname, s->s_hostname,
@@ -392,6 +395,7 @@ smtp_dispatch_queue(int sig, short event, void *p)
session_destroy(s);
break;
}
+ s->s_flags &= ~F_EVLOCKED;
(void)strlcpy(s->s_msg.message_id, ss->u.msgid,
sizeof(s->s_msg.message_id));
@@ -419,6 +423,7 @@ smtp_dispatch_queue(int sig, short event, void *p)
session_destroy(s);
break;
}
+ s->s_flags &= ~F_EVLOCKED;
if (fd != -1) {
s->s_msg.datafp = fdopen(fd, "w");
@@ -451,7 +456,7 @@ smtp_dispatch_queue(int sig, short event, void *p)
session_destroy(s);
break;
}
-
+ s->s_flags &= ~F_EVLOCKED;
s->s_msg.status |= S_MESSAGE_TEMPFAILURE;
break;
}
@@ -480,6 +485,7 @@ smtp_dispatch_queue(int sig, short event, void *p)
session_destroy(s);
break;
}
+ s->s_flags &= ~F_EVLOCKED;
session_pickup(s, ss);
break;
@@ -717,9 +723,9 @@ smtp_accept(int fd, short event, void *p)
session_init(l, s);
event_add(&l->ev, NULL);
- s_smtp.clients++;
+ s_smtp.sessions++;
- if (s_smtp.clients == s->s_env->sc_maxconn)
+ if (s_smtp.sessions == s->s_env->sc_maxconn)
event_del(&l->ev);
}
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index 3b1a6552371..ee9df424fcf 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.49 2009/01/30 17:34:58 gilles Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.50 2009/01/30 21:22:33 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -605,7 +605,6 @@ session_auth_pickup(struct session *s, char *arg, size_t nr)
if (s == NULL)
fatal("session_pickup: desynchronized");
- s->s_flags &= ~F_EVLOCKED;
bufferevent_enable(s->s_bev, EV_READ);
switch (s->s_state) {
@@ -637,7 +636,6 @@ session_pickup(struct session *s, struct submit_status *ss)
if (s == NULL)
fatal("session_pickup: desynchronized");
- s->s_flags &= ~F_EVLOCKED;
bufferevent_enable(s->s_bev, EV_READ);
if ((ss != NULL && ss->code == 421) ||
@@ -907,8 +905,8 @@ session_destroy(struct session *s)
log_debug("session_destroy: killing client: %p", s);
close(s->s_fd);
- s_smtp.clients--;
- if (s_smtp.clients < s->s_env->sc_maxconn)
+ s_smtp.sessions--;
+ if (s_smtp.sessions < s->s_env->sc_maxconn)
event_add(&s->s_l->ev, NULL);
if (s->s_bev != NULL) {
diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c
index 3d4f2efd277..c165c22590c 100644
--- a/usr.sbin/smtpd/smtpctl.c
+++ b/usr.sbin/smtpd/smtpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpctl.c,v 1.9 2009/01/29 22:34:21 jacekm Exp $ */
+/* $OpenBSD: smtpctl.c,v 1.10 2009/01/30 21:22:33 gilles Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -275,7 +275,7 @@ show_stats_output(struct imsg *imsg)
printf("parent.uptime = %d\n", time(NULL) - s_parent.start);
printf("queue.inserts = %zd\n", s_queue.inserts);
printf("runner.active = %zd\n", s_runner.active);
- printf("smtp.clients = %zd\n", s_smtp.clients);
+ printf("smtp.sessions = %zd\n", s_smtp.sessions);
return (1);
}
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index e2446f51438..fb9924fe721 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.65 2009/01/30 20:11:13 form Exp $ */
+/* $OpenBSD: smtpd.h,v 1.66 2009/01/30 21:22:33 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -655,7 +655,9 @@ struct s_runner {
};
struct s_smtp {
- size_t clients;
+ size_t sessions;
+ size_t ssmtp;
+ size_t starttls;
};
struct stats {