summaryrefslogtreecommitdiffstats
path: root/usr.sbin/smtpd/ramqueue.c
diff options
context:
space:
mode:
authorgilles <gilles@openbsd.org>2012-01-12 22:40:16 +0000
committergilles <gilles@openbsd.org>2012-01-12 22:40:16 +0000
commitee2a58c0e3dd45d581dbfab0de9331fba03c6f65 (patch)
tree58bb5987afe9fc0ef7e79a50b47f2e85c6ca7a3c /usr.sbin/smtpd/ramqueue.c
parentnow that we no longer do a stateful iteration on schedule queue, we need (diff)
downloadwireguard-openbsd-ee2a58c0e3dd45d581dbfab0de9331fba03c6f65.tar.xz
wireguard-openbsd-ee2a58c0e3dd45d581dbfab0de9331fba03c6f65.zip
the ramqueue filling at startup was busted, it would load envelopes one by
one instead of doing it efficiently. fix runner_timeout() and ramqueue_load() so that at startup smtpd fills the ramqueue as long as there's no schedulable envelope in it, interrupts filling if there is and resume once it's scheduled. bug spotted by Nathanael Rensel, bug fix by me w/ help from eric@ tested by eric@ and I
Diffstat (limited to 'usr.sbin/smtpd/ramqueue.c')
-rw-r--r--usr.sbin/smtpd/ramqueue.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.sbin/smtpd/ramqueue.c b/usr.sbin/smtpd/ramqueue.c
index 8d21afb75f3..929c9cd6ab6 100644
--- a/usr.sbin/smtpd/ramqueue.c
+++ b/usr.sbin/smtpd/ramqueue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ramqueue.c,v 1.29 2012/01/12 22:00:21 gilles Exp $ */
+/* $OpenBSD: ramqueue.c,v 1.30 2012/01/12 22:40:16 gilles Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -133,7 +133,7 @@ ramqueue_load(struct ramqueue *rqueue, time_t *nsched)
while (qwalk(q, &evpid)) {
curtm = time(NULL);
if (! queue_envelope_load(Q_QUEUE, evpid, &envelope)) {
- log_debug("failed to load envelope");
+ log_debug("ramqueue: moved envelope to /corrupt");
queue_message_corrupt(Q_QUEUE, evpid_to_msgid(evpid));
continue;
}
@@ -141,10 +141,14 @@ ramqueue_load(struct ramqueue *rqueue, time_t *nsched)
continue;
ramqueue_insert(rqueue, &envelope, curtm);
- rq_evp = TAILQ_FIRST(&rqueue->queue);
- *nsched = rq_evp->sched;
+ rq_evp = ramqueue_next_envelope(rqueue);
+ if (rq_evp == NULL)
+ continue;
+
+ if (rq_evp->sched <= *nsched)
+ *nsched = rq_evp->sched;
- if (rq_evp->sched <= *nsched) {
+ if (*nsched <= curtm) {
log_debug("ramqueue: loading interrupted");
return (0);
}