summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes1
-rw-r--r--ev.c29
-rw-r--r--ev_port.c4
3 files changed, 19 insertions, 15 deletions
diff --git a/Changes b/Changes
index 0a7bdfe..28fd4ed 100644
--- a/Changes
+++ b/Changes
@@ -12,6 +12,7 @@ TODO: section watcher states/lifetime
- replace EV_MINIMAL by EV_FEATURES.
- prefer EPOLL_CTL_ADD over EPOLL_CTL_MOD in some more cases, as it
seems the former is *much* faster than the latter.
+ - reduce the number of spurious wake-ups with the ports backend.
- remove dependency on sys/queue.h on freebsd (patch by Vanilla Hsu).
- add (undocumented) EV_ENABLE when adding events with kqueue,
this might help with OS X, which seems to need it despite documenting
diff --git a/ev.c b/ev.c
index 782cf28..9664499 100644
--- a/ev.c
+++ b/ev.c
@@ -945,13 +945,13 @@ fd_reify (EV_P)
ANFD *anfd = anfds + fd;
ev_io *w;
- unsigned char events = 0;
+ unsigned char o_events = anfd->events;
+ unsigned char o_reify = anfd->reify;
- for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next)
- events |= (unsigned char)w->events;
+ anfd->reify = 0;
#if EV_SELECT_IS_WINSOCKET
- if (events)
+ if (o_reify & EV__IOFDSET)
{
unsigned long arg;
anfd->handle = EV_FD_TO_WIN32_HANDLE (fd);
@@ -959,16 +959,19 @@ fd_reify (EV_P)
}
#endif
- {
- unsigned char o_events = anfd->events;
- unsigned char o_reify = anfd->reify;
+ /*if (expect_true (o_reify & EV_ANFD_REIFY)) probably a deoptimisation */
+ {
+ anfd->events = 0;
- anfd->reify = 0;
- anfd->events = events;
+ for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next)
+ anfd->events |= (unsigned char)w->events;
- if (o_events != events || o_reify & EV__IOFDSET)
- backend_modify (EV_A_ fd, o_events, events);
- }
+ if (o_events !=anfd-> events)
+ o_reify = EV__IOFDSET; /* actually |= */
+ }
+
+ if (o_reify & EV__IOFDSET)
+ backend_modify (EV_A_ fd, o_events, anfd->events);
}
fdchangecnt = 0;
@@ -2599,7 +2602,7 @@ ev_io_stop (EV_P_ ev_io *w)
wlist_del (&anfds[w->fd].head, (WL)w);
ev_stop (EV_A_ (W)w);
- fd_change (EV_A_ w->fd, 1);
+ fd_change (EV_A_ w->fd, EV_ANFD_REIFY);
EV_FREQUENT_CHECK;
}
diff --git a/ev_port.c b/ev_port.c
index a482ce6..801de15 100644
--- a/ev_port.c
+++ b/ev_port.c
@@ -1,7 +1,7 @@
/*
* libev solaris event port backend
*
- * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de>
+ * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libev@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
@@ -111,7 +111,7 @@ port_poll (EV_P_ ev_tstamp timeout)
| (port_events [i].portev_events & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0)
);
- port_associate_and_check (EV_A_ fd, anfds [fd].events);
+ fd_change (EV_A_ fd, EV__IOFDSET);
}
}