diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2009-06-02 11:33:07 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2009-06-02 11:33:07 +0000 |
commit | 57a4c5a772d575909ce181d00e9cd115f96c8cc0 (patch) | |
tree | 5d7d5779ba4aab945e11fe9275492f89cf135fd8 /usr.sbin/relayd/pfe.c | |
parent | 343879da2f1cf08b2a1b5390a13244334f657d96 (diff) |
Libevent may do an upcall with both EV_READ and EV_WRITE set.
So change the code accordingly to allow that.
Found by claudio@ in ospfd
Diffstat (limited to 'usr.sbin/relayd/pfe.c')
-rw-r--r-- | usr.sbin/relayd/pfe.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/usr.sbin/relayd/pfe.c b/usr.sbin/relayd/pfe.c index 0d1c45831f1..c46471e265e 100644 --- a/usr.sbin/relayd/pfe.c +++ b/usr.sbin/relayd/pfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfe.c,v 1.55 2009/04/17 09:47:06 reyk Exp $ */ +/* $OpenBSD: pfe.c,v 1.56 2009/06/02 11:33:06 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -229,8 +229,8 @@ pfe_dispatch_imsg(int fd, short event, void *ptr) struct ctl_status st; ibuf = ptr; - switch (event) { - case EV_READ: + + if (event & EV_READ) { if ((n = imsg_read(ibuf)) == -1) fatal("pfe_dispatch_imsg: imsg_read_error"); if (n == 0) { @@ -239,14 +239,13 @@ pfe_dispatch_imsg(int fd, short event, void *ptr) event_loopexit(NULL); return; } - break; - case EV_WRITE: + } + + if (event & EV_WRITE) { if (msgbuf_write(&ibuf->w) == -1) fatal("pfe_dispatch_imsg: msgbuf_write"); imsg_event_add(ibuf); return; - default: - fatalx("pfe_dispatch_imsg: unknown event"); } for (;;) { @@ -338,8 +337,8 @@ pfe_dispatch_parent(int fd, short event, void * ptr) struct address *virt; ibuf = ptr; - switch (event) { - case EV_READ: + + if (event & EV_READ) { if ((n = imsg_read(ibuf)) == -1) fatal("imsg_read error"); if (n == 0) { @@ -348,14 +347,14 @@ pfe_dispatch_parent(int fd, short event, void * ptr) 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("pfe_dispatch_parent: unknown event"); } for (;;) { @@ -461,8 +460,8 @@ pfe_dispatch_relay(int fd, short event, void * ptr) struct relay *rlay; ibuf = ptr; - switch (event) { - case EV_READ: + + if (event & EV_READ) { if ((n = imsg_read(ibuf)) == -1) fatal("imsg_read error"); if (n == 0) { @@ -471,14 +470,13 @@ pfe_dispatch_relay(int fd, short event, void * ptr) 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 (;;) { |