/*! \brief Enable enforcement of a single configuration object of this type */
unsigned int single_object:1;
+ /*! \brief Configuration is invalid in some way, force reload */
+ unsigned int configuration_invalid:1;
+
/*! \brief Filename of the configuration file */
char filename[];
};
static void sorcery_config_internal_load(void *data, const struct ast_sorcery *sorcery, const char *type, unsigned int reload)
{
struct sorcery_config *config = data;
- struct ast_flags flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
+ struct ast_flags flags = { reload && !config->configuration_invalid ? CONFIG_FLAG_FILEUNCHANGED : 0 };
struct ast_config *cfg = ast_config_load2(config->filename, config->uuid, flags);
struct ast_category *category = NULL;
RAII_VAR(struct ao2_container *, objects, NULL, ao2_cleanup);
return;
}
+ /* When parsing the configuration assume it is valid until proven otherwise */
+ config->configuration_invalid = 0;
+
if (!config->buckets) {
while ((category = ast_category_browse_filtered(cfg, NULL, category, NULL))) {
ast_log(LOG_ERROR, "Config file '%s' could not be loaded; configuration contains more than one object of type '%s'\n",
config->filename, type);
ast_config_destroy(cfg);
+ config->configuration_invalid = 1;
return;
}
ast_log(LOG_ERROR, "Could not create bucket for new objects from '%s', keeping existing objects\n",
config->filename);
ast_config_destroy(cfg);
+ config->configuration_invalid = 1; /* Not strictly invalid but we want to try next time */
return;
}
ast_log(LOG_ERROR, "Config file '%s' could not be loaded; configuration contains a duplicate object: '%s' of type '%s'\n",
config->filename, id, type);
ast_config_destroy(cfg);
+ config->configuration_invalid = 1;
return;
}
ast_log(LOG_ERROR, "Config file '%s' could not be loaded due to error with object '%s' of type '%s'\n",
config->filename, id, type);
ast_config_destroy(cfg);
+ config->configuration_invalid = 1;
return;
} else {
ast_log(LOG_ERROR, "Could not create an object of type '%s' with id '%s' from configuration file '%s'\n",
type, id, config->filename);
+ config->configuration_invalid = 1;
}
ao2_cleanup(obj);