Skip to content
Snippets Groups Projects
Commit abd17dc8 authored by Joshua Colp's avatar Joshua Colp
Browse files

Fix a bug where a changed configuration file might not be available to all sorcery object types.

Since res_sorcery_config used a static name of "res_sorcery_config" to inform the configuration
file API that it asked for the configuration file it was possible during a reload for some sorcery
object types not to receive the new configuration file.

This change introduces a UUID on a per-sorcery config instance basis so that the unchanged state
is kept on an instance basis and not for the res_sorcery_config module as a whole.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381037 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 67102c3d
No related branches found
No related tags found
No related merge requests found
......@@ -36,12 +36,16 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/sorcery.h"
#include "asterisk/astobj2.h"
#include "asterisk/config.h"
#include "asterisk/uuid.h"
/*! \brief Default number of buckets for sorcery objects */
#define DEFAULT_OBJECT_BUCKETS 53
/*! \brief Structure for storing configuration file sourced objects */
struct sorcery_config {
/*! \brief UUID for identifying us when opening a configuration file */
char uuid[AST_UUID_STR_LEN];
/*! \brief Objects retrieved from the configuration file */
struct ao2_global_obj objects;
......@@ -198,7 +202,7 @@ static void sorcery_config_internal_load(void *data, const struct ast_sorcery *s
{
struct sorcery_config *config = data;
struct ast_flags flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
struct ast_config *cfg = ast_config_load2(config->filename, "res_sorcery_config", flags);
struct ast_config *cfg = ast_config_load2(config->filename, config->uuid, flags);
RAII_VAR(struct ao2_container *, objects, NULL, ao2_cleanup);
const char *id = NULL;
......@@ -269,11 +273,20 @@ static void *sorcery_config_open(const char *data)
{
char *tmp = ast_strdupa(data), *filename = strsep(&tmp, ","), *option;
struct sorcery_config *config;
struct ast_uuid *uuid;
if (ast_strlen_zero(filename) || !(config = ao2_alloc_options(sizeof(*config) + strlen(filename) + 1, sorcery_config_destructor, AO2_ALLOC_OPT_LOCK_NOLOCK))) {
return NULL;
}
if (!(uuid = ast_uuid_generate())) {
ao2_ref(config, -1);
return NULL;
}
ast_uuid_to_str(uuid, config->uuid, AST_UUID_STR_LEN);
ast_free(uuid);
ast_rwlock_init(&config->objects.lock);
config->buckets = DEFAULT_OBJECT_BUCKETS;
strcpy(config->filename, filename);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment