[Asterisk-cvs] asterisk-addons/asterisk-ooh323c/src chan_h323.c,
1.14, 1.15
vphirke
vphirke
Mon Nov 7 11:04:40 CST 2005
Update of /usr/cvsroot/asterisk-addons/asterisk-ooh323c/src
In directory mongoose.digium.com:/tmp/cvs-serv11023/src
Modified Files:
chan_h323.c
Log Message:
Added mutex protection for ooh323c stack commands
Index: chan_h323.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/asterisk-ooh323c/src/chan_h323.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- chan_h323.c 4 Nov 2005 14:36:47 -0000 1.14
+++ chan_h323.c 7 Nov 2005 15:55:48 -0000 1.15
@@ -61,7 +61,7 @@
static struct ast_rtp *ooh323_get_rtp_peer(struct ast_channel *chan);
static struct ast_rtp *ooh323_get_vrtp_peer(struct ast_channel *chan);
static int ooh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp,
- struct ast_rtp *vrtp, int codecs);
+ struct ast_rtp *vrtp, int codecs, int nat_active);
@@ -87,7 +87,7 @@
.type = type,
.get_rtp_info = ooh323_get_rtp_peer,
.get_vrtp_info = ooh323_get_vrtp_peer,
- .set_rtp_peer= ooh323_set_rtp_peer,
+ .set_rtp_peer= ooh323_set_rtp_peer
};
/* H.323 channel specific data */
@@ -188,6 +188,7 @@
static int usecnt =0;
AST_MUTEX_DEFINE_STATIC(usecnt_lock);
+AST_MUTEX_DEFINE_STATIC(ooh323c_cmd_lock);
/* stack callbacks */
int onAlerting(ooCallData *call);
@@ -651,15 +652,23 @@
if(gH323Debug)
ast_verbose("--- ooh323_digit\n");
- if (p && p->rtp && (p->dtmfmode & H323_DTMF_RFC2833)) {
+ if(!p){
+ ast_log(LOG_ERROR, "No private structure for call\n");
+ return -1;
+ }
+ ast_mutex_lock(&p->lock);
+ if (p->rtp && (p->dtmfmode & H323_DTMF_RFC2833)) {
ast_rtp_senddigit(p->rtp, digit);
- }else if (p && ((p->dtmfmode & H323_DTMF_Q931) ||
+ }else if (((p->dtmfmode & H323_DTMF_Q931) ||
(p->dtmfmode & H323_DTMF_H245ALPHANUMERIC) ||
(p->dtmfmode & H323_DTMF_H245SIGNAL))){
dtmf[0]= digit;
dtmf[1]='\0';
+ ast_mutex_lock(&ooh323c_cmd_lock);
ooSendDTMFDigit(p->callToken, dtmf);
+ ast_mutex_unlock(&ooh323c_cmd_lock);
}
+ ast_mutex_unlock(&p->lock);
if(gH323Debug)
ast_verbose("+++ ooh323_digit\n");
@@ -746,11 +755,12 @@
destination[sizeof(destination)-1]='\0';
+ ast_mutex_lock(&ooh323c_cmd_lock);
if(OO_TESTFLAG(p->flags, H323_DISABLEGK))
res = ooMakeCall(destination, p->callToken, AST_MAX_EXTENSION, &opts);
else
res = ooMakeCall(destination, p->callToken, AST_MAX_EXTENSION, NULL);
-
+ ast_mutex_unlock(&ooh323c_cmd_lock);
ast_mutex_unlock(&p->lock);
if(res != OO_OK)
@@ -780,10 +790,12 @@
if(!ast_test_flag(p, H323_ALREADYGONE))
{
+ ast_mutex_lock(&ooh323c_cmd_lock);
ooHangCall(p->callToken,
- ooh323_convert_hangupcause_asteriskToH323(p->owner->hangupcause));
+ ooh323_convert_hangupcause_asteriskToH323(p->owner->hangupcause));
+ ast_mutex_unlock(&ooh323c_cmd_lock);
ast_set_flag(p, H323_ALREADYGONE);
- ast_mutex_unlock(&p->lock);
+ // ast_mutex_unlock(&p->lock);
}else {
ast_set_flag(p, H323_NEEDDESTROY);
}
@@ -828,7 +840,9 @@
if (option_debug)
ast_log(LOG_DEBUG, "ooh323_answer(%s)\n", ast->name);
ast_mutex_unlock(&ast->lock);
+ ast_mutex_lock(&ooh323c_cmd_lock);
ooAnswerCall(p->callToken);
+ ast_mutex_unlock(&ooh323c_cmd_lock);
}
ast_mutex_unlock(&p->lock);
@@ -910,13 +924,17 @@
switch(condition) {
case AST_CONTROL_CONGESTION:
if(!ast_test_flag(p, H323_ALREADYGONE)){
+ ast_mutex_lock(&ooh323c_cmd_lock);
ooHangCall(callToken, OO_REASON_LOCAL_CONGESTED);
+ ast_mutex_unlock(&ooh323c_cmd_lock);
ast_set_flag(p, H323_ALREADYGONE);
}
break;
case AST_CONTROL_BUSY:
if(!ast_test_flag(p, H323_ALREADYGONE)){
+ ast_mutex_lock(&ooh323c_cmd_lock);
ooHangCall(callToken, OO_REASON_LOCAL_BUSY);
+ ast_mutex_unlock(&ooh323c_cmd_lock);
ast_set_flag(p, H323_ALREADYGONE);
}
break;
@@ -936,7 +954,8 @@
return -1;
}
-static int ooh323_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
+static int ooh323_fixup
+ (struct ast_channel *oldchan, struct ast_channel *newchan)
{
if(gH323Debug)
ast_verbose("ooh323c ooh323_fixup\n");
@@ -1337,8 +1356,6 @@
if(gH323Debug)
ast_verbose("--- onCallCleared %s \n", call->callToken);
-
-
p = find_call(call);
if (!p) {
return 0;
@@ -1733,7 +1750,7 @@
pNewAlias = NULL;
}else if (!strcasecmp(v->name, "e164"))
{
- pNewAlias = malloc(sizeof(struct ooAliases));
+ pNewAlias = malloc(sizeof(struct ooAliases));
if(!pNewAlias){
ast_log(LOG_ERROR, "Failed to allocate memory for e164 alias\n");
return 1;
@@ -2756,7 +2773,7 @@
static int ooh323_set_rtp_peer
(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp,
- int codecs)
+ int codecs, int nat_active)
{
/* XXX Deal with Video */
struct ooh323_pvt *p;
More information about the svn-commits
mailing list