[asterisk-commits] pcadach: branch pcadach/chan_h323-live r39777 -
/team/pcadach/chan_h323-live/...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Aug 15 07:09:58 MST 2006
Author: pcadach
Date: Tue Aug 15 09:09:57 2006
New Revision: 39777
URL: http://svn.digium.com/view/asterisk?rev=39777&view=rev
Log:
Fix deadlock on receiving USERINPUT signal
Modified:
team/pcadach/chan_h323-live/channels/chan_h323.c
Modified: team/pcadach/chan_h323-live/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/chan_h323.c?rev=39777&r1=39776&r2=39777&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/chan_h323.c (original)
+++ team/pcadach/chan_h323-live/channels/chan_h323.c Tue Aug 15 09:09:57 2006
@@ -179,6 +179,7 @@
int hangupcause; /* Hangup cause from OpenH323 layer */
int newstate; /* Pending state change */
int newcontrol; /* Pending control to send */
+ int newdigit; /* Pending DTMF digit to send */
int pref_codec; /* Preferred codec */
int peercapability; /* Capabilities learned from peer */
int jointcapability; /* Common capabilities for local and remote side */
@@ -257,6 +258,8 @@
/* Channel and private structures should be already locked */
static void __oh323_update_info(struct ast_channel *c, struct oh323_pvt *pvt)
{
+ struct ast_frame f;
+
if (c->nativeformats != pvt->nativeformats) {
if (h323debug)
ast_log(LOG_DEBUG, "Preparing %s for new native format\n", c->name);
@@ -271,7 +274,7 @@
c->hangupcause = pvt->hangupcause;
ast_queue_hangup(c);
pvt->needhangup = 0;
- pvt->newstate = pvt->newcontrol = -1;
+ pvt->newstate = pvt->newcontrol = pvt->newdigit = -1;
}
if (pvt->newstate >= 0) {
ast_setstate(c, pvt->newstate);
@@ -280,6 +283,19 @@
if (pvt->newcontrol >= 0) {
ast_queue_control(c, pvt->newcontrol);
pvt->newcontrol = -1;
+ }
+ if (pvt->newdigit >= 0) {
+ memset(&f, 0, sizeof(f));
+ f.frametype = AST_FRAME_DTMF;
+ f.subclass = pvt->newdigit;
+ f.datalen = 0;
+ f.samples = 800;
+ f.offset = 0;
+ f.data = NULL;
+ f.mallocd = 0;
+ f.src = "UPDATE_INFO";
+ ast_queue_frame(c, &f);
+ pvt->newdigit = -1;
}
}
@@ -395,18 +411,19 @@
ast_log(LOG_DEBUG, "Sending out-of-band digit %c on %s\n", digit, c->name);
}
ast_rtp_senddigit(pvt->rtp, digit);
+ ast_mutex_unlock(&pvt->lock);
} else {
/* in-band DTMF */
if (h323debug) {
ast_log(LOG_DEBUG, "Sending inband digit %c on %s\n", digit, c->name);
}
token = pvt->cd.call_token ? strdup(pvt->cd.call_token) : NULL;
+ ast_mutex_unlock(&pvt->lock);
h323_send_tone(token, digit);
if (token) {
free(token);
}
}
- ast_mutex_unlock(&pvt->lock);
oh323_update_info(c);
return 0;
}
@@ -885,7 +902,7 @@
pvt->nonCodecCapability &= ~AST_RTP_DTMF;
}
strncpy(pvt->context, default_context, sizeof(pvt->context) - 1);
- pvt->newstate = pvt->newcontrol = -1;
+ pvt->newstate = pvt->newcontrol = pvt->newdigit = -1;
/* Add to interface list */
ast_mutex_lock(&iflock);
pvt->next = iflist;
@@ -1169,16 +1186,22 @@
ast_log(LOG_ERROR, "Private structure not found in send_digit.\n");
return -1;
}
- memset(&f, 0, sizeof(f));
- f.frametype = AST_FRAME_DTMF;
- f.subclass = digit;
- f.datalen = 0;
- f.samples = 800;
- f.offset = 0;
- f.data = NULL;
- f.mallocd = 0;
- f.src = "SEND_DIGIT";
- res = ast_queue_frame(pvt->owner, &f);
+ if (pvt->owner && !ast_mutex_trylock(&pvt->owner->lock)) {
+ memset(&f, 0, sizeof(f));
+ f.frametype = AST_FRAME_DTMF;
+ f.subclass = digit;
+ f.datalen = 0;
+ f.samples = 800;
+ f.offset = 0;
+ f.data = NULL;
+ f.mallocd = 0;
+ f.src = "SEND_DIGIT";
+ res = ast_queue_frame(pvt->owner, &f);
+ ast_mutex_unlock(&pvt->owner->lock);
+ } else {
+ pvt->newdigit = digit;
+ res = 0;
+ }
ast_mutex_unlock(&pvt->lock);
return res;
}
More information about the asterisk-commits
mailing list