[xiph-cvs] cvs commit: icecast/src slave.c

Michael Smith msmith at xiph.org
Fri Feb 7 03:46:03 PST 2003



msmith      03/02/07 06:46:03

  Modified:    src      slave.c
  Log:
  Fix relaying. Oops.

Revision  Changes    Path
1.14      +42 -37    icecast/src/slave.c

Index: slave.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/slave.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- slave.c	7 Feb 2003 10:53:38 -0000	1.13
+++ slave.c	7 Feb 2003 11:46:03 -0000	1.14
@@ -51,7 +51,8 @@
 void slave_initialize(void) {
         if (_initialized) return;
     /* Don't create a slave thread if it isn't configured */
-    if (config_get_config()->master_server == NULL)
+    if (config_get_config()->master_server == NULL && 
+            config_get_config()->relay == NULL)
         return;
 
         _initialized = 1;
@@ -129,43 +130,46 @@
         else
             interval = 0;
 
-		mastersock = sock_connect_wto(config_get_config()->master_server, config_get_config()->master_server_port, 0);
-		if (mastersock == SOCK_ERROR) {
-            WARN0("Relay slave failed to contact master server to fetch stream list");
-			continue;
-		}
-
-        len = strlen(username) + strlen(password) + 1;
-        authheader = malloc(len+1);
-        strcpy(authheader, username);
-        strcat(authheader, ":");
-        strcat(authheader, password);
-        data = util_base64_encode(authheader);
-		sock_write(mastersock, 
-                "GET /admin/streamlist HTTP/1.0\r\n"
-                "Authorization: Basic %s\r\n"
-                "\r\n", data);
-        free(authheader);
-        free(data);
-		while (sock_read_line(mastersock, buf, sizeof(buf))) {
-            if(!strlen(buf))
-                break;
-        }
+        if(config_get_config()->master_server != NULL) {
+		    mastersock = sock_connect_wto(config_get_config()->master_server, 
+                    config_get_config()->master_server_port, 0);
+    		if (mastersock == SOCK_ERROR) {
+                WARN0("Relay slave failed to contact master server to fetch stream list");
+		    	continue;
+    		}
+
+            len = strlen(username) + strlen(password) + 1;
+            authheader = malloc(len+1);
+            strcpy(authheader, username);
+            strcat(authheader, ":");
+            strcat(authheader, password);
+            data = util_base64_encode(authheader);
+		    sock_write(mastersock, 
+                    "GET /admin/streamlist HTTP/1.0\r\n"
+                    "Authorization: Basic %s\r\n"
+                    "\r\n", data);
+            free(authheader);
+            free(data);
+    		while (sock_read_line(mastersock, buf, sizeof(buf))) {
+                if(!strlen(buf))
+                    break;
+            }
 
-		while (sock_read_line(mastersock, buf, sizeof(buf))) {
-			avl_tree_rlock(global.source_tree);
-			if (!source_find_mount(buf)) {
-				avl_tree_unlock(global.source_tree);
-
-                create_relay_stream(
-                        config_get_config()->master_server,
-                        config_get_config()->master_server_port,
-                        buf);
-			} 
-            else
-    			avl_tree_unlock(global.source_tree);
-		}
-		sock_close(mastersock);
+	    	while (sock_read_line(mastersock, buf, sizeof(buf))) {
+		    	avl_tree_rlock(global.source_tree);
+			    if (!source_find_mount(buf)) {
+				    avl_tree_unlock(global.source_tree);
+
+                    create_relay_stream(
+                            config_get_config()->master_server,
+                            config_get_config()->master_server_port,
+                            buf);
+    			} 
+                else
+    	    		avl_tree_unlock(global.source_tree);
+    		}
+	    	sock_close(mastersock);
+        }
 
         /* And now, we process the individual mounts... */
         relay_server *relay = config_get_config()->relay;
@@ -178,6 +182,7 @@
             }
             else
                 avl_tree_unlock(global.source_tree);
+            relay = relay->next;
         }
         }
         thread_exit(0);

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list