Reported by: eliel
Tested by: murf
(closes issue #12960)
Reported by: mnicholson
In this 'omnibus' fix, I **think** I solved both
the problem in 13041, where unloading pbx_ael.so
caused crashes, or incomplete removal of previous
registrar'ed entries. And I added code to completely
remove all includes, switches, and ignorepats that
had a matching registrar entry, which should
appease 12960.
I also added a lot of seemingly useless brackets
around single statement if's, which helped debug
so much that I'm leaving them there.
I added a routine to check the correlation between
the extension tree lists and the hashtab
tables. It can be amazingly helpful when you have
lots of dialplan stuff, and need to narrow
down where a problem is occurring. It's ifdef'd
out by default.
I cleaned up the code around the new CIDmatch code.
It was leaving hanging extens with bad ptrs, getting confused
over which objects to remove, etc. I tightened
up the code and changed the call to remove_exten
in the merge_and_delete code.
I added more conditions to check for empty context
worthy of deletion. It's not empty if there are
any includes, switches, or ignorepats present.
If I've missed anything, please re-open this bug,
and be prepared to supply example dialplan code.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@130145 65c4cc65-6c06-0410-ace0-fbb531ad65f3
ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context records the exten %s (CID match: %s) but it is not in its root_table\n",file,line,c2->name,dummy_name,e1->cidmatch);
}else{
ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context records the exten %s but it is not in its root_table\n",file,line,c2->name,dummy_name);
}
check_contexts_trouble();
}
}
/* is every entry in the root_table also in the root list? */
if(!c2->root_table){
if(c2->root){
ast_log(LOG_NOTICE,"Called from: %s:%d: No c2->root_table for context %s!\n",file,line,c2->name);
usleep(500000);
}
}else{
t1=ast_hashtab_start_traversal(c2->root_table);
while((e2=ast_hashtab_next(t1))){
for(e1=c2->root;e1;e1=e1->next){
if(!strcmp(e1->exten,e2->exten)){
found=1;
break;
}
}
if(!found){
ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context records the exten %s but it is not in its root_table\n",file,line,c2->name,e2->exten);
check_contexts_trouble();
}
}
ast_hashtab_end_traversal(t1);
}
}
/* is every priority reflected in the peer_table at the head of the list? */
/* is every entry in the root list also in the root_table? */
/* are the per-extension peer_tables in the right place? */
for(e1=c2->root;e1;e1=e1->next){
for(e2=e1;e2;e2=e2->peer){
ex.priority=e2->priority;
if(e2!=e1&&e2->peer_table){
ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context, %s exten, %d priority has a peer_table entry, and shouldn't!\n",file,line,c2->name,e1->exten,e2->priority);
check_contexts_trouble();
}
if(e2!=e1&&e2->peer_label_table){
ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context, %s exten, %d priority has a peer_label_table entry, and shouldn't!\n",file,line,c2->name,e1->exten,e2->priority);
check_contexts_trouble();
}
if(e2==e1&&!e2->peer_table){
ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context, %s exten, %d priority doesn't have a peer_table!\n",file,line,c2->name,e1->exten,e2->priority);
check_contexts_trouble();
}
if(e2==e1&&!e2->peer_label_table){
ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context, %s exten, %d priority doesn't have a peer_label_table!\n",file,line,c2->name,e1->exten,e2->priority);
check_contexts_trouble();
}
e3=ast_hashtab_lookup(e1->peer_table,&ex);
if(!e3){
ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context, %s exten, %d priority is not reflected in the peer_table\n",file,line,c2->name,e1->exten,e2->priority);
check_contexts_trouble();
}
}
if(!e1->peer_table){
ast_log(LOG_NOTICE,"Called from: %s:%d: No e1->peer_table!\n",file,line);
usleep(500000);
}
/* is every entry in the peer_table also in the peer list? */
t1=ast_hashtab_start_traversal(e1->peer_table);
while((e2=ast_hashtab_next(t1))){
for(e3=e1;e3;e3=e3->peer){
if(e3->priority==e2->priority){
found=1;
break;
}
}
if(!found){
ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context, %s exten, %d priority is not reflected in the peer list\n",file,line,c2->name,e1->exten,e2->priority);