[svn-commits] russell: branch 1.4 r90145 - in /branches/1.4: funcs/ include/asterisk/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Nov 28 18:20:34 CST 2007


Author: russell
Date: Wed Nov 28 18:20:34 2007
New Revision: 90145

URL: http://svn.digium.com/view/asterisk?view=rev&rev=90145
Log:
This set of changes is to make some callerID handling thread-safe.
The ast_set_callerid() function needed to lock the channel.  Also, the handlers
for the CALLERID() dialplan function needed to lock the channel when reading
or writing callerid values directly on the channel structure.

Modified:
    branches/1.4/funcs/func_callerid.c
    branches/1.4/include/asterisk/channel.h
    branches/1.4/main/channel.c

Modified: branches/1.4/funcs/func_callerid.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/funcs/func_callerid.c?view=diff&rev=90145&r1=90144&r2=90145
==============================================================================
--- branches/1.4/funcs/func_callerid.c (original)
+++ branches/1.4/funcs/func_callerid.c Wed Nov 28 18:20:34 2007
@@ -64,6 +64,8 @@
 			ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
 		}
 	} else {
+		ast_channel_lock(chan);
+
 		if (!strncasecmp("all", data, 3)) {
 			snprintf(buf, len, "\"%s\" <%s>",
 				 S_OR(chan->cid.cid_name, ""),
@@ -92,6 +94,8 @@
 		} else {
 			ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
 		}
+
+		ast_channel_unlock(chan);
 	}
 
 	return 0;
@@ -107,8 +111,8 @@
 		char name[256];
 		char num[256];
 
-		if (!ast_callerid_split(value, name, sizeof(name), num, sizeof(num)))
-			ast_set_callerid(chan, num, name, num);
+	if (!ast_callerid_split(value, name, sizeof(name), num, sizeof(num)))
+		ast_set_callerid(chan, num, name, num);
 	} else if (!strncasecmp("name", data, 4)) {
 		ast_set_callerid(chan, NULL, value, NULL);
 	} else if (!strncasecmp("num", data, 3) ||
@@ -117,15 +121,17 @@
 	} else if (!strncasecmp("ani", data, 3)) {
 		ast_set_callerid(chan, NULL, NULL, value);
 	} else if (!strncasecmp("dnid", data, 4)) {
-		/* do we need to lock chan here? */
+		ast_channel_lock(chan);
 		if (chan->cid.cid_dnid)
 			free(chan->cid.cid_dnid);
 		chan->cid.cid_dnid = ast_strdup(value);
+		ast_channel_unlock(chan);
 	} else if (!strncasecmp("rdnis", data, 5)) {
-		/* do we need to lock chan here? */
+		ast_channel_lock(chan);
 		if (chan->cid.cid_rdnis)
 			free(chan->cid.cid_rdnis);
 		chan->cid.cid_rdnis = ast_strdup(value);
+		ast_channel_unlock(chan);
 	} else {
 		ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
 	}

Modified: branches/1.4/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/include/asterisk/channel.h?view=diff&rev=90145&r1=90144&r2=90145
==============================================================================
--- branches/1.4/include/asterisk/channel.h (original)
+++ branches/1.4/include/asterisk/channel.h Wed Nov 28 18:20:34 2007
@@ -1109,6 +1109,9 @@
 /*! Deactive an active generator */
 void ast_deactivate_generator(struct ast_channel *chan);
 
+/*!
+ * \note The channel does not need to be locked before calling this function.
+ */
 void ast_set_callerid(struct ast_channel *chan, const char *cidnum, const char *cidname, const char *ani);
 
 

Modified: branches/1.4/main/channel.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/channel.c?view=diff&rev=90145&r1=90144&r2=90145
==============================================================================
--- branches/1.4/main/channel.c (original)
+++ branches/1.4/main/channel.c Wed Nov 28 18:20:34 2007
@@ -3874,6 +3874,8 @@
 
 void ast_set_callerid(struct ast_channel *chan, const char *callerid, const char *calleridname, const char *ani)
 {
+	ast_channel_lock(chan);
+
 	if (callerid) {
 		if (chan->cid.cid_num)
 			free(chan->cid.cid_num);
@@ -3904,6 +3906,8 @@
 				chan->cid.cid_pres,
 				ast_describe_caller_presentation(chan->cid.cid_pres)
 				);
+	
+	ast_channel_unlock(chan);
 }
 
 int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)




More information about the svn-commits mailing list