diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2008-12-03 17:58:01 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2008-12-03 17:58:01 +0000 |
commit | adad4802d329834a5277b8ae5f11b1b89c3e20f6 (patch) | |
tree | f4200b2f16292f177afebcf74f9e69d829e2c6db /usr.sbin/smtpd/smtp.c | |
parent | 409ada53e614d1a9e6c07f9faf58c630baca98dc (diff) |
- fix event masking issues in smtp process which could lead to a fatal() if
queue process did not answer fast enough to an imsg. spotted by
Jacek Masiulaniec <jacekm@dobremiasto.net>
- queue layout was mostly to bootstrap the project, it does not behave good
under load, it does complex things to stay in a recoverable state
and it probably didnt do it too well. New queue code is simpler,
smaller and allows for atomic submissions (a mail can never be in a
state where it needs to be recovered). It still needs some work but
works better than previous code, no regression.
Diffstat (limited to 'usr.sbin/smtpd/smtp.c')
-rw-r--r-- | usr.sbin/smtpd/smtp.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c index 7e456a84508..a85baa45256 100644 --- a/usr.sbin/smtpd/smtp.c +++ b/usr.sbin/smtpd/smtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp.c,v 1.7 2008/11/24 22:30:19 gilles Exp $ */ +/* $OpenBSD: smtp.c,v 1.8 2008/12/03 17:58:00 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -358,11 +358,10 @@ smtp_dispatch_queue(int sig, short event, void *p) break; switch (imsg.hdr.type) { - case IMSG_SMTP_MESSAGE_FILE: { + case IMSG_SMTP_MESSAGE_ID: { struct submit_status *ss; struct session *s; struct session key; - int fd; log_debug("smtp_dispatch_queue: queue handled message creation"); ss = imsg.data; @@ -377,6 +376,25 @@ smtp_dispatch_queue(int sig, short event, void *p) (void)strlcpy(s->s_msg.message_id, ss->u.msgid, sizeof(s->s_msg.message_id)); + session_pickup(s, ss); + break; + } + case IMSG_SMTP_MESSAGE_FILE: { + struct submit_status *ss; + struct session *s; + struct session key; + int fd; + + log_debug("smtp_dispatch_queue: queue handled message creation"); + ss = imsg.data; + + key.s_id = ss->id; + + s = SPLAY_FIND(sessiontree, &env->sc_sessions, &key); + if (s == NULL) { + /* Session was removed while we were waiting for the message */ + break; + } fd = imsg_get_fd(ibuf, &imsg); if (fd != -1) { |