summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes2
-rw-r--r--ev.c24
2 files changed, 18 insertions, 8 deletions
diff --git a/Changes b/Changes
index a9dd69c..8f3d18c 100644
--- a/Changes
+++ b/Changes
@@ -3,7 +3,9 @@ Revision history for libev, a high-performance and full-featured event loop.
TODO: ev_walk
TODO: child wactehr execution order w.r.t. childsigcb reg. priorities
TODO: remain
+TODO: io_collect documentation
- Denis F. Latypoff corrected many typos in example code snippets.
+ - the ev_set_io_collect_interval interpretation has changed.
- honor autoconf detection of EV_USE_CLOCK_SYSCALL, also double-
check that the syscall number is available before trying to
use it (reported by ry@tinyclouds).
diff --git a/ev.c b/ev.c
index 5d86f37..c5c3989 100644
--- a/ev.c
+++ b/ev.c
@@ -629,7 +629,7 @@ ev_sleep (ev_tstamp delay)
tv.tv_usec = (long)((delay - (ev_tstamp)(tv.tv_sec)) * 1e6);
/* here we rely on sys/time.h + sys/types.h + unistd.h providing select */
- /* somehting nto guaranteed by newer posix versions, but guaranteed */
+ /* somehting not guaranteed by newer posix versions, but guaranteed */
/* by older ones */
select (0, 0, 0, 0, &tv);
#endif
@@ -2077,6 +2077,9 @@ ev_loop (EV_P_ int flags)
if (expect_true (!(flags & EVLOOP_NONBLOCK || idleall || !activecnt)))
{
+ /* remember old timestamp for io_blocktime calculation */
+ ev_tstamp prev_mn_now = mn_now;
+
/* update time to cancel out callback processing overhead */
time_update (EV_A_ 1e100);
@@ -2096,18 +2099,23 @@ ev_loop (EV_P_ int flags)
}
#endif
+ /* don't let timeouts decrease the waittime below timeout_blocktime */
if (expect_false (waittime < timeout_blocktime))
waittime = timeout_blocktime;
- sleeptime = waittime - backend_fudge;
+ /* extra check because io_blocktime is commonly 0 */
+ if (expect_false (io_blocktime))
+ {
+ sleeptime = io_blocktime - (mn_now - prev_mn_now);
- if (expect_true (sleeptime > io_blocktime))
- sleeptime = io_blocktime;
+ if (sleeptime > waittime - backend_fudge)
+ sleeptime = waittime - backend_fudge;
- if (sleeptime)
- {
- ev_sleep (sleeptime);
- waittime -= sleeptime;
+ if (expect_true (sleeptime > 0.))
+ {
+ ev_sleep (sleeptime);
+ waittime -= sleeptime;
+ }
}
}