1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-11-03 04:17:17 -05:00

make config lock a rwlock

svn path=/icecast/branches/kh/icecast/; revision=7522
This commit is contained in:
Karl Heyes 2004-08-11 02:56:08 +00:00
parent 3a51eb4e38
commit 640a7094b2
4 changed files with 14 additions and 7 deletions

View File

@ -569,7 +569,7 @@ static int admin_function (const char *function, char *buf, unsigned int len)
{
if (strcmp (function, "reopenlog") == 0)
{
ice_config_t *config = config_get_config();
ice_config_t *config = config_grab_config();
restart_logging (config);
config_release_config();

View File

@ -87,13 +87,13 @@ static void _add_server(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c);
static void create_locks() {
thread_mutex_create("relay lock", &_locks.relay_lock);
thread_mutex_create("mounts lock", &_locks.mounts_lock);
thread_mutex_create("config lock", &_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) {
@ -296,12 +296,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;
}

View File

@ -151,7 +151,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;
@ -170,6 +170,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 */

View File

@ -33,7 +33,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) {