[asterisk-commits] junky: branch junky/cli-tls r211036 - /team/junky/cli-tls/main/logger.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 7 11:39:06 CDT 2009


Author: junky
Date: Fri Aug  7 11:39:02 2009
New Revision: 211036

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=211036
Log:
to add comments for review 336:
ast_channel_ref and unref
return first to avoid indentation.



Modified:
    team/junky/cli-tls/main/logger.c

Modified: team/junky/cli-tls/main/logger.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/junky/cli-tls/main/logger.c?view=diff&rev=211036&r1=211035&r2=211036
==============================================================================
--- team/junky/cli-tls/main/logger.c (original)
+++ team/junky/cli-tls/main/logger.c Fri Aug  7 11:39:02 2009
@@ -1732,11 +1732,11 @@
         if ((channels = ast_threadstorage_get(&filter_channels, sizeof(*channels)))) {
                 my_printf("Adding channel(%s) to channels_list\n", chan->name);
                 filter = ast_calloc(1, sizeof(*filter));
-                if ( !filter ) {
+                if (!filter) {
                         ast_log(LOG_WARNING, "Out of memory\n");
                         return -1;
                 }
-                filter->chan = chan;
+                filter->chan = ast_channel_ref(chan);
 		my_printf("TLS channel name is:%s\n", filter->chan->name);
                 AST_RWLIST_INSERT_HEAD(channels, filter, next);
         } else {
@@ -1754,18 +1754,21 @@
 	int res = 0;
 
 	channels = ast_threadstorage_get(&filter_channels, sizeof(*channels));
-	if (channels) {
-		AST_LIST_TRAVERSE_SAFE_BEGIN(channels, filter, next) {
-			if (!strcmp(filter->chan->name, chan->name)) {
-				AST_LIST_REMOVE_CURRENT(next);
-				ast_log(LOG_WARNING, "%s has been sucessfully removed from CLI filter list.\n", chan->name);
-				ast_free(filter);
-				res=1;
-				break;
-			}
-			AST_LIST_TRAVERSE_SAFE_END;
-		}
-	}
+	if (!channels) {
+		return res;
+	}
+	AST_LIST_TRAVERSE_SAFE_BEGIN(channels, filter, next) {
+		if (!strcmp(filter->chan->name, chan->name)) {
+			AST_LIST_REMOVE_CURRENT(next);
+			ast_log(LOG_WARNING, "%s has been sucessfully removed from CLI filter list.\n", chan->name);
+			ast_channel_unref(chan);
+			ast_free(filter);
+			res=1;
+			break;
+		}
+	}
+	AST_LIST_TRAVERSE_SAFE_END;
+	
 	return res;
 }
 




More information about the asterisk-commits mailing list