#define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */
#define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */
+#define ev_can_stop(ev) (ev_is_pending(ev) || ev_is_active(ev)) /* ro, true when the watcher has been started */
+
#define ev_cb_(ev) (ev)->cb /* rw */
#define ev_cb(ev) (memmove (&ev_cb_ (ev), &((ev_watcher *)(ev))->cb, sizeof (ev_cb_ (ev))), (ev)->cb)
jittered = rspamd_time_jitter (m->ctx->monitoring_interval * m->monitoring_mult,
0.0);
- if (ev_is_active (&m->periodic)) {
+ if (ev_can_stop (&m->periodic)) {
ev_timer_stop (m->ctx->event_loop, &m->periodic);
}
/* Remove all events */
DL_FOREACH_SAFE (worker->accept_events, cur, tmp) {
- if (ev_is_active (&cur->accept_ev) || ev_is_pending (&cur->accept_ev)) {
+ if (ev_can_stop (&cur->accept_ev)) {
ev_io_stop (cur->event_loop, &cur->accept_ev);
}
- if (ev_is_active (&cur->throttling_ev) || ev_is_pending (&cur->throttling_ev)) {
+ if (ev_can_stop (&cur->throttling_ev)) {
ev_timer_stop (cur->event_loop, &cur->throttling_ev);
}
rt->has_event = FALSE;
/* Stop timeout */
- if (ev_is_active (&rt->timeout_event)) {
+ if (ev_can_stop (&rt->timeout_event)) {
ev_timer_stop (rt->task->event_loop, &rt->timeout_event);
}
/* Further is handled by rspamd_redis_processed */
final = FALSE;
/* Restart timeout */
- if (ev_is_active (&rt->timeout_event)) {
+ if (ev_can_stop (&rt->timeout_event)) {
rt->timeout_event.repeat = rt->ctx->timeout;
ev_timer_again (task->event_loop, &rt->timeout_event);
}
rt->has_event = TRUE;
rt->tokens = g_ptr_array_ref (tokens);
- if (ev_is_active (&rt->timeout_event)) {
+ if (ev_can_stop (&rt->timeout_event)) {
rt->timeout_event.repeat = rt->ctx->timeout;
ev_timer_again (task->event_loop, &rt->timeout_event);
}
struct redis_stat_runtime *rt = REDIS_RUNTIME (runtime);
redisAsyncContext *redis;
- if (ev_is_active (&rt->timeout_event)) {
+ if (ev_can_stop (&rt->timeout_event)) {
ev_timer_stop (task->event_loop, &rt->timeout_event);
}
rt->has_event = TRUE;
/* Set timeout */
- if (ev_is_active (&rt->timeout_event)) {
+ if (ev_can_stop (&rt->timeout_event)) {
rt->timeout_event.repeat = rt->ctx->timeout;
ev_timer_again (task->event_loop, &rt->timeout_event);
}
struct redis_stat_runtime *rt = REDIS_RUNTIME (runtime);
redisAsyncContext *redis;
- if (ev_is_active (&rt->timeout_event)) {
+ if (ev_can_stop (&rt->timeout_event)) {
ev_timer_stop (task->event_loop, &rt->timeout_event);
}
rspamd_ev_watcher_stop (struct ev_loop *loop,
struct rspamd_io_ev *ev)
{
- if (ev_is_pending (&ev->io) || ev_is_active (&ev->io)) {
+ if (ev_can_stop (&ev->io)) {
ev_io_stop (EV_A_ &ev->io);
}
{
g_assert (ev->cb != NULL);
- if (ev_is_pending (&ev->io) || ev_is_active (&ev->io)) {
+ if (ev_can_stop (&ev->io)) {
ev_io_stop (EV_A_ &ev->io);
ev_io_set (&ev->io, ev->io.fd, what);
ev_io_start (EV_A_ &ev->io);
}
if (ev->timeout > 0) {
- if (!(ev_is_active (&ev->tm) || ev_is_pending (&ev->tm))) {
+ if (!(ev_can_stop (&ev->tm))) {
ev->tm.data = ev;
ev_timer_init (&ev->tm, rspamd_ev_watcher_timer_cb, ev->timeout, 0.0);
ev_timer_start (EV_A_ &ev->tm);
while (cur) {
upstream = cur->data;
- if (!ev_is_active (&upstream->ev) && upstream->ls &&
+ if (!ev_can_stop (&upstream->ev) && upstream->ls &&
!(upstream->flags & RSPAMD_UPSTREAM_FLAG_NORESOLVE)) {
gdouble when = rspamd_time_jitter (upstream->ls->limits.lazy_resolve_time,
upstream->ls->limits.lazy_resolve_time * .1);
if (upstream->ctx && upstream->ctx->configured &&
!(upstream->flags & RSPAMD_UPSTREAM_FLAG_NORESOLVE)) {
- if (ev_is_active (&upstream->ev)) {
+ if (ev_can_stop (&upstream->ev)) {
ev_timer_stop (upstream->ctx->event_loop, &upstream->ev);
}
/* Start lazy names resolution */
ntim = rspamd_time_jitter (ls->limits.revive_time,
ls->limits.revive_jitter);
- if (ev_is_active (&upstream->ev)) {
+ if (ev_can_stop (&upstream->ev)) {
ev_timer_stop (upstream->ctx->event_loop, &upstream->ev);
}
if (up->ctx) {
- if (ev_is_active (&up->ev)) {
+ if (ev_can_stop (&up->ev)) {
ev_timer_stop (up->ctx->event_loop, &up->ev);
}
/* Here the upstreams list is already locked */
RSPAMD_UPSTREAM_LOCK (up->lock);
- if (ev_is_active (&up->ev)) {
+ if (ev_can_stop (&up->ev)) {
ev_timer_stop (up->ctx->event_loop, &up->ev);
}