diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2012-11-20 09:47:47 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2012-11-20 09:47:47 +0000 |
commit | 65898a3024a49104a9e8123deec105b11de001e3 (patch) | |
tree | 657d34d40deed3c1977a7b942dc5e32505512802 /usr.sbin/smtpd/queue.c | |
parent | f6aefaa94996adb3a94cf829d7d536f2457f186f (diff) |
Allow "smtpctl show queue" to run in "online" mode if the smtpd server
is running. The scheduler sends the runtime state of each envelope to
the queue process which loads the envelope, fills the runtime bits and
sends the envelope back to the client. Iteration over the envelope set
happens in small chunks to make the request interruptible and to allow
the server to keep doing its job in the meantime.
Adpat "smtpctl schedule-all" to schedule the messages one by one using
the same iteration mechanism.
Document "smtpctl monitor" and "smtpctl show queue".
ok gilles@
Diffstat (limited to 'usr.sbin/smtpd/queue.c')
-rw-r--r-- | usr.sbin/smtpd/queue.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index a4f5a19ecec..8bde4360274 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.142 2012/11/13 13:23:23 eric Exp $ */ +/* $OpenBSD: queue.c,v 1.143 2012/11/20 09:47:45 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -51,6 +51,7 @@ static void queue_sig_handler(int, short, void *); static void queue_imsg(struct imsgev *iev, struct imsg *imsg) { + struct evpstate *state; static uint64_t batch_id; struct submit_status ss; struct envelope *e, evp; @@ -197,7 +198,38 @@ queue_imsg(struct imsgev *iev, struct imsg *imsg) IMSG_BATCH_CLOSE, 0, 0, -1, &batch_id, sizeof batch_id); return; - } + + case IMSG_SCHEDULER_ENVELOPES: + if (imsg->hdr.len == sizeof imsg->hdr) { + imsg_compose_event(env->sc_ievs[PROC_CONTROL], + IMSG_SCHEDULER_ENVELOPES, imsg->hdr.peerid, + 0, -1, NULL, 0); + return; + } + state = imsg->data; + if (queue_envelope_load(state->evpid, &evp) == 0) + return; /* Envelope is gone, drop it */ + /* + * XXX consistency: The envelope might already be on + * its way back to the scheduler. We need to detect + * this properly and report that state. + */ + evp.flags |= state->flags; + /* In the past if running or runnable */ + evp.nexttry = state->time; + if (state->flags == DF_INFLIGHT) { + /* + * Not exactly correct but pretty close: The + * value is not recorded on the envelope unless + * a tempfail occurs. + */ + evp.lasttry = state->time; + } + imsg_compose_event(env->sc_ievs[PROC_CONTROL], + IMSG_SCHEDULER_ENVELOPES, imsg->hdr.peerid, 0, -1, + &evp, sizeof evp); + return; + } } if (iev->proc == PROC_MTA || iev->proc == PROC_MDA) { |