diff options
author | claudio <claudio@openbsd.org> | 2009-05-31 16:58:54 +0000 |
---|---|---|
committer | claudio <claudio@openbsd.org> | 2009-05-31 16:58:54 +0000 |
commit | b202c6d383d45de914c5d574713f4038ec18d75b (patch) | |
tree | 1fa711d2de6489b63e7b1f20f985994718da0c6f /usr.sbin/ospfd/control.c | |
parent | Do not access sc_scr[-1] from the wsmoused-related code if (diff) | |
download | wireguard-openbsd-b202c6d383d45de914c5d574713f4038ec18d75b.tar.xz wireguard-openbsd-b202c6d383d45de914c5d574713f4038ec18d75b.zip |
The libevent callback function may be called with EV_READ and EV_WRITE
set at the same time so using a switch to do read or write is a bad idea.
Problem noticed by Eygene Ryabinkin on FreeBSD for some reasons it is not
triggered on OpenBSD.
Fix aggreed by a most other libevent hackers
Diffstat (limited to 'usr.sbin/ospfd/control.c')
-rw-r--r-- | usr.sbin/ospfd/control.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/usr.sbin/ospfd/control.c b/usr.sbin/ospfd/control.c index d4269f8d518..49b37ae1a3f 100644 --- a/usr.sbin/ospfd/control.c +++ b/usr.sbin/ospfd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.23 2009/04/07 14:57:33 reyk Exp $ */ +/* $OpenBSD: control.c,v 1.24 2009/05/31 16:58:54 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -198,22 +198,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 (;;) { |