[asterisk-commits] russell: trunk r63447 - in /trunk: channels/ include/asterisk/ res/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue May 8 09:41:36 MST 2007


Author: russell
Date: Tue May  8 11:41:35 2007
New Revision: 63447

URL: http://svn.digium.com/view/asterisk?view=rev&rev=63447
Log:
I noted this on the dev list but got no response, so I just did it myself.
Lock the call features when being used in chan_sip.

Modified:
    trunk/channels/chan_sip.c
    trunk/include/asterisk/features.h
    trunk/res/res_features.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=63447&r1=63446&r2=63447
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue May  8 11:41:35 2007
@@ -11653,14 +11653,17 @@
 			pbx.
 		*/
 		/* first, get the feature string, if it exists */
-		struct ast_call_feature *feat = ast_find_call_feature("automon");
+		struct ast_call_feature *feat;
 		int j;
 		struct ast_frame f = { AST_FRAME_DTMF, };
-		
+
+		ast_rdlock_call_features();
+		feat = ast_find_call_feature("automon");
 		if (!feat || ast_strlen_zero(feat->exten)) {
 			ast_log(LOG_WARNING,"Recording requested, but no One Touch Monitor registered. (See features.conf)\n");
 			/* 403 means that we don't support this feature, so don't request it again */
 			transmit_response(p, "403 Forbidden", req);
+			ast_unlock_call_features();
 			return;
 		} 
 		/* OEJ: Why is the DTMF code included in the record section? */
@@ -11671,6 +11674,7 @@
 			if (sipdebug)
 				ast_verbose("* DTMF-relay event received: %c\n", f.subclass);
 		}
+		ast_unlock_call_features();
 #ifdef DISABLED_CODE
 		/* And feat isn't used here - Is this code tested at all??? 
 			We just send a reply ... 

Modified: trunk/include/asterisk/features.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/features.h?view=diff&rev=63447&r1=63446&r2=63447
==============================================================================
--- trunk/include/asterisk/features.h (original)
+++ trunk/include/asterisk/features.h Tue May  8 11:41:35 2007
@@ -96,6 +96,9 @@
 
 /*! \brief look for a call feature entry by its sname
 	\param name a string ptr, should match "automon", "blindxfer", "atxfer", etc. */
-struct ast_call_feature *ast_find_call_feature(char *name);
+struct ast_call_feature *ast_find_call_feature(const char *name);
+
+void ast_rdlock_call_features(void);
+void ast_unlock_call_features(void);
 
 #endif /* _AST_FEATURES_H */

Modified: trunk/res/res_features.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_features.c?view=diff&rev=63447&r1=63446&r2=63447
==============================================================================
--- trunk/res/res_features.c (original)
+++ trunk/res/res_features.c Tue May  8 11:41:35 2007
@@ -1070,14 +1070,23 @@
 	return tmp;
 }
 
+void ast_rdlock_call_features(void)
+{
+	ast_rwlock_rdlock(&features_lock);
+}
+
+void ast_unlock_call_features(void)
+{
+	ast_rwlock_unlock(&features_lock);
+}
+
 /*! \brief find a call feature by name */
-struct ast_call_feature *ast_find_call_feature(char *name)
+struct ast_call_feature *ast_find_call_feature(const char *name)
 {
 	int x;
 	for (x = 0; x < FEATURES_COUNT; x++) {
-		if (!strcasecmp(name, builtin_features[x].sname)) {
+		if (!strcasecmp(name, builtin_features[x].sname))
 			return &builtin_features[x];
-		}
 	}
 	return NULL;
 }



More information about the asterisk-commits mailing list