summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/smtpd.c
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2008-12-03 17:58:01 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2008-12-03 17:58:01 +0000
commitadad4802d329834a5277b8ae5f11b1b89c3e20f6 (patch)
treef4200b2f16292f177afebcf74f9e69d829e2c6db /usr.sbin/smtpd/smtpd.c
parent409ada53e614d1a9e6c07f9faf58c630baca98dc (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/smtpd.c')
-rw-r--r--usr.sbin/smtpd/smtpd.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c
index 335bb1e2ac7..1dd188dd22e 100644
--- a/usr.sbin/smtpd/smtpd.c
+++ b/usr.sbin/smtpd/smtpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.c,v 1.11 2008/11/22 22:22:05 gilles Exp $ */
+/* $OpenBSD: smtpd.c,v 1.12 2008/12/03 17:58:00 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -59,6 +59,7 @@ int parent_maildir_init(struct passwd *, char *);
int parent_external_mda(struct batch *, struct path *);
int check_child(pid_t, const char *);
int setup_spool(uid_t, gid_t);
+u_int16_t queue_message_hash(struct message *);
pid_t lka_pid = 0;
pid_t mfa_pid = 0;
@@ -622,8 +623,9 @@ int
setup_spool(uid_t uid, gid_t gid)
{
unsigned int n;
- char *paths[] = { PATH_MESSAGES, PATH_LOCAL, PATH_RELAY,
- PATH_DAEMON, PATH_ENVELOPES };
+ char *paths[] = { PATH_INCOMING, PATH_QUEUE,
+ PATH_RUNQUEUE, PATH_RUNQUEUELOW,
+ PATH_RUNQUEUEHIGH };
char pathname[MAXPATHLEN];
struct stat sb;
int ret;
@@ -751,9 +753,14 @@ parent_open_message_file(struct batch *batchp)
int fd;
char pathname[MAXPATHLEN];
int spret;
+ u_int16_t hval;
+ struct message *messagep;
- spret = snprintf(pathname, MAXPATHLEN, "%s%s/%s",
- PATH_SPOOL, PATH_MESSAGES, batchp->message_id);
+ messagep = &batchp->message;
+ hval = queue_message_hash(messagep);
+
+ spret = snprintf(pathname, MAXPATHLEN, "%s%s/%d/%s/message",
+ PATH_SPOOL, PATH_QUEUE, hval, batchp->message_id);
if (spret == -1 || spret >= MAXPATHLEN) {
batchp->message.status |= S_MESSAGE_PERMFAILURE;
return -1;