Cleanup indications on exit.

* Made ast_unregister_indication_country() unlink the found tone zone
before selecting a new default_tone_zone to make it impossible to select
the tone zone being unregistered again.

* Ringcadence is no longer parsed twice in store_config_tone_zone().

* Cleanup CLI commands and destroy default_tone_zone on exit.

(issue ASTERISK-20649)
Reported by: Corey Farrell
Patches:
      indications-cleanup-all.patch (license #5909) patch uploaded by Corey Farrell
      Modified
........

Merged revisions 377740 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 377741 from http://svn.asterisk.org/svn/asterisk/branches/10
........

Merged revisions 377742 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@377743 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Richard Mudgett 2012-12-11 02:13:37 +00:00
parent 7990b03e4e
commit 96a510e157
1 changed files with 10 additions and 5 deletions

View File

@ -560,11 +560,13 @@ static int ast_unregister_indication_country(const char *country)
ast_copy_string(zone_arg.country, country, sizeof(zone_arg.country));
if (!(tz = ao2_find(ast_tone_zones, &zone_arg, OBJ_POINTER))) {
ao2_lock(ast_tone_zones);
tz = ao2_find(ast_tone_zones, &zone_arg, OBJ_POINTER | OBJ_UNLINK);
if (!tz) {
ao2_unlock(ast_tone_zones);
return -1;
}
ao2_lock(ast_tone_zones);
if (default_tone_zone == tz) {
ast_tone_zone_unref(default_tone_zone);
/* Get a new default, punt to the first one we find */
@ -572,8 +574,6 @@ static int ast_unregister_indication_country(const char *country)
}
ao2_unlock(ast_tone_zones);
ao2_unlink(ast_tone_zones, tz);
tz = ast_tone_zone_unref(tz);
return 0;
@ -939,7 +939,6 @@ static void store_config_tone_zone(struct ast_tone_zone *zone, const char *var,
CV_STR("description", zone->description);
CV_F("ringcadence", store_tone_zone_ring_cadence(zone, value));
CV_F("ringcadance", store_tone_zone_ring_cadence(zone, value));
ast_register_indication(zone, var, value);
@ -1153,6 +1152,11 @@ int ast_tone_zone_data_add_structure(struct ast_data *tree, struct ast_tone_zone
/*! \internal \brief Clean up resources on Asterisk shutdown */
static void indications_shutdown(void)
{
ast_cli_unregister_multiple(cli_indications, ARRAY_LEN(cli_indications));
if (default_tone_zone) {
ast_tone_zone_unref(default_tone_zone);
default_tone_zone = NULL;
}
if (ast_tone_zones) {
ao2_ref(ast_tone_zones, -1);
ast_tone_zones = NULL;
@ -1168,6 +1172,7 @@ int ast_indications_init(void)
}
if (load_indications(0)) {
indications_shutdown();
return -1;
}