summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/smtp.c
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/smtpd/smtp.c
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/smtpd/smtp.c')
-rw-r--r--usr.sbin/smtpd/smtp.c14
1 files changed, 10 insertions, 4 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);
}