summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/smtpd.c
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2008-12-19 00:39:06 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2008-12-19 00:39:06 +0000
commit18ce8e5e07f49baaa4cc75fc8c818ffb24d766f2 (patch)
tree97cd27ac42bf686068eca29b8451be2b31898336 /usr.sbin/smtpd/smtpd.c
parentff67e0a17694010e5eb657df80fb35ebb7032763 (diff)
- smtpd handled mbox locking failures as "regular" temporary failures which
is not good at all. As a result, under heavy load messages would be kept in queue, and delayed for hours just because we failed locking a few times. This commit makes smtpd distinguish between lock fails and "regular" temporary fails. - delivery scheduler will reschedule immediately a message that couldn't be delivered because of a lock fail. If we fail to lock too many times we fallback to previous "delay increase" logic. "looks sane" jacekm@
Diffstat (limited to 'usr.sbin/smtpd/smtpd.c')
-rw-r--r--usr.sbin/smtpd/smtpd.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c
index 4d9643d57a6..870779b339e 100644
--- a/usr.sbin/smtpd/smtpd.c
+++ b/usr.sbin/smtpd/smtpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.c,v 1.15 2008/12/17 18:47:37 jacekm Exp $ */
+/* $OpenBSD: smtpd.c,v 1.16 2008/12/19 00:39:05 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -801,25 +801,29 @@ parent_open_mailbox(struct batch *batchp, struct path *path)
case EMFILE:
case ENFILE:
case ENOSPC:
- case EWOULDBLOCK:
batchp->message.status |= S_MESSAGE_TEMPFAILURE;
break;
+ case EWOULDBLOCK:
+ goto lockfail;
default:
batchp->message.status |= S_MESSAGE_PERMFAILURE;
}
-
return -1;
}
- if (flock(fd, LOCK_EX|LOCK_NB) == -1) {
- close(fd);
- batchp->message.status |= S_MESSAGE_TEMPFAILURE;
- return -1;
- }
+ if (flock(fd, LOCK_EX|LOCK_NB) == -1)
+ goto lockfail;
fchown(fd, pw->pw_uid, 0);
return fd;
+
+lockfail:
+ if (fd != -1)
+ close(fd);
+
+ batchp->message.status |= S_MESSAGE_TEMPFAILURE|S_MESSAGE_LOCKFAILURE;
+ return -1;
}
@@ -1008,22 +1012,27 @@ parent_open_filename(struct batch *batchp, struct path *path)
case EMFILE:
case ENFILE:
case ENOSPC:
- case EWOULDBLOCK:
batchp->message.status |= S_MESSAGE_TEMPFAILURE;
break;
+ case EWOULDBLOCK:
+ goto lockfail;
default:
batchp->message.status |= S_MESSAGE_PERMFAILURE;
}
return -1;
}
- if (flock(fd, LOCK_EX|LOCK_NB) == -1) {
- close(fd);
- batchp->message.status |= S_MESSAGE_TEMPFAILURE;
- return -1;
- }
+ if (flock(fd, LOCK_EX|LOCK_NB) == -1)
+ goto lockfail;
return fd;
+
+lockfail:
+ if (fd != -1)
+ close(fd);
+
+ batchp->message.status |= S_MESSAGE_TEMPFAILURE|S_MESSAGE_LOCKFAILURE;
+ return -1;
}
int