[asterisk-commits] junky: branch junky/cli-tls r204008 - in /team/junky/cli-tls: include/asteris...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Jun 28 01:38:26 CDT 2009
Author: junky
Date: Sun Jun 28 01:38:22 2009
New Revision: 204008
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=204008
Log:
change my list ast_channels to a non-static
change my tls_add_channels
to reflect phone conferences for the gsoc
Modified:
team/junky/cli-tls/include/asterisk/pbx.h
team/junky/cli-tls/main/logger.c
team/junky/cli-tls/main/pbx.c
Modified: team/junky/cli-tls/include/asterisk/pbx.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/junky/cli-tls/include/asterisk/pbx.h?view=diff&rev=204008&r1=204007&r2=204008
==============================================================================
--- team/junky/cli-tls/include/asterisk/pbx.h (original)
+++ team/junky/cli-tls/include/asterisk/pbx.h Sun Jun 28 01:38:22 2009
@@ -1210,7 +1210,8 @@
/* To add a channel to a TLS object */
-void tls_add_channel(struct ast_channel *chan);
+int tls_add_channel(struct ast_channel *chan);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
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=204008&r1=204007&r2=204008
==============================================================================
--- team/junky/cli-tls/main/logger.c (original)
+++ team/junky/cli-tls/main/logger.c Sun Jun 28 01:38:22 2009
@@ -1075,6 +1075,7 @@
int res = 0;
va_list ap;
char datestring[256];
+ //struct logger_filter_list_item *filter;
if (!(buf = ast_str_thread_get(&log_buf, LOG_BUF_INIT_SIZE)))
return;
@@ -1115,10 +1116,14 @@
if (AST_LIST_EMPTY(&ast_cli_filters)) {
}
+
+ if ((filter = ast_threadstorage_get(&filter_channels, sizeof(*filter)))) {
+ if (filter->chan) {
+ ast_log(LOG_WARNING, "chan is there!\n");
+ }
+ }
+
*/
-
-
-
/* Build string */
va_start(ap, fmt);
res = ast_str_set_va(&buf, BUFSIZ, fmt, ap);
Modified: team/junky/cli-tls/main/pbx.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/junky/cli-tls/main/pbx.c?view=diff&rev=204008&r1=204007&r2=204008
==============================================================================
--- team/junky/cli-tls/main/pbx.c (original)
+++ team/junky/cli-tls/main/pbx.c Sun Jun 28 01:38:22 2009
@@ -779,16 +779,20 @@
AST_THREADSTORAGE(switch_data);
AST_THREADSTORAGE(extensionstate_buf);
+
AST_THREADSTORAGE_CUSTOM(filter_channels, NULL, filter_channel_cleanup);
/* List of channels used for filtering */
-AST_LIST_HEAD_NOLOCK_STATIC(ast_channels, logger_filter_list_item);
+AST_LIST_HEAD_NOLOCK(ast_channels, logger_filter_list_item);
struct logger_filter_list_item {
- struct ast_channel *chan;
- AST_LIST_ENTRY(logger_filter_list_item) next;
+ struct ast_channels list;
+ struct ast_channel *chan;
+ AST_LIST_ENTRY(logger_filter_list_item) next;
};
+
+static void filter_channel_cleanup(void *data);
/* Structure for the cli filter */
@@ -3147,7 +3151,7 @@
/* Temporary debug function */
static char *handle_ts_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- struct logger_filter_list_item *filter;
+ struct logger_filter_list_item *filter;
switch (cmd) {
case CLI_INIT:
@@ -3164,9 +3168,23 @@
return CLI_SHOWUSAGE;
}
+
+ if ((filter = ast_threadstorage_get(&filter_channels, sizeof(*filter)))) {
+ ast_log(LOG_WARNING, "filter is there");
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&filter->list, filter, next) {
+ ast_log(LOG_WARNING, "filter!!!\n");
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+
+ if ( filter->chan) {
+ ast_log(LOG_WARNING, "channel is there\n");
+ }
+ }
+ /*
AST_LIST_TRAVERSE(&ast_channels, filter, next) {
ast_cli(a->fd, "TLS channel name=%s\n", filter->chan->name);
}
+ */
return CLI_SUCCESS;
}
@@ -10062,27 +10080,45 @@
static void filter_channel_cleanup(void *data)
{
struct logger_filter_list_item *filter = data;
- ast_log(LOG_WARNING, "%s is called.\n", __PRETTY_FUNCTION__ );
-
- while ((filter = AST_LIST_REMOVE_HEAD(&ast_channels, next))) {
+
+ ast_log(LOG_WARNING, "%s is called. data=%p\n", __PRETTY_FUNCTION__, data );
+ if (filter ) {
+ ast_log(LOG_WARNING, "filter is there\n");
+ if ( filter->chan) {
+ ast_log(LOG_WARNING, "chan is there\n");
+ }
+ }
+ //filter = ast_malloc(sizeof(*filter));
+
+ /*
+ if ((filter = ast_threadstorage_get(&filter_channels, sizeof(*filter)))) {
+ ast_log(LOG_WARNING, "ive to remove \n");
+ }
+ */
+
+ while ((filter = AST_LIST_REMOVE_HEAD(&filter->list, next))) {
ast_log(LOG_WARNING, "filter has been removed.\n");
ast_free(filter);
}
}
-void tls_add_channel(struct ast_channel *chan){
+//http://pastebin.ca/1474652
+int tls_add_channel(struct ast_channel *chan){
struct logger_filter_list_item *filter;
-
- filter = ast_malloc(sizeof(*filter));
-
- if ((filter = ast_threadstorage_get(&filter_channels, sizeof(*chan)))) {
+ int res = 0;
+
+ if ((filter = ast_threadstorage_get(&filter_channels, sizeof(*filter)))) {
ast_log(LOG_WARNING, "Adding channel(%s) to channels_list\n", chan->name);
+ filter = ast_calloc(1, sizeof(*filter));
filter->chan = chan;
ast_log(LOG_WARNING, "TLS channel name is:%s\n", filter->chan->name);
- AST_RWLIST_INSERT_HEAD(&ast_channels, filter, next);
+ AST_LIST_INSERT_HEAD(&filter->list, filter, next);
+ //AST_RWLIST_INSERT_HEAD(&ast_channels, filter, next);
} else {
- ast_log(LOG_WARNING, "obj already exists\n");
+ ast_log(LOG_WARNING, "Out of memory\n");
+ res = -1;
}
-
-}
+ return res;
+}
+
More information about the asterisk-commits
mailing list