guint dns_requests;
gint active_idx;
gchar *name;
- struct event ev;
+ ev_timer ev;
gdouble last_fail;
gpointer ud;
struct upstream_list *ls;
struct upstream_ctx {
struct rdns_resolver *res;
- struct ev_loop *ev_base;
+ struct ev_loop *event_loop;
struct upstream_limits limits;
GQueue *upstreams;
gboolean configured;
void
rspamd_upstreams_library_config (struct rspamd_config *cfg,
struct upstream_ctx *ctx,
- struct ev_loop *ev_base,
+ struct ev_loop *event_loop,
struct rdns_resolver *resolver)
{
g_assert (ctx != NULL);
ctx->limits.dns_timeout = cfg->dns_timeout;
}
- ctx->ev_base = ev_base;
+ ctx->event_loop = event_loop;
ctx->res = resolver;
ctx->configured = TRUE;
}
}
static void
-rspamd_upstream_revive_cb (int fd, short what, void *arg)
+rspamd_upstream_revive_cb (struct ev_loop *loop, ev_timer *w, int revents)
{
- struct upstream *up = (struct upstream *)arg;
+ struct upstream *up = (struct upstream *)w->data;
RSPAMD_UPSTREAM_LOCK (up->lock);
- event_del (&up->ev);
+ ev_timer_stop (loop, w);
if (up->ls) {
rspamd_upstream_set_active (up->ls, up);
}
gdouble ntim;
guint i;
struct upstream *cur;
- struct timeval tv;
struct upstream_list_watcher *w;
RSPAMD_UPSTREAM_LOCK (ls->lock);
rspamd_upstream_resolve_addrs (ls, up);
REF_RETAIN (up);
- evtimer_set (&up->ev, rspamd_upstream_revive_cb, up);
- if (up->ctx->ev_base != NULL && up->ctx->configured) {
- event_base_set (up->ctx->ev_base, &up->ev);
- }
-
ntim = rspamd_time_jitter (ls->limits.revive_time,
ls->limits.revive_jitter);
- double_to_tv (ntim, &tv);
- event_add (&up->ev, &tv);
+ ev_timer_init (&up->ev, rspamd_upstream_revive_cb, ntim, 0);
+ up->ev.data = up;
+
+ if (up->ctx->event_loop != NULL && up->ctx->configured) {
+ ev_timer_start (up->ctx->event_loop, &up->ev);
+ }
}
DL_FOREACH (up->ls->watchers, w) {