]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth lmdb random-ids: stop generating negative numbers
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 24 Feb 2022 16:19:21 +0000 (17:19 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Fri, 11 Mar 2022 14:49:55 +0000 (15:49 +0100)
regression testing now happens with random IDs, except for HTTP API testing

(cherry picked from commit 529fe29fd4064447a3298a02076059cc7ac0596b, backport of #11354)

ext/lmdb-safe/lmdb-typed.cc
regression-tests/backends/lmdb-master

index a366da227600743c70befb43338ae38bf2a59c45..7b0abd339aec8c7321e73902ff873bc6fa52ca5c 100644 (file)
@@ -19,9 +19,9 @@ unsigned int MDBGetRandomID(MDBRWTransaction& txn, MDBDbi& dbi)
   for(int attempts=0; attempts<20; attempts++) {
     MDBOutVal key, content;
 
-    // dns_random generates a random number in [0..type_max-1]. We add 1 to avoid 0 and allow type_max.
+    // dns_random generates a random number in [0..signed_int_max-1]. We add 1 to avoid 0 and allow type_max.
     // 0 is avoided because the put() interface uses it to mean "please allocate a number for me"
-    id = dns_random(std::numeric_limits<decltype(id)>::max()) + 1;
+    id = dns_random(std::numeric_limits<signed int>::max()) + 1;
     if(cursor.find(MDBInVal(id), key, content)) {
       return id;
     }
index ea0b4aa6a691891451ed648f7bf30cf27edf9d00..77a5dbe3b31fb5ab73f6ffd8b083a17a8093384c 100644 (file)
@@ -4,6 +4,7 @@ case $context in
 module-dir=./modules
 launch=lmdb
 lmdb-filename=./pdns.lmdb
+lmdb-random-ids=yes
 __EOF__
 
         rm -f pdns.lmdb*