diff options
author | zuul <zuul@gerrit.asterisk.org> | 2017-04-05 19:14:28 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-04-05 19:14:28 -0500 |
commit | d2e6eb2afe3f766915603fbc370aefc55cedd874 (patch) | |
tree | 1f4aedd0abc69d2126943e3e0c4ba06a5fd674d2 | |
parent | a385db5333b52dd74e237062d3e8edd03b1d2d88 (diff) | |
parent | 6c3ae397cbd8c5655e553e3ae7684bedbdfef178 (diff) |
Merge "Unused realtime MOH classes not purged on 'moh reload'"
-rw-r--r-- | res/res_musiconhold.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index 992737b15..71f4691af 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -155,6 +155,7 @@ struct moh_files_state { /* Custom astobj2 flag */ #define MOH_NOTDELETED (1 << 30) /*!< Find only records that aren't deleted? */ +#define MOH_REALTIME (1 << 31) /*!< Find only records that are realtime */ static struct ast_flags global_flags[1] = {{0}}; /*!< global MOH_ flags */ @@ -1676,7 +1677,9 @@ static int moh_class_mark(void *obj, void *arg, int flags) { struct mohclass *class = obj; - class->delete = 1; + if ( ((flags & MOH_REALTIME) && class->realtime) || !(flags & MOH_REALTIME) ) { + class->delete = 1; + } return 0; } @@ -1692,22 +1695,27 @@ static int load_moh_classes(int reload) { struct ast_config *cfg; struct ast_variable *var; - struct mohclass *class; + struct mohclass *class; char *cat; int numclasses = 0; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; cfg = ast_config_load("musiconhold.conf", config_flags); - if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) { + if (cfg == CONFIG_STATUS_FILEUNCHANGED) { if (ast_check_realtime("musiconhold") && reload) { - ao2_t_callback(mohclasses, OBJ_NODATA, moh_class_mark, NULL, "Mark deleted classes"); + ao2_t_callback(mohclasses, OBJ_NODATA | MOH_REALTIME, moh_class_mark, NULL, "Mark realtime classes for deletion"); ao2_t_callback(mohclasses, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, moh_classes_delete_marked, NULL, "Purge marked classes"); } + moh_rescan_files(); return 0; } - if (cfg == CONFIG_STATUS_FILEUNCHANGED) { - moh_rescan_files(); + + if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) { + if (ast_check_realtime("musiconhold") && reload) { + ao2_t_callback(mohclasses, OBJ_NODATA, moh_class_mark, NULL, "Mark deleted classes"); + ao2_t_callback(mohclasses, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, moh_classes_delete_marked, NULL, "Purge marked classes"); + } return 0; } |