summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2009-05-31 17:06:02 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2009-05-31 17:06:02 +0000
commitd978db156467c4c8858947d5112c464eb42baf33 (patch)
treebc35bf798b2f4b41fa65cfcb1d23dafb78d8f5e0 /usr.sbin
parent1ff0bb2172075b54cbadc12b25239b4bd99221c8 (diff)
Better EV_READ and EV_WRITE handling in the libevent callbacks. Again mostly
the same ospfd diff applied with some fuzz.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ripd/control.c14
-rw-r--r--usr.sbin/ripd/rde.c22
-rw-r--r--usr.sbin/ripd/ripd.c22
-rw-r--r--usr.sbin/ripd/ripe.c22
4 files changed, 26 insertions, 54 deletions
diff --git a/usr.sbin/ripd/control.c b/usr.sbin/ripd/control.c
index 9cee5dec02e..cc0878dd560 100644
--- a/usr.sbin/ripd/control.c
+++ b/usr.sbin/ripd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.7 2009/02/25 17:09:55 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.8 2009/05/31 17:06:01 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -197,22 +197,18 @@ control_dispatch_imsg(int fd, short event, void *bula)
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 (msgbuf_write(&c->ibuf.w) < 0) {
+ }
+ if (event & EV_WRITE) {
+ if (msgbuf_write(&c->ibuf.w) == -1) {
control_close(fd);
return;
}
imsg_event_add(&c->ibuf);
- return;
- default:
- fatalx("unknown event");
}
for (;;) {
diff --git a/usr.sbin/ripd/rde.c b/usr.sbin/ripd/rde.c
index a2614496c9d..6322dac1a4b 100644
--- a/usr.sbin/ripd/rde.c
+++ b/usr.sbin/ripd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.9 2007/10/24 20:38:03 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.10 2009/05/31 17:06:01 claudio Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -187,20 +187,16 @@ rde_dispatch_imsg(int fd, short event, void *bula)
ssize_t n;
int shut = 0;
- switch (event) {
- case EV_READ:
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
if (n == 0) /* connection closed */
shut = 1;
- 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 (;;) {
@@ -286,20 +282,16 @@ rde_dispatch_parent(int fd, short event, void *bula)
ssize_t n;
int shut = 0;
- switch (event) {
- case EV_READ:
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
if (n == 0) /* connection closed */
shut = 1;
- 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 (;;) {
diff --git a/usr.sbin/ripd/ripd.c b/usr.sbin/ripd/ripd.c
index c6ba4964b43..5dffa43989d 100644
--- a/usr.sbin/ripd/ripd.c
+++ b/usr.sbin/ripd/ripd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ripd.c,v 1.13 2009/03/27 14:37:25 michele Exp $ */
+/* $OpenBSD: ripd.c,v 1.14 2009/05/31 17:06:01 claudio Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -340,20 +340,16 @@ main_dispatch_ripe(int fd, short event, void *bula)
ssize_t n;
int shut = 0;
- switch (event) {
- case EV_READ:
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
if (n == 0) /* connection closed */
shut = 1;
- 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 (;;) {
@@ -416,20 +412,16 @@ main_dispatch_rde(int fd, short event, void *bula)
ssize_t n;
int shut = 0;
- switch (event) {
- case EV_READ:
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
if (n == 0) /* connection closed */
shut = 1;
- 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 (;;) {
diff --git a/usr.sbin/ripd/ripe.c b/usr.sbin/ripd/ripe.c
index 4524e51b5d8..6b1d23f27ee 100644
--- a/usr.sbin/ripd/ripe.c
+++ b/usr.sbin/ripd/ripe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ripe.c,v 1.9 2009/03/25 12:48:16 michele Exp $ */
+/* $OpenBSD: ripe.c,v 1.10 2009/05/31 17:06:01 claudio Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -229,20 +229,16 @@ ripe_dispatch_main(int fd, short event, void *bula)
ssize_t n;
int link_ok, shut = 0;
- switch (event) {
- case EV_READ:
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
if (n == 0) /* connection closed */
shut = 1;
- 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 (;;) {
@@ -313,20 +309,16 @@ ripe_dispatch_rde(int fd, short event, void *bula)
ssize_t n;
int shut = 0;
- switch (event) {
- case EV_READ:
+ if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read error");
if (n == 0) /* connection closed */
shut = 1;
- 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 (;;) {