[xiph-commits] r11721 - in icecast/branches/kh/icecast: . src win32

karl at svn.xiph.org karl at svn.xiph.org
Sat Jul 29 18:12:16 PDT 2006


Author: karl
Date: 2006-07-29 18:12:07 -0700 (Sat, 29 Jul 2006)
New Revision: 11721

Modified:
   icecast/branches/kh/icecast/NEWS
   icecast/branches/kh/icecast/configure.in
   icecast/branches/kh/icecast/src/cfgfile.c
   icecast/branches/kh/icecast/src/cfgfile.h
   icecast/branches/kh/icecast/src/connection.c
   icecast/branches/kh/icecast/src/format_ogg.c
   icecast/branches/kh/icecast/src/format_ogg.h
   icecast/branches/kh/icecast/src/format_vorbis.c
   icecast/branches/kh/icecast/src/logging.c
   icecast/branches/kh/icecast/src/main.c
   icecast/branches/kh/icecast/src/slave.c
   icecast/branches/kh/icecast/src/source.c
   icecast/branches/kh/icecast/src/source.h
   icecast/branches/kh/icecast/src/stats.c
   icecast/branches/kh/icecast/src/xslt.c
   icecast/branches/kh/icecast/src/yp.c
   icecast/branches/kh/icecast/win32/Icecast2winDlg.cpp
Log:
bump version to kh7. mainly memory leak fixes and stats update. win32 build
needs more work really


Modified: icecast/branches/kh/icecast/NEWS
===================================================================
--- icecast/branches/kh/icecast/NEWS	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/NEWS	2006-07-30 01:12:07 UTC (rev 11721)
@@ -12,6 +12,18 @@
 . stream-auth option for url authenticator.
 
 
+2.3-kh7
+. fix slow memory leak on metadata updates if <charset> was defined
+. fix minor leak on xml settings.
+. fix segv on 0-value duration in source, minimum is 2 secs (default 60)
+. fix small memory leak on xsl page requests.
+. stats update. kbytes used, and frequency of read kbytes reduced.
+. upate debian directory
+. change vorbis stream rebuilding to flush at 1 sec at the most.
+. minor changes to win32, buffer size issues for stats and xml cleanup
+  causes a crash in libxml2
+. minor log updates
+
 2.3-kh6
 . implement <limit-rate> bps in <mount>, the bitrate which triggers a timer for
   possible source termination, also causes a slow down in reading. default no
@@ -22,6 +34,7 @@
   source client terminates.
 . some internal cleanups
 . stats value cleanups.
+. possible segv on override case if source is slow to start streaming.
 . hardcoded AAC content type missing
 . initial xml setting bug, caused crash with later glibc.
 . streamlist.txt should list inactive mounts if their hidden fallback is active.

Modified: icecast/branches/kh/icecast/configure.in
===================================================================
--- icecast/branches/kh/icecast/configure.in	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/configure.in	2006-07-30 01:12:07 UTC (rev 11721)
@@ -1,4 +1,4 @@
-AC_INIT([Icecast], [2.3-kh6], [karl at xiph.org])
+AC_INIT([Icecast], [2.3-kh7], [karl at xiph.org])
 
 AC_PREREQ(2.54)
 AC_CONFIG_SRCDIR(src/main.c)

Modified: icecast/branches/kh/icecast/src/cfgfile.c
===================================================================
--- icecast/branches/kh/icecast/src/cfgfile.c	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/src/cfgfile.c	2006-07-30 01:12:07 UTC (rev 11721)
@@ -128,6 +128,7 @@
     if (str == NULL)
         return -1;
     *(int*)x = strtol ((char*)str, NULL, 0);
+    xmlFree (str);
     return 0;
 }
 
@@ -206,6 +207,8 @@
     xmlFree (mount->stream_genre);
     xmlFree (mount->bitrate);
     xmlFree (mount->type);
+    xmlFree (mount->subtype);
+    xmlFree (mount->charset);
     xmlFree (mount->cluster_password);
 
     xmlFree (mount->auth_type);
@@ -267,10 +270,12 @@
         xmlFree(c->access_log);
     if (c->error_log && c->error_log != CONFIG_DEFAULT_ERROR_LOG) 
         xmlFree(c->error_log);
+    xmlFree (c->access_log_exclude_ext);
     if (c->shoutcast_mount && c->shoutcast_mount != CONFIG_DEFAULT_SHOUTCAST_MOUNT)
         xmlFree(c->shoutcast_mount);
     for(i=0; i < MAX_LISTEN_SOCKETS; i++) {
         if (c->listeners[i].bind_address) xmlFree(c->listeners[i].bind_address);
+        xmlFree (c->listeners[i].shoutcast_mount);
     }
     if (c->master_server) xmlFree(c->master_server);
     if (c->master_username) xmlFree(c->master_username);
@@ -335,7 +340,6 @@
 
     if (filename == NULL || strcmp(filename, "") == 0) return CONFIG_EINSANE;
     
-    xmlInitParser();
     doc = xmlParseFile(filename);
     if (doc == NULL) {
         return CONFIG_EPARSE;
@@ -637,6 +641,8 @@
         { "charset",        config_get_str,     &mount->charset },
         { "mp3-metadata-interval",
                             config_get_int,     &mount->mp3_meta_interval },
+        { "ogg-passthrough",
+                            config_get_bool,    &mount->ogg_passthrough },
         { "allow-url-ogg-metadata",
                             config_get_bool,    &mount->url_ogg_meta },
         { "no-mount",       config_get_bool,    &mount->no_mount },

Modified: icecast/branches/kh/icecast/src/cfgfile.h
===================================================================
--- icecast/branches/kh/icecast/src/cfgfile.h	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/src/cfgfile.h	2006-07-30 01:12:07 UTC (rev 11721)
@@ -70,6 +70,7 @@
     int mp3_meta_interval; /* outgoing per-stream metadata interval */
     int filter_theora; /* prevent theora pages getting queued */
     int url_ogg_meta; /* enable to allow updates via url requests for ogg */
+    int ogg_passthrough; /* enable to prevent the ogg stream being rebuilt */
 
     /* duration in seconds for sampling the bandwidth */
     int avg_bitrate_duration;

Modified: icecast/branches/kh/icecast/src/connection.c
===================================================================
--- icecast/branches/kh/icecast/src/connection.c	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/src/connection.c	2006-07-30 01:12:07 UTC (rev 11721)
@@ -1149,6 +1149,7 @@
         else
             INFO1 ("password does not match \"%s\"", client->refbuf->data);
         client_destroy (client);
+        free (source_password);
         free (node->shoutcast_mount);
         free (node);
         return;

Modified: icecast/branches/kh/icecast/src/format_ogg.c
===================================================================
--- icecast/branches/kh/icecast/src/format_ogg.c	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/src/format_ogg.c	2006-07-30 01:12:07 UTC (rev 11721)
@@ -223,6 +223,9 @@
 
     ogg_info->use_url_metadata = mount->url_ogg_meta;
     DEBUG1 ("metadata via url is %d", ogg_info->use_url_metadata);
+
+    ogg_info->passthrough = mount->ogg_passthrough;
+    DEBUG1 ("oggpassthrough is %d", ogg_info->passthrough);
 }
 
 

Modified: icecast/branches/kh/icecast/src/format_ogg.h
===================================================================
--- icecast/branches/kh/icecast/src/format_ogg.h	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/src/format_ogg.h	2006-07-30 01:12:07 UTC (rev 11721)
@@ -34,6 +34,7 @@
     char *title;
     int log_metadata;
     int use_url_metadata;
+    int passthrough;
     refbuf_t *file_headers;
     refbuf_t *header_pages;
     refbuf_t *header_pages_tail;

Modified: icecast/branches/kh/icecast/src/format_vorbis.c
===================================================================
--- icecast/branches/kh/icecast/src/format_vorbis.c	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/src/format_vorbis.c	2006-07-30 01:12:07 UTC (rev 11721)
@@ -557,10 +557,10 @@
     DEBUG0 ("we have the header packets now");
 
     /* if vorbis is the only codec then allow rebuilding of the streams */
-    if (ogg_info->codecs->next == NULL)
+    if (ogg_info->codecs->next == NULL && ogg_info->passthrough == 0)
     {
-        /* set queued vorbis pages to contain about 1/2 of a second worth of samples */
-        source_vorbis->page_samples_trigger = (ogg_int64_t)(source_vorbis->vi.rate / 2);
+        /* set queued vorbis pages to contain about 1 second worth of samples */
+        source_vorbis->page_samples_trigger = (ogg_int64_t)(source_vorbis->vi.rate);
         source_vorbis->process_packet = process_vorbis_headers;
         source_vorbis->initial_audio_page = 1;
     }

Modified: icecast/branches/kh/icecast/src/logging.c
===================================================================
--- icecast/branches/kh/icecast/src/logging.c	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/src/logging.c	2006-07-30 01:12:07 UTC (rev 11721)
@@ -159,7 +159,7 @@
 #ifdef HAVE_LOG_DIRECT_KEEP
     log_write_direct_keep (accesslog, keep,
 #else
-    log_write_direct_keep (accesslog,
+    log_write_direct (accesslog,
 #endif
             "%s - %s [%s] \"%s\" %d " FORMAT_UINT64 " \"%s\" \"%s\" %lu",
             ip, username,

Modified: icecast/branches/kh/icecast/src/main.c
===================================================================
--- icecast/branches/kh/icecast/src/main.c	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/src/main.c	2006-07-30 01:12:07 UTC (rev 11721)
@@ -21,6 +21,9 @@
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
+#ifdef HAVE_CURL
+#include <curl/curl.h>
+#endif
 
 #include "thread/thread.h"
 #include "avl/avl.h"
@@ -123,11 +126,19 @@
     sock_shutdown();
     thread_shutdown();
 
+    DEBUG0 ("library cleanups");
+#ifdef WIN32
+    thread_sleep (500000);
+#else
+    xmlCleanupParser();
+#endif
+#ifdef HAVE_CURL
+    curl_global_cleanup();
+#endif
+
     /* Now that these are done, we can stop the loggers. */
     _stop_logging();
     log_shutdown();
-
-    xmlCleanupParser();
 }
 
 static int _parse_config_opts(int argc, char **argv, char *filename, int size)

Modified: icecast/branches/kh/icecast/src/slave.c
===================================================================
--- icecast/branches/kh/icecast/src/slave.c	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/src/slave.c	2006-07-30 01:12:07 UTC (rev 11721)
@@ -970,7 +970,7 @@
 
     if (global.redirect_count >= allowed)
     {
-        INFO1 ("redirect to slave limit reached (%d)", global.redirect_count);
+        INFO2 ("redirect to slave limit reached (%d, %d)", global.redirect_count, allowed);
         return;
     }
     redirect = calloc (1, sizeof (redirect_host));

Modified: icecast/branches/kh/icecast/src/source.c
===================================================================
--- icecast/branches/kh/icecast/src/source.c	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/src/source.c	2006-07-30 01:12:07 UTC (rev 11721)
@@ -96,6 +96,7 @@
         /* make duplicates for strings or similar */
         src->mount = strdup (mount);
         src->max_listeners = -1;
+        src->avg_bitrate_duration = 60;
 
         thread_mutex_create (src->mount, &src->lock);
 
@@ -254,6 +255,9 @@
     free(source->dumpfilename);
     source->dumpfilename = NULL;
 
+    free (source->charset);
+    source->charset = NULL;
+
     if (source->intro_file)
     {
         fclose (source->intro_file);
@@ -403,8 +407,10 @@
 {
     int     incoming_rate = 8 * rate_avg (source->format->in_bitrate);
     int64_t kbytes_sent = source->bytes_sent_since_update/1024;
+    int64_t kbytes_read = source->bytes_read_since_update/1024;
     source->format->sent_bytes += kbytes_sent*1024;
     source->bytes_sent_since_update %= 1024;
+    source->bytes_read_since_update %= 1024;
 
     stats_event_args (source->mount, "outgoing_bitrate", "%ld", 
             (8 * rate_avg (source->format->out_bitrate))/1000);
@@ -417,6 +423,7 @@
         stats_event_args (source->mount, "connected", FORMAT_UINT64,
                 (uint64_t)(global.time - source->client->con->con_time));
     stats_event_add (NULL, "stream_kbytes_sent", kbytes_sent);
+    stats_event_add (NULL, "stream_kbytes_read", kbytes_read);
 
     if (source->running && source->limit_rate)
     {
@@ -451,7 +458,6 @@
             source->throttle_stream = 0;
             source->throttle_termination = 0;
         }
-        source->stats_interval = 2;
     }
 }
 
@@ -535,7 +541,8 @@
         refbuf = source->format->get_buffer (source);
         if (refbuf)
         {
-            stats_event_add (NULL, "stream_kbytes_read", refbuf->len);
+            source->bytes_read_since_update += refbuf->len;
+
             /* append buffer to the in-flight data queue,  */
             if (source->stream_data == NULL)
             {
@@ -1154,6 +1161,8 @@
 
     if (mountinfo)
         source->avg_bitrate_duration = mountinfo->avg_bitrate_duration;
+    else
+        source->avg_bitrate_duration = 60;
 
     /* needs a better mechanism, probably via a client_t handle */
     if (mountinfo && mountinfo->dumpfile)

Modified: icecast/branches/kh/icecast/src/source.h
===================================================================
--- icecast/branches/kh/icecast/src/source.h	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/src/source.h	2006-07-30 01:12:07 UTC (rev 11721)
@@ -79,6 +79,7 @@
     int on_demand_req;
     int hidden;
     uint64_t bytes_sent_since_update;
+    uint64_t bytes_read_since_update;
     int stats_interval;
 
     time_t last_read;

Modified: icecast/branches/kh/icecast/src/stats.c
===================================================================
--- icecast/branches/kh/icecast/src/stats.c	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/src/stats.c	2006-07-30 01:12:07 UTC (rev 11721)
@@ -71,6 +71,7 @@
     event_queue_t queue;
     mutex_t mutex;
     int master;
+    char *source;
 
     struct _event_listener_tag *next;
 } event_listener_t;
@@ -229,7 +230,8 @@
             xmlBufferAdd (raw, (const xmlChar *)value, strlen (value));
             if (xmlCharEncInFunc (handle, conv, raw) > 0)
                 metadata = (char *)xmlBufferContent (conv);
-            xmlFree (raw);
+            xmlBufferFree (raw);
+            xmlCharEncCloseFunc (handle);
         }
         else
             WARN1 ("No charset found for \"%s\"", charset);
@@ -247,7 +249,7 @@
         free (s);
         logging_playlist (mount, metadata, listeners);
     }
-    xmlFree (conv);
+    xmlBufferFree (conv);
 }
 
 /* make stat hidden (non-zero). name can be NULL if it applies to a whole
@@ -477,14 +479,16 @@
         }
         str = malloc (20);
         snprintf (str, 20, FORMAT_INT64, value);
-        if (event->value == NULL)
-            event->value = strdup (str);
+        free (event->value);
+        event->value = strdup (str);
     }
     else
         str = (char *)strdup (event->value);
     free (node->value);
     node->value = str;
-    DEBUG2 ("update node %s (%s)", node->name, node->value);
+    DEBUG3 ("update node on %s \"%s\" (%s)",
+            event->source ? event->source : "global",
+            node->name, node->value);
 }
 
 
@@ -652,13 +656,11 @@
             while (listener)
             {
                 int send_it = 1;
-                if (listener->master && event->name)
-                {
-                    if (strcmp (event->name, "total_listeners") != 0 &&
-                            strcmp (event->name, "total_max_listeners") != 0)
-                        send_it = 0;
 
-                }
+                if (event->source && listener->source &&
+                        strcmp (event->source, listener->source) != 0)
+                    send_it = 0;
+
                 if (send_it)
                 {
                     stats_event_t *copy = _copy_event(event);
@@ -677,7 +679,7 @@
             continue;
         }
 
-        thread_sleep(300000);
+        thread_sleep(400000);
     }
 
     return NULL;
@@ -842,6 +844,15 @@
     thread_mutex_unlock(&_stats_mutex);
 }
 
+
+static void check_uri (event_listener_t *listener, client_t *client)
+{
+    char *mount = httpp_getvar (client->parser, HTTPP_VAR_URI);
+    if (strcmp (mount, "/") != 0)
+        listener->source = mount;
+}
+
+
 void *stats_connection(void *arg)
 {
     client_t *client = (client_t *)arg;
@@ -850,7 +861,10 @@
 
     INFO0 ("stats client starting");
 
+    memset (&listener, 0, sizeof (listener));
     event_queue_init (&listener.queue);
+    check_uri (&listener, client);
+
     /* increment the thread count */
     thread_mutex_lock(&_stats_mutex);
     _stats_threads++;
@@ -859,9 +873,6 @@
 
     thread_mutex_create("stats local event", &listener.mutex);
 
-    if (strcmp (httpp_getvar (client->parser, HTTPP_VAR_URI), "/admin/slave") == 0)
-        listener.master = 1;
-
     _register_listener (&listener);
 
     while (_stats_running) {

Modified: icecast/branches/kh/icecast/src/xslt.c
===================================================================
--- icecast/branches/kh/icecast/src/xslt.c	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/src/xslt.c	2006-07-30 01:12:07 UTC (rev 11721)
@@ -96,11 +96,10 @@
 
 void xslt_initialize(void)
 {
-    xmlSubstituteEntitiesDefault(1);
-    xmlLoadExtDtdDefaultValue = 1;
-
     memset(cache, 0, sizeof(stylesheet_cache_t)*CACHESIZE);
     thread_mutex_create("xslt", &xsltlock);
+    xmlInitParser();
+    LIBXML_TEST_VERSION
     xmlSubstituteEntitiesDefault(1);
     xmlLoadExtDtdDefaultValue = 1;
 }
@@ -236,8 +235,9 @@
                 "HTTP/1.0 200 OK\r\nContent-Type: %s\r\nContent-Length: %d\r\n\r\n%s",
                 mediatype, len, string);
 
+        client_set_queue (client, NULL);
         client->respcode = 200;
-        client_set_queue (client, refbuf);
+        client->refbuf = refbuf;
         refbuf->len = strlen (refbuf->data);
         fserve_add_client (client, NULL);
         xmlFree (string);

Modified: icecast/branches/kh/icecast/src/yp.c
===================================================================
--- icecast/branches/kh/icecast/src/yp.c	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/src/yp.c	2006-07-30 01:12:07 UTC (rev 11721)
@@ -931,7 +931,6 @@
     yp_update = 1;
     if (yp_thread)
         thread_join (yp_thread);
-    curl_global_cleanup();
     free ((char*)server_version);
     server_version = NULL;
     INFO0 ("YP thread down");

Modified: icecast/branches/kh/icecast/win32/Icecast2winDlg.cpp
===================================================================
--- icecast/branches/kh/icecast/win32/Icecast2winDlg.cpp	2006-07-29 09:58:36 UTC (rev 11720)
+++ icecast/branches/kh/icecast/win32/Icecast2winDlg.cpp	2006-07-30 01:12:07 UTC (rev 11721)
@@ -43,7 +43,7 @@
 char	gTitleSource[1024] = "";
 char	gTitleName[1024] = "";
 
-#define MAXSTATSPERSOURCE 30
+#define MAXSTATSPERSOURCE 60
 #define MAXSOURCES 1024
 
 typedef struct tagElement {
@@ -567,7 +567,6 @@
 				cur = cur->next;
 			}
 			xmlFreeDoc(doc);
-			xmlCleanupParser();
 			g_mainDialog->UpdateStatsLists();
 			Sleep(5000);
 		}



More information about the commits mailing list