diff options
author | Charles Longeau <chl@cvs.openbsd.org> | 2012-08-19 15:06:37 +0000 |
---|---|---|
committer | Charles Longeau <chl@cvs.openbsd.org> | 2012-08-19 15:06:37 +0000 |
commit | 0c0c72d3447ee021bcc2674934484c9aa1f2b59a (patch) | |
tree | 0159919437cb95109f40bff3b342e8f0c7acdda0 /usr.sbin | |
parent | 66f562b1ee962ba02e15dedcbcccb8b5e8871cf8 (diff) |
fix smtpctl schedule-all and schedule-id <msgid>
with help from eric@
ok eric@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/scheduler.c | 9 | ||||
-rw-r--r-- | usr.sbin/smtpd/scheduler_ramqueue.c | 59 |
2 files changed, 55 insertions, 13 deletions
diff --git a/usr.sbin/smtpd/scheduler.c b/usr.sbin/smtpd/scheduler.c index bf7ddf9d24d..4e9cd83014a 100644 --- a/usr.sbin/smtpd/scheduler.c +++ b/usr.sbin/smtpd/scheduler.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scheduler.c,v 1.12 2012/08/18 18:18:23 gilles Exp $ */ +/* $OpenBSD: scheduler.c,v 1.13 2012/08/19 15:06:36 chl Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -149,7 +149,12 @@ scheduler_imsg(struct imsgev *iev, struct imsg *imsg) case IMSG_SCHEDULER_SCHEDULE: id = *(uint64_t *)(imsg->data); - log_debug("scheduler: scheduling evp:%016" PRIx64, id); + if (id == 0) + log_debug("scheduler: scheduling all envelopes"); + else if (id <= 0xffffffffL) + log_debug("scheduler: scheduling msg:%08" PRIx64, id); + else + log_debug("scheduler: scheduling evp:%016" PRIx64, id); backend->schedule(id); scheduler_reset_events(); return; diff --git a/usr.sbin/smtpd/scheduler_ramqueue.c b/usr.sbin/smtpd/scheduler_ramqueue.c index c2c79008f12..4f823890085 100644 --- a/usr.sbin/smtpd/scheduler_ramqueue.c +++ b/usr.sbin/smtpd/scheduler_ramqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scheduler_ramqueue.c,v 1.16 2012/08/19 14:46:25 chl Exp $ */ +/* $OpenBSD: scheduler_ramqueue.c,v 1.17 2012/08/19 15:06:36 chl Exp $ */ /* * Copyright (c) 2012 Gilles Chehade <gilles@openbsd.org> @@ -446,18 +446,55 @@ scheduler_ramqueue_schedule(uint64_t evpid) struct rq_message *message; struct rq_envelope *envelope; uint32_t msgid; + void *i, *j; - msgid = evpid_to_msgid(evpid); - if ((message = tree_get(&ramqueue.messages, msgid)) == NULL) - return; - if ((envelope = tree_xget(&message->envelopes, evpid)) == NULL) - return; - if (envelope->flags & RQ_ENVELOPE_INFLIGHT) - return; + if (evpid == 0) { + j = NULL; + while (tree_iter(&ramqueue.messages, &j, NULL, + (void*)(&message))) { + + i = NULL; + while (tree_iter(&message->envelopes, &i, &evpid, + (void*)(&envelope))) { + if (envelope->flags & RQ_ENVELOPE_INFLIGHT) + continue; + + envelope->sched = time(NULL); + TAILQ_REMOVE(envelope->queue, envelope, entry); + sorted_insert(envelope->queue, envelope); + } + } + } + else if (evpid > 0xffffffff) { + msgid = evpid_to_msgid(evpid); + if ((message = tree_get(&ramqueue.messages, msgid)) == NULL) + return; + if ((envelope = tree_get(&message->envelopes, evpid)) == NULL) + return; + if (envelope->flags & RQ_ENVELOPE_INFLIGHT) + return; + + envelope->sched = time(NULL); + TAILQ_REMOVE(envelope->queue, envelope, entry); + sorted_insert(envelope->queue, envelope); + } + else { + msgid = evpid; + if ((message = tree_get(&ramqueue.messages, msgid)) == NULL) + return; + + i = NULL; + while (tree_iter(&message->envelopes, &i, &evpid, + (void*)(&envelope))) { + if (envelope->flags & RQ_ENVELOPE_INFLIGHT) + continue; + + envelope->sched = time(NULL); + TAILQ_REMOVE(envelope->queue, envelope, entry); + sorted_insert(envelope->queue, envelope); + } + } - envelope->sched = time(NULL); - TAILQ_REMOVE(envelope->queue, envelope, entry); - sorted_insert(envelope->queue, envelope); } static void |