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

karl at svn.xiph.org karl at svn.xiph.org
Wed Aug 17 18:10:46 PDT 2005


Author: karl
Date: 2005-08-17 18:10:43 -0700 (Wed, 17 Aug 2005)
New Revision: 9769

Modified:
   icecast/branches/kh/icecast/src/client.c
   icecast/branches/kh/icecast/src/connection.c
   icecast/branches/kh/icecast/src/source.c
Log:
don't overwrite any surplus read in data, save it seperately for the
later processing


Modified: icecast/branches/kh/icecast/src/client.c
===================================================================
--- icecast/branches/kh/icecast/src/client.c	2005-08-17 16:38:46 UTC (rev 9768)
+++ icecast/branches/kh/icecast/src/client.c	2005-08-18 01:10:43 UTC (rev 9769)
@@ -140,7 +140,7 @@
         if (client->refbuf->len < len)
             len = client->refbuf->len;
         memcpy (buf, client->refbuf->data, len);
-        if (client->refbuf->len < len)
+        if (len < client->refbuf->len)
         {
             char *ptr = client->refbuf->data;
             memmove (ptr, ptr+len, client->refbuf->len - len);

Modified: icecast/branches/kh/icecast/src/connection.c
===================================================================
--- icecast/branches/kh/icecast/src/connection.c	2005-08-17 16:38:46 UTC (rev 9768)
+++ icecast/branches/kh/icecast/src/connection.c	2005-08-18 01:10:43 UTC (rev 9769)
@@ -892,10 +892,14 @@
         }
         else
         {
+            refbuf_t *ok = refbuf_new (PER_CLIENT_REFBUF_SIZE);
             client->respcode = 200;
-            snprintf (client->refbuf->data, PER_CLIENT_REFBUF_SIZE,
+            snprintf (ok->data, PER_CLIENT_REFBUF_SIZE,
                     "HTTP/1.0 200 OK\r\n\r\n");
-            client->refbuf->len = strlen (client->refbuf->data);
+            ok->len = strlen (ok->data);
+            /* we may have unprocessed data read in, so don't overwrite it */
+            ok->associated = client->refbuf;
+            client->refbuf = ok;
             fserve_add_client_callback (client, source_client_callback, source);
         }
     }

Modified: icecast/branches/kh/icecast/src/source.c
===================================================================
--- icecast/branches/kh/icecast/src/source.c	2005-08-17 16:38:46 UTC (rev 9768)
+++ icecast/branches/kh/icecast/src/source.c	2005-08-18 01:10:43 UTC (rev 9769)
@@ -1196,6 +1196,7 @@
 {
     const char *agent;
     source_t *source = arg;
+    refbuf_t *old_data = client->refbuf;
 
     if (client->con->error)
     {
@@ -1206,6 +1207,9 @@
         client_destroy (client);
         return;
     }
+    client->refbuf = old_data->associated;
+    old_data->associated = NULL;
+    refbuf_release (old_data);
     stats_event (source->mount, "source_ip", source->client->con->ip);
     agent = httpp_getvar (source->client->parser, "user-agent");
     if (agent)



More information about the commits mailing list