/** if key has been created */
static int key_created = 0;
+/** if the key was deleted, i.e. we have quit */
+static int key_deleted = 0;
/** we hide the thread debug info with this key. */
static ub_thread_key_t thr_debug_key;
/** the list of threads, so all threads can be examined. NULL if unused. */
thr_debug_key);
if(!e)
fatal_exit("%s %s %d: out of memory", func, file, line);
+ if(!thr) {
+ /* this is called when log_init() calls lock_init()
+ * functions, and the test check code has not yet
+ * been initialised. But luckily, the checklock_start()
+ * routine can be called multiple times without ill effect.
+ */
+ checklock_start();
+ thr = (struct thr_check*)pthread_getspecific(thr_debug_key);
+ }
if(!thr)
fatal_exit("%s %s %d: lock_init no thread info", func, file,
line);
/** init the main thread */
void checklock_start(void)
{
+ if(key_deleted)
+ return;
if(!key_created) {
struct thr_check* thisthr = (struct thr_check*)calloc(1,
sizeof(struct thr_check));
{
if(key_created) {
int i;
+ key_deleted = 1;
if(check_locking_order)
fclose(thread_infos[0]->order_info);
free(thread_infos[0]);
rbtree_t* all_locks;
int i;
time_t starttime = time(NULL);
+#ifdef USE_THREAD_DEBUG
+ /* do not overwrite the ublocktrace files with the ones generated
+ * by this program (i.e. when the log code creates a lock) */
+ check_locking_order = 0;
+#endif
if(argc <= 1) {
usage();
return 1;