summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/smtpd/control.c41
-rw-r--r--usr.sbin/smtpd/lka.c3
-rw-r--r--usr.sbin/smtpd/mda.c11
-rw-r--r--usr.sbin/smtpd/mta.c21
-rw-r--r--usr.sbin/smtpd/queue.c58
-rw-r--r--usr.sbin/smtpd/runner.c190
-rw-r--r--usr.sbin/smtpd/smtp.c21
-rw-r--r--usr.sbin/smtpd/smtpctl.c14
-rw-r--r--usr.sbin/smtpd/smtpd.c11
-rw-r--r--usr.sbin/smtpd/smtpd.h23
10 files changed, 199 insertions, 194 deletions
diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c
index 61dced2793b..b4ec43365a9 100644
--- a/usr.sbin/smtpd/control.c
+++ b/usr.sbin/smtpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.48 2010/04/21 08:29:01 jacekm Exp $ */
+/* $OpenBSD: control.c,v 1.49 2010/04/21 18:54:43 jacekm Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -78,9 +78,9 @@ control_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
}
}
- if (iev->proc == PROC_RUNNER) {
+ if (iev->proc == PROC_QUEUE) {
switch (imsg->hdr.type) {
- case IMSG_RUNNER_SCHEDULE:
+ case IMSG_QUEUE_SCHEDULE:
sched = imsg->data;
c = control_connbyfd(sched->fd);
if (c == NULL)
@@ -90,7 +90,7 @@ control_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
NULL, 0);
return;
- case IMSG_RUNNER_REMOVE:
+ case IMSG_QUEUE_REMOVE:
rem = imsg->data;
c = control_connbyfd(rem->fd);
if (c == NULL)
@@ -146,7 +146,6 @@ control(struct smtpd *env)
struct event ev_sigterm;
struct peer peers [] = {
{ PROC_QUEUE, imsg_dispatch },
- { PROC_RUNNER, imsg_dispatch },
{ PROC_SMTP, imsg_dispatch },
{ PROC_MFA, imsg_dispatch },
{ PROC_PARENT, imsg_dispatch },
@@ -395,7 +394,7 @@ control_dispatch_ext(int fd, short event, void *arg)
imsg_compose_event(&c->iev, IMSG_STATS, 0, 0, -1,
env->stats, sizeof(struct stats));
break;
- case IMSG_RUNNER_SCHEDULE: {
+ case IMSG_QUEUE_SCHEDULE: {
struct sched *s = imsg.data;
if (euid)
@@ -412,11 +411,11 @@ control_dispatch_ext(int fd, short event, void *arg)
break;
}
- imsg_compose_event(env->sc_ievs[PROC_RUNNER], IMSG_RUNNER_SCHEDULE, 0, 0, -1, s, sizeof(*s));
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE], IMSG_QUEUE_SCHEDULE, 0, 0, -1, s, sizeof(*s));
break;
}
- case IMSG_RUNNER_REMOVE: {
+ case IMSG_QUEUE_REMOVE: {
struct remove *s = imsg.data;
if (euid)
@@ -433,7 +432,7 @@ control_dispatch_ext(int fd, short event, void *arg)
break;
}
- imsg_compose_event(env->sc_ievs[PROC_RUNNER], IMSG_RUNNER_REMOVE, 0, 0, -1, s, sizeof(*s));
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE], IMSG_QUEUE_REMOVE, 0, 0, -1, s, sizeof(*s));
break;
}
/*
@@ -488,7 +487,7 @@ control_dispatch_ext(int fd, short event, void *arg)
imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
break;
}
- case IMSG_MDA_PAUSE:
+ case IMSG_QUEUE_PAUSE_LOCAL:
if (euid)
goto badcred;
@@ -498,11 +497,11 @@ control_dispatch_ext(int fd, short event, void *arg)
break;
}
env->sc_flags |= SMTPD_MDA_PAUSED;
- imsg_compose_event(env->sc_ievs[PROC_RUNNER], IMSG_MDA_PAUSE,
- 0, 0, -1, NULL, 0);
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE],
+ IMSG_QUEUE_PAUSE_LOCAL, 0, 0, -1, NULL, 0);
imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
break;
- case IMSG_MTA_PAUSE:
+ case IMSG_QUEUE_PAUSE_OUTGOING:
if (euid)
goto badcred;
@@ -512,8 +511,8 @@ control_dispatch_ext(int fd, short event, void *arg)
break;
}
env->sc_flags |= SMTPD_MTA_PAUSED;
- imsg_compose_event(env->sc_ievs[PROC_RUNNER], IMSG_MTA_PAUSE,
- 0, 0, -1, NULL, 0);
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE],
+ IMSG_QUEUE_PAUSE_OUTGOING, 0, 0, -1, NULL, 0);
imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
break;
case IMSG_SMTP_PAUSE:
@@ -530,7 +529,7 @@ control_dispatch_ext(int fd, short event, void *arg)
0, 0, -1, NULL, 0);
imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
break;
- case IMSG_MDA_RESUME:
+ case IMSG_QUEUE_RESUME_LOCAL:
if (euid)
goto badcred;
@@ -540,11 +539,11 @@ control_dispatch_ext(int fd, short event, void *arg)
break;
}
env->sc_flags &= ~SMTPD_MDA_PAUSED;
- imsg_compose_event(env->sc_ievs[PROC_RUNNER], IMSG_MDA_RESUME,
- 0, 0, -1, NULL, 0);
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE],
+ IMSG_QUEUE_RESUME_LOCAL, 0, 0, -1, NULL, 0);
imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
break;
- case IMSG_MTA_RESUME:
+ case IMSG_QUEUE_RESUME_OUTGOING:
if (euid)
goto badcred;
@@ -554,8 +553,8 @@ control_dispatch_ext(int fd, short event, void *arg)
break;
}
env->sc_flags &= ~SMTPD_MTA_PAUSED;
- imsg_compose_event(env->sc_ievs[PROC_RUNNER], IMSG_MTA_RESUME,
- 0, 0, -1, NULL, 0);
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE],
+ IMSG_QUEUE_RESUME_OUTGOING, 0, 0, -1, NULL, 0);
imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
break;
case IMSG_SMTP_RESUME:
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c
index 2f52913b0b6..27a31a16d18 100644
--- a/usr.sbin/smtpd/lka.c
+++ b/usr.sbin/smtpd/lka.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka.c,v 1.103 2010/04/21 08:29:01 jacekm Exp $ */
+/* $OpenBSD: lka.c,v 1.104 2010/04/21 18:54:43 jacekm Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -315,7 +315,6 @@ lka(struct smtpd *env)
{ PROC_MFA, imsg_dispatch },
{ PROC_QUEUE, imsg_dispatch },
{ PROC_SMTP, imsg_dispatch },
- { PROC_RUNNER, imsg_dispatch },
{ PROC_MTA, imsg_dispatch }
};
diff --git a/usr.sbin/smtpd/mda.c b/usr.sbin/smtpd/mda.c
index 65cffd72e7d..006a896f5cb 100644
--- a/usr.sbin/smtpd/mda.c
+++ b/usr.sbin/smtpd/mda.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mda.c,v 1.42 2010/04/21 08:29:01 jacekm Exp $ */
+/* $OpenBSD: mda.c,v 1.43 2010/04/21 18:54:43 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -56,7 +56,7 @@ mda_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
struct mda_session *s;
struct path *path;
- if (iev->proc == PROC_RUNNER) {
+ if (iev->proc == PROC_QUEUE) {
switch (imsg->hdr.type) {
case IMSG_MDA_SESS_NEW:
/* make new session based on provided args */
@@ -231,8 +231,8 @@ mda_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
event_del(&s->ev);
free(s);
- /* update runner's session count */
- imsg_compose_event(env->sc_ievs[PROC_RUNNER],
+ /* update queue's session count */
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE],
IMSG_MDA_SESS_NEW, 0, 0, -1, NULL, 0);
return;
@@ -286,8 +286,7 @@ mda(struct smtpd *env)
struct peer peers[] = {
{ PROC_PARENT, imsg_dispatch },
- { PROC_QUEUE, imsg_dispatch },
- { PROC_RUNNER, imsg_dispatch }
+ { PROC_QUEUE, imsg_dispatch }
};
switch (pid = fork()) {
diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c
index 8fb66d9d024..9184b97f905 100644
--- a/usr.sbin/smtpd/mta.c
+++ b/usr.sbin/smtpd/mta.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mta.c,v 1.86 2010/04/21 08:29:01 jacekm Exp $ */
+/* $OpenBSD: mta.c,v 1.87 2010/04/21 18:54:43 jacekm Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -69,7 +69,7 @@ mta_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
struct dns *dns;
struct ssl *ssl;
- if (iev->proc == PROC_RUNNER) {
+ if (iev->proc == PROC_QUEUE) {
switch (imsg->hdr.type) {
case IMSG_BATCH_CREATE:
b = imsg->data;
@@ -144,6 +144,11 @@ mta_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
b = imsg->data;
mta_pickup(mta_lookup(env, b->id), NULL);
return;
+
+ case IMSG_QUEUE_MESSAGE_FD:
+ b = imsg->data;
+ mta_pickup(mta_lookup(env, b->id), &imsg->fd);
+ return;
}
}
@@ -184,15 +189,6 @@ mta_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
}
}
- if (iev->proc == PROC_QUEUE) {
- switch (imsg->hdr.type) {
- case IMSG_QUEUE_MESSAGE_FD:
- b = imsg->data;
- mta_pickup(mta_lookup(env, b->id), &imsg->fd);
- return;
- }
- }
-
if (iev->proc == PROC_PARENT) {
switch (imsg->hdr.type) {
case IMSG_CONF_START:
@@ -269,7 +265,6 @@ mta(struct smtpd *env)
struct peer peers[] = {
{ PROC_PARENT, imsg_dispatch },
{ PROC_QUEUE, imsg_dispatch },
- { PROC_RUNNER, imsg_dispatch },
{ PROC_LKA, imsg_dispatch }
};
@@ -502,7 +497,7 @@ mta_enter_state(struct mta_session *s, int newstate, void *p)
while ((m = TAILQ_FIRST(&s->recipients)))
mta_message_done(s, m);
- imsg_compose_event(s->env->sc_ievs[PROC_RUNNER],
+ imsg_compose_event(s->env->sc_ievs[PROC_QUEUE],
IMSG_BATCH_DONE, 0, 0, -1, NULL, 0);
/* deallocate resources */
diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c
index 5c693608d6d..ebd24c174a0 100644
--- a/usr.sbin/smtpd/queue.c
+++ b/usr.sbin/smtpd/queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue.c,v 1.79 2010/04/21 08:29:01 jacekm Exp $ */
+/* $OpenBSD: queue.c,v 1.80 2010/04/21 18:54:43 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -38,6 +38,7 @@
#include "smtpd.h"
void queue_imsg(struct smtpd *, struct imsgev *, struct imsg *);
+void queue_pass_to_runner(struct smtpd *, struct imsgev *, struct imsg *);
__dead void queue_shutdown(void);
void queue_sig_handler(int, short, void *);
void queue_setup_events(struct smtpd *);
@@ -57,7 +58,7 @@ queue_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
struct submit_status ss;
struct message *m;
struct batch *b;
- int fd, ret, verbose;
+ int fd, ret;
if (iev->proc == PROC_SMTP) {
m = imsg->data;
@@ -112,6 +113,10 @@ queue_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
imsg_compose_event(iev, IMSG_QUEUE_MESSAGE_FILE, 0, 0, fd,
&ss, sizeof ss);
return;
+
+ case IMSG_SMTP_ENQUEUE:
+ queue_pass_to_runner(env, iev, imsg);
+ return;
}
}
@@ -152,6 +157,15 @@ queue_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
}
}
+ if (iev->proc == PROC_RUNNER) {
+ /* forward imsgs from runner on its behalf */
+ log_debug("queue: runner sent %d imsg type %d", imsg->hdr.peerid, imsg->hdr.type);
+ imsg_compose_event(env->sc_ievs[imsg->hdr.peerid], imsg->hdr.type,
+ 0, imsg->hdr.pid, imsg->fd, (char *)imsg->data,
+ imsg->hdr.len - sizeof imsg->hdr);
+ return;
+ }
+
if (iev->proc == PROC_MTA) {
switch (imsg->hdr.type) {
case IMSG_QUEUE_MESSAGE_FD:
@@ -162,9 +176,8 @@ queue_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
return;
case IMSG_QUEUE_MESSAGE_UPDATE:
- imsg_compose_event(env->sc_ievs[PROC_RUNNER],
- IMSG_RUNNER_UPDATE_ENVELOPE, 0, 0, -1, imsg->data,
- sizeof(struct message));
+ case IMSG_BATCH_DONE:
+ queue_pass_to_runner(env, iev, imsg);
return;
}
}
@@ -172,18 +185,34 @@ queue_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
if (iev->proc == PROC_MDA) {
switch (imsg->hdr.type) {
case IMSG_QUEUE_MESSAGE_UPDATE:
- imsg_compose_event(env->sc_ievs[PROC_RUNNER],
- IMSG_RUNNER_UPDATE_ENVELOPE, 0, 0, -1, imsg->data,
- sizeof(struct message));
+ case IMSG_MDA_SESS_NEW:
+ queue_pass_to_runner(env, iev, imsg);
+ return;
+ }
+ }
+
+ if (iev->proc == PROC_CONTROL) {
+ switch (imsg->hdr.type) {
+ case IMSG_QUEUE_PAUSE_LOCAL:
+ case IMSG_QUEUE_PAUSE_OUTGOING:
+ case IMSG_QUEUE_RESUME_LOCAL:
+ case IMSG_QUEUE_RESUME_OUTGOING:
+ case IMSG_QUEUE_SCHEDULE:
+ case IMSG_QUEUE_REMOVE:
+ queue_pass_to_runner(env, iev, imsg);
return;
}
}
if (iev->proc == PROC_PARENT) {
switch (imsg->hdr.type) {
+ case IMSG_PARENT_ENQUEUE_OFFLINE:
+ queue_pass_to_runner(env, iev, imsg);
+ return;
+
case IMSG_CTL_VERBOSE:
- memcpy(&verbose, imsg->data, sizeof verbose);
- log_verbose(verbose);
+ log_verbose(*(int *)imsg->data);
+ queue_pass_to_runner(env, iev, imsg);
return;
}
}
@@ -192,6 +221,15 @@ queue_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
}
void
+queue_pass_to_runner(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
+{
+ log_debug("queue_pass_to_runner: from %d type %d", iev->proc, imsg->hdr.type);
+ imsg_compose_event(env->sc_ievs[PROC_RUNNER], imsg->hdr.type,
+ iev->proc, imsg->hdr.pid, imsg->fd, imsg->data,
+ imsg->hdr.len - sizeof imsg->hdr);
+}
+
+void
queue_sig_handler(int sig, short event, void *p)
{
switch (sig) {
diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c
index a78266219b7..1ee057d31bf 100644
--- a/usr.sbin/smtpd/runner.c
+++ b/usr.sbin/smtpd/runner.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: runner.c,v 1.83 2010/04/21 08:29:01 jacekm Exp $ */
+/* $OpenBSD: runner.c,v 1.84 2010/04/21 18:54:43 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -79,102 +79,87 @@ int runner_force_message_schedule(char *);
int runner_force_envelope_remove(char *);
int runner_force_message_remove(char *);
+void runner_imsg_compose(struct smtpd *, int, u_int16_t,
+ u_int32_t, pid_t, int, void *, u_int16_t);
+
void
runner_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
{
struct message *m;
struct remove *rem;
struct sched *sched;
-
- if (iev->proc == PROC_QUEUE) {
- switch (imsg->hdr.type) {
- case IMSG_RUNNER_UPDATE_ENVELOPE:
- env->stats->runner.active--;
- queue_message_update(imsg->data);
- return;
+ int proc;
+
+ /* queue stores imsg sender process number in the ``peerid'' field. */
+ proc = imsg->hdr.peerid;
+
+ switch (imsg->hdr.type) {
+ case IMSG_QUEUE_MESSAGE_UPDATE:
+ env->stats->runner.active--;
+ queue_message_update(imsg->data);
+ return;
+
+ case IMSG_MDA_SESS_NEW:
+ env->stats->mda.sessions_active--;
+ return;
+
+ case IMSG_BATCH_DONE:
+ env->stats->mta.sessions_active--;
+ return;
+
+ case IMSG_QUEUE_SCHEDULE:
+ sched = imsg->data;
+ sched->ret = 0;
+ if (valid_message_uid(sched->mid))
+ sched->ret = runner_force_envelope_schedule(sched->mid);
+ else if (valid_message_id(sched->mid))
+ sched->ret = runner_force_message_schedule(sched->mid);
+ runner_imsg_compose(env, proc, IMSG_QUEUE_SCHEDULE, 0, 0, -1,
+ sched, sizeof *sched);
+ return;
+
+ case IMSG_QUEUE_REMOVE:
+ rem = imsg->data;
+ rem->ret = 0;
+ if (valid_message_uid(rem->mid))
+ rem->ret = runner_force_envelope_remove(rem->mid);
+ else if (valid_message_id(rem->mid))
+ rem->ret = runner_force_message_remove(rem->mid);
+ runner_imsg_compose(env, proc, IMSG_QUEUE_REMOVE, 0, 0, -1, rem,
+ sizeof *rem);
+ return;
+
+ case IMSG_PARENT_ENQUEUE_OFFLINE:
+ runner_process_offline(env);
+ return;
+
+ case IMSG_SMTP_ENQUEUE:
+ m = imsg->data;
+ if (imsg->fd < 0 || !bounce_session(env, imsg->fd, m)) {
+ m->status = S_MESSAGE_TEMPFAILURE;
+ queue_message_update(m);
}
- }
+ return;
- if (iev->proc == PROC_MDA) {
- switch (imsg->hdr.type) {
- case IMSG_MDA_SESS_NEW:
- env->stats->mda.sessions_active--;
- return;
- }
- }
+ case IMSG_QUEUE_PAUSE_LOCAL:
+ env->sc_opts |= SMTPD_MDA_PAUSED;
+ return;
- if (iev->proc == PROC_MTA) {
- switch (imsg->hdr.type) {
- case IMSG_BATCH_DONE:
- env->stats->mta.sessions_active--;
- return;
- }
- }
-
- if (iev->proc == PROC_SMTP) {
- switch (imsg->hdr.type) {
- case IMSG_SMTP_ENQUEUE:
- m = imsg->data;
- if (imsg->fd < 0 || !bounce_session(env, imsg->fd, m)) {
- m->status = S_MESSAGE_TEMPFAILURE;
- queue_message_update(m);
- }
- return;
- }
- }
+ case IMSG_QUEUE_RESUME_LOCAL:
+ env->sc_opts &= ~SMTPD_MDA_PAUSED;
+ return;
- if (iev->proc == PROC_CONTROL) {
- switch (imsg->hdr.type) {
- case IMSG_MDA_PAUSE:
- env->sc_opts |= SMTPD_MDA_PAUSED;
- return;
-
- case IMSG_MTA_PAUSE:
- env->sc_opts |= SMTPD_MTA_PAUSED;
- return;
-
- case IMSG_MDA_RESUME:
- env->sc_opts &= ~SMTPD_MDA_PAUSED;
- return;
-
- case IMSG_MTA_RESUME:
- env->sc_opts &= ~SMTPD_MTA_PAUSED;
- return;
-
- case IMSG_RUNNER_SCHEDULE:
- sched = imsg->data;
- sched->ret = 0;
- if (valid_message_uid(sched->mid))
- sched->ret = runner_force_envelope_schedule(sched->mid);
- else if (valid_message_id(sched->mid))
- sched->ret = runner_force_message_schedule(sched->mid);
- imsg_compose_event(iev, IMSG_RUNNER_SCHEDULE, 0, 0, -1,
- sched, sizeof *sched);
- return;
-
- case IMSG_RUNNER_REMOVE:
- rem = imsg->data;
- rem->ret = 0;
- if (valid_message_uid(rem->mid))
- rem->ret = runner_force_envelope_remove(rem->mid);
- else if (valid_message_id(rem->mid))
- rem->ret = runner_force_message_remove(rem->mid);
- imsg_compose_event(iev, IMSG_RUNNER_REMOVE, 0, 0, -1,
- rem, sizeof *rem);
- return;
- }
- }
+ case IMSG_QUEUE_PAUSE_OUTGOING:
+ env->sc_opts |= SMTPD_MTA_PAUSED;
+ return;
- if (iev->proc == PROC_PARENT) {
- switch (imsg->hdr.type) {
- case IMSG_PARENT_ENQUEUE_OFFLINE:
- runner_process_offline(env);
- return;
+ case IMSG_QUEUE_RESUME_OUTGOING:
+ env->sc_opts &= ~SMTPD_MTA_PAUSED;
+ return;
- case IMSG_CTL_VERBOSE:
- log_verbose(*(int *)imsg->data);
- return;
- }
+ case IMSG_CTL_VERBOSE:
+ log_verbose(*(int *)imsg->data);
+ return;
}
fatalx("runner_imsg: unexpected imsg");
@@ -227,13 +212,7 @@ runner(struct smtpd *env)
struct event ev_sigterm;
struct peer peers[] = {
- { PROC_PARENT, imsg_dispatch },
- { PROC_CONTROL, imsg_dispatch },
- { PROC_MDA, imsg_dispatch },
- { PROC_MTA, imsg_dispatch },
- { PROC_QUEUE, imsg_dispatch },
- { PROC_LKA, imsg_dispatch },
- { PROC_SMTP, imsg_dispatch }
+ { PROC_QUEUE, imsg_dispatch }
};
switch (pid = fork()) {
@@ -302,7 +281,7 @@ runner_process_offline(struct smtpd *env)
q = qwalk_new(PATH_OFFLINE);
if (qwalk(q, path))
- imsg_compose_event(env->sc_ievs[PROC_PARENT],
+ runner_imsg_compose(env, PROC_PARENT,
IMSG_PARENT_ENQUEUE_OFFLINE, 0, 0, -1, path,
strlen(path) + 1);
@@ -493,8 +472,8 @@ runner_process_batchqueue(struct smtpd *env)
case T_MDA_BATCH:
m = TAILQ_FIRST(&batchp->messages);
fd = queue_open_message_file(m->message_id);
- imsg_compose_event(env->sc_ievs[PROC_MDA],
- IMSG_MDA_SESS_NEW, 0, 0, fd, m, sizeof *m);
+ runner_imsg_compose(env, PROC_MDA, IMSG_MDA_SESS_NEW,
+ 0, 0, fd, m, sizeof *m);
TAILQ_REMOVE(&batchp->messages, m, entry);
free(m);
env->stats->mda.sessions_active++;
@@ -502,17 +481,16 @@ runner_process_batchqueue(struct smtpd *env)
break;
case T_MTA_BATCH:
- imsg_compose_event(env->sc_ievs[PROC_MTA],
- IMSG_BATCH_CREATE, 0, 0, -1, batchp,
- sizeof *batchp);
+ runner_imsg_compose(env, PROC_MTA, IMSG_BATCH_CREATE,
+ 0, 0, -1, batchp, sizeof *batchp);
while ((m = TAILQ_FIRST(&batchp->messages))) {
- imsg_compose_event(env->sc_ievs[PROC_MTA],
+ runner_imsg_compose(env, PROC_MTA,
IMSG_BATCH_APPEND, 0, 0, -1, m, sizeof *m);
TAILQ_REMOVE(&batchp->messages, m, entry);
free(m);
}
- imsg_compose_event(env->sc_ievs[PROC_MTA],
- IMSG_BATCH_CLOSE, 0, 0, -1, batchp, sizeof *batchp);
+ runner_imsg_compose(env, PROC_MTA, IMSG_BATCH_CLOSE,
+ 0, 0, -1, batchp, sizeof *batchp);
env->stats->mta.sessions_active++;
env->stats->mta.sessions++;
break;
@@ -910,4 +888,14 @@ message_reset_flags(struct message *m)
sleep(1);
}
+void
+runner_imsg_compose(struct smtpd *env, int proc, u_int16_t type,
+ u_int32_t peerid, pid_t pid, int fd, void *data, u_int16_t datalen)
+{
+ /* forward via the queue process */
+ log_debug("runner: sending %d imsg type %d", proc, type);
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE], type, proc, pid, fd,
+ data, datalen);
+}
+
SPLAY_GENERATE(batchtree, batch, b_nodes, batch_cmp);
diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c
index 6eed38fde17..a977a3786a9 100644
--- a/usr.sbin/smtpd/smtp.c
+++ b/usr.sbin/smtpd/smtp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp.c,v 1.69 2010/04/21 08:29:01 jacekm Exp $ */
+/* $OpenBSD: smtp.c,v 1.70 2010/04/21 18:54:43 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -150,6 +150,12 @@ smtp_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
return;
session_pickup(s, ss);
return;
+
+ case IMSG_SMTP_ENQUEUE:
+ imsg_compose_event(iev, IMSG_SMTP_ENQUEUE, 0, 0,
+ smtp_enqueue(env, NULL), imsg->data,
+ sizeof(struct message));
+ return;
}
}
@@ -268,16 +274,6 @@ smtp_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
}
}
- if (iev->proc == PROC_RUNNER) {
- switch (imsg->hdr.type) {
- case IMSG_SMTP_ENQUEUE:
- imsg_compose_event(iev, IMSG_SMTP_ENQUEUE, 0, 0,
- smtp_enqueue(env, NULL), imsg->data,
- sizeof(struct message));
- return;
- }
- }
-
fatalx("smtp_imsg: unexpected imsg");
}
@@ -315,8 +311,7 @@ smtp(struct smtpd *env)
{ PROC_MFA, imsg_dispatch },
{ PROC_QUEUE, imsg_dispatch },
{ PROC_LKA, imsg_dispatch },
- { PROC_CONTROL, imsg_dispatch },
- { PROC_RUNNER, imsg_dispatch }
+ { PROC_CONTROL, imsg_dispatch }
};
switch (pid = fork()) {
diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c
index c81e9da9ce0..c04cd43c9b0 100644
--- a/usr.sbin/smtpd/smtpctl.c
+++ b/usr.sbin/smtpd/smtpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpctl.c,v 1.46 2010/01/10 16:42:35 gilles Exp $ */
+/* $OpenBSD: smtpctl.c,v 1.47 2010/04/21 18:54:43 jacekm Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -143,19 +143,19 @@ connected:
break;
*/
case PAUSE_MDA:
- imsg_compose(ibuf, IMSG_MDA_PAUSE, 0, 0, -1, NULL, 0);
+ imsg_compose(ibuf, IMSG_QUEUE_PAUSE_LOCAL, 0, 0, -1, NULL, 0);
break;
case PAUSE_MTA:
- imsg_compose(ibuf, IMSG_MTA_PAUSE, 0, 0, -1, NULL, 0);
+ imsg_compose(ibuf, IMSG_QUEUE_PAUSE_OUTGOING, 0, 0, -1, NULL, 0);
break;
case PAUSE_SMTP:
imsg_compose(ibuf, IMSG_SMTP_PAUSE, 0, 0, -1, NULL, 0);
break;
case RESUME_MDA:
- imsg_compose(ibuf, IMSG_MDA_RESUME, 0, 0, -1, NULL, 0);
+ imsg_compose(ibuf, IMSG_QUEUE_RESUME_LOCAL, 0, 0, -1, NULL, 0);
break;
case RESUME_MTA:
- imsg_compose(ibuf, IMSG_MTA_RESUME, 0, 0, -1, NULL, 0);
+ imsg_compose(ibuf, IMSG_QUEUE_RESUME_OUTGOING, 0, 0, -1, NULL, 0);
break;
case RESUME_SMTP:
imsg_compose(ibuf, IMSG_SMTP_RESUME, 0, 0, -1, NULL, 0);
@@ -169,7 +169,7 @@ connected:
s.fd = -1;
bzero(s.mid, sizeof (s.mid));
strlcpy(s.mid, res->data, sizeof (s.mid));
- imsg_compose(ibuf, IMSG_RUNNER_SCHEDULE, 0, 0, -1, &s, sizeof (s));
+ imsg_compose(ibuf, IMSG_QUEUE_SCHEDULE, 0, 0, -1, &s, sizeof (s));
break;
}
case REMOVE: {
@@ -178,7 +178,7 @@ connected:
s.fd = -1;
bzero(s.mid, sizeof (s.mid));
strlcpy(s.mid, res->data, sizeof (s.mid));
- imsg_compose(ibuf, IMSG_RUNNER_REMOVE, 0, 0, -1, &s, sizeof (s));
+ imsg_compose(ibuf, IMSG_QUEUE_REMOVE, 0, 0, -1, &s, sizeof (s));
break;
}
case MONITOR:
diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c
index 4e97facd3df..2c130732484 100644
--- a/usr.sbin/smtpd/smtpd.c
+++ b/usr.sbin/smtpd/smtpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.c,v 1.101 2010/04/20 15:34:56 jacekm Exp $ */
+/* $OpenBSD: smtpd.c,v 1.102 2010/04/21 18:54:43 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -116,7 +116,7 @@ parent_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
}
}
- if (iev->proc == PROC_RUNNER) {
+ if (iev->proc == PROC_QUEUE) {
switch (imsg->hdr.type) {
case IMSG_PARENT_ENQUEUE_OFFLINE:
if (! parent_enqueue_offline(env, imsg->data))
@@ -173,8 +173,6 @@ parent_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
0, 0, -1, imsg->data, sizeof(int));
imsg_compose_event(env->sc_ievs[PROC_QUEUE], IMSG_CTL_VERBOSE,
0, 0, -1, imsg->data, sizeof(int));
- imsg_compose_event(env->sc_ievs[PROC_RUNNER], IMSG_CTL_VERBOSE,
- 0, 0, -1, imsg->data, sizeof(int));
imsg_compose_event(env->sc_ievs[PROC_SMTP], IMSG_CTL_VERBOSE,
0, 0, -1, imsg->data, sizeof(int));
return;
@@ -393,7 +391,7 @@ parent_sig_handler(int sig, short event, void *p)
"message; smtpctl %s", cause);
else
log_debug("offline message enqueued");
- imsg_compose_event(env->sc_ievs[PROC_RUNNER],
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE],
IMSG_PARENT_ENQUEUE_OFFLINE, 0, 0, -1,
NULL, 0);
break;
@@ -434,8 +432,7 @@ main(int argc, char *argv[])
{ PROC_MFA, imsg_dispatch },
{ PROC_MTA, imsg_dispatch },
{ PROC_SMTP, imsg_dispatch },
- { PROC_QUEUE, imsg_dispatch },
- { PROC_RUNNER, imsg_dispatch }
+ { PROC_QUEUE, imsg_dispatch }
};
opts = 0;
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 96651f0ce9b..bdbf1d52bf9 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.174 2010/04/20 15:34:56 jacekm Exp $ */
+/* $OpenBSD: smtpd.h,v 1.175 2010/04/21 18:54:43 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -149,16 +149,17 @@ enum imsg_type {
IMSG_QUEUE_COMMIT_MESSAGE,
IMSG_QUEUE_TEMPFAIL,
IMSG_QUEUE_STATS,
+ IMSG_QUEUE_PAUSE_LOCAL,
+ IMSG_QUEUE_PAUSE_OUTGOING,
+ IMSG_QUEUE_RESUME_LOCAL,
+ IMSG_QUEUE_RESUME_OUTGOING,
IMSG_QUEUE_REMOVE_SUBMISSION,
IMSG_QUEUE_MESSAGE_UPDATE,
IMSG_QUEUE_MESSAGE_FD,
IMSG_QUEUE_MESSAGE_FILE,
-
- IMSG_RUNNER_UPDATE_ENVELOPE,
- IMSG_RUNNER_STATS,
- IMSG_RUNNER_SCHEDULE,
- IMSG_RUNNER_REMOVE,
+ IMSG_QUEUE_SCHEDULE,
+ IMSG_QUEUE_REMOVE,
IMSG_BATCH_CREATE,
IMSG_BATCH_APPEND,
@@ -173,18 +174,12 @@ enum imsg_type {
IMSG_PARENT_AUTHENTICATE,
IMSG_PARENT_SEND_CONFIG,
- IMSG_MDA_PAUSE,
- IMSG_MTA_PAUSE,
- IMSG_SMTP_PAUSE,
IMSG_SMTP_STATS,
- IMSG_MDA_RESUME,
- IMSG_MTA_RESUME,
- IMSG_SMTP_RESUME,
-
IMSG_STATS,
-
IMSG_SMTP_ENQUEUE,
+ IMSG_SMTP_PAUSE,
+ IMSG_SMTP_RESUME,
IMSG_DNS_A,
IMSG_DNS_A_END,