Module: sip-router
Branch: master
Commit: e723b2b24a87599d538b652ee60c862f769f8036
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e723b2b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Thu Jul 1 18:22:15 2010 +0200
htable: close db connection in case of mi cmd errors
- in some error cases while processing mi reload command, db connection
was left open
---
modules_k/htable/htable.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/modules_k/htable/htable.c b/modules_k/htable/htable.c
index d2d1b5f..85d238b 100644
--- a/modules_k/htable/htable.c
+++ b/modules_k/htable/htable.c
@@ -337,27 +337,38 @@ static struct mi_root* ht_mi_reload(struct mi_root* cmd_tree, void*
param)
node = cmd_tree->node.kids;
if(node == NULL)
+ {
+ ht_db_close_con();
return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN);
+ }
htname = node->value;
if(htname.len<=0 || htname.s==NULL)
{
LM_ERR("bad hash table name\n");
+ ht_db_close_con();
return init_mi_tree( 500, "bad hash table name", 19);
}
ht = ht_get_table(&htname);
if(ht==NULL || ht->dbtable.len<=0)
{
LM_ERR("bad hash table name\n");
+ ht_db_close_con();
return init_mi_tree( 500, "no such hash table", 18);
}
memcpy(&nht, ht, sizeof(ht_t));
nht.entries = (ht_entry_t*)shm_malloc(nht.htsize*sizeof(ht_entry_t));
if(nht.entries == NULL)
+ {
+ ht_db_close_con();
return init_mi_tree(500, MI_ERR_RELOAD, MI_ERR_RELOAD_LEN);
+ }
memset(nht.entries, 0, nht.htsize*sizeof(ht_entry_t));
if(ht_db_load_table(&nht, &ht->dbtable, 0)<0)
+ {
+ ht_db_close_con();
return init_mi_tree(500, MI_ERR_RELOAD, MI_ERR_RELOAD_LEN);
+ }
/* replace old entries */
for(i=0; i<nht.htsize; i++)