Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-01-05 19:04:41 +0400
committerFelix Fietkau <nbd@openwrt.org>2013-01-05 19:04:55 +0400
commitb7930023ee0d1b66b4bda9273639f4813e3b7043 (patch)
tree298a488fa76afb71e7ef3b26158b06207e3dcce9 /uloop.c
parentf1735cd94e55a3547254bd7d5f3c7c8cd79dac59 (diff)
uloop: add back state tracking on mac os x, it seems to work reliably now (after the other fixes)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'uloop.c')
-rw-r--r--uloop.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/uloop.c b/uloop.c
index 2d7b2c9..ecf26ec 100644
--- a/uloop.c
+++ b/uloop.c
@@ -96,20 +96,30 @@ static int register_kevent(struct uloop_fd *fd, unsigned int flags)
struct kevent ev[2];
int nev = 0;
unsigned int fl = 0;
+ unsigned int changed;
uint16_t kflags;
if (flags & ULOOP_EDGE_DEFER)
flags &= ~ULOOP_EDGE_TRIGGER;
- kflags = get_flags(flags, ULOOP_READ);
- EV_SET(&ev[nev++], fd->fd, EVFILT_READ, kflags, 0, 0, fd);
+ changed = flags ^ fd->flags;
+ if (changed & ULOOP_EDGE_TRIGGER)
+ changed |= flags;
- kflags = get_flags(flags, ULOOP_WRITE);
- EV_SET(&ev[nev++], fd->fd, EVFILT_WRITE, kflags, 0, 0, fd);
+ if (changed & ULOOP_READ) {
+ kflags = get_flags(flags, ULOOP_READ);
+ EV_SET(&ev[nev++], fd->fd, EVFILT_READ, kflags, 0, 0, fd);
+ }
+
+ if (changed & ULOOP_WRITE) {
+ kflags = get_flags(flags, ULOOP_WRITE);
+ EV_SET(&ev[nev++], fd->fd, EVFILT_WRITE, kflags, 0, 0, fd);
+ }
if (!flags)
fl |= EV_DELETE;
+ fd->flags = flags;
if (kevent(poll_fd, ev, nev, NULL, fl, &timeout) == -1)
return -1;
@@ -123,7 +133,6 @@ static int register_poll(struct uloop_fd *fd, unsigned int flags)
else
flags &= ~ULOOP_EDGE_DEFER;
- fd->flags = flags;
return register_kevent(fd, flags);
}