Index: res/res_musiconhold.c =================================================================== --- res/res_musiconhold.c (revision 250701) +++ res/res_musiconhold.c (working copy) @@ -1579,20 +1579,24 @@ struct ast_config *cfg; struct ast_variable *var; 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_FILEUNCHANGED || 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; } if (reload) { ao2_t_callback(mohclasses, OBJ_NODATA, moh_class_mark, NULL, "Mark deleted classes"); } ast_clear_flag(global_flags, AST_FLAGS_ALL); cat = ast_category_browse(cfg, NULL); @@ -1801,21 +1805,21 @@ } static int load_module(void) { int res; if (!(mohclasses = ao2_t_container_alloc(53, moh_class_hash, moh_class_cmp, "Moh class container"))) { return AST_MODULE_LOAD_DECLINE; } - if (!load_moh_classes(0)) { /* No music classes configured, so skip it */ + if (!load_moh_classes(0) && ast_check_realtime("musiconhold") == 0) { /* No music classes configured, so skip it */ ast_log(LOG_WARNING, "No music on hold classes configured, " "disabling music on hold.\n"); } else { ast_install_music_functions(local_ast_moh_start, local_ast_moh_stop, local_ast_moh_cleanup); } res = ast_register_application_xml(play_moh, play_moh_exec); ast_register_atexit(ast_moh_destroy); ast_cli_register_multiple(cli_moh, ARRAY_LEN(cli_moh));