[asterisk-commits] file: trunk r162923 - /trunk/res/res_clialiases.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 10 16:48:59 CST 2008


Author: file
Date: Wed Dec 10 16:48:58 2008
New Revision: 162923

URL: http://svn.digium.com/view/asterisk?view=rev&rev=162923
Log:
Fix reloads of aliased CLI commands. Due to changes done to turn it into a single memory allocation we can't just use the existing CLI alias structure. We have to destroy all existing ones and then create new ones.
(closes issue #14054)
Reported by: pj

Modified:
    trunk/res/res_clialiases.c

Modified: trunk/res/res_clialiases.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_clialiases.c?view=diff&rev=162923&r1=162922&r2=162923
==============================================================================
--- trunk/res/res_clialiases.c (original)
+++ trunk/res/res_clialiases.c Wed Dec 10 16:48:58 2008
@@ -46,7 +46,6 @@
 	struct ast_cli_entry cli_entry; /*!< Actual CLI structure used for this alias */
 	char *alias;                    /*!< CLI Alias */
 	char *real_cmd;                 /*!< Actual CLI command it is aliased to */
-	unsigned int marked:1;          /*!< Bit to indicate whether this CLI alias is marked for destruction or not */
 };
 
 static struct ao2_container *cli_aliases;
@@ -167,19 +166,10 @@
 	AST_CLI_DEFINE(alias_show, "Show CLI command aliases"),
 };
 
-/*! \brief Function called to mark an alias for destruction */
-static int alias_mark(void *obj, void *arg, int flags)
-{
-	struct cli_alias *alias = obj;
-	alias->marked = 1;
-	return 0;
-}
-
-/*! \brief Function called to see if an alias is marked for destruction */
+/*! \brief Function called to to see if an alias is marked for destruction, they always are! */
 static int alias_marked(void *obj, void *arg, int flags)
 {
-	struct cli_alias *alias = obj;
-	return alias->marked ? CMP_MATCH : 0;
+	return CMP_MATCH;
 }
 
 /*! \brief Function called to load or reload the configuration file */
@@ -197,9 +187,9 @@
 		return;
 	}
 
-	/* Mark CLI aliases for pruning */
+	/* Destroy any existing CLI aliases */
 	if (reload) {
-		ao2_callback(cli_aliases, OBJ_NODATA, alias_mark, NULL);
+		ao2_callback(cli_aliases, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE , alias_marked, NULL);
 	}
 
 	for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
@@ -227,11 +217,6 @@
 		}
 	}
 
-	/* Drop any CLI aliases that should no longer exist */
-	if (reload) {
-		ao2_callback(cli_aliases, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE , alias_marked, NULL);
-	}
-
 	ast_config_destroy(cfg);
 
 	return;




More information about the asterisk-commits mailing list