diff options
author | Richard Mudgett <rmudgett@digium.com> | 2013-06-07 00:33:20 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2013-06-07 00:33:20 +0000 |
commit | b8b7e8ab45c9786788c3a7121edc2a1413815590 (patch) | |
tree | 95e427e51b57b3c48834222664f0fd8271a9b87a | |
parent | 738c44405bf3c803f1f1c23423cd25fab48687a5 (diff) |
Tweak applicationmap and featuregroup config containers.
* Change applicationmap and featuregroup to replace duplicate config items
rather than reject them.
* Remove some unneeded warning messages when getting the applicationmap
allows duplicates from DYNAMIC_FEATURES.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@390803 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | main/features_config.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/main/features_config.c b/main/features_config.c index ab4be937a..4e5a65ecd 100644 --- a/main/features_config.c +++ b/main/features_config.c @@ -281,7 +281,7 @@ static void *featuregroup_alloc(const char *cat) } group->items = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK, - AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT, group_item_sort, NULL); + AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, group_item_sort, NULL); if (!group->items) { ao2_cleanup(group); return NULL; @@ -418,11 +418,11 @@ static struct features_global_config *global_config_alloc(void) return cfg; } -static struct ao2_container *applicationmap_alloc(int reject_duplicates) +static struct ao2_container *applicationmap_alloc(int replace_duplicates) { return ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK, - reject_duplicates ? AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT : AO2_CONTAINER_ALLOC_OPT_DUPS_ALLOW, - applicationmap_sort, NULL); + replace_duplicates ? AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE : AO2_CONTAINER_ALLOC_OPT_DUPS_ALLOW, + applicationmap_sort, NULL); } /*! @@ -902,13 +902,13 @@ int ast_get_feature(struct ast_channel *chan, const char *feature, char *buf, si { RAII_VAR(struct ao2_container *, applicationmap, NULL, ao2_cleanup); RAII_VAR(struct ast_applicationmap_item *, item, NULL, ao2_cleanup); + if (!ast_get_builtin_feature(chan, feature, buf, len)) { return 0; } /* Dang, must be in the application map */ applicationmap = ast_get_chan_applicationmap(chan); - if (!applicationmap) { return -1; } @@ -969,10 +969,7 @@ static int add_item(void *obj, void *arg, int flags) return 0; } - if (!ao2_link(applicationmap, appmap_item)) { - ast_log(LOG_WARNING, "Unable to add applicationmap item %s. Possible duplicate\n", - fg_item->appmap_item_name); - } + ao2_link(applicationmap, appmap_item); return 0; } @@ -1007,10 +1004,15 @@ struct ao2_container *ast_get_chan_applicationmap(struct ast_channel *chan) while ((name = strsep(&group_names, "#"))) { RAII_VAR(struct featuregroup *, group, ao2_find(cfg->featuregroups, name, OBJ_KEY), ao2_cleanup); + if (!group) { RAII_VAR(struct ast_applicationmap_item *, item, ao2_find(cfg->applicationmap, name, OBJ_KEY), ao2_cleanup); - if (item && !ao2_link(applicationmap, item)) { - ast_log(LOG_WARNING, "Unable to add applicationmap item %s. Possible duplicate.\n", item->name); + + if (item) { + ao2_link(applicationmap, item); + } else { + ast_log(LOG_WARNING, "Unknown DYNAMIC_FEATURES item '%s' on channel %s.\n", + name, ast_channel_name(chan)); } } else { ao2_callback(group->items, 0, add_item, applicationmap); @@ -1110,7 +1112,7 @@ static int applicationmap_handler(const struct aco_option *opt, } if (!ao2_link(applicationmap, item)) { - ast_log(LOG_WARNING, "Unable to add applicationmap item %s. Possible duplicate\n", item->name); + return -1; } return 0; @@ -1131,7 +1133,7 @@ static int featuregroup_handler(const struct aco_option *opt, ast_string_field_set(item, dtmf_override, var->value); if (!ao2_link(group->items, item)) { - ast_log(LOG_WARNING, "Unable to add featuregroup item %s. Possible duplicate\n", item->appmap_item_name); + return -1; } /* We wait to look up the application map item in the preapply callback */ |