Index: channels/chan_dahdi.c =================================================================== --- channels/chan_dahdi.c (revision 331954) +++ channels/chan_dahdi.c (working copy) @@ -17837,23 +17837,56 @@ int trunkgroup; int dchannels[SIG_PRI_NUM_DCHANS]; #endif + int have_cfg_now; + static int had_cfg_before = 1;/* So initial load will complain if we don't have cfg. */ cfg = ast_config_load(config, config_flags); - - /* Error if we have no config file */ + have_cfg_now = !!cfg; if (!cfg) { - ast_log(LOG_ERROR, "Unable to load config %s\n", config); - return 0; + /* Error if we have no config file */ + if (had_cfg_before) { + ast_log(LOG_ERROR, "Unable to load config %s\n", config); + ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); + } + cfg = ast_config_new();/* Dummy config */ + if (!cfg) { + return 0; + } + ucfg = ast_config_load("users.conf", config_flags); + if (ucfg == CONFIG_STATUS_FILEUNCHANGED) { + ast_config_destroy(cfg); + return 0; + } + if (ucfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "File users.conf cannot be parsed. Aborting.\n"); + ast_config_destroy(cfg); + return 0; + } } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { ucfg = ast_config_load("users.conf", config_flags); if (ucfg == CONFIG_STATUS_FILEUNCHANGED) { return 0; - } else if (ucfg == CONFIG_STATUS_FILEINVALID) { + } + if (ucfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_ERROR, "File users.conf cannot be parsed. Aborting.\n"); return 0; } ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - if ((cfg = ast_config_load(config, config_flags)) == CONFIG_STATUS_FILEINVALID) { + cfg = ast_config_load(config, config_flags); + have_cfg_now = !!cfg; + if (!cfg) { + if (had_cfg_before) { + /* We should have been able to load the config. */ + ast_log(LOG_ERROR, "Bad. Unable to load config %s\n", config); + ast_config_destroy(ucfg); + return 0; + } + cfg = ast_config_new();/* Dummy config */ + if (!cfg) { + ast_config_destroy(ucfg); + return 0; + } + } else if (cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_ERROR, "File %s cannot be parsed. Aborting.\n", config); ast_config_destroy(ucfg); return 0; @@ -17863,12 +17896,14 @@ return 0; } else { ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) { + ucfg = ast_config_load("users.conf", config_flags); + if (ucfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_ERROR, "File users.conf cannot be parsed. Aborting.\n"); ast_config_destroy(cfg); return 0; } } + had_cfg_before = have_cfg_now; /* It's a little silly to lock it, but we might as well just to be sure */ ast_mutex_lock(&iflock);