[xiph-commits] r7928 - icecast/branches/kh/icecast/src

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Thu Oct 7 12:18:07 PDT 2004


Author: karl
Date: 2004-10-07 12:18:07 -0700 (Thu, 07 Oct 2004)
New Revision: 7928

Modified:
   icecast/branches/kh/icecast/src/connection.c
   icecast/branches/kh/icecast/src/slave.c
   icecast/branches/kh/icecast/src/yp.c
Log:
avoid aliasing issues


Modified: icecast/branches/kh/icecast/src/connection.c
===================================================================
--- icecast/branches/kh/icecast/src/connection.c	2004-10-07 18:49:04 UTC (rev 7927)
+++ icecast/branches/kh/icecast/src/connection.c	2004-10-07 19:18:07 UTC (rev 7928)
@@ -75,10 +75,10 @@
 } thread_queue_t;
 
 static mutex_t _connection_mutex;
-static unsigned long _current_id = 0;
+static volatile unsigned long _current_id = 0;
 static int _initialized = 0;
 
-static con_queue_t *_queue = NULL, **_queue_tail = &_queue;
+static volatile con_queue_t *_queue = NULL, **_queue_tail = &_queue;
 static mutex_t _queue_mutex;
 
 static thread_queue_t *_conhands = NULL;
@@ -264,7 +264,7 @@
     node->next = NULL;
     thread_mutex_lock(&_queue_mutex);
     *_queue_tail = node;
-    _queue_tail = &node->next;
+    _queue_tail = (volatile con_queue_t **)&node->next;
     thread_mutex_unlock(&_queue_mutex);
 }
 
@@ -388,9 +388,9 @@
 
     thread_mutex_lock(&_queue_mutex);
     if (_queue) {
-        node = _queue;
+        node = (con_queue_t *)_queue;
         _queue = node->next;
-        if (_queue_tail == &node->next)
+        if ((con_queue_t**)_queue_tail == &node->next)
             _queue_tail = &_queue;
     }
     thread_mutex_unlock(&_queue_mutex);

Modified: icecast/branches/kh/icecast/src/slave.c
===================================================================
--- icecast/branches/kh/icecast/src/slave.c	2004-10-07 18:49:04 UTC (rev 7927)
+++ icecast/branches/kh/icecast/src/slave.c	2004-10-07 19:18:07 UTC (rev 7928)
@@ -64,8 +64,8 @@
 
 static thread_type *_slave_thread_id;
 static int slave_running = 0;
-static unsigned int max_interval = 0;
-static int rescan_relays = 0;
+static volatile unsigned int max_interval = 0;
+static volatile int rescan_relays = 0;
 static rwlock_t slaves_lock;
 
 relay_server *relay_free (relay_server *relay)

Modified: icecast/branches/kh/icecast/src/yp.c
===================================================================
--- icecast/branches/kh/icecast/src/yp.c	2004-10-07 18:49:04 UTC (rev 7927)
+++ icecast/branches/kh/icecast/src/yp.c	2004-10-07 19:18:07 UTC (rev 7928)
@@ -84,8 +84,8 @@
 static rwlock_t yp_lock;
 static mutex_t yp_pending_lock;
 
-static struct yp_server *active_yps = NULL, *pending_yps = NULL;
-static int yp_update = 0;
+static volatile struct yp_server *active_yps = NULL, *pending_yps = NULL;
+static volatile int yp_update = 0;
 static int yp_running;
 static time_t now;
 static thread_type *yp_thread;
@@ -153,14 +153,14 @@
 {
     struct yp_server *server;
 
-    server = active_yps;
+    server = (struct yp_server *)active_yps;
     while (server)
     {
         if (strcmp (server->url, url) == 0)
             return server;
         server = server->next;
     }
-    server = pending_yps;
+    server = (struct yp_server *)pending_yps;
     while (server)
     {
         if (strcmp (server->url, url) == 0)
@@ -208,7 +208,7 @@
     DEBUG0("Updating YP configuration");
     thread_rwlock_rlock (&yp_lock);
 
-    server = active_yps;
+    server = (struct yp_server *)active_yps;
     while (server)
     {
         server->remove = 1;
@@ -246,7 +246,7 @@
             curl_easy_setopt (server->curl, CURLOPT_TIMEOUT, server->url_timeout);
             curl_easy_setopt (server->curl, CURLOPT_NOSIGNAL, 1L);
             curl_easy_setopt (server->curl, CURLOPT_ERRORBUFFER, &(server->curl_error[0]));
-            server->next = pending_yps;
+            server->next = (struct yp_server *)pending_yps;
             pending_yps = server;
             INFO3 ("Adding new YP server \"%s\" (timeout %ds, default interval %ds)",
                     server->url, server->url_timeout, server->touch_interval);
@@ -538,7 +538,8 @@
 /* Check for changes in the YP servers configured */
 static void check_servers ()
 {
-    struct yp_server *server = active_yps, **server_p = &active_yps;
+    struct yp_server    *server = (struct yp_server *)active_yps,
+                        **server_p = (struct yp_server **)&active_yps;
 
     while (server)
     {
@@ -559,11 +560,11 @@
     {
         avl_node *node;
 
-        server = pending_yps;
+        server = (struct yp_server *)pending_yps;
         pending_yps = server->next;
 
         DEBUG1("Add pending yps %s", server->url);
-        server->next = active_yps;
+        server->next = (struct yp_server *)active_yps;
         active_yps = server;
 
         /* new YP server configured, need to populate with existing sources */
@@ -648,7 +649,7 @@
 
         /* do the YP communication */
         thread_rwlock_rlock (&yp_lock);
-        server = active_yps;
+        server = (struct yp_server *)active_yps;
         while (server)
         {
             /* DEBUG1 ("trying %s", server->url); */
@@ -662,7 +663,7 @@
         {
             thread_rwlock_wlock (&yp_lock);
             check_servers ();
-            server = active_yps;
+            server = (struct yp_server *)active_yps;
             while (server)
             {
                 /* DEBUG1 ("Checking yps %s", server->url); */
@@ -679,7 +680,7 @@
     /* free server and ypdata left */
     while (active_yps)
     {
-        struct yp_server *server = active_yps;
+        struct yp_server *server = (struct yp_server *)active_yps;
         active_yps = server->next;
         destroy_yp_server (server);
     }
@@ -831,7 +832,7 @@
 
     /* make sure we don't race against another yp_add */
     thread_mutex_lock (&yp_pending_lock);
-    server = active_yps;
+    server = (struct yp_server *)active_yps;
     while (server)
     {
         ypdata_t *yp;
@@ -857,7 +858,7 @@
 /* Mark an existing entry in the YP list as to be marked for deletion */
 void yp_remove (const char *mount)
 {
-    struct yp_server *server = active_yps;
+    struct yp_server *server = (struct yp_server *)active_yps;
 
     thread_rwlock_rlock (&yp_lock);
     while (server)
@@ -879,7 +880,7 @@
  * attempt */
 void yp_touch (const char *mount)
 {
-    struct yp_server *server = active_yps;
+    struct yp_server *server = (struct yp_server *)active_yps;
     time_t trigger;
     ypdata_t *search_list = NULL;
 



More information about the commits mailing list