[asterisk-commits] russell: branch russell/chan_refcount r105898 - in /team/russell/chan_refcoun...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Mar 4 18:43:37 CST 2008


Author: russell
Date: Tue Mar  4 18:43:37 2008
New Revision: 105898

URL: http://svn.digium.com/view/asterisk?view=rev&rev=105898
Log:
get the branch compiling again

Modified:
    team/russell/chan_refcount/apps/app_chanspy.c
    team/russell/chan_refcount/funcs/func_global.c

Modified: team/russell/chan_refcount/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_chanspy.c?view=diff&rev=105898&r1=105897&r2=105898
==============================================================================
--- team/russell/chan_refcount/apps/app_chanspy.c (original)
+++ team/russell/chan_refcount/apps/app_chanspy.c Tue Mar  4 18:43:37 2008
@@ -572,7 +572,6 @@
 			num_spyed_upon++;
 
 			if (res == -1) {
-				chanspy_ds_free(peer_chanspy_ds);
 				goto exit;
 			} else if (res == -2) {
 				res = 0;

Modified: team/russell/chan_refcount/funcs/func_global.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/funcs/func_global.c?view=diff&rev=105898&r1=105897&r2=105898
==============================================================================
--- team/russell/chan_refcount/funcs/func_global.c (original)
+++ team/russell/chan_refcount/funcs/func_global.c Tue Mar  4 18:43:37 2008
@@ -87,6 +87,7 @@
 	struct ast_datastore *varstore;
 	struct varshead *varshead;
 	struct ast_var_t *var;
+	struct ast_channel *chan2;
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(var);
 		AST_APP_ARG(chan);
@@ -102,15 +103,23 @@
 	if (!ast_strlen_zero(args.chan)) {
 		char *prefix = alloca(strlen(args.chan) + 2);
 		sprintf(prefix, "%s-", args.chan);
-		if (!(chan = ast_get_channel_by_name_locked(args.chan)) && !(chan = ast_get_channel_by_name_prefix_locked(prefix, strlen(prefix)))) {
+		if (!(chan2 = ast_channel_get_by_name(args.chan)) && !(chan2 = ast_channel_get_by_name_prefix(prefix, strlen(prefix)))) {
 			ast_log(LOG_ERROR, "Channel '%s' not found!  Variable '%s' will be blank.\n", args.chan, args.var);
 			return -1;
 		}
-	} else
-		ast_channel_lock(chan);
-
-	if (!(varstore = ast_channel_datastore_find(chan, &shared_variable_info, NULL)))
+	} else {
+		chan2 = chan;
+	}
+
+	ast_channel_lock(chan2);
+
+	if (!(varstore = ast_channel_datastore_find(chan2, &shared_variable_info, NULL))) {
+		ast_channel_unlock(chan2);
+		if (chan != chan2)
+			ast_channel_unref(chan2);
 		return -1;
+	}
+
 	varshead = varstore->data;
 	*buf = '\0';
 
@@ -122,6 +131,10 @@
 		}
 	}
 
+	ast_channel_unlock(chan2);
+	if (chan != chan2)
+		ast_channel_unref(chan2);
+
 	return 0;
 }
 
@@ -130,6 +143,7 @@
 	struct ast_datastore *varstore;
 	struct varshead *varshead;
 	struct ast_var_t *var;
+	struct ast_channel *chan2;
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(var);
 		AST_APP_ARG(chan);
@@ -145,29 +159,36 @@
 	if (!ast_strlen_zero(args.chan)) {
 		char *prefix = alloca(strlen(args.chan) + 2);
 		sprintf(prefix, "%s-", args.chan);
-		if (!(chan = ast_get_channel_by_name_locked(args.chan)) && !(chan = ast_get_channel_by_name_prefix_locked(prefix, strlen(prefix)))) {
+		if (!(chan2 = ast_channel_get_by_name(args.chan)) && !(chan2 = ast_channel_get_by_name_prefix(prefix, strlen(prefix)))) {
 			ast_log(LOG_ERROR, "Channel '%s' not found!  Variable '%s' not set to '%s'.\n", args.chan, args.var, value);
 			return -1;
 		}
-	} else
-		ast_channel_lock(chan);
-
-	if (!(varstore = ast_channel_datastore_find(chan, &shared_variable_info, NULL))) {
+	} else {
+		chan2 = chan;
+	}
+
+	ast_channel_lock(chan2);
+
+	if (!(varstore = ast_channel_datastore_find(chan2, &shared_variable_info, NULL))) {
 		if (!(varstore = ast_channel_datastore_alloc(&shared_variable_info, NULL))) {
 			ast_log(LOG_ERROR, "Unable to allocate new datastore.  Shared variable not set.\n");
-			ast_channel_unlock(chan);
+			ast_channel_unlock(chan2);
+			if (chan != chan2)
+				ast_channel_unref(chan2);
 			return -1;
 		}
 
 		if (!(varshead = ast_calloc(1, sizeof(*varshead)))) {
 			ast_log(LOG_ERROR, "Unable to allocate variable structure.  Shared variable not set.\n");
 			ast_channel_datastore_free(varstore);
-			ast_channel_unlock(chan);
+			ast_channel_unlock(chan2);
+			if (chan != chan2)
+				ast_channel_unref(chan2);
 			return -1;
 		}
 
 		varstore->data = varshead;
-		ast_channel_datastore_add(chan, varstore);
+		ast_channel_datastore_add(chan2, varstore);
 	}
 	varshead = varstore->data;
 
@@ -188,10 +209,13 @@
 		"Variable: SHARED(%s)\r\n"
 		"Value: %s\r\n"
 		"Uniqueid: %s\r\n", 
-		chan ? chan->name : "none", args.var, value, 
-		chan ? chan->uniqueid : "none");
-
-	ast_channel_unlock(chan);
+		chan2 ? chan2->name : "none", args.var, value, 
+		chan2 ? chan2->uniqueid : "none");
+
+	ast_channel_unlock(chan2);
+
+	if (chan != chan2)
+		ast_channel_unref(chan2);
 
 	return 0;
 }




More information about the asterisk-commits mailing list