[svn-commits] file: trunk r381037 - /trunk/res/res_sorcery_config.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Feb 7 11:57:14 CST 2013
Author: file
Date: Thu Feb 7 11:57:10 2013
New Revision: 381037
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=381037
Log:
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.
Modified:
trunk/res/res_sorcery_config.c
Modified: trunk/res/res_sorcery_config.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_sorcery_config.c?view=diff&rev=381037&r1=381036&r2=381037
==============================================================================
--- trunk/res/res_sorcery_config.c (original)
+++ trunk/res/res_sorcery_config.c Thu Feb 7 11:57:10 2013
@@ -36,12 +36,16 @@
#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 @@
{
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,10 +273,19 @@
{
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;
More information about the svn-commits
mailing list