summaryrefslogtreecommitdiff
path: root/src/fdevent_libev.c
diff options
context:
space:
mode:
authorArno Töll <arno@debian.org>2013-10-15 20:19:04 +0200
committerArno Töll <arno@debian.org>2013-10-15 20:19:04 +0200
commit1380410981681f011377225708e9c530330fd5a0 (patch)
tree7dd371bc4cac8910130e4ee0f4508bc519f1778d /src/fdevent_libev.c
parent5b23e76990e58208a01c2a5362362575bc12b397 (diff)
downloadlighttpd-upstream.tar.gz
Imported Upstream version 1.4.33upstream/1.4.33upstream
Diffstat (limited to 'src/fdevent_libev.c')
-rw-r--r--src/fdevent_libev.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/fdevent_libev.c b/src/fdevent_libev.c
index de62676..f6f6b63 100644
--- a/src/fdevent_libev.c
+++ b/src/fdevent_libev.c
@@ -87,19 +87,28 @@ static void timeout_watcher_cb(struct ev_loop *loop, ev_timer *w, int revents) {
UNUSED(loop);
UNUSED(w);
UNUSED(revents);
+
+ ev_timer_stop(loop, w);
}
static int fdevent_libev_poll(fdevents *ev, int timeout_ms) {
- ev_timer timeout_watcher;
+ union {
+ struct ev_watcher w;
+ struct ev_timer timer;
+ } timeout_watcher;
+
+ if (!timeout_ms) timeout_ms = 1;
- ev_init(&timeout_watcher, timeout_watcher_cb);
- ev_timer_set(&timeout_watcher, ((ev_tstamp) timeout_ms)/1000.0, 0.0);
- ev_timer_start(ev->libev_loop, &timeout_watcher);
+ ev_init(&timeout_watcher.w, NULL);
+ ev_set_cb(&timeout_watcher.timer, timeout_watcher_cb);
+ timeout_watcher.timer.repeat = ((ev_tstamp) timeout_ms)/1000.0;
+ assert(timeout_watcher.timer.repeat);
+ ev_timer_again(ev->libev_loop, &timeout_watcher.timer);
ev_loop(ev->libev_loop, EVLOOP_ONESHOT);
- ev_timer_stop(ev->libev_loop, &timeout_watcher);
+ ev_timer_stop(ev->libev_loop, &timeout_watcher.timer);
return 0;
}