[xiph-commits] r9240 - icecast/trunk/icecast/src

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Sun May 8 04:54:52 PDT 2005


Author: karl
Date: 2005-05-08 04:54:46 -0700 (Sun, 08 May 2005)
New Revision: 9240

Modified:
   icecast/trunk/icecast/src/cfgfile.c
   icecast/trunk/icecast/src/cfgfile.h
   icecast/trunk/icecast/src/connection.c
   icecast/trunk/icecast/src/connection.h
   icecast/trunk/icecast/src/source.c
Log:
add function to do mount list search (could be extended later), call it from
various places including the shoutcast source client auth which previously
only used the global source password.


Modified: icecast/trunk/icecast/src/cfgfile.c
===================================================================
--- icecast/trunk/icecast/src/cfgfile.c	2005-05-08 07:33:48 UTC (rev 9239)
+++ icecast/trunk/icecast/src/cfgfile.c	2005-05-08 11:54:46 UTC (rev 9240)
@@ -979,3 +979,17 @@
 }
 
 
+/* return the mount details that match the supplied mountpoint */
+mount_proxy *config_find_mount (ice_config_t *config, const char *mount)
+{
+    mount_proxy *mountinfo = config->mounts;
+
+    while (mountinfo)
+    {
+        if (strcmp (mountinfo->mountname, mount) == 0)
+            break;
+        mountinfo = mountinfo->next;
+    }
+    return mountinfo;
+}
+

Modified: icecast/trunk/icecast/src/cfgfile.h
===================================================================
--- icecast/trunk/icecast/src/cfgfile.h	2005-05-08 07:33:48 UTC (rev 9239)
+++ icecast/trunk/icecast/src/cfgfile.h	2005-05-08 11:54:46 UTC (rev 9240)
@@ -160,6 +160,7 @@
 int config_parse_cmdline(int arg, char **argv);
 void config_set_config(ice_config_t *config);
 void config_clear(ice_config_t *config);
+mount_proxy *config_find_mount (ice_config_t *config, const char *mount);
 
 int config_rehash(void);
 

Modified: icecast/trunk/icecast/src/connection.c
===================================================================
--- icecast/trunk/icecast/src/connection.c	2005-05-08 07:33:48 UTC (rev 9239)
+++ icecast/trunk/icecast/src/connection.c	2005-05-08 11:54:46 UTC (rev 9240)
@@ -449,7 +449,7 @@
     if (global.sources < config->source_limit)
     {
         char *contenttype;
-        mount_proxy *mountproxy = config->mounts;
+        mount_proxy *mountproxy;
         format_type_t format_type;
 
         /* setup format handler */
@@ -516,15 +516,10 @@
             }
         }
 
-        while (mountproxy)
-        {
-            if (strcmp (mountproxy->mountname, source->mount) == 0)
-            {
-                source_apply_mount (source, mountproxy);
-                break;
-            }
-            mountproxy = mountproxy->next;
-        }
+        mountproxy = config_find_mount (config, source->mount);
+        if (mountproxy)
+            source_apply_mount (source, mountproxy);
+
         config_release_config();
 
         source->shutdown_rwlock = &_source_shutdown_rwlock;
@@ -651,7 +646,7 @@
     return ret;
 }
 
-int connection_check_source_pass(http_parser_t *parser, char *mount)
+int connection_check_source_pass(http_parser_t *parser, const char *mount)
 {
     ice_config_t *config = config_get_config();
     char *pass = config->source_password;
@@ -660,22 +655,16 @@
     int ice_login = config->ice_login;
     char *protocol;
 
-    mount_proxy *mountinfo = config->mounts;
-    thread_mutex_lock(&(config_locks()->mounts_lock));
+    mount_proxy *mountinfo = config_find_mount (config, mount);
 
-    while(mountinfo) {
-        if(!strcmp(mountinfo->mountname, mount)) {
-            if(mountinfo->password)
-                pass = mountinfo->password;
-            if(mountinfo->username)
-                user = mountinfo->username;
-            break;
-        }
-        mountinfo = mountinfo->next;
+    if (mountinfo)
+    {
+        if (mountinfo->password)
+            pass = mountinfo->password;
+        if (mountinfo->username)
+            user = mountinfo->username;
     }
 
-    thread_mutex_unlock(&(config_locks()->mounts_lock));
-
     if(!pass) {
         WARN0("No source password set, rejecting source");
         config_release_config();
@@ -1081,7 +1070,11 @@
                     config = config_get_config();
                     if (config->listeners[i].shoutcast_compat) {
                         char *shoutcast_mount = strdup (config->shoutcast_mount);
-                        source_password = strdup(config->source_password);
+                        mount_proxy *mountinfo = config_find_mount (config, config->shoutcast_mount);
+                        if (mountinfo && mountinfo->password)
+                            source_password = strdup (mountinfo->password);
+                        else
+                            source_password = strdup (config->source_password);
                         config_release_config();
                         _handle_shoutcast_compatible(con, shoutcast_mount, source_password);
                         free(source_password);

Modified: icecast/trunk/icecast/src/connection.h
===================================================================
--- icecast/trunk/icecast/src/connection.h	2005-05-08 07:33:48 UTC (rev 9239)
+++ icecast/trunk/icecast/src/connection.h	2005-05-08 11:54:46 UTC (rev 9240)
@@ -52,7 +52,7 @@
 
 void connection_inject_event(int eventnum, void *event_data);
 
-int connection_check_source_pass(http_parser_t *parser, char *mount);
+int connection_check_source_pass(http_parser_t *parser, const char *mount);
 int connection_check_relay_pass(http_parser_t *parser);
 int connection_check_admin_pass(http_parser_t *parser);
 

Modified: icecast/trunk/icecast/src/source.c
===================================================================
--- icecast/trunk/icecast/src/source.c	2005-05-08 07:33:48 UTC (rev 9239)
+++ icecast/trunk/icecast/src/source.c	2005-05-08 11:54:46 UTC (rev 9240)
@@ -147,34 +147,22 @@
     int depth = 0;
 
     config = config_get_config();
-    while (mount != NULL)
+    while (mount && depth < MAX_FALLBACK_DEPTH)
     {
-        /* limit the number of times through, maybe infinite */
-        if (depth > MAX_FALLBACK_DEPTH)
-        {
-            source = NULL;
-            break;
-        }
-
         source = source_find_mount_raw(mount);
 
         if (source != NULL && source->running)
             break;
 
-        /* source is not running, meaning that the fallback is not configured
-           within the source, we need to check the mount list */
-        mountinfo = config->mounts;
+        /* we either have a source which is not active (relay) or no source
+         * at all. Check the mounts list for fallback settings
+         */
+        mountinfo = config_find_mount (config, mount);
         source = NULL;
-        while (mountinfo)
-        {
-            if (strcmp (mountinfo->mountname, mount) == 0)
-                break;
-            mountinfo = mountinfo->next;
-        }
-        if (mountinfo)
-            mount = mountinfo->fallback_mount;
-        else
-            mount = NULL;
+
+        if (mountinfo == NULL)
+            break;
+        mount = mountinfo->fallback_mount;
         depth++;
     }
 



More information about the commits mailing list