]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
lock verify nicer, manual test done.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 21 Mar 2007 14:54:37 +0000 (14:54 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 21 Mar 2007 14:54:37 +0000 (14:54 +0000)
git-svn-id: file:///svn/unbound/trunk@186 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
testcode/lock_verify.c

index fcd005a70cf57a9d99a8a629fd0d643dab0447c4..8a48129f3f3efc0a09dfe22fb8d6969222eecf73 100644 (file)
@@ -2,6 +2,7 @@
        - unit test of hash table, fixup locking problem in table_grow().
        - fixup accounting of sizes for removing items from hashtable.
        - unit test for hash table, single threaded test of integrity.
+       - lock-verify reports errors nicely. More quiet in operation.
 
 16 March 2007: Wouter
        - lock-verifier, checks consistent order of locking.
index 25cf563addd8ab3671520378a2fcae1b16681c6c..9f374f59d60e78ac9d497c77f03cefc0dd4b398f 100644 (file)
@@ -93,6 +93,8 @@ struct lock_ref {
 
 /** count of errors detected */
 static int errors_detected = 0;
+/** verbose? */
+static int verb = 0;
 
 /** print program usage help */
 static void
@@ -194,7 +196,7 @@ static void read_create(rbtree_t* all, FILE* in)
        o->node.key = &o->id;
        if(!rbtree_insert(all, &o->node))
                fatal_exit("lock created twice");
-       if(1) printf("read create %s %d\n", o->create_file, o->create_line);
+       if(verb) printf("read create %s %d\n", o->create_file, o->create_line);
 }
 
 /** read lock entry */
@@ -212,7 +214,7 @@ static void read_lock(rbtree_t* all, FILE* in, int val)
           !readup_str(&ref->file, in) ||
           fread(&ref->line, sizeof(int), 1, in) != 1)
                fatal_exit("fread: %s", strerror(errno));
-       if(1) printf("read lock %s %d\n", ref->file, ref->line);
+       if(verb) printf("read lock %s %d\n", ref->file, ref->line);
        /* find the two locks involved */
        prev = (struct order_lock*)rbtree_search(all, &prev_id);
        now = (struct order_lock*)rbtree_search(all, &now_id);
@@ -255,7 +257,7 @@ static void found_cycle(struct lock_ref* visit, int level)
        int i = 0;
        errors_detected++;
        printf("Found inconsistent locking order of length %d\n", level);
-       printf("for lock %d %d created %s %d", 
+       printf("for lock %d %d created %s %d\n", 
                visit->lock->id.thr, visit->lock->id.instance,
                visit->lock->create_file, visit->lock->create_line);
        printf("sequence is:\n");
@@ -264,8 +266,7 @@ static void found_cycle(struct lock_ref* visit, int level)
                struct order_lock* next = 
                        p->lock->dfs_next?p->lock->dfs_next->lock:visit->lock;
                printf("[%d] is locked at line %s %d before lock %d %d\n",
-                       i, visit->file, visit->line, 
-                       next->id.thr, next->id.instance);
+                       i, p->file, p->line, next->id.thr, next->id.instance);
                printf("[%d] lock %d %d is created at %s %d\n",
                        i, next->id.thr, next->id.instance,
                        next->create_file, next->create_line); 
@@ -337,13 +338,17 @@ static void check_order(rbtree_t* all_locks)
        struct order_lock* lock;
        int i=0;
        RBTREE_FOR(lock, struct order_lock*, all_locks) {
-               if(i % 100 == 0) printf("[%d/%d] Checking lock %d %d %s %d\n",
+               if(verb)
+                   printf("[%d/%d] Checking lock %d %d %s %d\n",
                        i, (int)all_locks->count,
                        lock->id.thr, lock->id.instance, 
                        lock->create_file, lock->create_line);
+               else if (i % 100 == 0) 
+                   fprintf(stderr, ".");
                i++;
                check_order_lock(lock);
        }
+       fprintf(stderr, "\n");
 }
 
 /** main program to verify all traces passed */