summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-06-01 13:20:57 +0000
committerJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-06-01 13:20:57 +0000
commiteb2c7fd4c525dbce423339d737b86ed9c30b308c (patch)
tree1306a31f459c4a6f982847eeff0325074918ce4c
parentfc7678b4f83d3e3982caba2cb908da6fc28b788f (diff)
Fix EV_READ/EV_WRITE testing inside IMSG handlers. Based on similar change
to the routing daemons by claudio@; ok gilles@
-rw-r--r--usr.sbin/smtpd/control.c92
-rw-r--r--usr.sbin/smtpd/dns.c27
-rw-r--r--usr.sbin/smtpd/lka.c80
-rw-r--r--usr.sbin/smtpd/mda.c41
-rw-r--r--usr.sbin/smtpd/mfa.c54
-rw-r--r--usr.sbin/smtpd/mta.c54
-rw-r--r--usr.sbin/smtpd/queue.c80
-rw-r--r--usr.sbin/smtpd/runner.c80
-rw-r--r--usr.sbin/smtpd/smtp.c67
-rw-r--r--usr.sbin/smtpd/smtpd.c93
10 files changed, 258 insertions, 410 deletions
diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c
index a81e7aa39a8..5f07380118c 100644
--- a/usr.sbin/smtpd/control.c
+++ b/usr.sbin/smtpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.31 2009/05/25 11:17:32 jacekm Exp $ */
+/* $OpenBSD: control.c,v 1.32 2009/06/01 13:20:56 jacekm Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -287,22 +287,18 @@ control_dispatch_ext(int fd, short event, void *arg)
return;
}
- switch (event) {
- case EV_READ:
+ if (event & EV_READ) {
if ((n = imsg_read(&c->ibuf)) == -1 || n == 0) {
control_close(fd);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&c->ibuf.w) < 0) {
control_close(fd);
return;
}
- imsg_event_add(&c->ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -494,8 +490,8 @@ control_dispatch_parent(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_PARENT];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -504,14 +500,11 @@ control_dispatch_parent(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -558,8 +551,8 @@ control_dispatch_lka(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_LKA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -568,14 +561,11 @@ control_dispatch_lka(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -604,8 +594,8 @@ control_dispatch_mfa(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_MFA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -614,14 +604,11 @@ control_dispatch_mfa(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -650,8 +637,8 @@ control_dispatch_queue(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_QUEUE];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -660,14 +647,11 @@ control_dispatch_queue(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -696,8 +680,8 @@ control_dispatch_runner(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_RUNNER];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -706,14 +690,11 @@ control_dispatch_runner(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -760,8 +741,8 @@ control_dispatch_smtp(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_SMTP];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -770,14 +751,11 @@ control_dispatch_smtp(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
diff --git a/usr.sbin/smtpd/dns.c b/usr.sbin/smtpd/dns.c
index db9b8c3526e..72a254c80db 100644
--- a/usr.sbin/smtpd/dns.c
+++ b/usr.sbin/smtpd/dns.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dns.c,v 1.11 2009/05/09 17:04:55 jacekm Exp $ */
+/* $OpenBSD: dns.c,v 1.12 2009/06/01 13:20:56 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -137,20 +137,17 @@ parent_dispatch_dns(int sig, short event, void *p)
ssize_t n;
ibuf = &rd->ibuf;
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0)
fatal("parent_dispatch_dns: pipe closed");
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("parent_dispatch_dns: msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -235,8 +232,7 @@ dns_dispatch_parent(int sig, short event, void *p)
struct imsg imsg;
ssize_t n;
- switch (event) {
- case EV_READ:
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -245,14 +241,11 @@ dns_dispatch_parent(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("dns_dispatch_parent: msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c
index 3b9a48adcd1..52d011309c5 100644
--- a/usr.sbin/smtpd/lka.c
+++ b/usr.sbin/smtpd/lka.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka.c,v 1.51 2009/05/24 14:38:56 jacekm Exp $ */
+/* $OpenBSD: lka.c,v 1.52 2009/06/01 13:20:56 jacekm Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -102,8 +102,8 @@ lka_dispatch_parent(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_PARENT];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -112,14 +112,11 @@ lka_dispatch_parent(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -325,8 +322,8 @@ lka_dispatch_mfa(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_MFA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -335,14 +332,11 @@ lka_dispatch_mfa(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -463,8 +457,8 @@ lka_dispatch_mta(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_MTA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -473,14 +467,11 @@ lka_dispatch_mta(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -540,8 +531,8 @@ lka_dispatch_smtp(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_SMTP];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -550,14 +541,11 @@ lka_dispatch_smtp(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -593,8 +581,8 @@ lka_dispatch_queue(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_QUEUE];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -603,14 +591,11 @@ lka_dispatch_queue(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -639,8 +624,8 @@ lka_dispatch_runner(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_RUNNER];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -649,14 +634,11 @@ lka_dispatch_runner(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
diff --git a/usr.sbin/smtpd/mda.c b/usr.sbin/smtpd/mda.c
index a46f0c30a04..73a93bf3fad 100644
--- a/usr.sbin/smtpd/mda.c
+++ b/usr.sbin/smtpd/mda.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mda.c,v 1.18 2009/05/24 14:38:56 jacekm Exp $ */
+/* $OpenBSD: mda.c,v 1.19 2009/06/01 13:20:56 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -64,8 +64,8 @@ mda_dispatch_parent(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_PARENT];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -74,14 +74,11 @@ mda_dispatch_parent(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -194,8 +191,8 @@ mda_dispatch_queue(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_QUEUE];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -204,14 +201,11 @@ mda_dispatch_queue(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -240,8 +234,8 @@ mda_dispatch_runner(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_RUNNER];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -250,14 +244,11 @@ mda_dispatch_runner(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
diff --git a/usr.sbin/smtpd/mfa.c b/usr.sbin/smtpd/mfa.c
index 97759962d46..26c55b382e7 100644
--- a/usr.sbin/smtpd/mfa.c
+++ b/usr.sbin/smtpd/mfa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfa.c,v 1.31 2009/05/24 14:38:56 jacekm Exp $ */
+/* $OpenBSD: mfa.c,v 1.32 2009/06/01 13:20:56 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -76,8 +76,8 @@ mfa_dispatch_parent(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_PARENT];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -86,14 +86,11 @@ mfa_dispatch_parent(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -243,8 +240,8 @@ mfa_dispatch_smtp(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_SMTP];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -253,14 +250,11 @@ mfa_dispatch_smtp(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -307,8 +301,8 @@ mfa_dispatch_lka(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_LKA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -317,14 +311,11 @@ mfa_dispatch_lka(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -371,8 +362,8 @@ mfa_dispatch_control(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_CONTROL];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -381,14 +372,11 @@ mfa_dispatch_control(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c
index 1ecc66748ef..6b4a8539927 100644
--- a/usr.sbin/smtpd/mta.c
+++ b/usr.sbin/smtpd/mta.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mta.c,v 1.54 2009/05/31 18:34:48 gilles Exp $ */
+/* $OpenBSD: mta.c,v 1.55 2009/06/01 13:20:56 jacekm Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -79,8 +79,8 @@ mta_dispatch_parent(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_PARENT];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -89,14 +89,11 @@ mta_dispatch_parent(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -159,8 +156,8 @@ mta_dispatch_lka(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_LKA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -169,14 +166,11 @@ mta_dispatch_lka(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -278,8 +272,8 @@ mta_dispatch_queue(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_QUEUE];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -288,14 +282,11 @@ mta_dispatch_queue(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -346,8 +337,8 @@ mta_dispatch_runner(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_RUNNER];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -356,14 +347,11 @@ mta_dispatch_runner(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c
index d8798802375..cb25bdc7a0f 100644
--- a/usr.sbin/smtpd/queue.c
+++ b/usr.sbin/smtpd/queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue.c,v 1.65 2009/05/24 14:38:56 jacekm Exp $ */
+/* $OpenBSD: queue.c,v 1.66 2009/06/01 13:20:56 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -78,8 +78,8 @@ queue_dispatch_control(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_CONTROL];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -88,14 +88,11 @@ queue_dispatch_control(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -124,8 +121,8 @@ queue_dispatch_smtp(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_SMTP];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -134,14 +131,11 @@ queue_dispatch_smtp(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -261,8 +255,8 @@ queue_dispatch_mda(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_MDA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -271,14 +265,11 @@ queue_dispatch_mda(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -313,8 +304,8 @@ queue_dispatch_mta(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_MTA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -323,14 +314,11 @@ queue_dispatch_mta(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -377,8 +365,8 @@ queue_dispatch_lka(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_LKA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -387,14 +375,11 @@ queue_dispatch_lka(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -470,8 +455,8 @@ queue_dispatch_runner(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_RUNNER];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -480,14 +465,11 @@ queue_dispatch_runner(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c
index 6f415ebf139..d995bb616fa 100644
--- a/usr.sbin/smtpd/runner.c
+++ b/usr.sbin/smtpd/runner.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: runner.c,v 1.48 2009/05/24 14:38:56 jacekm Exp $ */
+/* $OpenBSD: runner.c,v 1.49 2009/06/01 13:20:56 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -104,8 +104,8 @@ runner_dispatch_parent(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_PARENT];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -114,14 +114,11 @@ runner_dispatch_parent(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -153,8 +150,8 @@ runner_dispatch_control(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_CONTROL];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -163,14 +160,11 @@ runner_dispatch_control(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -225,8 +219,8 @@ runner_dispatch_queue(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_QUEUE];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -235,14 +229,11 @@ runner_dispatch_queue(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -280,8 +271,8 @@ runner_dispatch_mda(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_MDA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -290,14 +281,11 @@ runner_dispatch_mda(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -326,8 +314,8 @@ runner_dispatch_mta(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_MTA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -336,14 +324,11 @@ runner_dispatch_mta(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -373,8 +358,8 @@ runner_dispatch_lka(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_LKA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -383,14 +368,11 @@ runner_dispatch_lka(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c
index d1f353e52a5..7a09bfe1a81 100644
--- a/usr.sbin/smtpd/smtp.c
+++ b/usr.sbin/smtpd/smtp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp.c,v 1.52 2009/05/25 14:00:36 jacekm Exp $ */
+/* $OpenBSD: smtp.c,v 1.53 2009/06/01 13:20:56 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -74,8 +74,8 @@ smtp_dispatch_parent(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_PARENT];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -84,14 +84,11 @@ smtp_dispatch_parent(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -219,8 +216,8 @@ smtp_dispatch_mfa(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_MFA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -229,14 +226,11 @@ smtp_dispatch_mfa(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -280,8 +274,8 @@ smtp_dispatch_lka(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_LKA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -290,14 +284,11 @@ smtp_dispatch_lka(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -350,8 +341,8 @@ smtp_dispatch_queue(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_QUEUE];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -360,14 +351,11 @@ smtp_dispatch_queue(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -477,8 +465,8 @@ smtp_dispatch_control(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_CONTROL];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -487,14 +475,11 @@ smtp_dispatch_control(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c
index 707be6899e7..f02973cdaa6 100644
--- a/usr.sbin/smtpd/smtpd.c
+++ b/usr.sbin/smtpd/smtpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.c,v 1.69 2009/05/30 23:53:41 gilles Exp $ */
+/* $OpenBSD: smtpd.c,v 1.70 2009/06/01 13:20:56 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -241,8 +241,8 @@ parent_dispatch_lka(int fd, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_LKA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -251,14 +251,11 @@ parent_dispatch_lka(int fd, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -302,8 +299,8 @@ parent_dispatch_mfa(int fd, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_MFA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -312,14 +309,11 @@ parent_dispatch_mfa(int fd, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -348,8 +342,8 @@ parent_dispatch_mta(int fd, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_MTA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -358,14 +352,11 @@ parent_dispatch_mta(int fd, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -394,8 +385,8 @@ parent_dispatch_mda(int fd, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_MDA];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -404,14 +395,11 @@ parent_dispatch_mda(int fd, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -541,8 +529,8 @@ parent_dispatch_smtp(int fd, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_SMTP];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -551,14 +539,11 @@ parent_dispatch_smtp(int fd, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -603,8 +588,8 @@ parent_dispatch_runner(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_RUNNER];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -613,14 +598,11 @@ parent_dispatch_runner(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -654,8 +636,8 @@ parent_dispatch_control(int sig, short event, void *p)
ssize_t n;
ibuf = env->sc_ibufs[PROC_CONTROL];
- switch (event) {
- case EV_READ:
+
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
@@ -664,14 +646,11 @@ parent_dispatch_control(int sig, short event, void *p)
event_loopexit(NULL);
return;
}
- break;
- case EV_WRITE:
+ }
+
+ if (event & EV_WRITE) {
if (msgbuf_write(&ibuf->w) == -1)
fatal("msgbuf_write");
- imsg_event_add(ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {