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

karl at svn.xiph.org karl at svn.xiph.org
Sun Oct 21 19:29:49 PDT 2007


Author: karl
Date: 2007-10-21 19:29:49 -0700 (Sun, 21 Oct 2007)
New Revision: 14031

Modified:
   icecast/trunk/icecast/src/connection.c
   icecast/trunk/icecast/src/event.c
   icecast/trunk/icecast/src/slave.c
   icecast/trunk/icecast/src/slave.h
   icecast/trunk/icecast/src/source.c
Log:
merge work. mainly stats and some log message updates


Modified: icecast/trunk/icecast/src/connection.c
===================================================================
--- icecast/trunk/icecast/src/connection.c	2007-10-22 02:23:10 UTC (rev 14030)
+++ icecast/trunk/icecast/src/connection.c	2007-10-22 02:29:49 UTC (rev 14031)
@@ -161,10 +161,9 @@
 
 
 #ifdef HAVE_OPENSSL
-static void get_ssl_certificate ()
+static void get_ssl_certificate (ice_config_t *config)
 {
     SSL_METHOD *method;
-    ice_config_t *config;
     ssl_ok = 0;
 
     SSL_load_error_strings();                /* readable error messages */
@@ -173,7 +172,6 @@
     method = SSLv23_server_method();
     ssl_ctx = SSL_CTX_new (method);
 
-    config = config_get_config ();
     do
     {
         if (config->cert_file == NULL)
@@ -190,16 +188,14 @@
         }
         if (!SSL_CTX_check_private_key (ssl_ctx))
         {
-            ERROR0 ("Invalid icecast.pem - Private key doesn't"
-                    " match cert public key");
+            ERROR1 ("Invalid %s - Private key does not match cert public key", config->cert_file);
             break;
         }
         ssl_ok = 1;
         INFO1 ("SSL certificate found at %s", config->cert_file);
+        return;
     } while (0);
-    config_release_config ();
-    if (ssl_ok == 0)
-        INFO0 ("No SSL capability on any configured ports");
+    INFO0 ("No SSL capability on any configured ports");
 }
 
 
@@ -244,7 +240,7 @@
 #else
 
 /* SSL not compiled in, so at least log it */
-static void get_ssl_certificate ()
+static void get_ssl_certificate (ice_config_t *config)
 {
     ssl_ok = 0;
     INFO0 ("No SSL capability");
@@ -313,7 +309,7 @@
 static int wait_for_serversock(int timeout)
 {
 #ifdef HAVE_POLL
-    struct pollfd ufds[MAX_LISTEN_SOCKETS];
+    struct pollfd ufds [global.server_sockets];
     int i, ret;
 
     for(i=0; i < global.server_sockets; i++) {
@@ -580,8 +576,12 @@
 void connection_accept_loop(void)
 {
     connection_t *con;
+    ice_config_t *config;
 
-    get_ssl_certificate ();
+    config = config_get_config ();
+    get_ssl_certificate (config);
+    config_release_config ();
+
     tid = thread_create ("connection thread", _handle_connection, NULL, THREAD_ATTACHED);
 
     while (global.running == ICE_RUNNING)
@@ -600,6 +600,8 @@
             {
                 global_unlock();
                 client_send_403 (client, "Icecast connection limit reached");
+                /* don't be too eager as this is an imposed hard limit */
+                thread_sleep (400000);
                 continue;
             }
             global_unlock();

Modified: icecast/trunk/icecast/src/event.c
===================================================================
--- icecast/trunk/icecast/src/event.c	2007-10-22 02:23:10 UTC (rev 14030)
+++ icecast/trunk/icecast/src/event.c	2007-10-22 02:29:49 UTC (rev 14031)
@@ -67,7 +67,7 @@
         fserve_recheck_mime_types (config);
         stats_global (config);
         config_release_config();
-        slave_recheck_all();
+        slave_update_all_mounts();
     }
 }
 

Modified: icecast/trunk/icecast/src/slave.c
===================================================================
--- icecast/trunk/icecast/src/slave.c	2007-10-22 02:23:10 UTC (rev 14030)
+++ icecast/trunk/icecast/src/slave.c	2007-10-22 02:29:49 UTC (rev 14031)
@@ -64,7 +64,7 @@
 static thread_type *_slave_thread_id;
 static int slave_running = 0;
 static volatile int update_settings = 0;
-static volatile int update_streams = 0;
+static volatile int update_all_mounts = 0;
 static volatile unsigned int max_interval = 0;
 
 relay_server *relay_free (relay_server *relay)
@@ -107,12 +107,12 @@
 
 
 /* force a recheck of the relays. This will recheck the master server if
- * a this is a slave.
+ * this is a slave and rebuild all mountpoints in the stats tree
  */
-void slave_recheck_all (void)
+void slave_update_all_mounts (void)
 {
     max_interval = 0;
-    update_streams = 1;
+    update_all_mounts = 1;
     update_settings = 1;
 }
 
@@ -342,6 +342,7 @@
             yp_remove (relay->localmount);
             relay->source->yp_public = -1;
             relay->start = time(NULL) + 10; /* prevent busy looping if failing */
+            slave_update_all_mounts();
         }
 
         /* we've finished, now get cleaned up */
@@ -390,14 +391,9 @@
         relay->source = source_reserve (relay->localmount);
         if (relay->source)
         {
-            ice_config_t *config;
             DEBUG1("Adding relay source at mountpoint \"%s\"", relay->localmount);
-            config = config_get_config();
-            stats_event_args (relay->localmount, "listenurl", "http://%s:%d%s",
-                    config->hostname, config->port, relay->localmount);
-            config_release_config();
-            stats_event (relay->localmount, "listeners", "0");
-            slave_rebuild_mounts();
+            if (relay->on_demand)
+                slave_update_all_mounts();
         }
         else
             WARN1 ("new relay but source \"%s\" already exists", relay->localmount);
@@ -408,6 +404,7 @@
         /* skip relay if active, not configured or just not time yet */
         if (relay->source == NULL || relay->running || relay->start > time(NULL))
             break;
+        /* check if an inactive on-demand relay has a fallback that has listeners */
         if (relay->on_demand && source->on_demand_req == 0)
         {
             relay->source->on_demand = relay->on_demand;
@@ -685,7 +682,7 @@
     unsigned int interval = 0;
 
     update_settings = 0;
-    update_streams = 0;
+    update_all_mounts = 0;
 
     config = config_get_config();
     stats_global (config);
@@ -740,9 +737,9 @@
 
         if (update_settings)
         {
-            source_recheck_mounts (update_streams);
+            source_recheck_mounts (update_all_mounts);
             update_settings = 0;
-            update_streams = 0;
+            update_all_mounts = 0;
         }
     }
     INFO0 ("shutting down current relays");

Modified: icecast/trunk/icecast/src/slave.h
===================================================================
--- icecast/trunk/icecast/src/slave.h	2007-10-22 02:23:10 UTC (rev 14030)
+++ icecast/trunk/icecast/src/slave.h	2007-10-22 02:29:49 UTC (rev 14031)
@@ -35,7 +35,7 @@
 
 void slave_initialize(void);
 void slave_shutdown(void);
-void slave_recheck_all (void);
+void slave_update_all_mounts (void);
 void slave_rebuild_mounts (void);
 relay_server *relay_free (relay_server *relay);
 

Modified: icecast/trunk/icecast/src/source.c
===================================================================
--- icecast/trunk/icecast/src/source.c	2007-10-22 02:23:10 UTC (rev 14030)
+++ icecast/trunk/icecast/src/source.c	2007-10-22 02:29:49 UTC (rev 14031)
@@ -1164,6 +1164,9 @@
     source->timeout = config->source_timeout;
     source->burst_size = config->burst_size;
 
+    stats_event_args (source->mount, "listenurl", "http://%s:%d%s",
+            config->hostname, config->port, source->mount);
+
     source_apply_mount (source, mountinfo);
 
     if (source->fallback_mount)
@@ -1180,6 +1183,7 @@
     {
         DEBUG0 ("on_demand set");
         stats_event (source->mount, "on_demand", "1");
+        stats_event_args (source->mount, "listeners", "%ld", source->listeners);
     }
     else
         stats_event (source->mount, "on_demand", NULL);
@@ -1187,7 +1191,7 @@
     if (source->hidden)
     {
         stats_event_hidden (source->mount, NULL, 1);
-        DEBUG0 ("hidden from xsl");
+        DEBUG0 ("hidden from public");
     }
     else
         stats_event_hidden (source->mount, NULL, 0);
@@ -1316,7 +1320,7 @@
         file = fopen (path, "rb");
         if (file == NULL)
         {
-            DEBUG1 ("unable to open file \"%s\"", path);
+            WARN1 ("unable to open file \"%s\"", path);
             free (path);
             break;
         }
@@ -1324,9 +1328,10 @@
         source = source_reserve (mount);
         if (source == NULL)
         {
-            DEBUG1 ("mountpoint \"%s\" already reserved", mount);
+            WARN1 ("mountpoint \"%s\" already reserved", mount);
             break;
         }
+        INFO1 ("mountpoint %s is reserved", mount);
         type = fserve_content_type (mount);
         parser = httpp_create_parser();
         httpp_initialize (parser, NULL);
@@ -1361,7 +1366,8 @@
 
     avl_tree_rlock (global.source_tree);
 
-    stats_clear_virtual_mounts ();
+    if (update_all)
+        stats_clear_virtual_mounts ();
 
     while (mount)
     {
@@ -1370,16 +1376,16 @@
         if (source)
         {
             source = source_find_mount_raw (mount->mountname);
-            stats_event_args (mount->mountname, "listenurl", "http://%s:%d%s",
-                    config->hostname, config->port, mount->mountname);
-            if (source && update_all)
+            if (source)
             {
                 mount_proxy *mountinfo = config_find_mount (config, source->mount);
                 source_update_settings (config, source, mountinfo);
             }
-            else
+            else if (update_all)
             {
                 stats_event_hidden (mount->mountname, NULL, mount->hidden);
+                stats_event_args (mount->mountname, "listenurl", "http://%s:%d%s",
+                        config->hostname, config->port, mount->mountname);
                 stats_event (mount->mountname, "listeners", "0");
                 if (mount->max_listeners < 0)
                     stats_event (mount->mountname, "max_listeners", "unlimited");



More information about the commits mailing list