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

karl at svn.xiph.org karl at svn.xiph.org
Wed Jan 7 09:07:42 PST 2009


Author: karl
Date: 2009-01-07 09:07:41 -0800 (Wed, 07 Jan 2009)
New Revision: 15607

Modified:
   icecast/branches/kh/icecast/Makefile.am
   icecast/branches/kh/icecast/NEWS
   icecast/branches/kh/icecast/conf/icecast_shoutcast_compat.xml.in
   icecast/branches/kh/icecast/config.h.vc6
   icecast/branches/kh/icecast/configure.in
   icecast/branches/kh/icecast/src/admin.c
   icecast/branches/kh/icecast/src/cfgfile.c
   icecast/branches/kh/icecast/src/connection.c
   icecast/branches/kh/icecast/src/format_kate.c
   icecast/branches/kh/icecast/src/format_mp3.c
   icecast/branches/kh/icecast/src/format_mp3.h
   icecast/branches/kh/icecast/src/format_skeleton.c
   icecast/branches/kh/icecast/src/logging.c
   icecast/branches/kh/icecast/src/main.c
   icecast/branches/kh/icecast/src/refbuf.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/win32/Icecast2win.cpp
   icecast/branches/kh/icecast/win32/Icecast2win.dsp
   icecast/branches/kh/icecast/win32/Icecast2win.h
   icecast/branches/kh/icecast/win32/Icecast2winDlg.cpp
   icecast/branches/kh/icecast/win32/icecast2.iss
   icecast/branches/kh/icecast/win32/icecast2_console.dsp
Log:
sync up kh8. A number of reports have appeared over the last few weeks, these
include build failures, ogg handling problems, and memory corruption.

The only new feature is that metadata updates can take a url arg now. The
refbuf cleanup still needs confirming but it is required to prevent the ogg
stream header pages disappearing. Other cleanups have occurred to help
merging to trunk and clean up valgrind reporting.



Modified: icecast/branches/kh/icecast/Makefile.am
===================================================================
--- icecast/branches/kh/icecast/Makefile.am	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/Makefile.am	2009-01-07 17:07:41 UTC (rev 15607)
@@ -14,7 +14,7 @@
 doc_DATA = README AUTHORS COPYING NEWS TODO
 
 debug:
-	$(MAKE) all CFLAGS="@DEBUG@"
+	$(MAKE) all CFLAGS="-Wno-unused-parameter @DEBUG@"
 
 profile:
 	$(MAKE) all CFLAGS="@PROFILE@"

Modified: icecast/branches/kh/icecast/NEWS
===================================================================
--- icecast/branches/kh/icecast/NEWS	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/NEWS	2009-01-07 17:07:41 UTC (rev 15607)
@@ -15,6 +15,19 @@
 any extra tags are show in the conf/icecast.xml.dist file
 
 
+2.3.2-kh8
+. fix memory corruption which affected ogg streams.
+. fix for unsupported FBSD/win32 spin locking options. abort on initialisation failure.
+. win32 fix from kh7 causing stalling source threads. fallout from kh7 build failure
+
+2.3.2-kh7
+. merge fix for bug report on trunk for skeleton
+. fix for build failure with recent glibc
+. fix for admin.cgi metdata updates not applying (kh5 bug).
+. minor locking cleanup
+. win32 fixes. server restart could cause relay details to become corrupted
+. win32 update. updated libxml2/libxslt
+
 2.3.2-kh6
 . some source stats were not being reported on the xsl pages.
 . win32 access log timestamps should now to correct.

Modified: icecast/branches/kh/icecast/conf/icecast_shoutcast_compat.xml.in
===================================================================
--- icecast/branches/kh/icecast/conf/icecast_shoutcast_compat.xml.in	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/conf/icecast_shoutcast_compat.xml.in	2009-01-07 17:07:41 UTC (rev 15607)
@@ -36,9 +36,9 @@
 
     <fileserve>1</fileserve>
     <paths>
-        <logdir>@localstatedir@/log/@PACKAGE@</logdir>
-        <webroot>@pkgdatadir@/web</webroot>
-        <adminroot>@pkgdatadir@/admin</adminroot>
+        <logdir>./log/</logdir>
+        <webroot>./web</webroot>
+        <adminroot>./admin</adminroot>
     </paths>
     <logging>
         <accesslog>access.log</accesslog>

Modified: icecast/branches/kh/icecast/config.h.vc6
===================================================================
--- icecast/branches/kh/icecast/config.h.vc6	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/config.h.vc6	2009-01-07 17:07:41 UTC (rev 15607)
@@ -95,7 +95,7 @@
 #define PACKAGE_NAME "Icecast"
 
 /* Version number of package */
-#define VERSION "2.3.2-kh6"
+#define VERSION "2.3.2-kh8"
 
 /* Define to the version of this package. */
 #define PACKAGE_VERSION VERSION
@@ -163,3 +163,5 @@
 #define ICECAST_TIME_FMT "%a, %d %b %Y %H:%M:%S"
 
 #define PATH_MAX MAX_PATH
+#define HAVE_FTIME 1
+#define HAVE_SYS_TIMEB_H 1

Modified: icecast/branches/kh/icecast/configure.in
===================================================================
--- icecast/branches/kh/icecast/configure.in	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/configure.in	2009-01-07 17:07:41 UTC (rev 15607)
@@ -1,4 +1,4 @@
-AC_INIT([Icecast], [2.3.2-kh6], [karl at xiph.org])
+AC_INIT([Icecast], [2.3.2-kh8], [karl at xiph.org])
 
 AC_PREREQ(2.59)
 AC_CONFIG_SRCDIR(src/main.c)
@@ -33,7 +33,7 @@
 AC_HEADER_STDC
 AC_HEADER_TIME
 
-AC_CHECK_HEADERS([alloca.h fnmatch.h limits.h])
+AC_CHECK_HEADERS([alloca.h fnmatch.h limits.h sys/timeb.h])
 AC_CHECK_HEADERS(pwd.h, AC_DEFINE(CHUID, 1, [Define if you have pwd.h]),,)
 AC_CHECK_HEADERS(unistd.h, AC_DEFINE(CHROOT, 1, [Define if you have unistd.h]),,)
 
@@ -44,7 +44,7 @@
 AC_TYPE_OFF_T
 
 dnl Checks for library functions.
-AC_CHECK_FUNCS([localtime_r poll atoll strtoll getrlimit])
+AC_CHECK_FUNCS([localtime_r poll atoll strtoll getrlimit gettimeofday ftime])
 AC_SEARCH_LIBS(nanosleep, rt posix4,
         AC_DEFINE(HAVE_NANOSLEEP, 1, [Define if you have nanosleep]))
 XIPH_NET
@@ -83,10 +83,10 @@
     ])
 
 AC_CHECK_LIB(kate, kate_decode_init,[have_kate=yes],[have_kate=no], -logg)
-if test "x$have_kate" == "xyes"
+if test "x$have_kate" = "xyes"
 then
   AC_CHECK_LIB(oggkate, kate_ogg_decode_headerin,[have_kate=yes],[have_kate=no],-lkate -logg)
-  if test "x$have_kate" == "xyes"
+  if test "x$have_kate" = "xyes"
   then
     KATE_LIBS="-loggkate -lkate -logg"
     AC_DEFINE([HAVE_KATE],[1],[Define if you have libkate])

Modified: icecast/branches/kh/icecast/src/admin.c
===================================================================
--- icecast/branches/kh/icecast/src/admin.c	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/src/admin.c	2009-01-07 17:07:41 UTC (rev 15607)
@@ -1096,6 +1096,7 @@
     {
         httpp_set_query_param (client->parser, "mount", client->server_conn->shoutcast_mount);
         source->format->set_tag (source->format, "title", value, NULL);
+        source->format->set_tag (source->format, NULL, NULL, NULL);
 
         DEBUG2("Metadata on mountpoint %s changed to \"%s\"", 
                 source->mount, value);

Modified: icecast/branches/kh/icecast/src/cfgfile.c
===================================================================
--- icecast/branches/kh/icecast/src/cfgfile.c	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/src/cfgfile.c	2009-01-07 17:07:41 UTC (rev 15607)
@@ -327,8 +327,10 @@
     if (c->access_log.exclude_ext) xmlFree (c->access_log.exclude_ext);
     if (c->shoutcast_mount) xmlFree(c->shoutcast_mount);
 
+    global_lock();
     while ((c->listen_sock = config_clear_listener (c->listen_sock)))
         ;
+    global_unlock();
 
     if (c->master_server) xmlFree(c->master_server);
     if (c->master_username) xmlFree(c->master_username);

Modified: icecast/branches/kh/icecast/src/connection.c
===================================================================
--- icecast/branches/kh/icecast/src/connection.c	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/src/connection.c	2009-01-07 17:07:41 UTC (rev 15607)
@@ -117,7 +117,6 @@
 cache_file_contents useragents;
 
 int connection_running = 0;
-rwlock_t _source_shutdown_rwlock;
 
 static void _handle_connection(void);
 static int check_pass(http_parser_t *parser, const char *user, const char *pass);
@@ -157,7 +156,6 @@
 {
     thread_spin_create("connection", &_connection_mutex);
     thread_mutex_create("move_clients", &move_clients_mutex);
-    thread_rwlock_create(&_source_shutdown_rwlock);
     thread_cond_create(&global.shutdown_cond);
     _req_queue = NULL;
     _req_queue_tail = &_req_queue;
@@ -185,7 +183,6 @@
     if (useragents.contents) avl_tree_free (useragents.contents, free_filtered_line);
 
     thread_cond_destroy(&global.shutdown_cond);
-    thread_rwlock_destroy(&_source_shutdown_rwlock);
     thread_spin_destroy(&_connection_mutex);
     thread_mutex_destroy(&move_clients_mutex);
 }
@@ -702,8 +699,11 @@
     if (client->server_conn->shoutcast_compat)
         node->shoutcast = 1;
 
-    sock_set_blocking (client->con->sock, SOCK_NONBLOCK);
-    sock_set_nodelay (client->con->sock);
+    if (sock_set_blocking (client->con->sock, 0) || sock_set_nodelay (client->con->sock))
+    {
+        WARN0 ("failed to set tcp options on client connection, dropping");
+        client->con->error = 1;
+    }
 
     return node;
 }
@@ -858,7 +858,6 @@
         config_release_config();
         slave_rebuild_mounts();
 
-        source->shutdown_rwlock = &_source_shutdown_rwlock;
         DEBUG0 ("source is ready to start");
 
         return 0;
@@ -1489,7 +1488,7 @@
                 sock_close (sock);
                 break;
             }
-            sock_set_blocking (sock, SOCK_NONBLOCK);
+            sock_set_blocking (sock, 0);
             successful = 1;
             global.serversock [count] = sock;
             global.server_conn [count] = listener;

Modified: icecast/branches/kh/icecast/src/format_kate.c
===================================================================
--- icecast/branches/kh/icecast/src/format_kate.c	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/src/format_kate.c	2009-01-07 17:07:41 UTC (rev 15607)
@@ -180,7 +180,6 @@
  */
 ogg_codec_t *initial_kate_page (format_plugin_t *plugin, ogg_page *page)
 {
-    ogg_state_t *ogg_info = plugin->_state;
     ogg_codec_t *codec = calloc (1, sizeof (ogg_codec_t));
     ogg_packet packet;
 
@@ -226,7 +225,6 @@
     codec->name = "Kate";
 
     format_ogg_attach_header (codec, page);
-    ogg_info->codec_sync = codec;
     return codec;
 }
 

Modified: icecast/branches/kh/icecast/src/format_mp3.c
===================================================================
--- icecast/branches/kh/icecast/src/format_mp3.c	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/src/format_mp3.c	2009-01-07 17:07:41 UTC (rev 15607)
@@ -121,21 +121,25 @@
 static void mp3_set_tag (format_plugin_t *plugin, const char *tag, const char *in_value, const char *charset)
 {
     mp3_state *source_mp3 = plugin->_state;
-    char *value;
+    char *value = NULL;
 
-    if (tag==NULL || in_value == NULL)
+    /* protect against multiple updaters */
+    thread_mutex_lock (&source_mp3->url_lock);
+
+    if (tag==NULL)
     {
         source_mp3->update_metadata = 1;
+        thread_mutex_unlock (&source_mp3->url_lock);
         return;
     }
 
-    /* protect against multiple updaters */
-    thread_mutex_lock (&source_mp3->url_lock);
+    if (in_value)
+    {
+        value = util_conv_string (in_value, charset, plugin->charset);
+        if (value == NULL)
+            value = strdup (in_value);
+    }
 
-    value = util_conv_string (in_value, charset, plugin->charset);
-    if (value == NULL)
-        value = strdup (in_value);
-
     if (strcmp (tag, "title") == 0 || strcmp (tag, "song") == 0)
     {
         free (source_mp3->url_title);
@@ -229,12 +233,12 @@
  */
 static void mp3_set_title (source_t *source)
 {
-    const char meta[] = "StreamTitle='";
+    const char streamtitle[] = "StreamTitle='";
     const char streamurl[] = "StreamUrl='";
     size_t size;
     unsigned char len_byte;
     refbuf_t *p;
-    unsigned int len = sizeof(meta) + 2; /* the StreamTitle, quotes, ; and null */
+    unsigned int len = sizeof(streamtitle) + 2; /* the StreamTitle, quotes, ; and null */
     mp3_state *source_mp3 = source->format->_state;
 
     /* make sure the url data does not disappear from under us */
@@ -247,7 +251,13 @@
         len += strlen (source_mp3->url_title);
     if (source_mp3->url_artist && source_mp3->url_title)
         len += 3;
-    if (source_mp3->url)
+    if (source_mp3->inline_url)
+    {
+        char *end = strstr (source_mp3->inline_url, "';");
+        if (end)
+            len += end - source_mp3->inline_url+2;
+    }
+    else if (source_mp3->url)
         len += strlen (source_mp3->url) + strlen (streamurl) + 2;
 #define MAX_META_LEN 255*16
     if (len > MAX_META_LEN)
@@ -270,28 +280,29 @@
 
         memset (p->data, '\0', size);
         if (source_mp3->url_artist && source_mp3->url_title)
-            r = snprintf (p->data, size, "%c%s%s - %s';", len_byte, meta,
+            r = snprintf (p->data, size, "%c%s%s - %s';", len_byte, streamtitle,
                     source_mp3->url_artist, source_mp3->url_title);
         else
-            r = snprintf (p->data, size, "%c%s%s';", len_byte, meta,
+            r = snprintf (p->data, size, "%c%s%s';", len_byte, streamtitle,
                     source_mp3->url_title);
-        DEBUG2 ("r is %d, url %s", r, source_mp3->url);
-        if (r > 0 && source_mp3->url)
+        if (r > 0)
         {
-            snprintf (p->data+r, size-r, "StreamUrl='%s';", source_mp3->url);
-            DEBUG2 ("val %d %d", p->data[r-1], p->data[r]);
+            if (source_mp3->inline_url)
+            {
+                char *end = strstr (source_mp3->inline_url, "';");
+                int urllen = size;
+                if (end) urllen = end - source_mp3->inline_url + 2;
+                if (size-r > urllen)
+                    snprintf (p->data+r, size-r, "StreamUrl='%s';", source_mp3->inline_url+11);
+            }
+            else if (source_mp3->url)
+                snprintf (p->data+r, size-r, "StreamUrl='%s';", source_mp3->url);
         }
         DEBUG1 ("shoutcast metadata block setup with %s", p->data+1);
         filter_shoutcast_metadata (source, p->data, size);
 
         refbuf_release (source_mp3->metadata);
         source_mp3->metadata = p;
-        free (source_mp3->url);
-        source_mp3->url = NULL;
-        free (source_mp3->url_title);
-        source_mp3->url_title = NULL;
-        free (source_mp3->url_artist);
-        source_mp3->url_artist = NULL;
     }
     thread_mutex_unlock (&source_mp3->url_lock);
 }
@@ -637,6 +648,7 @@
                         source_mp3->build_metadata_len);
                 refbuf_release (source_mp3->metadata);
                 source_mp3->metadata = meta;
+                source_mp3->inline_url = strstr (meta->data+1, "StreamUrl='");
             }
             else
             {
@@ -678,7 +690,7 @@
     if (client_mp3 == NULL)
         return -1;
 
-    /* hack for flash player, it wants a length.  It has also been reported that the useragent 
+    /* hack for flash player, it wants a length.  It has also been reported that the useragent
      * appears as MSIE if run in internet explorer */
     useragent = httpp_getvar (client->parser, "user-agent");
     if (httpp_getvar(client->parser, "x-flash-version") ||

Modified: icecast/branches/kh/icecast/src/format_mp3.h
===================================================================
--- icecast/branches/kh/icecast/src/format_mp3.h	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/src/format_mp3.h	2009-01-07 17:07:41 UTC (rev 15607)
@@ -26,6 +26,7 @@
     char *url_artist;
     char *url_title;
     char *url;
+    char *inline_url;
     int update_metadata;
     int queue_block_size;
 

Modified: icecast/branches/kh/icecast/src/format_skeleton.c
===================================================================
--- icecast/branches/kh/icecast/src/format_skeleton.c	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/src/format_skeleton.c	2009-01-07 17:07:41 UTC (rev 15607)
@@ -96,7 +96,6 @@
     codec->name = "Skeleton";
 
     format_ogg_attach_header (codec, page);
-    ogg_info->codec_sync = codec;
     return codec;
 }
 

Modified: icecast/branches/kh/icecast/src/logging.c
===================================================================
--- icecast/branches/kh/icecast/src/logging.c	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/src/logging.c	2009-01-07 17:07:41 UTC (rev 15607)
@@ -112,11 +112,11 @@
     time_t now;
     time_t stayed;
     const char *referrer, *user_agent, *username, *ip = "-";
-#ifdef HAVE_LOG_DIRECT_KEEP
-    int keep = 0;
-#endif
     ice_config_t *config;
 
+    if (httpp_getvar (client->parser, "__avoid_access_log"))
+        return;
+
     now = global.time;
 
     localtime_r (&now, &thetime);
@@ -153,14 +153,7 @@
     if (config->access_log.log_ip)
         ip = client->con->ip;
     config_release_config ();
-#ifdef HAVE_LOG_DIRECT_KEEP
-    if (httpp_getvar (client->parser, "__avoid_access_log") == NULL)
-        keep = 1;
-
-    log_write_direct_keep (accesslog, keep,
-#else
     log_write_direct (accesslog,
-#endif
             "%s - %s [%s] \"%s\" %d %" PRIu64 " \"%s\" \"%s\" %lu",
             ip, username,
             datebuf, reqbuf, client->respcode, client->con->sent_bytes,

Modified: icecast/branches/kh/icecast/src/main.c
===================================================================
--- icecast/branches/kh/icecast/src/main.c	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/src/main.c	2009-01-07 17:07:41 UTC (rev 15607)
@@ -94,7 +94,7 @@
     log_close(playlistlog);
 }
 
-static void _initialize_subsystems(void)
+void _initialize_subsystems(void)
 {
     log_initialize();
     thread_initialize();
@@ -107,32 +107,24 @@
 
     stats_initialize();
     fserve_initialize();
-#if !defined(WIN32) || defined(WIN32_SERVICE)
-    /* win32 GUI needs to do the initialise before here */
     xslt_initialize();
 #ifdef HAVE_CURL_GLOBAL_INIT
     curl_global_init (CURL_GLOBAL_ALL);
 #endif
-#endif
 }
 
-static void _shutdown_subsystems(void)
+void _shutdown_subsystems(void)
 {
     fserve_shutdown();
-#if !defined(WIN32) || defined(WIN32_SERVICE)
-    /* If we do the following cleanup on the win32 GUI then the app will crash when libxml2 is
-     * initialised again as the process doesn't terminate */
-    xslt_shutdown();
-#endif
     refbuf_shutdown();
     slave_shutdown();
     auth_shutdown();
     yp_shutdown();
     stats_shutdown();
 
-    global_shutdown();
     connection_shutdown();
     config_shutdown();
+    global_shutdown();
     resolver_shutdown();
     sock_shutdown();
     thread_shutdown();
@@ -145,6 +137,7 @@
     /* Now that these are done, we can stop the loggers. */
     _stop_logging();
     log_shutdown();
+    xslt_shutdown();
 }
 
 static int _parse_config_opts(int argc, char **argv, char *filename, int size)
@@ -411,10 +404,11 @@
     ** only, so that we can read a configfile
     */
     res = _parse_config_opts(argc, argv, filename, 512);
-    if (res == 1) {
+    if (res == 1) {
+#if !defined(_WIN32) || defined(_CONSOLE)
         /* startup all the modules */
         _initialize_subsystems();
-
+#endif
         /* parse the config file */
         config_get_config();
         ret = config_initial_parse_file(filename);
@@ -494,9 +488,9 @@
     _server_proc();
 
     INFO0("Shutting down");
-
+#if !defined(_WIN32) || defined(_CONSOLE)
     _shutdown_subsystems();
-
+#endif
     if (pidfile)
     {
         remove (pidfile);

Modified: icecast/branches/kh/icecast/src/refbuf.c
===================================================================
--- icecast/branches/kh/icecast/src/refbuf.c	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/src/refbuf.c	2009-01-07 17:07:41 UTC (rev 15607)
@@ -20,13 +20,16 @@
 #include <config.h>
 #endif
 
-#include <sys/types.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "compat.h"
 #include "refbuf.h"
 
+#define CATMODULE "refbuf"
+
+#include "logging.h"
+
+
 void refbuf_initialize(void)
 {
 }
@@ -65,18 +68,29 @@
     self->_count++;
 }
 
+static void refbuf_release_associated (refbuf_t *ref)
+{
+    if (ref == NULL)
+        return;
+    while (ref && ref->_count == 1)
+    {
+        refbuf_t *to_go = ref;
+        ref = to_go->next;
+        to_go->next = NULL;
+        refbuf_release (to_go);
+    }
+}
+
 void refbuf_release(refbuf_t *self)
 {
     if (self == NULL)
         return;
     self->_count--;
-    if (self->_count == 0) {
-        while (self->associated)
-        {
-            refbuf_t *ref = self->associated;
-            self->associated = ref->next;
-            refbuf_release (ref);
-        }
+    if (self->_count == 0)
+    {
+        refbuf_release_associated (self->associated);
+        if (self->next)
+            DEBUG0 ("next not null");
         free(self->data);
         free(self);
     }

Modified: icecast/branches/kh/icecast/src/slave.c
===================================================================
--- icecast/branches/kh/icecast/src/slave.c	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/src/slave.c	2009-01-07 17:07:41 UTC (rev 15607)
@@ -76,7 +76,7 @@
 static redirect_host *find_slave_host (const char *server, int port);
 static void redirector_clearall (void);
 
-static int slave_running = 0;
+int slave_running = 0;
 static volatile int update_settings = 0;
 static volatile int update_all_mounts = 0;
 static volatile int restart_connection_thread = 0;
@@ -191,6 +191,8 @@
     ERROR0 ("streamlist request disabled, rebuild with libcurl if required");
 #endif
     _slave_thread (NULL);
+    slave_running = 0;
+    thread_rwlock_destroy (&slaves_lock);
 }
 
 
@@ -199,7 +201,6 @@
     if (!slave_running)
         return;
     slave_running = 0;
-    thread_rwlock_destroy (&slaves_lock);
 }
 
 
@@ -391,7 +392,7 @@
             global_lock ();
             client = client_create (con, parser);
             global_unlock ();
-            sock_set_blocking (streamsock, SOCK_NONBLOCK);
+            sock_set_blocking (streamsock, 0);
             client_set_queue (client, NULL);
             free (server);
             free (mount);
@@ -1066,16 +1067,19 @@
         /* only update relays lists from master when required */
         if (streamlist_check <= global.time)
         {
-            ice_config_t *config = config_get_config();
+            ice_config_t *config;
 
             if (streamlist_check == 0)
                 skip_timer = 1;
+
+            thread_mutex_lock (&(config_locks()->relay_lock));
+            config = config_get_config();
+
             streamlist_check = global.time + config->master_update_interval;
             update_master_as_slave (config);
 
             update_from_master (config);
 
-            thread_mutex_lock (&(config_locks()->relay_lock));
             cleanup_relays = update_relays (&global.relays, config->relay);
 
             config_release_config();
@@ -1106,6 +1110,8 @@
     INFO0 ("shutting down current relays");
     relay_check_streams (NULL, global.relays, 0);
     relay_check_streams (NULL, global.master_relays, 0);
+    global.relays = NULL;
+    global.master_relays = NULL;
     redirector_clearall();
     /* send any removals to the YP servers */
     yp_thread_startup();

Modified: icecast/branches/kh/icecast/src/source.c
===================================================================
--- icecast/branches/kh/icecast/src/source.c	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/src/source.c	2009-01-07 17:07:41 UTC (rev 15607)
@@ -311,8 +311,6 @@
 
     free (source->mount);
     free (source);
-
-    return;
 }
 
 
@@ -811,9 +809,6 @@
         }
     }
 
-    /* grab a read lock, to make sure we get a chance to cleanup */
-    thread_rwlock_rlock (source->shutdown_rwlock);
-
     /* start off the statistics */
     stats_event_inc (NULL, "source_total_connections");
     stats_event_hidden (source->mount, "slow_listeners", "0", STATS_COUNTERS);
@@ -968,10 +963,13 @@
          */
         if (mountinfo->fallback_mount)
         {
+            char *mount = strdup (mountinfo->fallback_mount);
             source_t *fallback_source;
 
+            config_release_config();
             avl_tree_rlock (global.source_tree);
-            fallback_source = source_find_mount (mountinfo->fallback_mount);
+            fallback_source = source_find_mount (mount);
+            free (mount);
 
             if (fallback_source != NULL)
             {
@@ -984,7 +982,8 @@
             avl_tree_unlock (global.source_tree);
         }
     }
-    config_release_config();
+    else
+        config_release_config();
 
     /* delete this sources stats */
     stats_event(source->mount, NULL, NULL);
@@ -999,9 +998,6 @@
     global.sources--;
     stats_event_args (NULL, "sources", "%d", global.sources);
     global_unlock();
-
-    /* release our hold on the lock so the main thread can continue cleaning up */
-    thread_rwlock_unlock(source->shutdown_rwlock);
 }
 
 

Modified: icecast/branches/kh/icecast/src/source.h
===================================================================
--- icecast/branches/kh/icecast/src/source.h	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/src/source.h	2009-01-07 17:07:41 UTC (rev 15607)
@@ -37,7 +37,6 @@
     client_t *active_clients;
     client_t **fast_clients_p;
 
-    rwlock_t *shutdown_rwlock;
     util_dict *audio_info;
 
     /* name of a file, whose contents are sent at listener connection */

Modified: icecast/branches/kh/icecast/win32/Icecast2win.cpp
===================================================================
--- icecast/branches/kh/icecast/win32/Icecast2win.cpp	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/win32/Icecast2win.cpp	2009-01-07 17:07:41 UTC (rev 15607)
@@ -5,6 +5,11 @@
 #include "Icecast2win.h"
 #include "Icecast2winDlg.h"
 
+extern "C" {
+#include "xslt.h"
+void _initialize_subsystems(void);
+void _shutdown_subsystems(void);
+}
 #ifdef _DEBUG
 #define new DEBUG_NEW
 #undef THIS_FILE
@@ -49,6 +54,7 @@
 	//  of your final executable, you should remove from the following
 	//  the specific initialization routines you do not need.
 
+	_initialize_subsystems();
 	if (strlen(m_lpCmdLine) > 0) {
 		strcpy(m_configFile, m_lpCmdLine);
 	}
@@ -87,3 +93,9 @@
 	//  application, rather than start the application's message pump.
 	return FALSE;
 }
+
+int CIcecast2winApp::ExitInstance()
+{
+    _shutdown_subsystems();
+    return CWinApp::ExitInstance();
+}

Modified: icecast/branches/kh/icecast/win32/Icecast2win.dsp
===================================================================
--- icecast/branches/kh/icecast/win32/Icecast2win.dsp	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/win32/Icecast2win.dsp	2009-01-07 17:07:41 UTC (rev 15607)
@@ -79,7 +79,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 libspeex.lib theora_static_d.lib ogg_static.lib vorbis_static.lib pthreadVSE.lib ssleay32MT.lib libcurl.lib libxml2.lib libxslt.lib iconv.lib ws2_32.lib winmm.lib /nologo /version:2.3 /subsystem:windows /incremental:no /debug /machine:I386 /nodefaultlib:"libcd.lib" /pdbtype:sept
+# ADD LINK32 libspeex.lib theora_static_d.lib ogg_static.lib vorbis_static.lib pthreadVSE.lib ssleay32MT.lib libcurl.lib libxml2.lib libxslt.lib iconv.lib ws2_32.lib winmm.lib /nologo /version:2.3 /subsystem:windows /incremental:no /debug /machine:I386 /nodefaultlib:"libcd.lib libcmt.lib" /pdbtype:sept
 # SUBTRACT LINK32 /verbose
 
 !ENDIF 

Modified: icecast/branches/kh/icecast/win32/Icecast2win.h
===================================================================
--- icecast/branches/kh/icecast/win32/Icecast2win.h	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/win32/Icecast2win.h	2009-01-07 17:07:41 UTC (rev 15607)
@@ -31,6 +31,7 @@
 	//{{AFX_VIRTUAL(CIcecast2winApp)
 	public:
 	virtual BOOL InitInstance();
+	virtual int ExitInstance();
 	//}}AFX_VIRTUAL
 
 // Implementation

Modified: icecast/branches/kh/icecast/win32/Icecast2winDlg.cpp
===================================================================
--- icecast/branches/kh/icecast/win32/Icecast2winDlg.cpp	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/win32/Icecast2winDlg.cpp	2009-01-07 17:07:41 UTC (rev 15607)
@@ -339,9 +339,6 @@
 	sprintf(version, "Icecast2 Version %s", ICECAST_VERSION);
 	SetWindowText(version);
 
-    xslt_initialize();
-    curl_global_init (CURL_GLOBAL_ALL);
-
 	if (m_Autostart) {
 		OnStart();
 	}

Modified: icecast/branches/kh/icecast/win32/icecast2.iss
===================================================================
--- icecast/branches/kh/icecast/win32/icecast2.iss	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/win32/icecast2.iss	2009-01-07 17:07:41 UTC (rev 15607)
@@ -3,7 +3,7 @@
 
 [Setup]
 AppName=Icecast2-KH
-AppVerName=Icecast v2.3.2-kh6
+AppVerName=Icecast v2.3.2-kh8
 AppPublisherURL=http://www.icecast.org
 AppSupportURL=http://www.icecast.org
 AppUpdatesURL=http://www.icecast.org
@@ -13,7 +13,7 @@
 LicenseFile=..\COPYING
 InfoAfterFile=..\README
 OutputDir=.
-OutputBaseFilename=icecast2_win32_v2.3.2-kh6_setup
+OutputBaseFilename=icecast2_win32_v2.3.2-kh8_setup
 WizardImageFile=icecast2logo2.bmp
 WizardImageStretch=no
 ; uncomment the following line if you want your installation to run on NT 3.51 too.

Modified: icecast/branches/kh/icecast/win32/icecast2_console.dsp
===================================================================
--- icecast/branches/kh/icecast/win32/icecast2_console.dsp	2009-01-05 23:51:43 UTC (rev 15606)
+++ icecast/branches/kh/icecast/win32/icecast2_console.dsp	2009-01-07 17:07:41 UTC (rev 15607)
@@ -67,7 +67,7 @@
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I ".." /I "..\src" /D "_DEBUG" /D "_CONSOLE" /D HAVE_CONFIG_H=1 /D "WIN32" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I ".." /I "..\src" /D "_DEBUG" /D "_CONSOLE" /D HAVE_CONFIG_H=1 /D "WIN32" /D "_MBCS" /YX /FD /GZ /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe



More information about the commits mailing list