[sr-dev] git:4.1:9e57273d: debugger: fix issue #463

Stefan Mititelu stefan.mititelu at 1and1.ro
Thu Jan 7 10:51:28 CET 2016


Module: kamailio
Branch: 4.1
Commit: 9e57273df9b33a14f258e0c04b699d34655d7fec
URL: https://github.com/kamailio/kamailio/commit/9e57273df9b33a14f258e0c04b699d34655d7fec

Author: Stefan Mititelu <stefan.mititelu at 1and1.ro>
Committer: Stefan Mititelu <stefan.mititelu at 1and1.ro>
Date: 2016-01-07T11:50:40+02:00

debugger: fix issue #463

Don't shm_malloc() while the lock is taken.

(cherry picked from commit 3668618369a8a1db8cb3410c0a7f50ce74150cd2)

---

Modified: modules/debugger/debugger_api.c

---

Diff:  https://github.com/kamailio/kamailio/commit/9e57273df9b33a14f258e0c04b699d34655d7fec.diff
Patch: https://github.com/kamailio/kamailio/commit/9e57273df9b33a14f258e0c04b699d34655d7fec.patch

---

diff --git a/modules/debugger/debugger_api.c b/modules/debugger/debugger_api.c
index 90ba11f..3f30cb5 100644
--- a/modules/debugger/debugger_api.c
+++ b/modules/debugger/debugger_api.c
@@ -1145,15 +1145,14 @@ int dbg_set_mod_debug_level(char *mname, int mnlen, int *mlevel)
 		itp = it;
 		it = it->next;
 	}
+	lock_release(&_dbg_mod_table[idx].lock);
 	/* not found - add */
 	if(mlevel==NULL) {
-		lock_release(&_dbg_mod_table[idx].lock);
 		return 0;
 	}
 	itn = (dbg_mod_level_t*)shm_malloc(sizeof(dbg_mod_level_t) + (mnlen+1)*sizeof(char));
 	if(itn==NULL) {
 		LM_ERR("no more shm\n");
-		lock_release(&_dbg_mod_table[idx].lock);
 		return -1;
 	}
 	memset(itn, 0, sizeof(dbg_mod_level_t) + (mnlen+1)*sizeof(char));
@@ -1164,6 +1163,7 @@ int dbg_set_mod_debug_level(char *mname, int mnlen, int *mlevel)
 	strncpy(itn->name.s, mname, mnlen);
 	itn->name.s[itn->name.len] = '\0';
 
+	lock_get(&_dbg_mod_table[idx].lock);
 	if(itp==NULL) {
 		itn->next = _dbg_mod_table[idx].first;
 		_dbg_mod_table[idx].first = itn;




More information about the sr-dev mailing list