summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/smtpctl.c
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2013-07-19 15:14:24 +0000
committerEric Faurot <eric@cvs.openbsd.org>2013-07-19 15:14:24 +0000
commit1116f6a34a5908ad89288723f7e30bb15a022ae3 (patch)
treedd52716eb6eb081ef8e73f4b6258b458db2d81d5 /usr.sbin/smtpd/smtpctl.c
parente67d86d2f4e72f70db6e6c0aabcb4d931e6b3600 (diff)
scheduler improvements:
- implement suspend/resume scheduling for individual envelopes or message, with the associated smtpctl commands. - allow the mta to request immediate scheduling of an envelope. - on temporary failures a penalty can be given to further delay the next try.
Diffstat (limited to 'usr.sbin/smtpd/smtpctl.c')
-rw-r--r--usr.sbin/smtpd/smtpctl.c61
1 files changed, 60 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c
index c19bb7d012f..6c7dfe3d766 100644
--- a/usr.sbin/smtpd/smtpctl.c
+++ b/usr.sbin/smtpd/smtpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpctl.c,v 1.106 2013/07/19 13:41:23 eric Exp $ */
+/* $OpenBSD: smtpctl.c,v 1.107 2013/07/19 15:14:23 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -368,6 +368,33 @@ do_monitor(int argc, struct parameter *argv)
}
static int
+do_pause_envelope(int argc, struct parameter *argv)
+{
+ struct envelope evp;
+ uint32_t msgid;
+
+ if (argc == 0) {
+ while (srv_iter_messages(&msgid)) {
+ while (srv_iter_envelopes(msgid, &evp)) {
+ srv_send(IMSG_CTL_PAUSE_EVP, &evp.id,
+ sizeof(evp.id));
+ srv_check_result();
+ }
+ }
+ } else if (argv[0].type == P_MSGID) {
+ while (srv_iter_envelopes(argv[0].u.u_msgid, &evp)) {
+ srv_send(IMSG_CTL_PAUSE_EVP, &evp.id, sizeof(evp.id));
+ srv_check_result();
+ }
+ } else {
+ srv_send(IMSG_CTL_PAUSE_EVP, &argv[0].u.u_evpid, sizeof(evp.id));
+ srv_check_result();
+ }
+
+ return (0);
+}
+
+static int
do_pause_mda(int argc, struct parameter *argv)
{
srv_send(IMSG_CTL_PAUSE_MDA, NULL, 0);
@@ -427,6 +454,33 @@ do_remove(int argc, struct parameter *argv)
}
static int
+do_resume_envelope(int argc, struct parameter *argv)
+{
+ struct envelope evp;
+ uint32_t msgid;
+
+ if (argc == 0) {
+ while (srv_iter_messages(&msgid)) {
+ while (srv_iter_envelopes(msgid, &evp)) {
+ srv_send(IMSG_CTL_RESUME_EVP, &evp.id,
+ sizeof(evp.id));
+ srv_check_result();
+ }
+ }
+ } else if (argv[0].type == P_MSGID) {
+ while (srv_iter_envelopes(argv[0].u.u_msgid, &evp)) {
+ srv_send(IMSG_CTL_RESUME_EVP, &evp.id, sizeof(evp.id));
+ srv_check_result();
+ }
+ } else {
+ srv_send(IMSG_CTL_RESUME_EVP, &argv[0].u.u_evpid, sizeof(evp.id));
+ srv_check_result();
+ }
+
+ return (0);
+}
+
+static int
do_resume_mda(int argc, struct parameter *argv)
{
srv_send(IMSG_CTL_RESUME_MDA, NULL, 0);
@@ -694,12 +748,16 @@ main(int argc, char **argv)
cmd_install("log brief", do_log_brief);
cmd_install("log verbose", do_log_verbose);
cmd_install("monitor", do_monitor);
+ cmd_install("pause envelope <evpid>", do_pause_envelope);
+ cmd_install("pause envelope <msgid>", do_pause_envelope);
cmd_install("pause mda", do_pause_mda);
cmd_install("pause mta", do_pause_mta);
cmd_install("pause smtp", do_pause_smtp);
cmd_install("profile <str>", do_profile);
cmd_install("remove <evpid>", do_remove);
cmd_install("remove <msgid>", do_remove);
+ cmd_install("resume envelope <evpid>", do_resume_envelope);
+ cmd_install("resume envelope <msgid>", do_resume_envelope);
cmd_install("resume mda", do_resume_mda);
cmd_install("resume mta", do_resume_mta);
cmd_install("resume smtp", do_resume_smtp);
@@ -739,6 +797,7 @@ show_queue_envelope(struct envelope *e, int online)
getflag(&e->flags, EF_BOUNCE, "bounce", status, sizeof(status));
getflag(&e->flags, EF_AUTHENTICATED, "auth", status, sizeof(status));
getflag(&e->flags, EF_INTERNAL, "internal", status, sizeof(status));
+ getflag(&e->flags, EF_SUSPEND, "suspend", status, sizeof(status));
if (online) {
if (e->flags & EF_PENDING)