summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/smtpd/runner.c17
-rw-r--r--usr.sbin/smtpd/smtpd.c37
-rw-r--r--usr.sbin/smtpd/smtpd.h17
3 files changed, 44 insertions, 27 deletions
diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c
index 204ff58bafc..cafedacd3cd 100644
--- a/usr.sbin/smtpd/runner.c
+++ b/usr.sbin/smtpd/runner.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: runner.c,v 1.8 2008/12/17 18:47:37 jacekm Exp $ */
+/* $OpenBSD: runner.c,v 1.9 2008/12/19 00:39:05 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -765,11 +765,18 @@ runner_message_schedule(struct message *messagep, time_t tm)
delay = SMTPD_QUEUE_MAXINTERVAL;
if (messagep->type & T_MDA_MESSAGE) {
- if (messagep->retry < 5)
- return 1;
-
- if (messagep->retry < 15)
+ if (messagep->status & S_MESSAGE_LOCKFAILURE) {
+ if (messagep->retry < 128)
+ return 1;
delay = (messagep->retry * 60) + arc4random() % 60;
+ }
+ else {
+ if (messagep->retry < 5)
+ return 1;
+
+ if (messagep->retry < 15)
+ delay = (messagep->retry * 60) + arc4random() % 60;
+ }
}
if (messagep->type & T_MTA_MESSAGE) {
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
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 914f527d0dc..663ce549ec7 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.31 2008/12/18 23:57:17 jacekm Exp $ */
+/* $OpenBSD: smtpd.h,v 1.32 2008/12/19 00:39:05 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -393,13 +393,14 @@ enum message_type {
};
enum message_status {
- S_MESSAGE_PERMFAILURE = 0x1,
- S_MESSAGE_TEMPFAILURE = 0x2,
- S_MESSAGE_REJECTED = 0x4,
- S_MESSAGE_ACCEPTED = 0x8,
- S_MESSAGE_RETRY = 0x10,
- S_MESSAGE_EDNS = 0x20,
- S_MESSAGE_ECONNECT = 0x40
+ S_MESSAGE_LOCKFAILURE = 0x1,
+ S_MESSAGE_PERMFAILURE = 0x2,
+ S_MESSAGE_TEMPFAILURE = 0x4,
+ S_MESSAGE_REJECTED = 0x8,
+ S_MESSAGE_ACCEPTED = 0x10,
+ S_MESSAGE_RETRY = 0x20,
+ S_MESSAGE_EDNS = 0x40,
+ S_MESSAGE_ECONNECT = 0x80
};
enum message_flags {