summaryrefslogtreecommitdiff
path: root/res/res_sorcery_config.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2013-02-07 17:57:10 +0000
committerJoshua Colp <jcolp@digium.com>2013-02-07 17:57:10 +0000
commitabd17dc8497da673ab39272ce857490c4db26078 (patch)
tree85c0909b5f56bbe3fde080cb934205eb7834c761 /res/res_sorcery_config.c
parent67102c3d3f624ed87e098c59fb86bfaf541e5957 (diff)
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
Diffstat (limited to 'res/res_sorcery_config.c')
-rw-r--r--res/res_sorcery_config.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/res/res_sorcery_config.c b/res/res_sorcery_config.c
index 4ab0d237e..1b43a187e 100644
--- a/res/res_sorcery_config.c
+++ b/res/res_sorcery_config.c
@@ -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);