[xiph-cvs] cvs commit: icecast/src connection.c stats.c xslt.c

Michael Smith msmith at xiph.org
Fri Aug 9 07:15:08 PDT 2002



msmith      02/08/09 10:15:08

  Modified:    src      connection.c stats.c xslt.c
  Log:
  Various cleanups for accounting of sent bytes.
  Crash bug in stats fixed.

Revision  Changes    Path
1.16      +16 -6     icecast/src/connection.c

Index: connection.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/connection.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- connection.c	9 Aug 2002 08:06:00 -0000	1.15
+++ connection.c	9 Aug 2002 14:15:08 -0000	1.16
@@ -459,12 +459,14 @@
                                                 /* If the file exists, then transform it, otherwise, write a 404 error */
                                                 if (stat(fullPath, &statbuf) == 0) {
                             DEBUG0("Stats request, sending XSL transformed stats");
-							sock_write(client->con->sock, "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n");
+							bytes = sock_write(client->con->sock, "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n");
+                            if(bytes > 0) client->con->sent_bytes = bytes;
                             stats_transform_xslt(client, fullPath);
                                                 }
                                                 else {
-							sock_write(client->con->sock, "HTTP/1.0 404 File Not Found\r\nContent-Type: text/html\r\n\r\n"\
+							bytes = sock_write(client->con->sock, "HTTP/1.0 404 File Not Found\r\nContent-Type: text/html\r\n\r\n"\
                                                                    "<b>The file you requested could not be found.</b>\r\n");
+                            if(bytes > 0) client->con->sent_bytes = bytes;
                                                 }
                                                 client_destroy(client);
                                                 continue;
@@ -486,7 +488,12 @@
                                                         node = avl_get_first(global.source_tree);
                                                         while (node) {
                                                                 s = (source_t *)node->key;
-								sock_write(client->con->sock, "%s\r\n", s->mount);
+								bytes = sock_write(client->con->sock, "%s\r\n", s->mount);
+                                if(bytes > 0) 
+                                    client->con->sent_bytes += bytes;
+                                else 
+                                    break;
+
                                                                 node = avl_get_next(node);
                                                         }
                                                         avl_tree_unlock(global.source_tree);
@@ -531,20 +538,23 @@
                                                 
                                                 if (parser->req_type == httpp_req_get) {
                                                         client->respcode = 200;
-							sock_write(client->con->sock, "HTTP/1.0 200 OK\r\nContent-Type: %s\r\n", format_get_mimetype(source->format->type));
+							bytes = sock_write(client->con->sock, "HTTP/1.0 200 OK\r\nContent-Type: %s\r\n", format_get_mimetype(source->format->type));
+                            if(bytes > 0) client->con->sent_bytes += bytes;
                                                         /* iterate through source http headers and send to client */
                                                         avl_tree_rlock(source->parser->vars);
                                                         node = avl_get_first(source->parser->vars);
                                                         while (node) {
                                                                 var = (http_var_t *)node->key;
                                                                 if (strcasecmp(var->name, "ice-password") && !strncasecmp("ice-", var->name, 4)) {
-									sock_write(client->con->sock, "%s: %s\r\n", var->name, var->value);
+									bytes = sock_write(client->con->sock, "%s: %s\r\n", var->name, var->value);
+                                    if(bytes > 0) client->con->sent_bytes += bytes;
                                                                 }
                                                                 node = avl_get_next(node);
                                                         }
                                                         avl_tree_unlock(source->parser->vars);
                                                         
-							sock_write(client->con->sock, "\r\n");
+							bytes = sock_write(client->con->sock, "\r\n");
+                            if(bytes > 0) client->con->sent_bytes += bytes;
                                                         
                                                         sock_set_blocking(client->con->sock, SOCK_NONBLOCK);
                                                 }

<p><p>1.17      +0 -1      icecast/src/stats.c

Index: stats.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/stats.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- stats.c	9 Aug 2002 06:52:07 -0000	1.16
+++ stats.c	9 Aug 2002 14:15:08 -0000	1.17
@@ -823,7 +823,6 @@
                 src_nodes = snd;
         }
         if (buff) free(buff);
-	client_destroy(client);
 }
 
 static int _compare_stats(void *arg, void *a, void *b)

<p><p>1.2       +10 -4     icecast/src/xslt.c

Index: xslt.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/xslt.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- xslt.c	9 Aug 2002 08:16:51 -0000	1.1
+++ xslt.c	9 Aug 2002 14:15:08 -0000	1.2
@@ -32,7 +32,7 @@
         xmlDocPtr	res;
         xsltStylesheetPtr cur;
         const char *params[16 + 1];
-    size_t count,nBytes;
+    size_t count,bytes;
 
         params[0] = NULL;
 
@@ -41,7 +41,10 @@
 
         cur = xsltParseStylesheetFile(xslfilename);
         if (cur == NULL) {
-		sock_write_string(client->con->sock, (char *)"Could not parse XSLT file");
+		bytes = sock_write_string(client->con->sock, 
+                (char *)"Could not parse XSLT file");
+        if(bytes > 0) client->con->sent_bytes += bytes;
+        
         return;
         }
 
@@ -52,9 +55,12 @@
     count = xsltSaveResultTo(outputBuffer, res, cur);
 
     /*  Add null byte to end. */
-    nBytes = xmlOutputBufferWrite(outputBuffer, 1, "");
+    bytes = xmlOutputBufferWrite(outputBuffer, 1, "");
 
-	sock_write_string(client->con->sock, (char *)outputBuffer->buffer->content);
+	if(sock_write_string(client->con->sock, 
+                (char *)outputBuffer->buffer->content))
+        client->con->sent_bytes += bytes;
+    
 
     xmlFree(outputBuffer);
     xsltFreeStylesheet(cur);

<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