[svn-commits] murf: branch murf/11583-disconB4bridge r180298 - in /team/murf/11583-disconB4...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Mar 4 17:07:51 CST 2009


Author: murf
Date: Wed Mar  4 17:06:40 2009
New Revision: 180298

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=180298
Log:
OK, I think I've covered all the issues that Russell brought forward. Now is the time to get this on reviewboard

Modified:
    team/murf/11583-disconB4bridge/apps/app_dial.c
    team/murf/11583-disconB4bridge/include/asterisk/features.h
    team/murf/11583-disconB4bridge/main/features.c

Modified: team/murf/11583-disconB4bridge/apps/app_dial.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/11583-disconB4bridge/apps/app_dial.c?view=diff&rev=180298&r1=180297&r2=180298
==============================================================================
--- team/murf/11583-disconB4bridge/apps/app_dial.c (original)
+++ team/murf/11583-disconB4bridge/apps/app_dial.c Wed Mar  4 17:06:40 2009
@@ -558,7 +558,7 @@
 	uint64_t flags;
 };
 
-static int detect_disconnect(struct ast_channel *chan, char code);
+static int detect_disconnect(struct ast_channel *chan, char code, char featurecode[FEATURE_MAX_LEN + 1]);
 
 static void hanguptree(struct chanlist *outgoing, struct ast_channel *exception, int answered_elsewhere)
 {
@@ -808,6 +808,9 @@
 #ifdef HAVE_EPOLL
 	struct chanlist *epollo;
 #endif
+	char featurecode[FEATURE_MAX_LEN + 1];
+
+	featurecode[0] = 0;
 
 	if (single) {
 		/* Turn off hold music, etc */
@@ -827,9 +830,7 @@
 		int numlines = prestart;
 		struct ast_channel *winner;
 		struct ast_channel *watchers[AST_MAX_WATCHERS];
-		char featurecode[FEATURE_MAX_LEN + 1];
-
-		featurecode[0] = 0;
+
 		watchers[pos++] = in;
 		for (o = outgoing; o; o = o->next) {
 			/* Keep track of important channels */
@@ -1102,10 +1103,10 @@
 
 static int detect_disconnect(struct ast_channel *chan, char code, char featurecode[FEATURE_MAX_LEN + 1])
 {
-	struct feature_interpret_result result;
+	struct ast_feature_interpret_result result;
 	int x;
-	struct ast_flags features;
-	int res = FEATURE_RETURN_PASSDIGITS;
+	struct ast_flags features = { AST_FEATURE_DISCONNECT };
+	int res = AST_FEATURE_RETURN_PASSDIGITS;
 	struct ast_call_feature *feature;
 	char *cptr;
 	const char *dynamic_features = pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES");
@@ -1119,16 +1120,11 @@
 	cptr[0] = code;
 	cptr[1] = '\0';
 
-	memset(&features, 0, sizeof(struct ast_flags));
-	ast_set_flag(&features, AST_FEATURE_DISCONNECT);
-
 	ast_features_lock();
-
 	res = ast_feature_detect(chan, &features, featurecode, &result, dynamic_features);
-
-	if (res != FEATURE_RETURN_STOREDIGITS)
+	if (res != AST_FEATURE_RETURN_STOREDIGITS) {
 		featurecode[0] = '\0';
-
+	}
 
 	if (result.builtin_feature && result.builtin_feature->feature_mask & AST_FEATURE_DISCONNECT) {
 		ast_features_unlock();

Modified: team/murf/11583-disconB4bridge/include/asterisk/features.h
URL: http://svn.digium.com/svn-view/asterisk/team/murf/11583-disconB4bridge/include/asterisk/features.h?view=diff&rev=180298&r1=180297&r2=180298
==============================================================================
--- team/murf/11583-disconB4bridge/include/asterisk/features.h (original)
+++ team/murf/11583-disconB4bridge/include/asterisk/features.h Wed Mar  4 17:06:40 2009
@@ -36,14 +36,15 @@
 
 #define PARK_APP_NAME "Park"
 
-#define FEATURE_RETURN_HANGUP		-1
-#define FEATURE_RETURN_SUCCESSBREAK	 0
-#define FEATURE_RETURN_PBX_KEEPALIVE	AST_PBX_KEEPALIVE
-#define FEATURE_RETURN_NO_HANGUP_PEER	AST_PBX_NO_HANGUP_PEER
-#define FEATURE_RETURN_PASSDIGITS	 21
-#define FEATURE_RETURN_STOREDIGITS	 22
-#define FEATURE_RETURN_SUCCESS	 	 23
-#define FEATURE_RETURN_KEEPTRYING    24
+#define AST_FEATURE_RETURN_HANGUP			-1
+#define AST_FEATURE_RETURN_SUCCESSBREAK	 	0
+#define AST_FEATURE_RETURN_PBX_KEEPALIVE	AST_PBX_KEEPALIVE
+#define AST_FEATURE_RETURN_NO_HANGUP_PEER	AST_PBX_NO_HANGUP_PEER
+#define AST_FEATURE_RETURN_PASSDIGITS	 	21
+#define AST_FEATURE_RETURN_STOREDIGITS	 	22
+#define AST_FEATURE_RETURN_SUCCESS	 	 	23
+#define AST_FEATURE_RETURN_KEEPTRYING    	24
+#define AST_FEATURE_RETURN_PARKFAILED		25
 
 #define FEATURE_SENSE_CHAN	(1 << 0)
 #define FEATURE_SENSE_PEER	(1 << 1)
@@ -75,15 +76,7 @@
 	AST_LIST_ENTRY(ast_call_feature) feature_entry;
 };
 
-#define AST_FEATURE_RETURN_HANGUP                   -1
-#define AST_FEATURE_RETURN_SUCCESSBREAK             0
-#define AST_FEATURE_RETURN_PASSDIGITS               21
-#define AST_FEATURE_RETURN_STOREDIGITS              22
-#define AST_FEATURE_RETURN_SUCCESS                  23
-#define AST_FEATURE_RETURN_KEEPTRYING               24
-#define AST_FEATURE_RETURN_PARKFAILED               25
-
-struct feature_interpret_result {
+struct ast_feature_interpret_result {
     struct ast_call_feature *builtin_feature;
     struct ast_call_feature *dynamic_features[20];
     struct ast_call_feature *group_features[20];
@@ -145,9 +138,14 @@
     \param feature the ast_call_feature object which was registered before*/
 void ast_unregister_feature(struct ast_call_feature *feature);
 
-int ast_feature_detect(struct ast_channel *chan, const struct ast_flags *features, char *code, struct feature_interpret_result *result, const char *dynamic_features);
+int ast_feature_detect(struct ast_channel *chan, const struct ast_flags *features, char *code, struct ast_feature_interpret_result *result, const char *dynamic_features);
 
+/*! \brief readlocks the features_lock; writelocks the feature list; then readlocks the feature_groups
+ */	
 void ast_features_lock(void);
+
+/*! \brief unlocks (in the reverse order of ast_features_lock) feature_groups; feature_list; and the features_lock.
+ */	
 void ast_features_unlock(void);
 
 

Modified: team/murf/11583-disconB4bridge/main/features.c
URL: http://svn.digium.com/svn-view/asterisk/team/murf/11583-disconB4bridge/main/features.c?view=diff&rev=180298&r1=180297&r2=180298
==============================================================================
--- team/murf/11583-disconB4bridge/main/features.c (original)
+++ team/murf/11583-disconB4bridge/main/features.c Wed Mar  4 17:06:40 2009
@@ -1979,10 +1979,10 @@
 	ast_rwlock_unlock(&features_lock);
 }
 
-int ast_feature_detect(struct ast_channel *chan, const struct ast_flags *features, char *code, struct feature_interpret_result *result, const char *dynamic_features)
+int ast_feature_detect(struct ast_channel *chan, const struct ast_flags *features, char *code, struct ast_feature_interpret_result *result, const char *dynamic_features)
 {
 	int x;
-	int res = FEATURE_RETURN_PASSDIGITS;
+	int res = AST_FEATURE_RETURN_PASSDIGITS;
 	struct ast_call_feature *feature;
 	struct feature_group *fg = NULL;
 	struct feature_group_exten *fge;
@@ -1991,7 +1991,6 @@
 	result->builtin_feature = NULL;
 	result->num_dyn_features = 0;
 	result->num_grp_features = 0;
-	
 	for (x = 0; x < FEATURES_COUNT; x++) {
 		if ((ast_test_flag(features, builtin_features[x].feature_mask)) &&
 		    !ast_strlen_zero(builtin_features[x].exten)) {
@@ -2039,7 +2038,7 @@
 		if (!strcmp(feature->exten, code)) {
 			ast_verb(3, " Feature Found: %s exten: %s\n",feature->sname, tok);
 			result->dynamic_features[result->num_dyn_features++] = feature;
-			if (result->num_dyn_features >= (sizeof(result->dynamic_features) / sizeof(result->dynamic_features[0]))) {
+			if (result->num_dyn_features >= ARRAY_LEN(result->dynamic_features)) {
 				break;
 			}
 			res = AST_FEATURE_RETURN_PASSDIGITS;
@@ -2059,19 +2058,26 @@
  */
 static int ast_feature_interpret(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense)
 {
-	struct feature_interpret_result result;
+	struct ast_feature_interpret_result result;
 	int x;
 	struct ast_flags features;
 	int res = AST_FEATURE_RETURN_PASSDIGITS;
 	struct ast_call_feature *feature;
 	const char *dynamic_features;
+	const char *z;
 	
 	if (sense == FEATURE_SENSE_CHAN) {
 		ast_copy_flags(&features, &(config->features_caller), AST_FLAGS_ALL);
-		dynamic_features = pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES");
+		ast_channel_lock(chan);
+		z = pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES");
+		dynamic_features = (z ? strdup(z) : NULL);
+		ast_channel_unlock(chan);
 	} else {
 		ast_copy_flags(&features, &(config->features_callee), AST_FLAGS_ALL);
-		dynamic_features = pbx_builtin_getvar_helper(peer, "DYNAMIC_FEATURES");
+		ast_channel_lock(peer);
+		z = pbx_builtin_getvar_helper(peer, "DYNAMIC_FEATURES");
+		dynamic_features = (z ? strdup(z) : NULL);
+		ast_channel_unlock(peer);
 	}
 	ast_debug(3, "Feature interpret: chan=%s, peer=%s, code=%s, sense=%d, features=%d, dynamic=%s\n", chan->name, peer->name, code, sense, features.flags, dynamic_features);
 	
@@ -2085,18 +2091,21 @@
 	for (x = 0; x < result.num_grp_features; ++x) {
 		feature = result.group_features[x];
 		res = feature->operation(chan, peer, config, code, sense, feature);
-		if (res != FEATURE_RETURN_KEEPTRYING) {
+		if (res != AST_FEATURE_RETURN_KEEPTRYING) {
 			break;
 		}
-		res = FEATURE_RETURN_PASSDIGITS;
+		res = AST_FEATURE_RETURN_PASSDIGITS;
 	}
 	for (x = 0; x < result.num_dyn_features; ++x) {
 		feature = result.dynamic_features[x];
 		res = feature->operation(chan, peer, config, code, sense, feature);
-		if (res != FEATURE_RETURN_KEEPTRYING) {
+		if (res != AST_FEATURE_RETURN_KEEPTRYING) {
 			break;
 		}
-		res = FEATURE_RETURN_PASSDIGITS;
+		res = AST_FEATURE_RETURN_PASSDIGITS;
+	}
+	if (dynamic_features) {
+		free((char *)dynamic_features);
 	}
 	ast_features_unlock();
 	
@@ -2123,7 +2132,16 @@
 	ast_rwlock_unlock(&features_lock);
 	
 	if (chan && peer && !(ast_test_flag(config, AST_BRIDGE_DTMF_CHANNEL_0) && ast_test_flag(config, AST_BRIDGE_DTMF_CHANNEL_1))) {
-		const char *dynamic_features = pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES");
+		const char *dynamic_features, *x;
+
+		ast_channel_lock(chan);
+		x = pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES");
+		if (x) {
+			dynamic_features = strdup(x);
+		} else {
+			dynamic_features = NULL;
+		}
+		ast_channel_unlock(chan);
 
 		if (dynamic_features) {
 			char *tmp = ast_strdupa(dynamic_features);
@@ -2141,6 +2159,8 @@
 				}
 				AST_RWLIST_UNLOCK(&feature_list);
 			}
+			free((char*)dynamic_features);
+			dynamic_features = NULL;
 		}
 	}
 }




More information about the svn-commits mailing list