Commit 148af4e6 authored by Karl Heyes's avatar Karl Heyes

merge work. mainly stats and some log message updates

svn path=/icecast/trunk/icecast/; revision=14031
parent 27f58c11
......@@ -161,10 +161,9 @@ static unsigned long _next_connection_id(void)
#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 @@ static void get_ssl_certificate ()
method = SSLv23_server_method();
ssl_ctx = SSL_CTX_new (method);
config = config_get_config ();
do
{
if (config->cert_file == NULL)
......@@ -190,16 +188,14 @@ static void get_ssl_certificate ()
}
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 @@ static int connection_send_ssl (connection_t *con, const void *buf, size_t len)
#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 @@ void connection_uses_ssl (connection_t *con)
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 @@ static void _add_request_queue (client_queue_t *node)
void connection_accept_loop(void)
{
connection_t *con;
ice_config_t *config;
config = config_get_config ();
get_ssl_certificate (config);
config_release_config ();
get_ssl_certificate ();
tid = thread_create ("connection thread", _handle_connection, NULL, THREAD_ATTACHED);
while (global.running == ICE_RUNNING)
......@@ -600,6 +600,8 @@ void connection_accept_loop(void)
{
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();
......
......@@ -67,7 +67,7 @@ void event_config_read(void *arg)
fserve_recheck_mime_types (config);
stats_global (config);
config_release_config();
slave_recheck_all();
slave_update_all_mounts();
}
}
......@@ -64,7 +64,7 @@ static void *_slave_thread(void *arg);
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 @@ relay_server *relay_copy (relay_server *r)
/* 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 @@ static void *start_relay_stream (void *arg)
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 @@ static void check_relay_stream (relay_server *relay)
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 @@ static void check_relay_stream (relay_server *relay)
/* 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 @@ static void *_slave_thread(void *arg)
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 @@ static void *_slave_thread(void *arg)
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");
......
......@@ -35,7 +35,7 @@ typedef struct _relay_server {
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);
......
......@@ -1164,6 +1164,9 @@ void source_update_settings (ice_config_t *config, source_t *source, mount_proxy
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 @@ void source_update_settings (ice_config_t *config, source_t *source, mount_proxy
{
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 @@ void source_update_settings (ice_config_t *config, source_t *source, mount_proxy
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 @@ static void *source_fallback_file (void *arg)
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 @@ static void *source_fallback_file (void *arg)
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 @@ void source_recheck_mounts (int update_all)
avl_tree_rlock (global.source_tree);
stats_clear_virtual_mounts ();
if (update_all)
stats_clear_virtual_mounts ();
while (mount)
{
......@@ -1370,16 +1376,16 @@ void source_recheck_mounts (int update_all)
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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment