diff options
-rw-r--r-- | src/libserver/fuzzy_backend_redis.c | 2 | ||||
-rw-r--r-- | src/libserver/milter.c | 4 | ||||
-rw-r--r-- | src/libserver/monitored.c | 6 | ||||
-rw-r--r-- | src/libserver/redis_pool.c | 2 | ||||
-rw-r--r-- | src/libserver/task.c | 2 | ||||
-rw-r--r-- | src/libserver/worker_util.c | 4 | ||||
-rw-r--r-- | src/libstat/backends/redis_backend.c | 12 | ||||
-rw-r--r-- | src/libstat/learn_cache/redis_cache.c | 2 | ||||
-rw-r--r-- | src/libutil/http.c | 10 | ||||
-rw-r--r-- | src/libutil/ssl_util.c | 4 | ||||
-rw-r--r-- | src/libutil/upstream.c | 2 | ||||
-rw-r--r-- | src/libutil/util.c | 10 | ||||
-rw-r--r-- | src/libutil/util.h | 3 |
13 files changed, 38 insertions, 25 deletions
diff --git a/src/libserver/fuzzy_backend_redis.c b/src/libserver/fuzzy_backend_redis.c index 7bb442a27..5081170b6 100644 --- a/src/libserver/fuzzy_backend_redis.c +++ b/src/libserver/fuzzy_backend_redis.c @@ -126,7 +126,7 @@ rspamd_fuzzy_redis_session_dtor (struct rspamd_fuzzy_redis_session *session, ac, is_fatal); } - if (event_get_base (&session->timeout)) { + if (rspamd_event_pending (&session->timeout, EV_TIMEOUT)) { event_del (&session->timeout); } diff --git a/src/libserver/milter.c b/src/libserver/milter.c index 4f6d05d6a..16d6252e9 100644 --- a/src/libserver/milter.c +++ b/src/libserver/milter.c @@ -185,7 +185,7 @@ rspamd_milter_session_dtor (struct rspamd_milter_session *session) priv = session->priv; msg_debug_milter ("destroying milter session"); - if (event_get_base (&priv->ev)) { + if (rspamd_event_pending (&priv->ev, EV_TIMEOUT|EV_WRITE|EV_READ)) { event_del (&priv->ev); } @@ -265,7 +265,7 @@ static inline void rspamd_milter_plan_io (struct rspamd_milter_session *session, struct rspamd_milter_private *priv, gshort what) { - if (event_get_base (&priv->ev)) { + if (rspamd_event_pending (&priv->ev, EV_TIMEOUT|EV_WRITE|EV_READ)) { event_del (&priv->ev); } diff --git a/src/libserver/monitored.c b/src/libserver/monitored.c index 7928615f9..9adcab943 100644 --- a/src/libserver/monitored.c +++ b/src/libserver/monitored.c @@ -589,7 +589,7 @@ rspamd_monitored_stop (struct rspamd_monitored *m) { g_assert (m != NULL); - if (event_get_base (&m->periodic)) { + if (rspamd_event_pending (&m->periodic, EV_TIMEOUT)) { event_del (&m->periodic); } } @@ -606,7 +606,7 @@ rspamd_monitored_start (struct rspamd_monitored *m) 0.0); double_to_tv (jittered, &tv); - if (event_get_base (&m->periodic)) { + if (rspamd_event_pending (&m->periodic, EV_TIMEOUT)) { event_del (&m->periodic); } @@ -626,8 +626,8 @@ rspamd_monitored_ctx_destroy (struct rspamd_monitored_ctx *ctx) for (i = 0; i < ctx->elts->len; i ++) { m = g_ptr_array_index (ctx->elts, i); rspamd_monitored_stop (m); - g_free (m->url); m->proc.monitored_dtor (m, m->ctx, m->proc.ud); + g_free (m->url); g_free (m); } diff --git a/src/libserver/redis_pool.c b/src/libserver/redis_pool.c index 3d77aca1c..98f20ca9c 100644 --- a/src/libserver/redis_pool.c +++ b/src/libserver/redis_pool.c @@ -120,7 +120,7 @@ rspamd_redis_pool_conn_dtor (struct rspamd_redis_pool_connection *conn) else { msg_debug_rpool ("inactive connection removed"); - if (event_get_base (&conn->timeout)) { + if (rspamd_event_pending (&conn->timeout, EV_TIMEOUT)) { event_del (&conn->timeout); } diff --git a/src/libserver/task.c b/src/libserver/task.c index d77fc0145..0fde93f55 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -296,7 +296,7 @@ rspamd_task_free (struct rspamd_task *task) g_error_free (task->err); } - if (event_get_base (&task->timeout_ev) != NULL) { + if (rspamd_event_pending (&task->timeout_ev, EV_TIMEOUT)) { event_del (&task->timeout_ev); } diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c index 64e0bae2e..cdd98ded5 100644 --- a/src/libserver/worker_util.c +++ b/src/libserver/worker_util.c @@ -359,11 +359,11 @@ rspamd_worker_stop_accept (struct rspamd_worker *worker) while (cur) { events = cur->data; - if (event_get_base (&events[0])) { + if (rspamd_event_pending (&events[0], EV_TIMEOUT|EV_READ|EV_WRITE)) { event_del (&events[0]); } - if (event_get_base (&events[1])) { + if (rspamd_event_pending (&events[1], EV_TIMEOUT|EV_READ|EV_WRITE)) { event_del (&events[1]); } diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c index 35930c923..74d8c3bf1 100644 --- a/src/libstat/backends/redis_backend.c +++ b/src/libstat/backends/redis_backend.c @@ -994,7 +994,7 @@ rspamd_redis_fin (gpointer data) rt->has_event = FALSE; /* Stop timeout */ - if (event_get_base (&rt->timeout_event)) { + if (rspamd_event_pending (&rt->timeout_event, EV_TIMEOUT)) { event_del (&rt->timeout_event); } @@ -1014,7 +1014,7 @@ rspamd_redis_fin_learn (gpointer data) rt->has_event = FALSE; /* Stop timeout */ - if (event_get_base (&rt->timeout_event)) { + if (rspamd_event_pending (&rt->timeout_event, EV_TIMEOUT)) { event_del (&rt->timeout_event); } @@ -1597,7 +1597,7 @@ rspamd_redis_process_tokens (struct rspamd_task *task, rspamd_session_add_event (task->s, NULL, rspamd_redis_fin, rt, rspamd_redis_stat_quark ()); rt->has_event = TRUE; - if (event_get_base (&rt->timeout_event)) { + if (rspamd_event_pending (&rt->timeout_event, EV_TIMEOUT)) { event_del (&rt->timeout_event); } event_set (&rt->timeout_event, -1, EV_TIMEOUT, rspamd_redis_timeout, rt); @@ -1634,7 +1634,7 @@ rspamd_redis_finalize_process (struct rspamd_task *task, gpointer runtime, struct redis_stat_runtime *rt = REDIS_RUNTIME (runtime); redisAsyncContext *redis; - if (event_get_base (&rt->timeout_event)) { + if (rspamd_event_pending (&rt->timeout_event, EV_TIMEOUT)) { event_del (&rt->timeout_event); } @@ -1802,7 +1802,7 @@ rspamd_redis_learn_tokens (struct rspamd_task *task, GPtrArray *tokens, rt->has_event = TRUE; /* Set timeout */ - if (event_get_base (&rt->timeout_event)) { + if (rspamd_event_pending (&rt->timeout_event, EV_TIMEOUT)) { event_del (&rt->timeout_event); } event_set (&rt->timeout_event, -1, EV_TIMEOUT, rspamd_redis_timeout, rt); @@ -1827,7 +1827,7 @@ rspamd_redis_finalize_learn (struct rspamd_task *task, gpointer runtime, struct redis_stat_runtime *rt = REDIS_RUNTIME (runtime); redisAsyncContext *redis; - if (event_get_base (&rt->timeout_event)) { + if (rspamd_event_pending (&rt->timeout_event, EV_TIMEOUT)) { event_del (&rt->timeout_event); } diff --git a/src/libstat/learn_cache/redis_cache.c b/src/libstat/learn_cache/redis_cache.c index 22de2c1bc..11bc13aae 100644 --- a/src/libstat/learn_cache/redis_cache.c +++ b/src/libstat/learn_cache/redis_cache.c @@ -73,7 +73,7 @@ rspamd_redis_cache_fin (gpointer data) redisAsyncContext *redis; rt->has_event = FALSE; - if (event_get_base (&rt->timeout_event)) { + if (rspamd_event_pending (&rt->timeout_event, EV_TIMEOUT)) { event_del (&rt->timeout_event); } diff --git a/src/libutil/http.c b/src/libutil/http.c index 2f78def47..637548dac 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -629,7 +629,7 @@ rspamd_http_on_headers_complete (http_parser * parser) if (msg->method == HTTP_HEAD) { /* We don't care about the rest */ - if (event_pending (&priv->ev, EV_READ, NULL)) { + if (rspamd_event_pending (&priv->ev, EV_READ)) { event_del (&priv->ev); } @@ -804,7 +804,7 @@ rspamd_http_on_headers_complete_decrypted (http_parser *parser) if (msg->method == HTTP_HEAD) { /* We don't care about the rest */ - if (event_pending (&priv->ev, EV_READ, NULL)) { + if (rspamd_event_pending (&priv->ev, EV_READ)) { event_del (&priv->ev); } @@ -949,7 +949,7 @@ rspamd_http_on_message_complete (http_parser * parser) } if (ret == 0) { - if (event_pending (&priv->ev, EV_READ, NULL)) { + if (rspamd_event_pending (&priv->ev, EV_READ)) { event_del (&priv->ev); } @@ -1370,7 +1370,7 @@ rspamd_http_connection_reset (struct rspamd_http_connection *conn) if (!(priv->flags & RSPAMD_HTTP_CONN_FLAG_RESETED)) { - if (event_get_base (&priv->ev)) { + if (rspamd_event_pending (&priv->ev, EV_READ|EV_WRITE|EV_TIMEOUT)) { event_del (&priv->ev); } @@ -2296,7 +2296,7 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn priv->flags &= ~RSPAMD_HTTP_CONN_FLAG_RESETED; - if (base != NULL && event_get_base (&priv->ev) == base) { + if (rspamd_event_pending (&priv->ev, EV_TIMEOUT|EV_WRITE|EV_READ)) { event_del (&priv->ev); } diff --git a/src/libutil/ssl_util.c b/src/libutil/ssl_util.c index 09ce9b01b..95245aa4c 100644 --- a/src/libutil/ssl_util.c +++ b/src/libutil/ssl_util.c @@ -534,7 +534,7 @@ rspamd_ssl_connect_fd (struct rspamd_ssl_connection *conn, gint fd, if (ret == 1) { conn->state = ssl_conn_connected; - if (event_get_base (ev)) { + if (rspamd_event_pending (ev, EV_TIMEOUT|EV_WRITE|EV_READ)) { event_del (ev); } @@ -561,7 +561,7 @@ rspamd_ssl_connect_fd (struct rspamd_ssl_connection *conn, gint fd, return FALSE; } - if (event_get_base (ev)) { + if (rspamd_event_pending (ev, EV_TIMEOUT|EV_WRITE|EV_READ)) { event_del (ev); } diff --git a/src/libutil/upstream.c b/src/libutil/upstream.c index 883c6f2eb..3703bdd19 100644 --- a/src/libutil/upstream.c +++ b/src/libutil/upstream.c @@ -837,7 +837,7 @@ rspamd_upstream_restore_cb (gpointer elt, gpointer ls) /* Here the upstreams list is already locked */ RSPAMD_UPSTREAM_LOCK (up->lock); - if (event_get_base (&up->ev)) { + if (rspamd_event_pending (&up->ev, EV_TIMEOUT)) { event_del (&up->ev); } g_ptr_array_add (ups->alive, up); diff --git a/src/libutil/util.c b/src/libutil/util.c index 9b5cc6b6c..b17766144 100644 --- a/src/libutil/util.c +++ b/src/libutil/util.c @@ -2469,6 +2469,16 @@ event_get_base (struct event *ev) #endif int +rspamd_event_pending (struct event *ev, short what) +{ + if (ev->ev_base == NULL) { + return 0; + } + + return event_pending (ev, what, NULL); +} + +int rspamd_file_xopen (const char *fname, int oflags, guint mode, gboolean allow_symlink) { diff --git a/src/libutil/util.h b/src/libutil/util.h index 4338d5557..875388432 100644 --- a/src/libutil/util.h +++ b/src/libutil/util.h @@ -429,6 +429,9 @@ struct event_base * event_get_base (struct event *ev); event_set((ev), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg)) #endif +/* Avoid stupidity in libevent > 1.4 */ +int rspamd_event_pending (struct event *ev, short what); + /** * Open file without following symlinks or special stuff * @param fname filename |