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

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Fri Apr 15 16:02:13 PDT 2005


Author: karl
Date: 2005-04-15 16:02:10 -0700 (Fri, 15 Apr 2005)
New Revision: 9144

Modified:
   icecast/branches/kh/icecast/src/client.c
   icecast/branches/kh/icecast/src/connection.c
   icecast/branches/kh/icecast/src/source.c
Log:
file fallback update


Modified: icecast/branches/kh/icecast/src/client.c
===================================================================
--- icecast/branches/kh/icecast/src/client.c	2005-04-15 21:22:21 UTC (rev 9143)
+++ icecast/branches/kh/icecast/src/client.c	2005-04-15 23:02:10 UTC (rev 9144)
@@ -83,7 +83,7 @@
     /* write log entry if ip is set (some things don't set it, like outgoing 
      * slave requests
      */
-    if(client->con->ip)
+    if (client->con && client->con->ip)
         logging_access(client);
 
 #ifdef HAVE_AIO
@@ -98,7 +98,8 @@
     if (client->is_slave)
         slave_host_remove (client);
 
-    connection_close(client->con);
+    if (client->con)
+        connection_close(client->con);
     httpp_destroy(client->parser);
 
     global_lock ();

Modified: icecast/branches/kh/icecast/src/connection.c
===================================================================
--- icecast/branches/kh/icecast/src/connection.c	2005-04-15 21:22:21 UTC (rev 9143)
+++ icecast/branches/kh/icecast/src/connection.c	2005-04-15 23:02:10 UTC (rev 9144)
@@ -489,12 +489,11 @@
          * because we can't use this client to return an error code/message,
          * so we only do this once we know we're going to accept the source.
          */
-        if (source->client == NULL && con)
+        if (source->client == NULL)
         {
             source->client = client_create (con, parser);
             if (source->client == NULL)
             {
-                global_unlock();
                 config_release_config();
                 return -1;
             }

Modified: icecast/branches/kh/icecast/src/source.c
===================================================================
--- icecast/branches/kh/icecast/src/source.c	2005-04-15 21:22:21 UTC (rev 9143)
+++ icecast/branches/kh/icecast/src/source.c	2005-04-15 23:02:10 UTC (rev 9144)
@@ -467,7 +467,8 @@
         {
             if (source->active_clients != source->first_normal_client)
             {
-                delay = 0;
+                if (source->client->con)
+                    delay = 0;
                 no_delay_count++;
             }
         }
@@ -1144,7 +1145,7 @@
         stats_event (source->mount, "bitrate", str);
     }
 
-    if (mountinfo && source->file_only == 0)
+    if (mountinfo)
         source_apply_mount (source, mountinfo);
 
     if (source->fallback_mount)
@@ -1224,31 +1225,27 @@
     const char ok_msg[] = "HTTP/1.0 200 OK\r\n\r\n";
     int bytes = sizeof (ok_msg)-1;
 
-    if (source->client)
+    if (source->client && source->client->con)
     {
         source->client->respcode = 200;
         bytes = sock_write_bytes (source->client->con->sock, ok_msg, sizeof (ok_msg)-1);
+        if (bytes < (int)(sizeof (ok_msg)-1))
+        {
+            global_lock();
+            global.sources--;
+            global_unlock();
+            WARN0 ("Error writing 200 OK message to source client");
+            source_free_source (source);
+            return NULL;
+        }
+        source->client->con->sent_bytes += bytes;
     }
-    if (bytes < (int)sizeof (ok_msg)-1)
-    {
-        global_lock();
-        global.sources--;
-        global_unlock();
-        WARN0 ("Error writing 200 OK message to source client");
-        source_free_source (source);
-    }
-    else
-    {
-        if (source->client)
-            source->client->con->sent_bytes += bytes;
+    stats_event_inc(NULL, "source_client_connections");
+    stats_event (source->mount, "listeners", "0");
+    source_main (source);
+    source_free_source (source);
 
-        stats_event_inc(NULL, "source_client_connections");
-        stats_event (source->mount, "listeners", "0");
-        source_main (source);
-        source_free_source (source);
-
-        slave_rebuild ();
-    }
+    slave_rebuild ();
     return NULL;
 }
 
@@ -1297,6 +1294,7 @@
     FILE *file = NULL;
     source_t *source = NULL;
     ice_config_t *config;
+    http_parser_t *parser;
 
     do
     {
@@ -1327,16 +1325,17 @@
             break;
         }
         type = fserve_content_type (mount);
-        source->client->parser = httpp_create_parser();
-        httpp_initialize (source->client->parser, NULL);
-        httpp_setvar (source->client->parser, "content-type", type);
+        parser = httpp_create_parser();
+        httpp_initialize (parser, NULL);
+        httpp_setvar (parser, "content-type", type);
+
         source->hidden = 1;
         source->file_only = 1;
         source->yp_prevent = 1;
         source->intro_file = file;
         file = NULL;
 
-        if (connection_complete_source (source, NULL, NULL) < 0)
+        if (connection_complete_source (source, NULL, parser) < 0)
             break;
         source_client_thread (source);
     } while (0);



More information about the commits mailing list