@@ -705,6 +705,8 @@ EV_API_DECL void ev_resume (EV_P) EV_NOEXCEPT; | |||
#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) |
@@ -651,7 +651,7 @@ rspamd_monitored_start (struct rspamd_monitored *m) | |||
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); | |||
} | |||
@@ -399,12 +399,12 @@ rspamd_worker_stop_accept (struct rspamd_worker *worker) | |||
/* 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); | |||
} | |||
@@ -1021,7 +1021,7 @@ rspamd_redis_fin (gpointer data) | |||
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); | |||
} | |||
@@ -1280,7 +1280,7 @@ rspamd_redis_connected (redisAsyncContext *c, gpointer r, gpointer priv) | |||
/* 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); | |||
} | |||
@@ -1684,7 +1684,7 @@ rspamd_redis_process_tokens (struct rspamd_task *task, | |||
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); | |||
} | |||
@@ -1706,7 +1706,7 @@ rspamd_redis_finalize_process (struct rspamd_task *task, gpointer runtime, | |||
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); | |||
} | |||
@@ -1889,7 +1889,7 @@ rspamd_redis_learn_tokens (struct rspamd_task *task, GPtrArray *tokens, | |||
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); | |||
} | |||
@@ -1917,7 +1917,7 @@ rspamd_redis_finalize_learn (struct rspamd_task *task, gpointer runtime, | |||
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); | |||
} | |||
@@ -80,7 +80,7 @@ void | |||
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); | |||
} | |||
@@ -96,7 +96,7 @@ rspamd_ev_watcher_reschedule (struct ev_loop *loop, | |||
{ | |||
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); | |||
@@ -108,7 +108,7 @@ rspamd_ev_watcher_reschedule (struct ev_loop *loop, | |||
} | |||
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); |
@@ -172,7 +172,7 @@ rspamd_upstreams_library_config (struct rspamd_config *cfg, | |||
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); | |||
@@ -281,7 +281,7 @@ rspamd_upstream_set_active (struct upstream_list *ls, struct upstream *upstream) | |||
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 */ | |||
@@ -525,7 +525,7 @@ rspamd_upstream_set_inactive (struct upstream_list *ls, struct upstream *upstrea | |||
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); | |||
} | |||
@@ -721,7 +721,7 @@ rspamd_upstream_dtor (struct upstream *up) | |||
if (up->ctx) { | |||
if (ev_is_active (&up->ev)) { | |||
if (ev_can_stop (&up->ev)) { | |||
ev_timer_stop (up->ctx->event_loop, &up->ev); | |||
} | |||
@@ -1030,7 +1030,7 @@ rspamd_upstream_restore_cb (gpointer elt, gpointer ls) | |||
/* 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); | |||
} | |||