Skip to content
Snippets Groups Projects
Commit fb21acf3 authored by Joshua Colp's avatar Joshua Colp
Browse files

Fix reloads of aliased CLI commands. Due to changes done to turn it into a...

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@162923 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 689465ba
No related branches found
No related tags found
No related merge requests found
...@@ -46,7 +46,6 @@ struct cli_alias { ...@@ -46,7 +46,6 @@ struct cli_alias {
struct ast_cli_entry cli_entry; /*!< Actual CLI structure used for this alias */ struct ast_cli_entry cli_entry; /*!< Actual CLI structure used for this alias */
char *alias; /*!< CLI Alias */ char *alias; /*!< CLI Alias */
char *real_cmd; /*!< Actual CLI command it is aliased to */ 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; static struct ao2_container *cli_aliases;
...@@ -167,19 +166,10 @@ static struct ast_cli_entry cli_alias[] = { ...@@ -167,19 +166,10 @@ static struct ast_cli_entry cli_alias[] = {
AST_CLI_DEFINE(alias_show, "Show CLI command aliases"), AST_CLI_DEFINE(alias_show, "Show CLI command aliases"),
}; };
/*! \brief Function called to mark an alias for destruction */ /*! \brief Function called to to see if an alias is marked for destruction, they always are! */
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 */
static int alias_marked(void *obj, void *arg, int flags) static int alias_marked(void *obj, void *arg, int flags)
{ {
struct cli_alias *alias = obj; return CMP_MATCH;
return alias->marked ? CMP_MATCH : 0;
} }
/*! \brief Function called to load or reload the configuration file */ /*! \brief Function called to load or reload the configuration file */
...@@ -197,9 +187,9 @@ static void load_config(int reload) ...@@ -197,9 +187,9 @@ static void load_config(int reload)
return; return;
} }
/* Mark CLI aliases for pruning */ /* Destroy any existing CLI aliases */
if (reload) { 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) { for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
...@@ -227,11 +217,6 @@ static void load_config(int reload) ...@@ -227,11 +217,6 @@ static void load_config(int reload)
} }
} }
/* 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); ast_config_destroy(cfg);
return; return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment