Module: sip-router
Branch: 4.1
Commit: 2b450f573bdbcb88d0418a43a6707875f050eb33
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2b450f5…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Jan 6 22:46:48 2014 +0100
htable: use system malloc for temporary allocation of hash table realod slots
- copes better with large number of slots, without a need to use shm
(cherry picked from commit 13626ccffeaa7654c58576c3d1cc417dea865ca9)
---
modules/htable/htable.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/modules/htable/htable.c b/modules/htable/htable.c
index 6345b9e..682b847 100644
--- a/modules/htable/htable.c
+++ b/modules/htable/htable.c
@@ -490,7 +490,8 @@ static struct mi_root* ht_mi_reload(struct mi_root* cmd_tree, void*
param)
return init_mi_tree( 500, "no such hash table", 18);
}
memcpy(&nht, ht, sizeof(ht_t));
- nht.entries = (ht_entry_t*)pkg_malloc(nht.htsize*sizeof(ht_entry_t));
+ /* it's temporary operation - use system malloc */
+ nht.entries = (ht_entry_t*)malloc(nht.htsize*sizeof(ht_entry_t));
if(nht.entries == NULL)
{
ht_db_close_con();
@@ -500,6 +501,18 @@ static struct mi_root* ht_mi_reload(struct mi_root* cmd_tree, void*
param)
if(ht_db_load_table(&nht, &ht->dbtable, 0)<0)
{
+ /* free any entry set if it was a partial load */
+ for(i=0; i<nht.htsize; i++)
+ {
+ first = nht.entries[i].first;
+ while(first)
+ {
+ it = first;
+ first = first->next;
+ ht_cell_free(it);
+ }
+ }
+ free(nht.entries);
ht_db_close_con();
return init_mi_tree(500, MI_ERR_RELOAD, MI_ERR_RELOAD_LEN);
}
@@ -525,7 +538,7 @@ static struct mi_root* ht_mi_reload(struct mi_root* cmd_tree, void*
param)
ht_cell_free(it);
}
}
- pkg_free(nht.entries);
+ free(nht.entries);
ht_db_close_con();
return init_mi_tree( 200, MI_OK_S, MI_OK_LEN);
}