From 96a510e157e3f972a44fc5268321d9410cd141f7 Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Tue, 11 Dec 2012 02:13:37 +0000 Subject: [PATCH] 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 --- main/indications.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/main/indications.c b/main/indications.c index 8854ad9091..6ad30bfcf5 100644 --- a/main/indications.c +++ b/main/indications.c @@ -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; }