mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
- Fixup checklock code for log lock and its mutual initialization
dependency. git-svn-id: file:///svn/unbound/trunk@3214 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
4153f386d1
commit
912b10a789
3 changed files with 23 additions and 0 deletions
|
|
@ -1,3 +1,7 @@
|
|||
25 August 2014: Wouter
|
||||
- Fixup checklock code for log lock and its mutual initialization
|
||||
dependency.
|
||||
|
||||
19 August 2014: Wouter
|
||||
- Update unbound manpage with more explanation (from Florian Obser).
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@
|
|||
|
||||
/** 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. */
|
||||
|
|
@ -273,6 +275,15 @@ checklock_init(enum check_lock_type type, struct checked_lock** lock,
|
|||
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);
|
||||
|
|
@ -676,6 +687,8 @@ static void* checklock_main(void* arg)
|
|||
/** 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));
|
||||
|
|
@ -696,6 +709,7 @@ void checklock_stop(void)
|
|||
{
|
||||
if(key_created) {
|
||||
int i;
|
||||
key_deleted = 1;
|
||||
if(check_locking_order)
|
||||
fclose(thread_infos[0]->order_info);
|
||||
free(thread_infos[0]);
|
||||
|
|
|
|||
|
|
@ -391,6 +391,11 @@ main(int argc, char* argv[])
|
|||
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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue