mirror of
https://github.com/troglobit/libuev.git
synced 2026-10-12 10:02:22 +00:00
uev_run(): Exit event loop as soon as there are no more watchers
The purpose of the event loop is to process events on all registered
watches. When all watchers have completed the event loop should exit.
Having implemented a workaround for issue #12 in commit e0cebc3 it has
become evident we need to check the list of watchers at the beginning
of the event loop rather than the end, since the workaround skips past
the end.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -284,7 +284,7 @@ int uev_run(uev_ctx_t *ctx, int flags)
|
||||
uev_timer_set(w, w->u.t.timeout, w->u.t.period);
|
||||
}
|
||||
|
||||
while (ctx->running) {
|
||||
while (ctx->running && !LIST_EMPTY(&ctx->watchers)) {
|
||||
int i, nfds, rerun = 0;
|
||||
struct epoll_event events[UEV_MAX_EVENTS];
|
||||
|
||||
@@ -408,7 +408,7 @@ int uev_run(uev_ctx_t *ctx, int flags)
|
||||
}
|
||||
}
|
||||
|
||||
if ((flags & UEV_ONCE) || LIST_EMPTY(&ctx->watchers))
|
||||
if (flags & UEV_ONCE)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user