[Asterisk-cvs] asterisk/channels chan_sip.c,1.323,1.324

markster at lists.digium.com markster at lists.digium.com
Fri Apr 2 02:25:25 CST 2004


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv19889/channels

Modified Files:
	chan_sip.c 
Log Message:
Update security document, work on threading with pbx.c and small SIP fixes


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.323
retrieving revision 1.324
diff -u -d -r1.323 -r1.324
--- chan_sip.c	1 Apr 2004 06:27:10 -0000	1.323
+++ chan_sip.c	2 Apr 2004 07:24:33 -0000	1.324
@@ -5885,6 +5885,7 @@
 
 static int restart_monitor(void)
 {
+	pthread_attr_t attr;
 	/* If we're supposed to be stopped -- stay stopped */
 	if (monitor_thread == AST_PTHREADT_STOP)
 		return 0;
@@ -5901,8 +5902,10 @@
 		/* Wake up the thread */
 		pthread_kill(monitor_thread, SIGURG);
 	} else {
+		pthread_attr_init(&attr);
+		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 		/* Start a new monitor */
-		if (pthread_create(&monitor_thread, NULL, do_monitor, NULL) < 0) {
+		if (pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) {
 			ast_mutex_unlock(&monlock);
 			ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
 			return -1;
@@ -6701,26 +6704,34 @@
 static char *app_dtmfmode = "SIPDtmfMode";
 static int sip_dtmfmode(struct ast_channel *chan, void *data)
 {
-	struct sip_pvt *p = chan->pvt->pvt;
+	struct sip_pvt *p;
 	char *mode;
-	if (chan->type != type) {
-		ast_log(LOG_WARNING, "Call this application only on SIP incoming calls\n");
-		return 0;
-	}
 	if (data)
 		mode = (char *)data;
 	else {
 		ast_log(LOG_WARNING, "This application requires the argument: info, inband, rfc2833\n");
 		return 0;
 	}
-	if (!strcasecmp(mode,"info"))
-		p->dtmfmode = SIP_DTMF_INFO;
-	else if (!strcasecmp(mode,"rfc2833"))
-		p->dtmfmode = SIP_DTMF_RFC2833;
-	else if (!strcasecmp(mode,"inband"))
-		p->dtmfmode = SIP_DTMF_INBAND;
-	else
-		ast_log(LOG_WARNING, "I don't know about this dtmf mode: %s\n",mode);
+	ast_mutex_lock(&chan->lock);
+	if (chan->type != type) {
+		ast_log(LOG_WARNING, "Call this application only on SIP incoming calls\n");
+		ast_mutex_unlock(&chan->lock);
+		return 0;
+	}
+	p = chan->pvt->pvt;
+	if (p) {
+		ast_mutex_lock(&p->lock);
+		if (!strcasecmp(mode,"info"))
+			p->dtmfmode = SIP_DTMF_INFO;
+		else if (!strcasecmp(mode,"rfc2833"))
+			p->dtmfmode = SIP_DTMF_RFC2833;
+		else if (!strcasecmp(mode,"inband"))
+			p->dtmfmode = SIP_DTMF_INBAND;
+		else
+			ast_log(LOG_WARNING, "I don't know about this dtmf mode: %s\n",mode);
+		ast_mutex_unlock(&p->lock);
+	}
+	ast_mutex_unlock(&chan->lock);
 	return 0;
 }
 




More information about the svn-commits mailing list