Module: sip-router Branch: 4.1 Commit: 3bfb9030dda5776744efc4f408557e044b4ebb75 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3bfb9030...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Mon Jan 6 22:52:11 2014 +0100
htable: free temporary slots used to reload hash table via rpc command
- use system memory for temporary slots
(cherry picked from commit f35c49085bdcc623ef45aa33a99af3265d3e6eeb)
---
modules/htable/htable.c | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/modules/htable/htable.c b/modules/htable/htable.c index 682b847..ab2ecea 100644 --- a/modules/htable/htable.c +++ b/modules/htable/htable.c @@ -1049,7 +1049,8 @@ static void htable_rpc_reload(rpc_t* rpc, void* c)
memcpy(&nht, ht, sizeof(ht_t)); - nht.entries = (ht_entry_t*)shm_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(); @@ -1060,6 +1061,18 @@ static void htable_rpc_reload(rpc_t* rpc, void* c)
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(); rpc->fault(c, 500, "Mtree reload failed"); return; @@ -1086,6 +1099,7 @@ static void htable_rpc_reload(rpc_t* rpc, void* c) ht_cell_free(it); } } + free(nht.entries); ht_db_close_con(); return; }