check if the bchannel stack id is already used, if so don't use it a second time. Also added a release_chan lock, so that the same chan_list object cannot be freed twice. chan_misdn does not crash anymore on heavy load with these changes.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@72585 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.2
Christian Richter 18 years ago
parent aac9dd609c
commit fc4111b44f

@ -103,6 +103,7 @@ int misdn_jb_empty(struct misdn_jb *jb, char *data, int len);
/* BEGIN: chan_misdn.h */ /* BEGIN: chan_misdn.h */
ast_mutex_t release_lock;
enum misdn_chan_state { enum misdn_chan_state {
@ -3286,10 +3287,13 @@ static void hangup_chan(struct chan_list *ch)
/** Isdn asks us to release channel, pendant to misdn_hangup **/ /** Isdn asks us to release channel, pendant to misdn_hangup **/
static void release_chan(struct misdn_bchannel *bc) { static void release_chan(struct misdn_bchannel *bc) {
struct ast_channel *ast=NULL; struct ast_channel *ast=NULL;
ast_mutex_lock(&release_lock);
{ {
struct chan_list *ch=find_chan_by_bc(cl_te, bc); struct chan_list *ch=find_chan_by_bc(cl_te, bc);
if (!ch) { if (!ch) {
chan_misdn_log(1, bc->port, "release_chan: Ch not found!\n"); chan_misdn_log(1, bc->port, "release_chan: Ch not found!\n");
ast_mutex_unlock(&release_lock);
return; return;
} }
@ -3341,6 +3345,8 @@ static void release_chan(struct misdn_bchannel *bc) {
/* chan is already cleaned, so exiting */ /* chan is already cleaned, so exiting */
} }
} }
ast_mutex_unlock(&release_lock);
} }
/*** release end **/ /*** release end **/
@ -4537,6 +4543,7 @@ int load_module(void)
} }
ast_mutex_init(&cl_te_lock); ast_mutex_init(&cl_te_lock);
ast_mutex_init(&release_lock);
misdn_cfg_update_ptp(); misdn_cfg_update_ptp();
misdn_cfg_get_ports_string(ports); misdn_cfg_get_ports_string(ports);

@ -977,6 +977,15 @@ int setup_bc(struct misdn_bchannel *bc)
cb_log(5, stack->port, "$$$ Setting up bc with stid :%x\n", b_stid); cb_log(5, stack->port, "$$$ Setting up bc with stid :%x\n", b_stid);
/*check if the b_stid is alread initialized*/
int i;
for (i=0; i <= stack->b_num; i++) {
if (stack->bc[i].b_stid == b_stid) {
cb_log(0, bc->port, "setup_bc: b_stid:%x already in use !!!\n", b_stid);
return -1;
}
}
if (b_stid <= 0) { if (b_stid <= 0) {
cb_log(0, stack->port," -- Stid <=0 at the moment in channel:%d\n",channel); cb_log(0, stack->port," -- Stid <=0 at the moment in channel:%d\n",channel);

Loading…
Cancel
Save