summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2014-07-13 15:38:09 +0000
committerkrw <krw@openbsd.org>2014-07-13 15:38:09 +0000
commitf485ae0dc19c5809145d83e350a15fcf97f731ad (patch)
treebcec36ec2437d1f4dc92995320e310d588721fb9
parentCompatibility hack for the old "manpath=OpenBSD<blank>" query parameter format; (diff)
downloadwireguard-openbsd-f485ae0dc19c5809145d83e350a15fcf97f731ad.tar.xz
wireguard-openbsd-f485ae0dc19c5809145d83e350a15fcf97f731ad.zip
Since the event(s) passed to a callback can be a mask of all events
of interest and EV_WRITE is or'ed into the interesting events, it is more correct to check both events each time. Pointed out by Claudio. ok henning@ claudio@
-rw-r--r--usr.sbin/ypldap/ldapclient.c29
-rw-r--r--usr.sbin/ypldap/ypldap.c16
-rw-r--r--usr.sbin/ypldap/ypldap_dns.c16
3 files changed, 30 insertions, 31 deletions
diff --git a/usr.sbin/ypldap/ldapclient.c b/usr.sbin/ypldap/ldapclient.c
index e31596929aa..486cb3e00e7 100644
--- a/usr.sbin/ypldap/ldapclient.c
+++ b/usr.sbin/ypldap/ldapclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldapclient.c,v 1.29 2014/07/13 12:07:59 krw Exp $ */
+/* $OpenBSD: ldapclient.c,v 1.30 2014/07/13 15:38:09 krw Exp $ */
/*
* Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org>
@@ -152,7 +152,7 @@ client_sig_handler(int sig, short event, void *p)
}
void
-client_dispatch_dns(int fd, short event, void *p)
+client_dispatch_dns(int fd, short events, void *p)
{
struct imsg imsg;
u_int16_t dlen;
@@ -166,21 +166,21 @@ client_dispatch_dns(int fd, short event, void *p)
struct imsgev *iev = env->sc_iev_dns;
struct imsgbuf *ibuf = &iev->ibuf;
- switch (event) {
- case EV_READ:
+ if ((events & (EV_READ | EV_WRITE)) == 0)
+ fatalx("unknown event");
+
+ if (events & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
if (n == 0)
shut = 1;
- break;
- case EV_WRITE:
+ }
+ if (events & EV_WRITE) {
if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
if (n == 0)
shut = 1;
goto done;
- default:
- fatalx("unknown event");
}
for (;;) {
@@ -260,7 +260,7 @@ done:
}
void
-client_dispatch_parent(int fd, short event, void *p)
+client_dispatch_parent(int fd, short events, void *p)
{
int n;
int shut = 0;
@@ -269,22 +269,21 @@ client_dispatch_parent(int fd, short event, void *p)
struct imsgev *iev = env->sc_iev;
struct imsgbuf *ibuf = &iev->ibuf;
+ if ((events & (EV_READ | EV_WRITE)) == 0)
+ fatalx("unknown event");
- switch (event) {
- case EV_READ:
+ if (events & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
if (n == 0)
shut = 1;
- break;
- case EV_WRITE:
+ }
+ if (events & EV_WRITE) {
if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
if (n == 0)
shut = 1;
goto done;
- default:
- fatalx("unknown event");
}
for (;;) {
diff --git a/usr.sbin/ypldap/ypldap.c b/usr.sbin/ypldap/ypldap.c
index 27208c14640..5f7b479e0b9 100644
--- a/usr.sbin/ypldap/ypldap.c
+++ b/usr.sbin/ypldap/ypldap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypldap.c,v 1.13 2014/07/13 12:07:59 krw Exp $ */
+/* $OpenBSD: ypldap.c,v 1.14 2014/07/13 15:38:09 krw Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -346,7 +346,7 @@ make_uids:
}
void
-main_dispatch_client(int fd, short event, void *p)
+main_dispatch_client(int fd, short events, void *p)
{
int n;
int shut = 0;
@@ -356,21 +356,21 @@ main_dispatch_client(int fd, short event, void *p)
struct idm_req ir;
struct imsg imsg;
- switch (event) {
- case EV_READ:
+ if ((events & (EV_READ | EV_WRITE)) == 0)
+ fatalx("unknown event");
+
+ if (events & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
if (n == 0)
shut = 1;
- break;
- case EV_WRITE:
+ }
+ if (events & EV_WRITE) {
if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
if (n == 0)
shut = 1;
goto done;
- default:
- fatalx("unknown event");
}
for (;;) {
diff --git a/usr.sbin/ypldap/ypldap_dns.c b/usr.sbin/ypldap/ypldap_dns.c
index 677b03aa042..1e4aa6bb4b1 100644
--- a/usr.sbin/ypldap/ypldap_dns.c
+++ b/usr.sbin/ypldap/ypldap_dns.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypldap_dns.c,v 1.6 2014/07/13 12:07:59 krw Exp $ */
+/* $OpenBSD: ypldap_dns.c,v 1.7 2014/07/13 15:38:09 krw Exp $ */
/*
* Copyright (c) 2003-2008 Henning Brauer <henning@openbsd.org>
@@ -122,7 +122,7 @@ ypldap_dns(int pipe_ntp[2], struct passwd *pw)
}
void
-dns_dispatch_imsg(int fd, short event, void *p)
+dns_dispatch_imsg(int fd, short events, void *p)
{
struct imsg imsg;
int n, cnt;
@@ -134,21 +134,21 @@ dns_dispatch_imsg(int fd, short event, void *p)
struct imsgbuf *ibuf = &iev->ibuf;
int shut = 0;
- switch (event) {
- case EV_READ:
+ if ((events & (EV_READ | EV_WRITE)) == 0)
+ fatalx("unknown event");
+
+ if (events & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
if (n == 0)
shut = 1;
- break;
- case EV_WRITE:
+ }
+ if (events & EV_WRITE) {
if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN)
fatal("msgbuf_write");
if (n == 0)
shut = 1;
goto done;
- default:
- fatalx("unknown event");
}
for (;;) {