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

karl at svn.xiph.org karl at svn.xiph.org
Wed Nov 16 16:54:32 PST 2005


Author: karl
Date: 2005-11-16 16:54:28 -0800 (Wed, 16 Nov 2005)
New Revision: 10393

Modified:
   icecast/trunk/icecast/src/auth.c
   icecast/trunk/icecast/src/client.c
   icecast/trunk/icecast/src/client.h
   icecast/trunk/icecast/src/connection.c
Log:
change status code for server/stream full cases (#738), also some others places
where connections are terminated.


Modified: icecast/trunk/icecast/src/auth.c
===================================================================
--- icecast/trunk/icecast/src/auth.c	2005-11-17 00:35:44 UTC (rev 10392)
+++ icecast/trunk/icecast/src/auth.c	2005-11-17 00:54:28 UTC (rev 10393)
@@ -389,7 +389,7 @@
     if (mountinfo && mountinfo->no_mount)
     {
         config_release_config ();
-        client_send_404 (client, "mountpoint unavailable");
+        client_send_403 (client, "mountpoint unavailable");
         return;
     }
     if (mountinfo && mountinfo->auth)
@@ -400,7 +400,7 @@
         {
             config_release_config ();
             WARN0 ("too many clients awaiting authentication");
-            client_send_404 (client, "busy, please try again later");
+            client_send_403 (client, "busy, please try again later");
             return;
         }
         auth_client_setup (mountinfo, client);
@@ -429,7 +429,7 @@
         int ret = add_authenticated_client (mount, mountinfo, client);
         config_release_config ();
         if (ret < 0)
-            client_send_404 (client, "stream full");
+            client_send_403 (client, "max listeners reached");
     }
 }
 

Modified: icecast/trunk/icecast/src/client.c
===================================================================
--- icecast/trunk/icecast/src/client.c	2005-11-17 00:35:44 UTC (rev 10392)
+++ icecast/trunk/icecast/src/client.c	2005-11-17 00:54:28 UTC (rev 10393)
@@ -190,14 +190,15 @@
     fserve_add_client (client, NULL);
 }
 
-void client_send_403(client_t *client) {
-    int bytes = sock_write(client->con->sock, 
-            "HTTP/1.0 403 Forbidden\r\n"
-            "\r\n"
-            "Access restricted.\r\n");
-    if(bytes > 0) client->con->sent_bytes = bytes;
+void client_send_403(client_t *client, const char *reason)
+{
+    if (reason == NULL)
+        reason = "Forbidden";
+    snprintf (client->refbuf->data, PER_CLIENT_REFBUF_SIZE,
+            "HTTP/1.0 403 %s\r\n\r\n", reason);
     client->respcode = 403;
-    client_destroy(client);
+    client->refbuf->len = strlen (client->refbuf->data);
+    fserve_add_client (client, NULL);
 }
 
 

Modified: icecast/trunk/icecast/src/client.h
===================================================================
--- icecast/trunk/icecast/src/client.h	2005-11-17 00:35:44 UTC (rev 10392)
+++ icecast/trunk/icecast/src/client.h	2005-11-17 00:54:28 UTC (rev 10393)
@@ -72,7 +72,7 @@
 void client_send_504(client_t *client, char *message);
 void client_send_404(client_t *client, char *message);
 void client_send_401(client_t *client);
-void client_send_403(client_t *client);
+void client_send_403(client_t *client, const char *reason);
 void client_send_400(client_t *client, char *message);
 int client_send_bytes (client_t *client, const void *buf, unsigned len);
 int client_read_bytes (client_t *client, void *buf, unsigned len);

Modified: icecast/trunk/icecast/src/connection.c
===================================================================
--- icecast/trunk/icecast/src/connection.c	2005-11-17 00:35:44 UTC (rev 10392)
+++ icecast/trunk/icecast/src/connection.c	2005-11-17 00:54:28 UTC (rev 10393)
@@ -438,7 +438,7 @@
             if (client_create (&client, con, NULL) < 0)
             {
                 global_unlock();
-                client_send_404 (client, "Icecast connection limit reached");
+                client_send_403 (client, "Icecast connection limit reached");
                 continue;
             }
             global_unlock();
@@ -515,7 +515,7 @@
                 config_release_config();
                 if (response)
                 {
-                    client_send_404 (source->client, "Content-type not supported");
+                    client_send_403 (source->client, "Content-type not supported");
                     source->client = NULL;
                 }
                 WARN1("Content-type \"%s\" not supported, dropping source", contenttype);
@@ -535,7 +535,7 @@
             config_release_config();
             if (response)
             {
-                client_send_404 (source->client, "internal format allocation problem");
+                client_send_403 (source->client, "internal format allocation problem");
                 source->client = NULL;
             }
             WARN1 ("plugin format failed for \"%s\"", source->mount);
@@ -566,7 +566,7 @@
 
     if (response)
     {
-        client_send_404 (source->client, "too many sources connected");
+        client_send_403 (source->client, "too many sources connected");
         source->client = NULL;
     }
 
@@ -776,7 +776,7 @@
     }
     else
     {
-        client_send_404 (client, "Mountpoint in use");
+        client_send_403 (client, "Mountpoint in use");
         WARN1 ("Mountpoint %s in use", uri);
     }
 }



More information about the commits mailing list