]> source.dussan.org Git - rspamd.git/commitdiff
[Project] Fix compare function
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 5 Mar 2019 16:35:15 +0000 (16:35 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 5 Mar 2019 16:35:15 +0000 (16:35 +0000)
src/libutil/http_context.c

index d9b6c0d50dca9869f5e96ddd9ad65fdc9718bbac..a17b86af36da9364a3adacecac6d3fe0002b26a7 100644 (file)
@@ -300,7 +300,7 @@ rspamd_keep_alive_key_equal (struct rspamd_keepalive_hash_key *k1,
 {
        if (k1->host && k2->host) {
                if (rspamd_inet_address_port_equal (k1->addr, k2->addr)) {
-                       return strcmp (k1->host, k2->host);
+                       return strcmp (k1->host, k2->host) == 0;
                }
        }
        else if (!k1->host && !k2->host) {
@@ -330,10 +330,6 @@ rspamd_http_context_check_keepalive (struct rspamd_http_context *ctx,
 
                /* Use stack based approach */
 
-               msg_debug_http_context ("check keepalive element %s (%s), %d elts",
-                               rspamd_inet_address_to_string_pretty (phk->addr),
-                               phk->host, conns->length);
-
                if (g_queue_get_length (conns) > 0) {
                        struct rspamd_http_keepalive_cbdata *cbd;
                        struct rspamd_http_connection *conn;
@@ -343,9 +339,18 @@ rspamd_http_context_check_keepalive (struct rspamd_http_context *ctx,
                        conn = cbd->conn;
                        g_free (cbd);
 
+                       msg_debug_http_context ("reused keepalive element %s (%s), %d connections queued",
+                                       rspamd_inet_address_to_string_pretty (phk->addr),
+                                       phk->host, conns->length);
+
                        /* We transfer refcount here! */
                        return conn;
                }
+               else {
+                       msg_debug_http_context ("found empty keepalive element %s (%s), cannot reuse",
+                                       rspamd_inet_address_to_string_pretty (phk->addr),
+                                       phk->host);
+               }
        }
 
        return NULL;
@@ -493,7 +498,7 @@ rspamd_http_context_push_keepalive (struct rspamd_http_context *ctx,
                        rspamd_http_keepalive_handler,
                        cbdata);
 
-       msg_debug_http_context ("push keepalive element %s (%s), %d connections left, %.1f timeout",
+       msg_debug_http_context ("push keepalive element %s (%s), %d connections queued, %.1f timeout",
                        rspamd_inet_address_to_string_pretty (cbdata->conn->keepalive_hash_key->addr),
                        cbdata->conn->keepalive_hash_key->host,
                        cbdata->queue->length,