]> granicus.if.org Git - pgbouncer/commitdiff
dns: need to use statlist_remove() instead list_del()
authorMarko Kreen <markokr@gmail.com>
Wed, 31 Oct 2012 08:51:23 +0000 (10:51 +0200)
committerMarko Kreen <markokr@gmail.com>
Wed, 31 Oct 2012 08:51:23 +0000 (10:51 +0200)
Otherwise host_list will have wrong count.

It does not look like the codepath is actually ever used,
but still...

src/dnslookup.c

index fd5200daeedbc7b67ca0057df13597956a8c4a9d..b22b902f74aa4e0ba7bae56bd9aa789482f74f6d 100644 (file)
@@ -75,6 +75,7 @@ struct DNSRequest {
        struct List znode;      /* DNSZone->host_list */
 
        struct DNSContext *ctx;
+       struct DNSZone *zone;
 
        struct List ucb_list;   /* DNSToken->node */
 
@@ -747,7 +748,8 @@ static void req_free(struct AANode *node, void *arg)
                freeaddrinfo(req->oldres);
                req->oldres = NULL;
        }
-       list_del(&req->znode);
+       if (req->zone)
+               statlist_remove(&req->zone->host_list, &req->znode);
        free(req->name);
        free(req);
 }
@@ -974,6 +976,7 @@ static void zone_register(struct DNSContext *ctx, struct DNSRequest *req)
        if (n) {
                /* already exists */
                z = container_of(n, struct DNSZone, tnode);
+               req->zone = z;
                statlist_append(&z->host_list, &req->znode);
                return;
        }
@@ -994,6 +997,7 @@ static void zone_register(struct DNSContext *ctx, struct DNSRequest *req)
        aatree_insert(&ctx->zone_tree, (uintptr_t)z->zonename, &z->tnode);
        list_append(&ctx->zone_list, &z->lnode);
        statlist_append(&z->host_list, &req->znode);
+       req->zone = z;
 }
 
 static void zone_timer(int fd, short flg, void *arg)