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

karl at svn.xiph.org karl at svn.xiph.org
Mon Aug 8 11:39:38 PDT 2005


Author: karl
Date: 2005-08-08 11:39:34 -0700 (Mon, 08 Aug 2005)
New Revision: 9717

Modified:
   icecast/trunk/icecast/src/auth.c
   icecast/trunk/icecast/src/connection.c
   icecast/trunk/icecast/src/fserve.c
Log:
allow for webroot requests to be sent via an authenticator


Modified: icecast/trunk/icecast/src/auth.c
===================================================================
--- icecast/trunk/icecast/src/auth.c	2005-08-08 05:03:59 UTC (rev 9716)
+++ icecast/trunk/icecast/src/auth.c	2005-08-08 18:39:34 UTC (rev 9717)
@@ -31,6 +31,7 @@
 #include "cfgfile.h"
 #include "stats.h"
 #include "httpp/httpp.h"
+#include "fserve.h"
 
 #include "logging.h"
 #define CATMODULE "auth"
@@ -317,6 +318,11 @@
         if (ret == 0)
             DEBUG0 ("client authenticated, passed to source");
     }
+    else
+    {
+        avl_tree_unlock (global.source_tree);
+        fserve_client_create (client, mount);
+    }
     return ret;
 }
 

Modified: icecast/trunk/icecast/src/connection.c
===================================================================
--- icecast/trunk/icecast/src/connection.c	2005-08-08 05:03:59 UTC (rev 9716)
+++ icecast/trunk/icecast/src/connection.c	2005-08-08 18:39:34 UTC (rev 9717)
@@ -823,12 +823,6 @@
         return;
     }
 
-    if (fserve_client_create (client, uri))
-    {
-        if (uri != passed_uri) free (uri);
-        return;
-    }
-
     sock_set_blocking(client->con->sock, SOCK_NONBLOCK);
     sock_set_nodelay(client->con->sock);
 

Modified: icecast/trunk/icecast/src/fserve.c
===================================================================
--- icecast/trunk/icecast/src/fserve.c	2005-08-08 05:03:59 UTC (rev 9716)
+++ icecast/trunk/icecast/src/fserve.c	2005-08-08 18:39:34 UTC (rev 9717)
@@ -19,6 +19,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <errno.h>
 
 #ifdef HAVE_POLL
 #include <sys/poll.h>
@@ -65,7 +66,7 @@
 #endif
 
 static fserve_t *active_list = NULL;
-volatile static fserve_t *pending_list = NULL;
+static volatile fserve_t *pending_list = NULL;
 
 static mutex_t pending_lock;
 static avl_tree *mimetypes = NULL;
@@ -232,7 +233,7 @@
 static void *fserv_thread_function(void *arg)
 {
     fserve_t *fclient, **trail;
-    int sbytes, bytes;
+    int bytes;
 
     INFO0("file serving thread started");
     while (run_fserv) {
@@ -271,7 +272,7 @@
                 }
 
                 /* Now try and send current chunk. */
-                sbytes = format_generic_write_to_client (client);
+                format_generic_write_to_client (client);
 
                 if (client->con->error)
                 {
@@ -358,7 +359,10 @@
 }
 
 
-int fserve_client_create(client_t *httpclient, const char *path)
+/* client has requested a file, so check for it and send the file.  Do not
+ * refer to the client_t afterwards.  return 0 for success, -1 on error.
+ */
+int fserve_client_create (client_t *httpclient, const char *path)
 {
     int bytes;
     struct stat file_buf;
@@ -384,8 +388,10 @@
         /* the m3u can be generated, but send an m3u file if available */
         if (m3u_requested == 0)
         {
+            WARN2 ("req for file \"%s\" %s", fullpath, strerror (errno));
+            client_send_404 (httpclient, "The file you requested could not be found");
             free (fullpath);
-            return 0;
+            return -1;
         }
         m3u_file_available = 0;
     }
@@ -426,7 +432,7 @@
         fserve_add_client (httpclient, NULL);
         free (sourceuri);
         free (fullpath);
-        return 1;
+        return 0;
     }
 
     /* on demand file serving check */
@@ -437,7 +443,7 @@
         client_send_404 (httpclient, "The file you requested could not be found");
         config_release_config();
         free (fullpath);
-        return 0;
+        return -1;
     }
     config_release_config();
 
@@ -446,7 +452,7 @@
         client_send_404 (httpclient, "The file you requested could not be found");
         WARN1 ("found requested file but there is no handler for it: %s", fullpath);
         free (fullpath);
-        return 1;
+        return -1;
     }
 
     file = fopen (fullpath, "rb");
@@ -455,7 +461,7 @@
     {
         WARN1 ("Problem accessing file \"%s\"", fullpath);
         client_send_404 (httpclient, "File not readable");
-        return 1;
+        return -1;
     }
 
     content_length = (int64_t)file_buf.st_size;
@@ -515,7 +521,7 @@
                 sock_write (httpclient->con->sock,
                     "HTTP/1.0 416 Request Range Not Satisfiable\r\n\r\n");
                 client_destroy (httpclient);
-                return 1;
+                return -1;
             }
         }
         else {
@@ -525,7 +531,7 @@
             sock_write (httpclient->con->sock,
                 "HTTP/1.0 416 Request Range Not Satisfiable\r\n\r\n");
             client_destroy (httpclient);
-            return 1;
+            return -1;
         }
     }
     else {
@@ -544,7 +550,7 @@
     stats_event_inc (NULL, "file_connections");
     fserve_add_client (httpclient, file);
 
-    return 1;
+    return 0;
 }
 
 



More information about the commits mailing list