Module: sip-router Branch: master Commit: d896bb5f001641a6fcd9cd598eb3edf0255f1546 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d896bb5f...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Mon Mar 15 12:16:58 2010 +0100
mtree: mt_reload updated
- reload function takes in consideration the operation mode
---
modules/mtree/mtree_mod.c | 62 ++++++++++++++++++++++++++------------------- 1 files changed, 36 insertions(+), 26 deletions(-)
diff --git a/modules/mtree/mtree_mod.c b/modules/mtree/mtree_mod.c index 9eea87e..a5d42f7 100644 --- a/modules/mtree/mtree_mod.c +++ b/modules/mtree/mtree_mod.c @@ -726,42 +726,52 @@ static struct mi_root* mt_mi_reload(struct mi_root *cmd_tree, void *param) m_tree_t *pt; struct mi_node* node = NULL;
- if(!mt_defined_trees()) + if(db_table.len>0) { - LM_ERR("empty tree list\n"); - return init_mi_tree( 500, MI_INTERNAL_ERR_S, MI_INTERNAL_ERR_LEN); - } + /* re-loading all information from database */ + if(mt_load_db_trees()!=0) + { + LM_ERR("cannot re-load info from database\n"); + goto error; + } + } else { + if(!mt_defined_trees()) + { + LM_ERR("empty tree list\n"); + return init_mi_tree( 500, MI_INTERNAL_ERR_S, MI_INTERNAL_ERR_LEN); + }
- /* read tree name */ - node = cmd_tree->node.kids; - if(node != NULL) - { - tname = node->value; - if(tname.s == NULL || tname.len== 0) - return init_mi_tree( 404, "domain not found", 16); + /* read tree name */ + node = cmd_tree->node.kids; + if(node != NULL) + { + tname = node->value; + if(tname.s == NULL || tname.len== 0) + return init_mi_tree( 404, "domain not found", 16);
- if(*tname.s=='.') { - tname.s = 0; - tname.len = 0; + if(*tname.s=='.') { + tname.s = 0; + tname.len = 0; + } } - }
- pt = mt_get_first_tree(); + pt = mt_get_first_tree(); - while(pt!=NULL) - { - if(tname.s==NULL || - (tname.s!=NULL && pt->tname.len>=tname.len && - strncmp(pt->tname.s, tname.s, tname.len)==0)) + while(pt!=NULL) { - /* re-loading table from database */ - if(mt_load_db(&pt->tname)!=0) + if(tname.s==NULL + || (tname.s!=NULL && pt->tname.len>=tname.len + && strncmp(pt->tname.s, tname.s, tname.len)==0)) { - LM_ERR("cannot re-load info from database\n"); - goto error; + /* re-loading table from database */ + if(mt_load_db(&pt->tname)!=0) + { + LM_ERR("cannot re-load info from database\n"); + goto error; + } } + pt = pt->next; } - pt = pt->next; } return init_mi_tree( 200, MI_OK_S, MI_OK_LEN);