]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix a leak of query fetchlock (#38454)
authorMukund Sivaraman <muks@isc.org>
Tue, 3 Feb 2015 06:12:58 +0000 (11:42 +0530)
committerMukund Sivaraman <muks@isc.org>
Tue, 3 Feb 2015 06:24:16 +0000 (11:54 +0530)
4052. [bug] Fix a leak of query fetchlock. [RT #38454]

Conflicts:
CHANGES

CHANGES
bin/named/client.c
bin/named/query.c

diff --git a/CHANGES b/CHANGES
index 12848245c2e3d24d685937df35060ae9da962b39..0ecea87b6a83d12576c4dedd9fc457c77987ab00 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+4052.  [bug]           Fix a leak of query fetchlock. [RT #38454]
+
 4049.  [bug]           CDS and CDNSKEY had the wrong attributes. [RT #38491]
 
 4048.  [bug]           adb hash table was not being grown. [RT #38470]
index b323516d09f12c99df9a8daea4e3b28af7a55282..f66ceda83d50297f693ad49373760f45f12d3313 100644 (file)
@@ -532,6 +532,17 @@ exit_check(ns_client_t *client) {
                INSIST(client->recursionquota == NULL);
                INSIST(!ISC_QLINK_LINKED(client, ilink));
 
+               if (manager != NULL) {
+                       LOCK(&manager->listlock);
+                       ISC_LIST_UNLINK(manager->clients, client, link);
+                       LOCK(&manager->lock);
+                       if (manager->exiting &&
+                           ISC_LIST_EMPTY(manager->clients))
+                               destroy_manager = ISC_TRUE;
+                       UNLOCK(&manager->lock);
+                       UNLOCK(&manager->listlock);
+               }
+
                ns_query_free(client);
                isc_mem_put(client->mctx, client->recvbuf, RECV_BUFFER_SIZE);
                isc_event_free((isc_event_t **)&client->sendevent);
@@ -549,16 +560,6 @@ exit_check(ns_client_t *client) {
                }
 
                dns_message_destroy(&client->message);
-               if (manager != NULL) {
-                       LOCK(&manager->listlock);
-                       ISC_LIST_UNLINK(manager->clients, client, link);
-                       LOCK(&manager->lock);
-                       if (manager->exiting &&
-                           ISC_LIST_EMPTY(manager->clients))
-                               destroy_manager = ISC_TRUE;
-                       UNLOCK(&manager->lock);
-                       UNLOCK(&manager->listlock);
-               }
 
                /*
                 * Detaching the task must be done after unlinking from
@@ -579,6 +580,13 @@ exit_check(ns_client_t *client) {
                        isc_mem_stats(client->mctx, stderr);
                        INSIST(0);
                }
+
+               /*
+                * Destroy the fetchlock mutex that was created in
+                * ns_query_init().
+                */
+               DESTROYLOCK(&client->query.fetchlock);
+
                isc_mem_putanddetach(&client->mctx, client, sizeof(*client));
        }
 
index 20cce1544d1263d30a3304389aa168b67927815b..eae3e617805a954a68bce5e89f5a546cceb9edcf 100644 (file)
@@ -614,6 +614,10 @@ ns_query_init(ns_client_t *client) {
        client->query.timerset = ISC_FALSE;
        client->query.rpz_st = NULL;
        client->query.qname = NULL;
+       /*
+        * This mutex is destroyed when the client is destroyed in
+        * exit_check().
+        */
        result = isc_mutex_init(&client->query.fetchlock);
        if (result != ISC_R_SUCCESS)
                return (result);
@@ -633,8 +637,10 @@ ns_query_init(ns_client_t *client) {
                return (result);
        }
        result = query_newnamebuf(client);
-       if (result != ISC_R_SUCCESS)
+       if (result != ISC_R_SUCCESS) {
                query_freefreeversions(client, ISC_TRUE);
+               DESTROYLOCK(&client->query.fetchlock);
+       }
 
        return (result);
 }