diff options
author | Martin Hedenfal <martinh@cvs.openbsd.org> | 2010-06-15 14:43:57 +0000 |
---|---|---|
committer | Martin Hedenfal <martinh@cvs.openbsd.org> | 2010-06-15 14:43:57 +0000 |
commit | ac2467c4c91b5bce0ee1d16c760443914f54fcf2 (patch) | |
tree | 417d36e07ccac00fbd9b508889b6390cfcee7af4 /usr.sbin/ldapd | |
parent | d2ee0ee1bcb8090adc1356dde3db4c53e3d917e0 (diff) |
EV_READ and EV_WRITE are not mutually exclusive, so check if we get both in
the same event.
Diffstat (limited to 'usr.sbin/ldapd')
-rw-r--r-- | usr.sbin/ldapd/ldapd.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/usr.sbin/ldapd/ldapd.c b/usr.sbin/ldapd/ldapd.c index 8069df7cd8d..d0be869613d 100644 --- a/usr.sbin/ldapd/ldapd.c +++ b/usr.sbin/ldapd/ldapd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldapd.c,v 1.2 2010/05/31 18:29:04 martinh Exp $ */ +/* $OpenBSD: ldapd.c,v 1.3 2010/06/15 14:43:56 martinh Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se> @@ -253,10 +253,12 @@ imsg_compose_event(struct imsgev *iev, u_int16_t type, int imsg_event_handle(struct imsgev *iev, short event) { - ssize_t n; + ssize_t n = 0; + + if ((event & ~(EV_READ | EV_WRITE)) != 0) + fatalx("unknown event"); - switch (event) { - case EV_READ: + if (event & EV_READ) { if ((n = imsg_read(&iev->ibuf)) == -1) fatal("imsg_read error"); if (n == 0) { @@ -265,17 +267,15 @@ imsg_event_handle(struct imsgev *iev, short event) event_loopexit(NULL); return -1; } - break; - case EV_WRITE: + } + + if (event & EV_WRITE) { if (msgbuf_write(&iev->ibuf.w) == -1) fatal("msgbuf_write"); imsg_event_add(iev); - return 1; - default: - fatalx("unknown event"); } - return 0; + return (n == 0) ? 1 : 0; } void |