summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2017-11-23 07:23:37 +0000
committerEric Faurot <eric@cvs.openbsd.org>2017-11-23 07:23:37 +0000
commit602f72dea8011b7a9c702eebcd696f0439cf9502 (patch)
tree6d1631b200159a64429498ff3ad97da9b59f4cfd /usr.sbin/smtpd
parentd40561b65b158fffaae18ae47124709f7d347de0 (diff)
simplify imsg handler.
ok sunil@ gilles@
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r--usr.sbin/smtpd/control.c81
1 files changed, 27 insertions, 54 deletions
diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c
index 6e4c6e98cf3..b30d53cdb31 100644
--- a/usr.sbin/smtpd/control.c
+++ b/usr.sbin/smtpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.118 2017/01/09 09:53:23 reyk Exp $ */
+/* $OpenBSD: control.c,v 1.119 2017/11/23 07:23:36 eric Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@poolp.org>
@@ -94,62 +94,33 @@ control_imsg(struct mproc *p, struct imsg *imsg)
return;
}
- if (p->proc == PROC_PONY) {
- switch (imsg->hdr.type) {
- case IMSG_CTL_SMTP_SESSION:
- c = tree_get(&ctl_conns, imsg->hdr.peerid);
- if (c == NULL)
- return;
- m_compose(&c->mproc, IMSG_CTL_OK, 0, 0, imsg->fd,
- NULL, 0);
- return;
- }
- }
- 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;
- }
- }
- if (p->proc == PROC_QUEUE) {
- switch (imsg->hdr.type) {
- case IMSG_CTL_LIST_ENVELOPES:
- case IMSG_CTL_DISCOVER_EVPID:
- case IMSG_CTL_DISCOVER_MSGID:
- case IMSG_CTL_UNCORRUPT_MSGID:
- c = tree_get(&ctl_conns, imsg->hdr.peerid);
- if (c == NULL)
- return;
- m_forward(&c->mproc, imsg);
+ switch (imsg->hdr.type) {
+ case IMSG_CTL_OK:
+ case IMSG_CTL_FAIL:
+ case IMSG_CTL_LIST_MESSAGES:
+ case IMSG_CTL_LIST_ENVELOPES:
+ case IMSG_CTL_DISCOVER_EVPID:
+ case IMSG_CTL_DISCOVER_MSGID:
+ case IMSG_CTL_UNCORRUPT_MSGID:
+ case IMSG_CTL_MTA_SHOW_HOSTS:
+ case IMSG_CTL_MTA_SHOW_RELAYS:
+ case IMSG_CTL_MTA_SHOW_ROUTES:
+ case IMSG_CTL_MTA_SHOW_HOSTSTATS:
+ case IMSG_CTL_MTA_SHOW_BLOCK:
+ c = tree_get(&ctl_conns, imsg->hdr.peerid);
+ if (c == NULL)
return;
- }
- }
- if (p->proc == PROC_PONY) {
- switch (imsg->hdr.type) {
- case IMSG_CTL_OK:
- case IMSG_CTL_FAIL:
- case IMSG_CTL_MTA_SHOW_HOSTS:
- case IMSG_CTL_MTA_SHOW_RELAYS:
- case IMSG_CTL_MTA_SHOW_ROUTES:
- case IMSG_CTL_MTA_SHOW_HOSTSTATS:
- case IMSG_CTL_MTA_SHOW_BLOCK:
- c = tree_get(&ctl_conns, imsg->hdr.peerid);
- if (c == NULL)
- return;
- imsg->hdr.peerid = 0;
- m_forward(&c->mproc, imsg);
+ imsg->hdr.peerid = 0;
+ m_forward(&c->mproc, imsg);
+ return;
+
+ case IMSG_CTL_SMTP_SESSION:
+ c = tree_get(&ctl_conns, imsg->hdr.peerid);
+ if (c == NULL)
return;
- }
- }
+ m_compose(&c->mproc, IMSG_CTL_OK, 0, 0, imsg->fd, NULL, 0);
+ return;
- switch (imsg->hdr.type) {
case IMSG_STAT_INCREMENT:
m_msg(&m, imsg);
m_get_string(&m, &key);
@@ -162,6 +133,7 @@ control_imsg(struct mproc *p, struct imsg *imsg)
stat_backend->increment(key, val.u.counter);
control_digest_update(key, val.u.counter, 1);
return;
+
case IMSG_STAT_DECREMENT:
m_msg(&m, imsg);
m_get_string(&m, &key);
@@ -174,6 +146,7 @@ control_imsg(struct mproc *p, struct imsg *imsg)
stat_backend->decrement(key, val.u.counter);
control_digest_update(key, val.u.counter, 0);
return;
+
case IMSG_STAT_SET:
m_msg(&m, imsg);
m_get_string(&m, &key);