Index: asterisk-1.6.2.17/main/pbx.c =================================================================== --- asterisk-1.6.2.17.orig/main/pbx.c 2011-03-24 14:28:05.000000000 +0000 +++ asterisk-1.6.2.17/main/pbx.c 2011-03-25 10:03:01.000000000 +0000 @@ -1138,9 +1138,10 @@ static int stateid = 1; /* WARNING: - When holding this container's lock, do _not_ do anything that will cause conlock - to be taken, unless you _already_ hold it. The ast_merge_contexts_and_delete - function will take the locks in conlock/hints order, so any other + Do _not_ try to get this container's lock while holding the conlock. There is a + natural locking order, which results in conlock being locked periodically while + looping through hints. As a result, the ast_merge_contexts_and_delete + function will take the locks in hints/conlock order, so any other paths that require both locks must also take them in that order. */ static struct ao2_container *hints; @@ -6704,6 +6705,7 @@ struct timeval begintime, writelocktime, endlocktime, enddeltime; begintime = ast_tvnow(); + ao2_lock(hints); ast_rdlock_contexts(); iter = ast_hashtab_start_traversal(contexts_table); while ((tmp = ast_hashtab_next(iter))) { @@ -6711,7 +6713,6 @@ } ast_hashtab_end_traversal(iter); - ao2_lock(hints); writelocktime = ast_tvnow(); /* preserve all watchers for hints */