[asterisk-commits] junky: branch junky/cli-tls r203108 - in /team/junky/cli-tls: include/asteris...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jun 24 23:51:06 CDT 2009
Author: junky
Date: Wed Jun 24 23:51:01 2009
New Revision: 203108
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=203108
Log:
created handle_ts_show_channels(), which is a debug function to list all the function from the thread storage
Move the addition of a channel to tls to a new function: tls_add_channel()
start working in filter_channel_cleanup()
removed unused code, which I introduced since the beginning of gsoc.
Modified:
team/junky/cli-tls/include/asterisk/pbx.h
team/junky/cli-tls/main/frame.c
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=203108&r1=203107&r2=203108
==============================================================================
--- team/junky/cli-tls/include/asterisk/pbx.h (original)
+++ team/junky/cli-tls/include/asterisk/pbx.h Wed Jun 24 23:51:01 2009
@@ -1207,6 +1207,11 @@
*/
char *ast_complete_applications(const char *line, const char *word, int state);
+
+
+/* To add a channel to a TLS object */
+void tls_add_channel(struct ast_channel *chan);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
Modified: team/junky/cli-tls/main/frame.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/junky/cli-tls/main/frame.c?view=diff&rev=203108&r1=203107&r2=203108
==============================================================================
--- team/junky/cli-tls/main/frame.c (original)
+++ team/junky/cli-tls/main/frame.c Wed Jun 24 23:51:01 2009
@@ -327,8 +327,6 @@
ast_free(f);
ast_free(frames);
-
- ast_log(LOG_WARNING, "frame_cache_cleanup has been called.\n");
}
#endif
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=203108&r1=203107&r2=203108
==============================================================================
--- team/junky/cli-tls/main/logger.c (original)
+++ team/junky/cli-tls/main/logger.c Wed Jun 24 23:51:01 2009
@@ -1109,6 +1109,15 @@
/* Ignore anything that never gets logged anywhere */
if (!(global_logmask & (1 << level)))
return;
+
+ /* If filters are enabled
+ ignore if the string doesnt match these filters
+ if (AST_LIST_EMPTY(&ast_cli_filters)) {
+
+ }
+ */
+
+
/* Build string */
va_start(ap, fmt);
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=203108&r1=203107&r2=203108
==============================================================================
--- team/junky/cli-tls/main/pbx.c (original)
+++ team/junky/cli-tls/main/pbx.c Wed Jun 24 23:51:01 2009
@@ -781,29 +781,25 @@
AST_THREADSTORAGE(extensionstate_buf);
AST_THREADSTORAGE_CUSTOM(filter_channels, NULL, filter_channel_cleanup);
+
/* List of channels used for filtering */
-//AST_LIST_HEAD_NOLOCK(ast_channels, ast_channel);
-//AST_LIST_HEAD_NOLOCK_STATIC(ast_channels, ast_channel);
-
-AST_LIST_HEAD_NOLOCK(ast_channels, logger_filter_list_item);
+AST_LIST_HEAD_NOLOCK_STATIC(ast_channels, logger_filter_list_item);
struct logger_filter_list_item {
- struct ast_channel *channel;
+ struct ast_channel *chan;
AST_LIST_ENTRY(logger_filter_list_item) next;
};
/* Structure for the cli filter */
struct ast_cli_filter {
- char *name; /*!< Name of the filter */
- int type; /*!< Type of the filter currently, only 0 is used */
- AST_DECLARE_STRING_FIELDS(
- AST_STRING_FIELD(name2);
- );
- AST_LIST_ENTRY(ast_cli_filter) filter_list; /*!< pointer to the next element */
+ char *name; /*!< Name of the filter */
+ int type; /*!< Type of the filter currently, only 0 is used */
+ AST_LIST_ENTRY(ast_cli_filter) filter_list; /*!< pointer to the next element */
};
/* List used to store all cli filters entered by the user */
AST_LIST_HEAD_NOLOCK_STATIC(ast_cli_filters, ast_cli_filter);
+
/*!
@@ -3148,6 +3144,34 @@
.read = acf_exception_read,
};
+/* 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;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "ts show channels";
+ e->usage =
+ "Usage: ts show channels\n"
+ " List All TLS channels\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 3) {
+ return CLI_SHOWUSAGE;
+ }
+
+ AST_LIST_TRAVERSE(&ast_channels, filter, next) {
+ ast_cli(a->fd, "TLS channel name=%s\n", filter->chan->name);
+ }
+
+ return CLI_SUCCESS;
+}
+
+
static char *handle_show_filters(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
@@ -3208,7 +3232,6 @@
}
c->name = ast_strdup(a->argv[3]);
c->type = 1;
- //ast_copy_string((char *)c->name2, a->argv[3], sizeof(c->name2));
/* TODO search it that filter already exists */
AST_RWLIST_INSERT_HEAD(&ast_cli_filters, c, filter_list);
@@ -3249,7 +3272,8 @@
if (!strcmp(c->name, a->argv[3])) {
AST_LIST_REMOVE_CURRENT(filter_list);
ast_cli(a->fd, "%s has been sucessfully removed from CLI filter list.\n", a->argv[3]);
- /* TODO when you destroy c, you must ast_free(c->name), since I ast_strdup it */
+ ast_free(c->name); /* since I ast_strdup it */
+ ast_free(c);
break;
}
AST_LIST_TRAVERSE_SAFE_END;
@@ -5017,27 +5041,8 @@
PBX has finished running on the channel
*/
struct ast_channel *c = data;
- struct logger_filter_list_item *filter;
- /*
- if ( !ast_malloc(sizeof(*filter)) ) {
- ast_log(LOG_ERROR, "Not enough memory to create the filter");
- }
- */
- ast_log(LOG_WARNING, "New thread started. (channel name=%s)\n", c->name);
-
-
- filter = ast_malloc(sizeof(*filter));
-
- filter->channel = c;
- ast_log(LOG_WARNING, "filter channel name is:%s\n", filter->channel->name);
-
- if ((filter = ast_threadstorage_get(&filter_channels, sizeof(*c)))) {
- ast_log(LOG_WARNING, "Adding channel(%s) to channels_list\n", c->name);
- //AST_LIST_INSERT_HEAD(&channels->list, c, chan_list);
- //AST_RWLIST_INSERT_HEAD(&ast_channels, filter, next);
- } else {
- ast_log(LOG_WARNING, "obj already exists\n");
- }
+
+ tls_add_channel(c);
__ast_pbx_run(c, NULL);
decrease_call_count();
@@ -6793,6 +6798,7 @@
AST_CLI_DEFINE(handle_show_filters, "Show CLI filters"),
AST_CLI_DEFINE(handle_add_filter, "Add CLI filter"),
AST_CLI_DEFINE(handle_remove_filter, "Remove CLI filter"),
+ AST_CLI_DEFINE(handle_ts_show_channels, "List all TLS channels"),
};
static void unreference_cached_app(struct ast_app *app)
@@ -10055,7 +10061,28 @@
static void filter_channel_cleanup(void *data)
{
- ast_log(LOG_WARNING, "%s is called.\n", __PRETTY_FUNCTION__);
-}
-
-
+ 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, "filter has been removed.\n");
+ ast_free(filter);
+ }
+}
+
+
+void 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)))) {
+ ast_log(LOG_WARNING, "Adding channel(%s) to channels_list\n", chan->name);
+ filter->chan = chan;
+ ast_log(LOG_WARNING, "TLS channel name is:%s\n", filter->chan->name);
+ AST_RWLIST_INSERT_HEAD(&ast_channels, filter, next);
+ } else {
+ ast_log(LOG_WARNING, "obj already exists\n");
+ }
+
+}
More information about the asterisk-commits
mailing list