summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/control.c
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2013-10-25 18:58:11 +0000
committerEric Faurot <eric@cvs.openbsd.org>2013-10-25 18:58:11 +0000
commitc916cfb2bbc330d4419049d33e5888b3f427e48e (patch)
tree41a6a46c58262b70e4de44ceaafa404dacc1bdb5 /usr.sbin/smtpd/control.c
parentbee20e9a4e2f481f6762d7a8ccc33627df1c9893 (diff)
Improve reporting in smtpctl and a few fixes.
When sending a request to the scheduler, wait for the success/failure report from the scheduler. Simplify the code by introducing generic functions for interruptible iteration over envelopes. Report the total number of affected envelopes for schedule, pause, resume and remove envelope operations.
Diffstat (limited to 'usr.sbin/smtpd/control.c')
-rw-r--r--usr.sbin/smtpd/control.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c
index 5c92ae0243c..d816fd09307 100644
--- a/usr.sbin/smtpd/control.c
+++ b/usr.sbin/smtpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.89 2013/07/19 21:14:52 eric Exp $ */
+/* $OpenBSD: control.c,v 1.90 2013/10/25 18:58:10 eric Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@poolp.org>
@@ -98,10 +98,13 @@ control_imsg(struct mproc *p, struct imsg *imsg)
}
if (p->proc == PROC_SCHEDULER) {
switch (imsg->hdr.type) {
+ case IMSG_CTL_OK:
+ case IMSG_CTL_FAIL:
case IMSG_CTL_LIST_MESSAGES:
c = tree_get(&ctl_conns, imsg->hdr.peerid);
if (c == NULL)
return;
+ imsg->hdr.peerid = 0;
m_forward(&c->mproc, imsg);
return;
}
@@ -119,15 +122,11 @@ control_imsg(struct mproc *p, struct imsg *imsg)
if (p->proc == PROC_MTA) {
switch (imsg->hdr.type) {
case IMSG_CTL_MTA_SHOW_ROUTES:
- c = tree_get(&ctl_conns, imsg->hdr.peerid);
- if (c == NULL)
- return;
- m_forward(&c->mproc, imsg);
- return;
case IMSG_CTL_MTA_SHOW_HOSTSTATS:
c = tree_get(&ctl_conns, imsg->hdr.peerid);
if (c == NULL)
return;
+ imsg->hdr.peerid = 0;
m_forward(&c->mproc, imsg);
return;
}
@@ -579,8 +578,8 @@ control_dispatch_ext(struct mproc *p, struct imsg *imsg)
if (c->euid)
goto badcred;
+ imsg->hdr.peerid = c->id;
m_forward(p_scheduler, imsg);
- m_compose(p, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
return;
case IMSG_CTL_PAUSE_MDA:
@@ -629,8 +628,8 @@ control_dispatch_ext(struct mproc *p, struct imsg *imsg)
if (c->euid)
goto badcred;
+ imsg->hdr.peerid = c->id;
m_forward(p_scheduler, imsg);
- m_compose(p, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
return;
case IMSG_CTL_RESUME_MDA:
@@ -699,33 +698,28 @@ control_dispatch_ext(struct mproc *p, struct imsg *imsg)
return;
case IMSG_CTL_MTA_SHOW_ROUTES:
- if (c->euid)
- goto badcred;
- m_compose(p_mta, IMSG_CTL_MTA_SHOW_ROUTES, c->id, 0, -1,
- imsg->data, imsg->hdr.len - sizeof(imsg->hdr));
- return;
-
case IMSG_CTL_MTA_SHOW_HOSTSTATS:
if (c->euid)
goto badcred;
- m_compose(p_mta, IMSG_CTL_MTA_SHOW_HOSTSTATS, c->id, 0, -1,
- imsg->data, imsg->hdr.len - sizeof(imsg->hdr));
+
+ imsg->hdr.peerid = c->id;
+ m_forward(p_mta, imsg);
return;
case IMSG_CTL_SCHEDULE:
if (c->euid)
goto badcred;
+ imsg->hdr.peerid = c->id;
m_forward(p_scheduler, imsg);
- m_compose(p, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
return;
case IMSG_CTL_REMOVE:
if (c->euid)
goto badcred;
+ imsg->hdr.peerid = c->id;
m_forward(p_scheduler, imsg);
- m_compose(p, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
return;
case IMSG_LKA_UPDATE_TABLE: