[xiph-commits] r9160 - icecast/trunk/icecast/src

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Wed Apr 20 15:34:56 PDT 2005


Author: karl
Date: 2005-04-20 15:34:54 -0700 (Wed, 20 Apr 2005)
New Revision: 9160

Modified:
   icecast/trunk/icecast/src/cfgfile.c
   icecast/trunk/icecast/src/cfgfile.h
   icecast/trunk/icecast/src/event.c
Log:
merge from branch, make the config lock a rwlock instead of mutex


Modified: icecast/trunk/icecast/src/cfgfile.c
===================================================================
--- icecast/trunk/icecast/src/cfgfile.c	2005-04-20 20:18:51 UTC (rev 9159)
+++ icecast/trunk/icecast/src/cfgfile.c	2005-04-20 22:34:54 UTC (rev 9160)
@@ -87,13 +87,13 @@
 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) {
@@ -226,7 +226,7 @@
     }
 #ifdef USE_YP
     i = 0;
-    while (i < c->num_yp_directories) 
+    while (i < c->num_yp_directories)
     {
         xmlFree (c->yp_url[i]);
         i++;
@@ -291,15 +291,21 @@
 
 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;
+}
+
 /* MUST be called with the lock held! */
 void config_set_config(ice_config_t *config) {
     memcpy(&_current_configuration, config, sizeof(ice_config_t));
@@ -614,7 +620,6 @@
             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);
         }

Modified: icecast/trunk/icecast/src/cfgfile.h
===================================================================
--- icecast/trunk/icecast/src/cfgfile.h	2005-04-20 20:18:51 UTC (rev 9159)
+++ icecast/trunk/icecast/src/cfgfile.h	2005-04-20 22:34:54 UTC (rev 9160)
@@ -146,7 +146,7 @@
 } 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 @@
 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 */

Modified: icecast/trunk/icecast/src/event.c
===================================================================
--- icecast/trunk/icecast/src/event.c	2005-04-20 20:18:51 UTC (rev 9159)
+++ icecast/trunk/icecast/src/event.c	2005-04-20 22:34:54 UTC (rev 9160)
@@ -32,7 +32,7 @@
     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) {



More information about the commits mailing list