1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-09-29 04:25:55 -04:00

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

svn path=/icecast/trunk/icecast/; revision=9160
This commit is contained in:
Karl Heyes 2005-04-20 22:34:54 +00:00
parent 19cb11cc31
commit acd1b8ad96
3 changed files with 14 additions and 8 deletions

View File

@ -87,13 +87,13 @@ static void _add_server(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
static void create_locks() { static void create_locks() {
thread_mutex_create(&_locks.relay_lock); thread_mutex_create(&_locks.relay_lock);
thread_mutex_create(&_locks.mounts_lock); thread_mutex_create(&_locks.mounts_lock);
thread_mutex_create(&_locks.config_lock); thread_rwlock_create(&_locks.config_lock);
} }
static void release_locks() { static void release_locks() {
thread_mutex_destroy(&_locks.relay_lock); thread_mutex_destroy(&_locks.relay_lock);
thread_mutex_destroy(&_locks.mounts_lock); thread_mutex_destroy(&_locks.mounts_lock);
thread_mutex_destroy(&_locks.config_lock); thread_rwlock_destroy(&_locks.config_lock);
} }
void config_initialize(void) { void config_initialize(void) {
@ -226,7 +226,7 @@ void config_clear(ice_config_t *c)
} }
#ifdef USE_YP #ifdef USE_YP
i = 0; i = 0;
while (i < c->num_yp_directories) while (i < c->num_yp_directories)
{ {
xmlFree (c->yp_url[i]); xmlFree (c->yp_url[i]);
i++; i++;
@ -291,12 +291,18 @@ ice_config_locks *config_locks(void)
void config_release_config(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) 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; return &_current_configuration;
} }
@ -614,7 +620,6 @@ static void _parse_mount(xmlDocPtr doc, xmlNodePtr node,
mount->burst_size = atoi(tmp); mount->burst_size = atoi(tmp);
if (tmp) xmlFree(tmp); if (tmp) xmlFree(tmp);
} else if (strcmp(node->name, "cluster-password") == 0) { } else if (strcmp(node->name, "cluster-password") == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
mount->cluster_password = (char *)xmlNodeListGetString( mount->cluster_password = (char *)xmlNodeListGetString(
doc, node->xmlChildrenNode, 1); doc, node->xmlChildrenNode, 1);
} }

View File

@ -146,7 +146,7 @@ typedef struct ice_config_tag
} ice_config_t; } ice_config_t;
typedef struct { typedef struct {
mutex_t config_lock; rwlock_t config_lock;
mutex_t relay_lock; mutex_t relay_lock;
mutex_t mounts_lock; mutex_t mounts_lock;
} ice_config_locks; } ice_config_locks;
@ -165,6 +165,7 @@ int config_rehash(void);
ice_config_locks *config_locks(void); ice_config_locks *config_locks(void);
ice_config_t *config_get_config(void); ice_config_t *config_get_config(void);
ice_config_t *config_grab_config(void);
void config_release_config(void); void config_release_config(void);
/* To be used ONLY in one-time startup code */ /* To be used ONLY in one-time startup code */

View File

@ -32,7 +32,7 @@ void event_config_read(void *arg)
ice_config_t new_config; ice_config_t new_config;
/* reread config file */ /* 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 */ to find out the config filename */
ret = config_parse_file(config->config_filename, &new_config); ret = config_parse_file(config->config_filename, &new_config);
if(ret < 0) { if(ret < 0) {