[asterisk-commits] pcadach: branch pcadach/chan_h323_exts r39778 - /team/pcadach/chan_h323_exts/...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Aug 15 07:10:19 MST 2006


Author: pcadach
Date: Tue Aug 15 09:10:19 2006
New Revision: 39778

URL: http://svn.digium.com/view/asterisk?rev=39778&view=rev
Log:
Fix deadlock on receiving USERINPUT signal

Modified:
    team/pcadach/chan_h323_exts/channels/chan_h323.c

Modified: team/pcadach/chan_h323_exts/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323_exts/channels/chan_h323.c?rev=39778&r1=39777&r2=39778&view=diff
==============================================================================
--- team/pcadach/chan_h323_exts/channels/chan_h323.c (original)
+++ team/pcadach/chan_h323_exts/channels/chan_h323.c Tue Aug 15 09:10:19 2006
@@ -166,6 +166,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 */
@@ -253,6 +254,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);
@@ -267,7 +270,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);
@@ -276,6 +279,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;
 	}
 }
 
@@ -403,18 +419,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;
 }
@@ -984,7 +1001,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;
@@ -1295,16 +1312,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);
+	} else {
+		pvt->newdigit = digit;
+		res = 0;
+	}
 	ast_mutex_unlock(&pvt->lock);
 	return res;
 }
@@ -1396,6 +1419,9 @@
 		break;
 	case 2:
 		rtp = pvt->vrtp;
+		break;
+	default:
+		rtp = (struct ast_rtp *)NULL;
 		break;
 	}
 	if (!rtp) {



More information about the asterisk-commits mailing list