summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/control.c
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 /usr.sbin/smtpd/control.c
parentfc7678b4f83d3e3982caba2cb908da6fc28b788f (diff)
Fix EV_READ/EV_WRITE testing inside IMSG handlers. Based on similar change
to the routing daemons by claudio@; ok gilles@
Diffstat (limited to 'usr.sbin/smtpd/control.c')
-rw-r--r--usr.sbin/smtpd/control.c92
1 files changed, 35 insertions, 57 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 (;;) {