[xiph-cvs] cvs commit: icecast/src cfgfile.c cfgfile.h connection.c source.c source.h

Karl Heyes karl at xiph.org
Thu Feb 26 03:56:49 PST 2004



karl        04/02/26 06:56:49

  Modified:    src      cfgfile.c cfgfile.h connection.c source.c source.h
  Log:
  Add per mount queue size and source timeout, which can override the
  general settings.

Revision  Changes    Path
1.11      +14 -1     icecast/src/cfgfile.c

Index: cfgfile.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/cfgfile.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- cfgfile.c	19 Feb 2004 14:48:31 -0000	1.10
+++ cfgfile.c	26 Feb 2004 11:56:48 -0000	1.11
@@ -556,6 +556,19 @@
                 option = option->next;
             }
         }
+        else if (strcmp(node->name, "queue-size") == 0) {
+            tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+            mount->queue_size_limit = atoi (tmp);
+            if(tmp) xmlFree(tmp);
+        }
+        else if (strcmp(node->name, "source-timeout") == 0) {
+            tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+            if (tmp)
+            {
+                mount->source_timeout = atoi (tmp);
+                xmlFree(tmp);
+            }
+        }
     } while ((node = node->next));
 }
 
@@ -566,7 +579,7 @@
     relay_server *relay = calloc(1, sizeof(relay_server));
     relay_server *current = configuration->relay;
     relay_server *last=NULL;
-    
+
     while(current) {
         last = current;
         current = current->next;

<p><p>1.8       +2 -0      icecast/src/cfgfile.h

Index: cfgfile.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/cfgfile.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- cfgfile.h	19 Feb 2004 20:28:20 -0000	1.7
+++ cfgfile.h	26 Feb 2004 11:56:48 -0000	1.8
@@ -54,6 +54,8 @@
                               clients from the fallback? */
     int no_mount; /* Do we permit direct requests of this mountpoint? (or only
                      indirect, through fallbacks) */
+    unsigned queue_size_limit;
+    unsigned source_timeout;  /* source timeout in seconds */
 
     char *auth_type; /* Authentication type */
     config_options_t *auth_options; /* Options for this type */

<p><p>1.91      +5 -1      icecast/src/connection.c

Index: connection.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/connection.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -r1.90 -r1.91
--- connection.c	25 Feb 2004 16:24:30 -0000	1.90
+++ connection.c	26 Feb 2004 11:56:48 -0000	1.91
@@ -461,7 +461,7 @@
         }
         else
         {
-            WARN0("No content-type header, falling back to backwards compatibility mode"
+            WARN0("No content-type header, falling back to backwards compatibility mode "
                     "for icecast 1.x relays. Assuming content is mp3.");
             format_type = FORMAT_TYPE_MP3;
         }
@@ -480,6 +480,10 @@
         global.sources++;
         global_unlock();
 
+        /* set global settings first */
+        source->queue_size_limit = config->queue_size_limit;
+        source->timeout = config->source_timeout;
+
         /* for relays, we don't yet have a client, however we do require one
          * to retrieve the stream from.  This is created here, quite late,
          * because we can't use this client to return an error code/message,

<p><p>1.77      +14 -7     icecast/src/source.c

Index: source.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/source.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- source.c	25 Feb 2004 16:24:30 -0000	1.76
+++ source.c	26 Feb 2004 11:56:48 -0000	1.77
@@ -351,7 +351,7 @@
     source_t *fallback_source;
     char buffer[4096];
     long bytes, sbytes;
-    int ret, timeout;
+    int ret;
     client_t *client;
     avl_node *client_node;
 
@@ -365,7 +365,6 @@
     char *ai;
 #endif
 
-    long queue_limit;
     ice_config_t *config;
     char *hostname;
     char *listenurl;
@@ -374,8 +373,6 @@
 
     config = config_get_config();
     
-    queue_limit = config->queue_size_limit;
-    timeout = config->source_timeout;
     hostname = strdup(config->hostname);
     port = config->port;
 
@@ -544,13 +541,13 @@
         while (refbuf == NULL) {
             bytes = 0;
             while (bytes <= 0) {
-                ret = util_timed_wait_for_fd(source->con->sock, timeout*1000);
+                ret = util_timed_wait_for_fd(source->con->sock, source->timeout*1000);
 
                 if (ret < 0 && sock_recoverable (sock_error()))
                    continue;
                 if (ret <= 0) { /* timeout expired */
                     WARN1("Disconnecting source: socket timeout (%d s) expired",
-                           timeout);
+                           source->timeout);
                     bytes = 0;
                     break;
                 }
@@ -678,7 +675,7 @@
             ** we need to make sure the client is keeping up with the
             ** data, so we'll kick any client who's queue gets to large.
             */
-            if (refbuf_queue_length(&client->queue) > queue_limit) {
+            if (refbuf_queue_length(&client->queue) > source->queue_size_limit) {
                 DEBUG0("Client has fallen too far behind, removing");
                 client->con->error = 1;
             }
@@ -900,6 +897,16 @@
         DEBUG1("Dumping stream to %s", mountinfo->dumpfile);
         source->dumpfilename = strdup (mountinfo->dumpfile);
     }
+    if (mountinfo->queue_size_limit)
+    {
+        source->queue_size_limit = mountinfo->queue_size_limit;
+        DEBUG1 ("queue size to %u", source->queue_size_limit);
+    }
+    if (mountinfo->source_timeout)
+    {
+        source->timeout = mountinfo->source_timeout;
+        DEBUG1 ("source timeout to %u", source->timeout);
+    }
 }
 
 

<p><p>1.22      +2 -0      icecast/src/source.h

Index: source.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/source.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- source.h	25 Feb 2004 16:24:30 -0000	1.21
+++ source.h	26 Feb 2004 11:56:48 -0000	1.22
@@ -56,6 +56,8 @@
     struct auth_tag *authenticator;
     int fallback_override;
     int no_mount;
+    unsigned queue_size_limit;
+    unsigned timeout;  /* source timeout in seconds */
 } source_t;
 
 source_t *source_reserve (const char *mount);

<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