[xiph-commits] r9285 - in icecast/branches/kh/icecast: doc src

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Sun May 15 10:24:52 PDT 2005


Author: karl
Date: 2005-05-15 10:24:44 -0700 (Sun, 15 May 2005)
New Revision: 9285

Modified:
   icecast/branches/kh/icecast/doc/icecast2_config_file.html
   icecast/branches/kh/icecast/src/auth.c
   icecast/branches/kh/icecast/src/cfgfile.c
   icecast/branches/kh/icecast/src/connection.c
   icecast/branches/kh/icecast/src/event.c
   icecast/branches/kh/icecast/src/format.c
   icecast/branches/kh/icecast/src/logging.c
   icecast/branches/kh/icecast/src/logging.h
   icecast/branches/kh/icecast/src/slave.c
   icecast/branches/kh/icecast/src/slave.h
   icecast/branches/kh/icecast/src/source.c
   icecast/branches/kh/icecast/src/source.h
Log:
sync-up work for trunk merging, cleanup the mechanism for rebuilding the
mount stats.


Modified: icecast/branches/kh/icecast/doc/icecast2_config_file.html
===================================================================
--- icecast/branches/kh/icecast/doc/icecast2_config_file.html	2005-05-15 16:24:00 UTC (rev 9284)
+++ icecast/branches/kh/icecast/doc/icecast2_config_file.html	2005-05-15 17:24:44 UTC (rev 9285)
@@ -95,6 +95,7 @@
 <pre>
     &lt;authentication&gt;
         &lt;source-password&gt;hackme&lt;/source-password&gt;
+        &lt;relay-user&gt;relay&lt;/relay-user&gt;
         &lt;relay-password&gt;hackme&lt;/relay-password&gt;
         &lt;admin-user&gt;admin&lt;/admin-user&gt;
         &lt;admin-password&gt;hackme&lt;/admin-password&gt;
@@ -106,9 +107,15 @@
 <div class="indentedbox">
 The unencrypted password used by sources to connect to icecast2.  Currently, the username for all source connections must be 'source'.  This is likely to change in the future.
 </div>
+<h4>relay-user</h4>
+<div class="indentedbox">
+Used in the master server as part of the authentication when a slave requests
+the list of streams to relay.  The default username is 'relay'
+</div>
 <h4>relay-password</h4>
 <div class="indentedbox">
-Currently not used.
+Used in the master server as part of the authentication when a slave requests
+the list of streams to relay.
 </div>
 <h4>admin-user</h4>
 <h4>admin-password</h4>
@@ -201,6 +208,7 @@
     &lt;master-server&gt;127.0.0.1&lt;/master-server&gt;
     &lt;master-server-port&gt;8001&lt;/master-server-port&gt;
     &lt;master-update-interval&gt;120&lt;/master-update-interval&gt;
+    &lt;master-username&gt;relay&lt;/master-username&gt;
     &lt;master-password&gt;hackme&lt;/master-password&gt;
     &lt;relays-on-demand&gt;0&lt;/relays-on-demand&gt;
 
@@ -253,14 +261,14 @@
 </div>
 <h4>master-username</h4>
 <div class="indentedbox">
-This is the username to authenticate with the master. The default is "relay". This is used to
-get hold of the streamlist and can be used to authenticate master relays. The master server
-will compare with the relay-user.
+This is the relay username on the master server.  It is used to query the
+server for a list of mountpoints to relay. If not specified then 'relay' is
+used
 </div>
 <h4>master-password</h4>
 <div class="indentedbox">
-As with master-username, this is the password to authenticate with the master server. The
-relay-password on the master server is used for comparison.
+This is the relay password on the Master server.  It is used to query the
+server for a list of mountpoints to relay.
 </div>
 <h4>master-redirect-port</h4>
 <div class="indentedbox">

Modified: icecast/branches/kh/icecast/src/auth.c
===================================================================
--- icecast/branches/kh/icecast/src/auth.c	2005-05-15 16:24:00 UTC (rev 9284)
+++ icecast/branches/kh/icecast/src/auth.c	2005-05-15 17:24:44 UTC (rev 9285)
@@ -258,7 +258,7 @@
         /* enable on-demand relay to start, wake up the slave thread */
         DEBUG0("kicking off on-demand relay");
         source->on_demand_req = 1;
-        slave_rescan();
+        slave_rebuild_mounts();
     }
     DEBUG1 ("Added client to pending on %s", source->mount);
     return 0;

Modified: icecast/branches/kh/icecast/src/cfgfile.c
===================================================================
--- icecast/branches/kh/icecast/src/cfgfile.c	2005-05-15 16:24:00 UTC (rev 9284)
+++ icecast/branches/kh/icecast/src/cfgfile.c	2005-05-15 17:24:44 UTC (rev 9285)
@@ -39,6 +39,7 @@
 #define CONFIG_DEFAULT_SOURCE_TIMEOUT 10
 #define CONFIG_DEFAULT_SOURCE_PASSWORD "changeme"
 #define CONFIG_DEFAULT_RELAY_PASSWORD "changeme"
+#define CONFIG_DEFAULT_MASTER_USERNAME "relay"
 #define CONFIG_DEFAULT_SHOUTCAST_MOUNT "/stream"
 #define CONFIG_DEFAULT_ICE_LOGIN 0
 #define CONFIG_DEFAULT_FILESERVE 1
@@ -350,7 +351,7 @@
     configuration->master_server = NULL;
     configuration->master_server_port = 0;
     configuration->master_update_interval = CONFIG_MASTER_UPDATE_INTERVAL;
-    configuration->master_username = NULL;
+    configuration->master_username = xmlStrdup (CONFIG_DEFAULT_MASTER_USERNAME);
     configuration->master_password = NULL;
     configuration->master_relay_auth = 0;
     configuration->master_redirect_port = 0;
@@ -368,7 +369,7 @@
     configuration->group = CONFIG_DEFAULT_GROUP;
     configuration->num_yp_directories = 0;
     configuration->slaves_count = 0;
-    configuration->relay_username = NULL;
+    configuration->relay_username = xmlStrdup (CONFIG_DEFAULT_MASTER_USERNAME);
     configuration->relay_password = NULL;
     /* default to a typical prebuffer size used by clients */
     configuration->burst_size = CONFIG_DEFAULT_BURST_SIZE;

Modified: icecast/branches/kh/icecast/src/connection.c
===================================================================
--- icecast/branches/kh/icecast/src/connection.c	2005-05-15 16:24:00 UTC (rev 9284)
+++ icecast/branches/kh/icecast/src/connection.c	2005-05-15 17:24:44 UTC (rev 9285)
@@ -333,7 +333,6 @@
 
     config = config_get_config();
     threadpool_size = config->threadpool_size;
-    source_update (config);
     config_release_config();
 
     for (i = 0; i < threadpool_size; i++) {
@@ -857,7 +856,7 @@
             "SOURCE %s HTTP/1.0\r\n%s", mount, header);
     parser = httpp_create_parser();
     httpp_initialize(parser, NULL);
-    if (httpp_parse(parser, http_compliant, strlen(http_compliant)))
+    if (httpp_parse (parser, http_compliant, strlen(http_compliant)))
     {
         client_t *client = client_create (con, parser);
         if (client)

Modified: icecast/branches/kh/icecast/src/event.c
===================================================================
--- icecast/branches/kh/icecast/src/event.c	2005-05-15 16:24:00 UTC (rev 9284)
+++ icecast/branches/kh/icecast/src/event.c	2005-05-15 17:24:44 UTC (rev 9285)
@@ -59,12 +59,10 @@
         config_clear(config);
         config_set_config(&new_config);
         restart_logging (config_get_config_unlocked());
-        slave_recheck();
         yp_recheck_config (config_get_config_unlocked());
-        source_update (config_get_config_unlocked());
 
         config_release_config();
-        source_recheck_mounts();
+        slave_recheck_mounts();
     }
 }
 

Modified: icecast/branches/kh/icecast/src/format.c
===================================================================
--- icecast/branches/kh/icecast/src/format.c	2005-05-15 16:24:00 UTC (rev 9284)
+++ icecast/branches/kh/icecast/src/format.c	2005-05-15 17:24:44 UTC (rev 9285)
@@ -45,8 +45,8 @@
 
 #ifdef WIN32
 #define strcasecmp stricmp
-#define strncasecmp strnicmp
-#define snprintf _snprintf
+#define strncasecmp strnicmp
+#define snprintf _snprintf
 #endif
 
 static int format_prepare_headers (source_t *source, client_t *client);

Modified: icecast/branches/kh/icecast/src/logging.c
===================================================================
--- icecast/branches/kh/icecast/src/logging.c	2005-05-15 16:24:00 UTC (rev 9284)
+++ icecast/branches/kh/icecast/src/logging.c	2005-05-15 17:24:44 UTC (rev 9285)
@@ -160,7 +160,7 @@
 /* This function will provide a log of metadata for each
    mountpoint.  The metadata *must* be in UTF-8, and thus
    you can assume that the log itself is UTF-8 encoded */
-void logging_playlist(const char *mount, char *metadata, long listeners)
+void logging_playlist(const char *mount, const char *metadata, long listeners)
 {
     char datebuf[128];
     struct tm thetime;

Modified: icecast/branches/kh/icecast/src/logging.h
===================================================================
--- icecast/branches/kh/icecast/src/logging.h	2005-05-15 16:24:00 UTC (rev 9284)
+++ icecast/branches/kh/icecast/src/logging.h	2005-05-15 17:24:44 UTC (rev 9285)
@@ -89,9 +89,8 @@
 #define LOGGING_FORMAT_CLF "%d/%b/%Y:%H:%M:%S %z"
 
 void logging_access(client_t *client);
-void logging_playlist(const char *mount, char *metadata, long listeners);
+void logging_playlist(const char *mount, const char *metadata, long listeners);
 void restart_logging (ice_config_t *config);
 
 #endif  /* __LOGGING_H__ */
 
-

Modified: icecast/branches/kh/icecast/src/slave.c
===================================================================
--- icecast/branches/kh/icecast/src/slave.c	2005-05-15 16:24:00 UTC (rev 9284)
+++ icecast/branches/kh/icecast/src/slave.c	2005-05-15 17:24:44 UTC (rev 9285)
@@ -114,25 +114,22 @@
 /* force a recheck of the relays. This will recheck the master server if
  * a this is a slave.
  */
-void slave_recheck (void)
+void slave_recheck_mounts (void)
 {
     max_interval = 0;
+    update_settings = 1;
 }
 
-/* rescan the current relays to see if any need starting or if any
- * relay threads have terminated
+
+/* Request slave thread to check the relay list for changes and to
+ * update the stats for the current streams.
  */
-void slave_rescan (void)
+void slave_rebuild_mounts (void)
 {
+    update_settings = 1;
     rescan_relays = 1;
 }
 
-/* kick off a rescan but force a recheck of the mounts afterwards */
-void slave_rebuild (void)
-{
-    update_settings = 1;
-    slave_rescan ();
-}
 
 void slave_initialize(void)
 {
@@ -312,11 +309,10 @@
         {
             /* only keep refreshing YP entries for inactive on-demand relays */
             yp_remove (relay->localmount);
-            update_settings = 1;
         }
         /* initiate an immediate relay cleanup run */
         relay->cleanup = 1;
-        slave_rescan();
+        rescan_relays = 1;
 
         return NULL;
     } while (0);
@@ -344,7 +340,7 @@
 
     /* initiate an immediate relay cleanup run */
     relay->cleanup = 1;
-    slave_rescan();
+    rescan_relays = 1;
 
     return NULL;
 }
@@ -375,11 +371,11 @@
                     yp_add (relay->source);
                 config_release_config ();
                 stats_event (relay->localmount, "listeners", "0");
-                DEBUG0 ("setting on_demand");
+
+                /* on-demand relays can be used as fallback mounts so we need
+                 * to recheck other mountpoints for the xsl pages */
+                slave_rebuild_mounts();
             }
-            /* on-demand relays can be used as fallback mounts so allow
-             * for dependant mountpoints to show up on xsl pages */
-            update_settings = 1;
         }
         else
             WARN1 ("new relay but source \"%s\" already exists", relay->localmount);
@@ -416,7 +412,6 @@
     /* the relay thread may of shut down itself */
     if (relay->cleanup && relay->thread)
     {
-        ice_config_t *config;
         DEBUG1 ("waiting for relay thread for \"%s\"", relay->localmount);
         thread_join (relay->thread);
         relay->thread = NULL;
@@ -426,12 +421,11 @@
 
         if (relay->on_demand)
         {
-            config = config_get_config ();
+            ice_config_t *config = config_get_config ();
             source_update_settings (config, relay->source);
             config_release_config ();
             stats_event (relay->localmount, "listeners", "0");
         }
-        update_settings = 1;
     }
 }
 
@@ -534,7 +528,7 @@
                 DEBUG1 ("source shutdown request on \"%s\"", to_free->localmount);
                 to_free->source->running = 0;
                 thread_join (to_free->thread);
-                update_settings = 1;
+                slave_rebuild_mounts();
             }
             else
                 stats_event (to_free->localmount, NULL, NULL);
@@ -565,10 +559,7 @@
         int len, count = 1;
         int on_demand, send_auth;
 
-        if (config->master_username)
-            username = strdup (config->master_username);
-        else
-            username = strdup ("relay");
+        username = strdup (config->master_username);
         if (config->master_password)
             password = strdup (config->master_password);
 

Modified: icecast/branches/kh/icecast/src/slave.h
===================================================================
--- icecast/branches/kh/icecast/src/slave.h	2005-05-15 16:24:00 UTC (rev 9284)
+++ icecast/branches/kh/icecast/src/slave.h	2005-05-15 17:24:44 UTC (rev 9285)
@@ -43,9 +43,8 @@
 
 void slave_initialize(void);
 void slave_shutdown(void);
-void slave_recheck (void);
-void slave_rescan (void);
-void slave_rebuild (void);
+void slave_recheck_mounts (void);
+void slave_rebuild_mounts (void);
 int slave_redirect (const char *mountpoint, struct _client_tag *client);
 void slave_host_add (struct _client_tag *client, const char *header);
 void slave_host_remove (struct _client_tag *client);

Modified: icecast/branches/kh/icecast/src/source.c
===================================================================
--- icecast/branches/kh/icecast/src/source.c	2005-05-15 16:24:00 UTC (rev 9284)
+++ icecast/branches/kh/icecast/src/source.c	2005-05-15 17:24:44 UTC (rev 9285)
@@ -64,6 +64,7 @@
 static void _parse_audio_info (source_t *source, const char *s);
 static void source_shutdown (source_t *source);
 static void process_listeners (source_t *source, int fast_clients_only, int deletion_expected);
+static int source_free_client (source_t *source, client_t *client);
 #ifdef _WIN32
 #define source_run_script(x,y)  WARN0("on [dis]connect scripts disabled");
 #else
@@ -415,7 +416,7 @@
     if (dest->running == 0 && dest->on_demand && count)
     {
         dest->on_demand_req = 1;
-        slave_rescan();
+        slave_rebuild_mounts();
     }
     thread_mutex_unlock (&dest->lock);
     thread_mutex_unlock (&move_clients_mutex);
@@ -482,12 +483,6 @@
         /* 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 (current >= source->client_stats_update)
         {
             stats_event_args (source->mount, "outgoing_bitrate", "%ld", 
@@ -830,7 +825,7 @@
 
         avl_tree_unlock(global.source_tree);
     }
-    slave_rebuild ();
+    slave_rebuild_mounts ();
     thread_mutex_lock (&source->lock);
     if (source->on_demand == 0 && source->yp_public)
         yp_add (source);
@@ -1111,6 +1106,7 @@
     mount_proxy *mountinfo = config_find_mount (config, source->mount);
     char *str;
 
+    thread_mutex_lock (&source->lock);
     /* set global settings first */
     source->queue_size_limit = config->queue_size_limit;
     source->timeout = config->source_timeout;
@@ -1212,37 +1208,10 @@
     DEBUG1 ("burst size to %u", source->burst_size);
     DEBUG1 ("source timeout to %u", source->timeout);
     DEBUG1 ("fallback_when_full to %u", source->fallback_when_full);
-    source->recheck_settings = 0;
+    thread_mutex_unlock (&source->lock);
 }
 
 
-void source_update (ice_config_t *config)
-{
-    avl_node *node;
-    char limit [20];
-
-    snprintf (limit, sizeof (limit), "%d", config->client_limit);
-    stats_event (NULL, "client_limit", limit);
-    snprintf (limit, sizeof (limit), "%d", config->source_limit);
-    stats_event (NULL, "source_limit", limit);
-
-    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);
-}
-
-
 void *source_client_thread (void *arg)
 {
     source_t *source = arg;
@@ -1268,7 +1237,7 @@
     source_main (source);
     source_free_source (source);
 
-    slave_rebuild ();
+    slave_rebuild_mounts ();
     return NULL;
 }
 

Modified: icecast/branches/kh/icecast/src/source.h
===================================================================
--- icecast/branches/kh/icecast/src/source.h	2005-05-15 16:24:00 UTC (rev 9284)
+++ icecast/branches/kh/icecast/src/source.h	2005-05-15 17:24:44 UTC (rev 9285)
@@ -70,7 +70,6 @@
     int on_demand;
     int on_demand_req;
     int hidden;
-    int recheck_settings;
 
     time_t last_read;
     char *on_connect;
@@ -88,7 +87,6 @@
 source_t *source_reserve (const char *mount);
 void *source_client_thread (void *arg);
 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);
@@ -98,7 +96,6 @@
 void source_move_clients (source_t *source, source_t *dest);
 int source_remove_client(void *key);
 void source_main(source_t *source);
-int source_free_client (source_t *source, client_t *client);
 void source_recheck_mounts (void);
 
 extern mutex_t move_clients_mutex;



More information about the commits mailing list