Browse code

debugger: fix issue #463

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

(cherry picked from commit 3668618369a8a1db8cb3410c0a7f50ce74150cd2)

Stefan Mititelu authored on 07/01/2016 07:58:42
Showing 1 changed files
... ...
@@ -1145,15 +1145,14 @@ int dbg_set_mod_debug_level(char *mname, int mnlen, int *mlevel)
1145 1145
 		itp = it;
1146 1146
 		it = it->next;
1147 1147
 	}
1148
+	lock_release(&_dbg_mod_table[idx].lock);
1148 1149
 	/* not found - add */
1149 1150
 	if(mlevel==NULL) {
1150
-		lock_release(&_dbg_mod_table[idx].lock);
1151 1151
 		return 0;
1152 1152
 	}
1153 1153
 	itn = (dbg_mod_level_t*)shm_malloc(sizeof(dbg_mod_level_t) + (mnlen+1)*sizeof(char));
1154 1154
 	if(itn==NULL) {
1155 1155
 		LM_ERR("no more shm\n");
1156
-		lock_release(&_dbg_mod_table[idx].lock);
1157 1156
 		return -1;
1158 1157
 	}
1159 1158
 	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)
1164 1163
 	strncpy(itn->name.s, mname, mnlen);
1165 1164
 	itn->name.s[itn->name.len] = '\0';
1166 1165
 
1166
+	lock_get(&_dbg_mod_table[idx].lock);
1167 1167
 	if(itp==NULL) {
1168 1168
 		itn->next = _dbg_mod_table[idx].first;
1169 1169
 		_dbg_mod_table[idx].first = itn;