diff --git a/src/io.c b/src/io.c index 5c64d49..57aac47 100644 --- a/src/io.c +++ b/src/io.c @@ -61,7 +61,7 @@ int uev_io_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int fd, int e int uev_io_set(uev_t *w, int fd, int events) { - if ((events & UEV_ONESHOT) && w->active) + if ((events & UEV_ONESHOT) && _uev_watcher_active(w)) return _uev_watcher_rearm(w); /* Ignore any errors, only to clean up anything lingering ... */ diff --git a/src/uev.c b/src/uev.c index b38aeb0..4d25981 100644 --- a/src/uev.c +++ b/src/uev.c @@ -85,7 +85,7 @@ int _uev_watcher_start(uev_t *w) return -1; } - if (w->active) + if (_uev_watcher_active(w)) return 0; ev.events = w->events | EPOLLRDHUP; @@ -109,7 +109,7 @@ int _uev_watcher_stop(uev_t *w) return -1; } - if (!w->active) + if (!_uev_watcher_active(w)) return 0; w->active = 0; @@ -130,7 +130,7 @@ int _uev_watcher_active(uev_t *w) if (!w) return 0; - return w->active; + return w->active > 0; } /* Private to libuEv, do not use directly! */ @@ -189,7 +189,7 @@ int uev_exit(uev_ctx_t *ctx) /* Remove from internal list */ LIST_REMOVE(w, link); - if (!w->active) + if (!_uev_watcher_active(w)) continue; switch (w->type) { @@ -290,7 +290,7 @@ int uev_run(uev_ctx_t *ctx, int flags) /* Restart watchers in new efd */ LIST_FOREACH_SAFE(w, &ctx->watchers, link, tmp) { - if (w->active) { + if (_uev_watcher_active(w)) { w->active = 0; LIST_REMOVE(w, link); _uev_watcher_start(w);