Changeset 250 for test


Ignore:
Timestamp:
05/05/11 00:00:24 (14 years ago)
Author:
tim
Message:

added key caching
readded SK caching
fixed races and deadlocks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/regfi-threadtest.c

    r228 r250  
    4444#include "common.c"
    4545
    46 
     46static bool keysEqual(const REGFI_NK* x, const REGFI_NK* y)
     47{
     48  return (x != NULL && y != NULL && x->offset == y->offset);
     49}
    4750
    4851void traverseValueList(REGFI_ITERATOR* iter)
     
    5760    value = regfi_iterator_cur_value(iter);
    5861    printMsgs(iter->f);
    59     regfi_free_record(value);
     62    regfi_free_record(iter->f, value);
    6063  }
    6164}
     
    7073  bool print_this = true;
    7174
    72   root = cur = regfi_iterator_cur_key(iter);
     75  root = regfi_iterator_cur_key(iter);
     76  regfi_reference_record(iter->f, root);
     77  cur = root;
    7378  regfi_iterator_first_subkey(iter);
    7479  sub = regfi_iterator_cur_subkey(iter);
     
    8590    if(sub == NULL)
    8691    {
    87       if(cur != root)
     92      if(!keysEqual(cur,root))
    8893      {
    8994        /* We're done with this sub-tree, going up and hitting other branches. */
    90         regfi_free_record(cur);
     95        regfi_free_record(iter->f, cur);
     96        cur = NULL;
    9197        if(!regfi_iterator_up(iter))
    9298        {
     
    102108        sk = regfi_fetch_sk(iter->f, cur);
    103109        printMsgs(iter->f);
    104         regfi_free_record(sk);
     110        regfi_free_record(iter->f, sk);
    105111
    106112        regfi_iterator_next_subkey(iter);
     
    113119       * Let's move down and print this first sub-tree out.
    114120       */
    115       regfi_free_record(cur);
     121      regfi_free_record(iter->f, cur);
     122      cur = NULL;
    116123      if(!regfi_iterator_down(iter))
    117124      {
     
    122129      cur = regfi_iterator_cur_key(iter);
    123130      printMsgs(iter->f);
    124       regfi_free_record(sub);
     131      regfi_free_record(iter->f, sub);
    125132
    126133      regfi_iterator_first_subkey(iter);
     
    130137    }
    131138    printMsgs(iter->f);
    132   } while(!((cur == root) && (sub == NULL)));
    133   regfi_free_record(root);
     139  } while(!(keysEqual(cur,root) && (sub == NULL)));
     140  if(cur != NULL)
     141    regfi_free_record(iter->f, cur);
     142  regfi_free_record(iter->f, root);
    134143
    135144  if(print_verbose)
Note: See TracChangeset for help on using the changeset viewer.