Commit acd1b8ad authored by Karl Heyes's avatar Karl Heyes

merge from branch, make the config lock a rwlock instead of mutex

svn path=/icecast/trunk/icecast/; revision=9160
parent 19cb11cc
......@@ -87,13 +87,13 @@ static void _add_server(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
static void create_locks() {
thread_mutex_create(&_locks.relay_lock);
thread_mutex_create(&_locks.mounts_lock);
thread_mutex_create(&_locks.config_lock);
thread_rwlock_create(&_locks.config_lock);
}
static void release_locks() {
thread_mutex_destroy(&_locks.relay_lock);
thread_mutex_destroy(&_locks.mounts_lock);
thread_mutex_destroy(&_locks.config_lock);
thread_rwlock_destroy(&_locks.config_lock);
}
void config_initialize(void) {
......@@ -291,12 +291,18 @@ ice_config_locks *config_locks(void)
void config_release_config(void)
{
thread_mutex_unlock(&(_locks.config_lock));
thread_rwlock_unlock(&(_locks.config_lock));
}
ice_config_t *config_get_config(void)
{
thread_mutex_lock(&(_locks.config_lock));
thread_rwlock_rlock(&(_locks.config_lock));
return &_current_configuration;
}
ice_config_t *config_grab_config(void)
{
thread_rwlock_wlock(&(_locks.config_lock));
return &_current_configuration;
}
......@@ -614,7 +620,6 @@ static void _parse_mount(xmlDocPtr doc, xmlNodePtr node,
mount->burst_size = atoi(tmp);
if (tmp) xmlFree(tmp);
} else if (strcmp(node->name, "cluster-password") == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
mount->cluster_password = (char *)xmlNodeListGetString(
doc, node->xmlChildrenNode, 1);
}
......
......@@ -146,7 +146,7 @@ typedef struct ice_config_tag
} ice_config_t;
typedef struct {
mutex_t config_lock;
rwlock_t config_lock;
mutex_t relay_lock;
mutex_t mounts_lock;
} ice_config_locks;
......@@ -165,6 +165,7 @@ int config_rehash(void);
ice_config_locks *config_locks(void);
ice_config_t *config_get_config(void);
ice_config_t *config_grab_config(void);
void config_release_config(void);
/* To be used ONLY in one-time startup code */
......
......@@ -32,7 +32,7 @@ void event_config_read(void *arg)
ice_config_t new_config;
/* reread config file */
config = config_get_config(); /* Both to get the lock, and to be able
config = config_grab_config(); /* Both to get the lock, and to be able
to find out the config filename */
ret = config_parse_file(config->config_filename, &new_config);
if(ret < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment