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

karl at dactyl.lonelymoon.com karl
Wed Jul 28 14:28:46 PDT 2004


Author: karl
Date: Wed Jul 28 14:28:46 2004
New Revision: 7402

Modified:
icecast/branches/kh/icecast/src/connection.c
icecast/branches/kh/icecast/src/event.c
icecast/branches/kh/icecast/src/source.c
icecast/branches/kh/icecast/src/source.h
Log:
allow for HUP to update mount settings on active sources without having
to stop them


Modified: icecast/branches/kh/icecast/src/connection.c
===================================================================
--- icecast/branches/kh/icecast/src/connection.c	2004-07-28 19:09:45 UTC (rev 7401)
+++ icecast/branches/kh/icecast/src/connection.c	2004-07-28 21:28:45 UTC (rev 7402)
@@ -432,7 +432,6 @@
if (global.sources < config->source_limit)
{
char *contenttype;
-        mount_proxy *mountproxy = config->mounts;
format_type_t format_type;

/* setup format handler */
@@ -471,12 +470,6 @@
global.sources++;
global_unlock();

-        /* set global settings first */
-        source->queue_size_limit = config->queue_size_limit;
-        source->timeout = config->source_timeout;
-        source->on_demand = config->on_demand;
-        source->burst_size_limit = config->burst_size_limit;
-
/* 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,
@@ -485,15 +478,7 @@
if (source->client == NULL)
source->client = client_create (source->con, source->parser);

-        while (mountproxy)
-        {
-            if (strcmp (mountproxy->mountname, source->mount) == 0)
-            {
-                source_apply_mount (source, mountproxy);
-                break;
-            }
-            mountproxy = mountproxy->next;
-        }
+        source_update_settings (config, source);
config_release_config();

source->shutdown_rwlock = &_source_shutdown_rwlock;

Modified: icecast/branches/kh/icecast/src/event.c
===================================================================
--- icecast/branches/kh/icecast/src/event.c	2004-07-28 19:09:45 UTC (rev 7401)
+++ icecast/branches/kh/icecast/src/event.c	2004-07-28 21:28:45 UTC (rev 7402)
@@ -17,6 +17,7 @@
#include "event.h"
#include "cfgfile.h"
#include "yp.h"
+#include "source.h"

#include "refbuf.h"
#include "client.h"
@@ -60,6 +61,7 @@
restart_logging ();
slave_recheck();
yp_recheck_config (config);
+        source_update (config);

config_release_config();
}

Modified: icecast/branches/kh/icecast/src/source.c
===================================================================
--- icecast/branches/kh/icecast/src/source.c	2004-07-28 19:09:45 UTC (rev 7401)
+++ icecast/branches/kh/icecast/src/source.c	2004-07-28 21:28:45 UTC (rev 7402)
@@ -421,10 +421,6 @@
}
refbuf = refbuf->next;
}
-#if 0
-    if (refbuf == NULL)
-        DEBUG1 ("no start point for client %u", client->con->id);
-#endif
client->refbuf = refbuf;
}

@@ -581,6 +577,12 @@
/* take the lock */
thread_mutex_lock (&source->lock);

+        if (source->recheck_settings)
+        {
+            ice_config_t *config = config_get_config();
+            source_update_settings (config, source);
+            config_release_config ();
+        }
if (fds < 0)
{
if (! sock_recoverable (sock_error()))
@@ -626,7 +628,6 @@
source->burst_size += refbuf->len;
if (source->burst_size > source->burst_size_limit)
{
-                // DEBUG2 ("starting counts are %d, %d", source->burst_size, source->burst_size_limit);
source->burst_size -= source->burst_point->len;
source->burst_point = source->burst_point->next;
}
@@ -968,8 +969,6 @@
source->active_clients = to_go;
if (*source->active_clients_tail == to_go)
source->active_clients_tail = &to_go->next;
-//            *source->active_clients_tail = to_go;
-            //source->active_clients_tail = &to_go->next;
count++;
}
source->new_listeners--;
@@ -1041,7 +1040,6 @@
if (source->format->prerelease)
source->format->prerelease (source, to_go);
refbuf_release (to_go);
-                // DEBUG1 ("releasing %p", to_go);
}
else
WARN0("possible queue length error");
@@ -1123,17 +1121,16 @@
}


-void source_apply_mount (source_t *source, mount_proxy *mountinfo)
+static void source_apply_mount (source_t *source, mount_proxy *mountinfo)
{
-    DEBUG1("Applying mount information for \"%s\"", source->mount);
+    DEBUG1 ("Applying mount information for \"%s\"", source->mount);
source->max_listeners = mountinfo->max_listeners;
source->fallback_override = mountinfo->fallback_override;
source->no_mount = mountinfo->no_mount;
+
if (mountinfo->fallback_mount)
-    {
source->fallback_mount = strdup (mountinfo->fallback_mount);
-        DEBUG1 ("fallback %s", mountinfo->fallback_mount);
-    }
+
if (mountinfo->auth_type != NULL)
{
source->authenticator = auth_get_authenticator(
@@ -1141,45 +1138,93 @@
stats_event(source->mount, "authenticator", mountinfo->auth_type);
}
if (mountinfo->dumpfile)
-    {
-        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);
-    }
+
if (mountinfo->burst_size)
-    {
source->burst_size_limit = mountinfo->burst_size;
-        DEBUG1 ("burst size to %u", source->burst_size_limit);
-    }
+
if (mountinfo->fallback_when_full)
-    {
source->fallback_when_full = mountinfo->fallback_when_full;
-        DEBUG1 ("fallback_when_full to %u", source->fallback_when_full);
-    }
+
if (mountinfo->no_yp)
-    {
source->yp_prevent = 1;
-        DEBUG0("prevent YP listings");
-    }
+
if (mountinfo->on_connect)
-    {
source->on_connect = strdup(mountinfo->on_connect);
-        DEBUG1 ("connect script \"%s\"", source->on_connect);
-    }
+
if (mountinfo->on_disconnect)
+        source->on_disconnect = strdup(mountinfo->on_disconnect);
+}
+
+
+void source_update_settings (ice_config_t *config, source_t *source)
+{
+    mount_proxy *mountproxy = config->mounts;
+
+    /* set global settings first */
+    source->queue_size_limit = config->queue_size_limit;
+    source->timeout = config->source_timeout;
+    source->burst_size_limit = config->burst_size_limit;
+
+    source->dumpfilename = NULL;
+    auth_clear (source->authenticator);
+    source->authenticator = NULL;
+
+    while (mountproxy)
{
-        source->on_disconnect = strdup(mountinfo->on_disconnect);
+        if (strcmp (mountproxy->mountname, source->mount) == 0)
+        {
+            source_apply_mount (source, mountproxy);
+            break;
+        }
+        mountproxy = mountproxy->next;
+    }
+    if (source->fallback_mount)
+        DEBUG1 ("fallback %s", source->fallback_mount);
+    if (source->dumpfilename)
+        DEBUG1 ("Dumping stream to %s", source->dumpfilename);
+    if (source->yp_prevent)
+        DEBUG0 ("preventing YP listings");
+    if (source->on_connect)
+        DEBUG1 ("connect script \"%s\"", source->on_connect);
+    if (source->on_disconnect)
DEBUG1 ("disconnect script \"%s\"", source->on_disconnect);
+    if (source->on_demand)
+        DEBUG0 ("on-demand set");
+
+    DEBUG1 ("max listeners to %d", source->max_listeners);
+    DEBUG1 ("queue size to %u", source->queue_size_limit);
+    DEBUG1 ("burst size to %u", source->burst_size_limit);
+    DEBUG1 ("source timeout to %u", source->timeout);
+    DEBUG1 ("fallback_when_full to %u", source->fallback_when_full);
+    source->recheck_settings = 0;
+}
+
+
+void source_update (ice_config_t *config)
+{
+    avl_node *node;
+
+    avl_tree_rlock (global.source_tree);
+    node = avl_get_first (global.source_tree);
+    while (node)
+    {
+        source_t *source = node->key;
+
+        /* we can't lock the source as we have config locked, so flag the
+         * source for updating */
+        source->recheck_settings = 1;
+
+        node = avl_get_next (node);
}
+
+    avl_tree_unlock (global.source_tree);
}



Modified: icecast/branches/kh/icecast/src/source.h
===================================================================
--- icecast/branches/kh/icecast/src/source.h	2004-07-28 19:09:45 UTC (rev 7401)
+++ icecast/branches/kh/icecast/src/source.h	2004-07-28 21:28:45 UTC (rev 7402)
@@ -67,6 +67,7 @@

int on_demand;
int on_demand_req;
+    int recheck_settings;

time_t last_read;
char *on_connect;
@@ -84,7 +85,8 @@

source_t *source_reserve (const char *mount);
void *source_client_thread (void *arg);
-void source_apply_mount (source_t *source, mount_proxy *mountinfo);
+void source_update_settings (ice_config_t *config, source_t *source);
+void source_update (ice_config_t *config);
void source_clear_source (source_t *source);
source_t *source_find_mount(const char *mount);
source_t *source_find_mount_raw(const char *mount);



More information about the commits mailing list