]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add more sanity checks to redis pool
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 14 Jan 2017 12:39:50 +0000 (12:39 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 14 Jan 2017 12:39:50 +0000 (12:39 +0000)
src/libserver/redis_pool.c

index 4e1a788ad453f480b497d8e7005619a1095ff391..6aa4b6565265e5f568f584cf64673433311d42ea 100644 (file)
@@ -176,6 +176,7 @@ rspamd_redis_conn_timeout (gint fd, short what, gpointer p)
 {
        struct rspamd_redis_pool_connection *conn = p;
 
+       g_assert (!conn->active);
        msg_debug_rpool ("scheduled removal of connection, refcount: %d",
                        conn->ref.refcount);
        REF_RELEASE (conn);
@@ -346,12 +347,10 @@ rspamd_redis_pool_connect (struct rspamd_redis_pool *pool,
                if (g_queue_get_length (elt->inactive) > 0) {
                        conn_entry = g_queue_pop_head_link (elt->inactive);
                        conn = conn_entry->data;
+                       g_assert (!conn->active);
 
                        if (conn->ctx->err == REDIS_OK) {
-                               if (event_get_base (&conn->timeout)) {
-                                       event_del (&conn->timeout);
-                               }
-
+                               event_del (&conn->timeout);
                                conn->active = TRUE;
                                g_queue_push_tail_link (elt->active, conn_entry);
                                msg_debug_rpool ("reused existing connection to %s:%d", ip, port);