mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
merge work. mainly stats and some log message updates
svn path=/icecast/trunk/icecast/; revision=14031
This commit is contained in:
parent
27f58c1189
commit
148af4e6ee
@ -161,10 +161,9 @@ static unsigned long _next_connection_id(void)
|
|||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENSSL
|
#ifdef HAVE_OPENSSL
|
||||||
static void get_ssl_certificate ()
|
static void get_ssl_certificate (ice_config_t *config)
|
||||||
{
|
{
|
||||||
SSL_METHOD *method;
|
SSL_METHOD *method;
|
||||||
ice_config_t *config;
|
|
||||||
ssl_ok = 0;
|
ssl_ok = 0;
|
||||||
|
|
||||||
SSL_load_error_strings(); /* readable error messages */
|
SSL_load_error_strings(); /* readable error messages */
|
||||||
@ -173,7 +172,6 @@ static void get_ssl_certificate ()
|
|||||||
method = SSLv23_server_method();
|
method = SSLv23_server_method();
|
||||||
ssl_ctx = SSL_CTX_new (method);
|
ssl_ctx = SSL_CTX_new (method);
|
||||||
|
|
||||||
config = config_get_config ();
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (config->cert_file == NULL)
|
if (config->cert_file == NULL)
|
||||||
@ -190,15 +188,13 @@ static void get_ssl_certificate ()
|
|||||||
}
|
}
|
||||||
if (!SSL_CTX_check_private_key (ssl_ctx))
|
if (!SSL_CTX_check_private_key (ssl_ctx))
|
||||||
{
|
{
|
||||||
ERROR0 ("Invalid icecast.pem - Private key doesn't"
|
ERROR1 ("Invalid %s - Private key does not match cert public key", config->cert_file);
|
||||||
" match cert public key");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ssl_ok = 1;
|
ssl_ok = 1;
|
||||||
INFO1 ("SSL certificate found at %s", config->cert_file);
|
INFO1 ("SSL certificate found at %s", config->cert_file);
|
||||||
|
return;
|
||||||
} while (0);
|
} 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
|
#else
|
||||||
|
|
||||||
/* SSL not compiled in, so at least log it */
|
/* 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;
|
ssl_ok = 0;
|
||||||
INFO0 ("No SSL capability");
|
INFO0 ("No SSL capability");
|
||||||
@ -313,7 +309,7 @@ void connection_uses_ssl (connection_t *con)
|
|||||||
static int wait_for_serversock(int timeout)
|
static int wait_for_serversock(int timeout)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_POLL
|
#ifdef HAVE_POLL
|
||||||
struct pollfd ufds[MAX_LISTEN_SOCKETS];
|
struct pollfd ufds [global.server_sockets];
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
for(i=0; i < global.server_sockets; i++) {
|
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)
|
void connection_accept_loop(void)
|
||||||
{
|
{
|
||||||
connection_t *con;
|
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);
|
tid = thread_create ("connection thread", _handle_connection, NULL, THREAD_ATTACHED);
|
||||||
|
|
||||||
while (global.running == ICE_RUNNING)
|
while (global.running == ICE_RUNNING)
|
||||||
@ -600,6 +600,8 @@ void connection_accept_loop(void)
|
|||||||
{
|
{
|
||||||
global_unlock();
|
global_unlock();
|
||||||
client_send_403 (client, "Icecast connection limit reached");
|
client_send_403 (client, "Icecast connection limit reached");
|
||||||
|
/* don't be too eager as this is an imposed hard limit */
|
||||||
|
thread_sleep (400000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
global_unlock();
|
global_unlock();
|
||||||
|
@ -67,7 +67,7 @@ void event_config_read(void *arg)
|
|||||||
fserve_recheck_mime_types (config);
|
fserve_recheck_mime_types (config);
|
||||||
stats_global (config);
|
stats_global (config);
|
||||||
config_release_config();
|
config_release_config();
|
||||||
slave_recheck_all();
|
slave_update_all_mounts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
25
src/slave.c
25
src/slave.c
@ -64,7 +64,7 @@ static void *_slave_thread(void *arg);
|
|||||||
static thread_type *_slave_thread_id;
|
static thread_type *_slave_thread_id;
|
||||||
static int slave_running = 0;
|
static int slave_running = 0;
|
||||||
static volatile int update_settings = 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;
|
static volatile unsigned int max_interval = 0;
|
||||||
|
|
||||||
relay_server *relay_free (relay_server *relay)
|
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
|
/* 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;
|
max_interval = 0;
|
||||||
update_streams = 1;
|
update_all_mounts = 1;
|
||||||
update_settings = 1;
|
update_settings = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,6 +342,7 @@ static void *start_relay_stream (void *arg)
|
|||||||
yp_remove (relay->localmount);
|
yp_remove (relay->localmount);
|
||||||
relay->source->yp_public = -1;
|
relay->source->yp_public = -1;
|
||||||
relay->start = time(NULL) + 10; /* prevent busy looping if failing */
|
relay->start = time(NULL) + 10; /* prevent busy looping if failing */
|
||||||
|
slave_update_all_mounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we've finished, now get cleaned up */
|
/* 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);
|
relay->source = source_reserve (relay->localmount);
|
||||||
if (relay->source)
|
if (relay->source)
|
||||||
{
|
{
|
||||||
ice_config_t *config;
|
|
||||||
DEBUG1("Adding relay source at mountpoint \"%s\"", relay->localmount);
|
DEBUG1("Adding relay source at mountpoint \"%s\"", relay->localmount);
|
||||||
config = config_get_config();
|
if (relay->on_demand)
|
||||||
stats_event_args (relay->localmount, "listenurl", "http://%s:%d%s",
|
slave_update_all_mounts();
|
||||||
config->hostname, config->port, relay->localmount);
|
|
||||||
config_release_config();
|
|
||||||
stats_event (relay->localmount, "listeners", "0");
|
|
||||||
slave_rebuild_mounts();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
WARN1 ("new relay but source \"%s\" already exists", relay->localmount);
|
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 */
|
/* skip relay if active, not configured or just not time yet */
|
||||||
if (relay->source == NULL || relay->running || relay->start > time(NULL))
|
if (relay->source == NULL || relay->running || relay->start > time(NULL))
|
||||||
break;
|
break;
|
||||||
|
/* check if an inactive on-demand relay has a fallback that has listeners */
|
||||||
if (relay->on_demand && source->on_demand_req == 0)
|
if (relay->on_demand && source->on_demand_req == 0)
|
||||||
{
|
{
|
||||||
relay->source->on_demand = relay->on_demand;
|
relay->source->on_demand = relay->on_demand;
|
||||||
@ -685,7 +682,7 @@ static void *_slave_thread(void *arg)
|
|||||||
unsigned int interval = 0;
|
unsigned int interval = 0;
|
||||||
|
|
||||||
update_settings = 0;
|
update_settings = 0;
|
||||||
update_streams = 0;
|
update_all_mounts = 0;
|
||||||
|
|
||||||
config = config_get_config();
|
config = config_get_config();
|
||||||
stats_global (config);
|
stats_global (config);
|
||||||
@ -740,9 +737,9 @@ static void *_slave_thread(void *arg)
|
|||||||
|
|
||||||
if (update_settings)
|
if (update_settings)
|
||||||
{
|
{
|
||||||
source_recheck_mounts (update_streams);
|
source_recheck_mounts (update_all_mounts);
|
||||||
update_settings = 0;
|
update_settings = 0;
|
||||||
update_streams = 0;
|
update_all_mounts = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
INFO0 ("shutting down current relays");
|
INFO0 ("shutting down current relays");
|
||||||
|
@ -35,7 +35,7 @@ typedef struct _relay_server {
|
|||||||
|
|
||||||
void slave_initialize(void);
|
void slave_initialize(void);
|
||||||
void slave_shutdown(void);
|
void slave_shutdown(void);
|
||||||
void slave_recheck_all (void);
|
void slave_update_all_mounts (void);
|
||||||
void slave_rebuild_mounts (void);
|
void slave_rebuild_mounts (void);
|
||||||
relay_server *relay_free (relay_server *relay);
|
relay_server *relay_free (relay_server *relay);
|
||||||
|
|
||||||
|
20
src/source.c
20
src/source.c
@ -1164,6 +1164,9 @@ void source_update_settings (ice_config_t *config, source_t *source, mount_proxy
|
|||||||
source->timeout = config->source_timeout;
|
source->timeout = config->source_timeout;
|
||||||
source->burst_size = config->burst_size;
|
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);
|
source_apply_mount (source, mountinfo);
|
||||||
|
|
||||||
if (source->fallback_mount)
|
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");
|
DEBUG0 ("on_demand set");
|
||||||
stats_event (source->mount, "on_demand", "1");
|
stats_event (source->mount, "on_demand", "1");
|
||||||
|
stats_event_args (source->mount, "listeners", "%ld", source->listeners);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
stats_event (source->mount, "on_demand", NULL);
|
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)
|
if (source->hidden)
|
||||||
{
|
{
|
||||||
stats_event_hidden (source->mount, NULL, 1);
|
stats_event_hidden (source->mount, NULL, 1);
|
||||||
DEBUG0 ("hidden from xsl");
|
DEBUG0 ("hidden from public");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
stats_event_hidden (source->mount, NULL, 0);
|
stats_event_hidden (source->mount, NULL, 0);
|
||||||
@ -1316,7 +1320,7 @@ static void *source_fallback_file (void *arg)
|
|||||||
file = fopen (path, "rb");
|
file = fopen (path, "rb");
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
{
|
{
|
||||||
DEBUG1 ("unable to open file \"%s\"", path);
|
WARN1 ("unable to open file \"%s\"", path);
|
||||||
free (path);
|
free (path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1324,9 +1328,10 @@ static void *source_fallback_file (void *arg)
|
|||||||
source = source_reserve (mount);
|
source = source_reserve (mount);
|
||||||
if (source == NULL)
|
if (source == NULL)
|
||||||
{
|
{
|
||||||
DEBUG1 ("mountpoint \"%s\" already reserved", mount);
|
WARN1 ("mountpoint \"%s\" already reserved", mount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
INFO1 ("mountpoint %s is reserved", mount);
|
||||||
type = fserve_content_type (mount);
|
type = fserve_content_type (mount);
|
||||||
parser = httpp_create_parser();
|
parser = httpp_create_parser();
|
||||||
httpp_initialize (parser, NULL);
|
httpp_initialize (parser, NULL);
|
||||||
@ -1361,6 +1366,7 @@ void source_recheck_mounts (int update_all)
|
|||||||
|
|
||||||
avl_tree_rlock (global.source_tree);
|
avl_tree_rlock (global.source_tree);
|
||||||
|
|
||||||
|
if (update_all)
|
||||||
stats_clear_virtual_mounts ();
|
stats_clear_virtual_mounts ();
|
||||||
|
|
||||||
while (mount)
|
while (mount)
|
||||||
@ -1370,16 +1376,16 @@ void source_recheck_mounts (int update_all)
|
|||||||
if (source)
|
if (source)
|
||||||
{
|
{
|
||||||
source = source_find_mount_raw (mount->mountname);
|
source = source_find_mount_raw (mount->mountname);
|
||||||
stats_event_args (mount->mountname, "listenurl", "http://%s:%d%s",
|
if (source)
|
||||||
config->hostname, config->port, mount->mountname);
|
|
||||||
if (source && update_all)
|
|
||||||
{
|
{
|
||||||
mount_proxy *mountinfo = config_find_mount (config, source->mount);
|
mount_proxy *mountinfo = config_find_mount (config, source->mount);
|
||||||
source_update_settings (config, source, mountinfo);
|
source_update_settings (config, source, mountinfo);
|
||||||
}
|
}
|
||||||
else
|
else if (update_all)
|
||||||
{
|
{
|
||||||
stats_event_hidden (mount->mountname, NULL, mount->hidden);
|
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");
|
stats_event (mount->mountname, "listeners", "0");
|
||||||
if (mount->max_listeners < 0)
|
if (mount->max_listeners < 0)
|
||||||
stats_event (mount->mountname, "max_listeners", "unlimited");
|
stats_event (mount->mountname, "max_listeners", "unlimited");
|
||||||
|
Loading…
Reference in New Issue
Block a user