Ignore:
Timestamp:
04/18/11 16:25:46 (13 years ago)
Author:
tim
Message:

added a test case for pyregfi multithreaded use
updated the regfi multithreaded test case
fixed several ctypes interface problems in pyregfi
added locking to pyregfi iterators for thread safety
fixed regfi talloc race conditions with an additional lock

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/pyregfi-smoketest.py

    r227 r228  
    55import io
    66import time
     7import threading
    78import pyregfi
    89
     
    189190        pass
    190191
     192
     193def threadIterMain(iter):
     194    x = 0
     195    try:
     196        for k in iter:
     197            #x += len(k.name) + len(k.subkeys)
     198            pass
     199    except Exception as e:
     200        print("%s dying young: %s" % (threading.current_thread().name, repr(e)))
     201        # Exceptions are thrown on iteration because python state gets out of
     202        # whack.  That's fine, because we're really just interested in finding
     203        # segfaults.  People should not use iterators without locks, but it
     204        # should at least not segfault on them.
     205        pass
     206    print("%s finished" % threading.current_thread().name)
     207
     208def iterMultithread(hive, fh):
     209    num_threads = 10
     210    iter = pyregfi.HiveIterator(hive)
     211    threads = []
     212    for t in range(0,num_threads):
     213        threads.append(threading.Thread(target=threadIterMain, args=(iter,)))
     214    for t in threads:
     215        t.start()
     216    for t in threads:
     217        t.join()
     218   
     219
    191220tests = {
    192221    "iterTallyNames":iterTallyNames,
     
    197226    "iterIterWalk":iterIterWalk,
    198227    "iterCallbackIO":iterCallbackIO,
     228    "iterMultithread":iterMultithread,
    199229    }
    200230
Note: See TracChangeset for help on using the changeset viewer.