]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
added pre-initialization check on cachedb->node_lock_count.
authorTatuya JINMEI 神明達哉 <jinmei@isc.org>
Mon, 27 Oct 2008 22:43:34 +0000 (22:43 +0000)
committerTatuya JINMEI 神明達哉 <jinmei@isc.org>
Mon, 27 Oct 2008 22:43:34 +0000 (22:43 +0000)
lib/dns/rbtdb.c

index 41d04cbe25e8285dd44f75708ea08b9272846617..1882009e2428d6807feace39bf8c4606fac5ebae 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: rbtdb.c,v 1.266 2008/10/27 03:52:43 marka Exp $ */
+/* $Id: rbtdb.c,v 1.267 2008/10/27 22:43:34 jinmei Exp $ */
 
 /*! \file */
 
@@ -6768,11 +6768,20 @@ dns_rbtdb_create
        if (result != ISC_R_SUCCESS)
                goto cleanup_lock;
 
+       /*
+        * Initialize node_lock_count in a generic way to support future
+        * extension which allows the user to specify this value on creation.
+        * Note that when specified for a cache DB it must be larger than 1
+        * as commented with the definition of DEFAULT_CACHE_NODE_LOCK_COUNT.
+        */
        if (rbtdb->node_lock_count == 0) {
                if (IS_CACHE(rbtdb))
                        rbtdb->node_lock_count = DEFAULT_CACHE_NODE_LOCK_COUNT;
                else
                        rbtdb->node_lock_count = DEFAULT_NODE_LOCK_COUNT;
+       } else if (rbtdb->node_lock_count < 2 && IS_CACHE(rbtdb)) {
+               result = ISC_R_RANGE;
+               goto cleanup_tree_lock;
        }
        INSIST(rbtdb->node_lock_count < (1 << DNS_RBT_LOCKLENGTH));
        rbtdb->node_locks = isc_mem_get(mctx, rbtdb->node_lock_count *