diff options
author | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2009-06-01 13:20:57 +0000 |
---|---|---|
committer | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2009-06-01 13:20:57 +0000 |
commit | eb2c7fd4c525dbce423339d737b86ed9c30b308c (patch) | |
tree | 1306a31f459c4a6f982847eeff0325074918ce4c /usr.sbin/smtpd/lka.c | |
parent | fc7678b4f83d3e3982caba2cb908da6fc28b788f (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/lka.c')
-rw-r--r-- | usr.sbin/smtpd/lka.c | 80 |
1 files changed, 31 insertions, 49 deletions
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 (;;) { |