mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Triggers for source stats updated. No point updating all source stats if fewer
need updating. Fixes a few unusual cases, if a mount was removed (with xml reload) whilst no source was reserved then those stats were left behind. svn path=/icecast/trunk/icecast/; revision=13538
This commit is contained in:
parent
2a0c3cdefa
commit
bb0b1a2a32
@ -564,10 +564,9 @@ int connection_complete_source (source_t *source, int response)
|
|||||||
|
|
||||||
source->running = 1;
|
source->running = 1;
|
||||||
mountinfo = config_find_mount (config, source->mount);
|
mountinfo = config_find_mount (config, source->mount);
|
||||||
if (mountinfo == NULL)
|
source_update_settings (config, source, mountinfo);
|
||||||
source_update_settings (config, source, mountinfo);
|
|
||||||
source_recheck_mounts ();
|
|
||||||
config_release_config();
|
config_release_config();
|
||||||
|
slave_rebuild_mounts();
|
||||||
|
|
||||||
source->shutdown_rwlock = &_source_shutdown_rwlock;
|
source->shutdown_rwlock = &_source_shutdown_rwlock;
|
||||||
DEBUG0 ("source is ready to start");
|
DEBUG0 ("source is ready to start");
|
||||||
|
@ -63,7 +63,7 @@ void event_config_read(void *arg)
|
|||||||
yp_recheck_config (config_get_config_unlocked());
|
yp_recheck_config (config_get_config_unlocked());
|
||||||
|
|
||||||
config_release_config();
|
config_release_config();
|
||||||
slave_recheck_mounts();
|
slave_recheck_all();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
27
src/slave.c
27
src/slave.c
@ -63,7 +63,8 @@
|
|||||||
static void *_slave_thread(void *arg);
|
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 int update_settings = 0;
|
static volatile int update_settings = 0;
|
||||||
|
static volatile int update_streams = 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)
|
||||||
@ -108,9 +109,10 @@ 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.
|
* a this is a slave.
|
||||||
*/
|
*/
|
||||||
void slave_recheck_mounts (void)
|
void slave_recheck_all (void)
|
||||||
{
|
{
|
||||||
max_interval = 0;
|
max_interval = 0;
|
||||||
|
update_streams = 1;
|
||||||
update_settings = 1;
|
update_settings = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,7 +303,6 @@ static void *start_relay_stream (void *arg)
|
|||||||
relay_server *relay = arg;
|
relay_server *relay = arg;
|
||||||
source_t *src = relay->source;
|
source_t *src = relay->source;
|
||||||
client_t *client;
|
client_t *client;
|
||||||
ice_config_t *config;
|
|
||||||
|
|
||||||
INFO1("Starting relayed source at mountpoint \"%s\"", relay->localmount);
|
INFO1("Starting relayed source at mountpoint \"%s\"", relay->localmount);
|
||||||
do
|
do
|
||||||
@ -324,10 +325,6 @@ static void *start_relay_stream (void *arg)
|
|||||||
}
|
}
|
||||||
stats_event_inc(NULL, "source_relay_connections");
|
stats_event_inc(NULL, "source_relay_connections");
|
||||||
stats_event (relay->localmount, "source_ip", client->con->ip);
|
stats_event (relay->localmount, "source_ip", client->con->ip);
|
||||||
config = config_get_config();
|
|
||||||
stats_event_args (relay->localmount, "listenurl", "http://%s:%d%s",
|
|
||||||
config->hostname, config->port, relay->localmount);
|
|
||||||
config_release_config();
|
|
||||||
|
|
||||||
source_main (relay->source);
|
source_main (relay->source);
|
||||||
|
|
||||||
@ -341,6 +338,7 @@ static void *start_relay_stream (void *arg)
|
|||||||
|
|
||||||
/* we've finished, now get cleaned up */
|
/* we've finished, now get cleaned up */
|
||||||
relay->cleanup = 1;
|
relay->cleanup = 1;
|
||||||
|
slave_rebuild_mounts();
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
} while (0); /* TODO allow looping through multiple servers */
|
} while (0); /* TODO allow looping through multiple servers */
|
||||||
@ -384,7 +382,13 @@ 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();
|
||||||
|
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();
|
slave_rebuild_mounts();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -547,7 +551,6 @@ static void relay_check_streams (relay_server *to_start,
|
|||||||
to_free->running = 0;
|
to_free->running = 0;
|
||||||
to_free->source->running = 0;
|
to_free->source->running = 0;
|
||||||
thread_join (to_free->thread);
|
thread_join (to_free->thread);
|
||||||
slave_rebuild_mounts();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
stats_event (to_free->localmount, NULL, NULL);
|
stats_event (to_free->localmount, NULL, NULL);
|
||||||
@ -673,7 +676,10 @@ static void *_slave_thread(void *arg)
|
|||||||
ice_config_t *config;
|
ice_config_t *config;
|
||||||
unsigned int interval = 0;
|
unsigned int interval = 0;
|
||||||
|
|
||||||
source_recheck_mounts();
|
update_settings = 0;
|
||||||
|
update_streams = 0;
|
||||||
|
|
||||||
|
source_recheck_mounts (1);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@ -723,8 +729,9 @@ static void *_slave_thread(void *arg)
|
|||||||
|
|
||||||
if (update_settings)
|
if (update_settings)
|
||||||
{
|
{
|
||||||
|
source_recheck_mounts (update_streams);
|
||||||
update_settings = 0;
|
update_settings = 0;
|
||||||
source_recheck_mounts();
|
update_streams = 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_mounts (void);
|
void slave_recheck_all (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);
|
||||||
|
|
||||||
|
13
src/source.c
13
src/source.c
@ -424,10 +424,7 @@ void source_move_clients (source_t *source, source_t *dest)
|
|||||||
|
|
||||||
/* see if we need to wake up an on-demand relay */
|
/* see if we need to wake up an on-demand relay */
|
||||||
if (dest->running == 0 && dest->on_demand && count)
|
if (dest->running == 0 && dest->on_demand && count)
|
||||||
{
|
|
||||||
dest->on_demand_req = 1;
|
dest->on_demand_req = 1;
|
||||||
slave_rebuild_mounts();
|
|
||||||
}
|
|
||||||
|
|
||||||
avl_tree_unlock (dest->pending_tree);
|
avl_tree_unlock (dest->pending_tree);
|
||||||
thread_mutex_unlock (&move_clients_mutex);
|
thread_mutex_unlock (&move_clients_mutex);
|
||||||
@ -1211,7 +1208,7 @@ void *source_client_thread (void *arg)
|
|||||||
source_main (source);
|
source_main (source);
|
||||||
|
|
||||||
source_free_source (source);
|
source_free_source (source);
|
||||||
source_recheck_mounts ();
|
slave_rebuild_mounts();
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1345,13 +1342,15 @@ static void *source_fallback_file (void *arg)
|
|||||||
/* rescan the mount list, so that xsl files are updated to show
|
/* rescan the mount list, so that xsl files are updated to show
|
||||||
* unconnected but active fallback mountpoints
|
* unconnected but active fallback mountpoints
|
||||||
*/
|
*/
|
||||||
void source_recheck_mounts (void)
|
void source_recheck_mounts (int update_all)
|
||||||
{
|
{
|
||||||
ice_config_t *config = config_get_config();
|
ice_config_t *config = config_get_config();
|
||||||
mount_proxy *mount = config->mounts;
|
mount_proxy *mount = config->mounts;
|
||||||
|
|
||||||
avl_tree_rlock (global.source_tree);
|
avl_tree_rlock (global.source_tree);
|
||||||
|
|
||||||
|
stats_clear_virtual_mounts ();
|
||||||
|
|
||||||
while (mount)
|
while (mount)
|
||||||
{
|
{
|
||||||
source_t *source = source_find_mount (mount->mountname);
|
source_t *source = source_find_mount (mount->mountname);
|
||||||
@ -1359,7 +1358,9 @@ void source_recheck_mounts (void)
|
|||||||
if (source)
|
if (source)
|
||||||
{
|
{
|
||||||
source = source_find_mount_raw (mount->mountname);
|
source = source_find_mount_raw (mount->mountname);
|
||||||
if (source)
|
stats_event_args (mount->mountname, "listenurl", "http://%s:%d%s",
|
||||||
|
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);
|
||||||
|
@ -91,7 +91,7 @@ void source_free_source(source_t *source);
|
|||||||
void source_move_clients (source_t *source, source_t *dest);
|
void source_move_clients (source_t *source, source_t *dest);
|
||||||
int source_remove_client(void *key);
|
int source_remove_client(void *key);
|
||||||
void source_main(source_t *source);
|
void source_main(source_t *source);
|
||||||
void source_recheck_mounts (void);
|
void source_recheck_mounts (int update_all);
|
||||||
|
|
||||||
extern mutex_t move_clients_mutex;
|
extern mutex_t move_clients_mutex;
|
||||||
|
|
||||||
|
30
src/stats.c
30
src/stats.c
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
|
|
||||||
|
#include "source.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "refbuf.h"
|
#include "refbuf.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
@ -1062,3 +1063,32 @@ void stats_get_streamlist (char *buffer, size_t remaining)
|
|||||||
thread_mutex_unlock (&_stats_mutex);
|
thread_mutex_unlock (&_stats_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This removes any source stats from virtual mountpoints, ie mountpoints
|
||||||
|
* where no source_t exists. This function requires the global sources lock
|
||||||
|
* to be held before calling.
|
||||||
|
*/
|
||||||
|
void stats_clear_virtual_mounts (void)
|
||||||
|
{
|
||||||
|
avl_node *snode;
|
||||||
|
|
||||||
|
thread_mutex_lock (&_stats_mutex);
|
||||||
|
snode = avl_get_first(_stats.source_tree);
|
||||||
|
while (snode)
|
||||||
|
{
|
||||||
|
stats_source_t *src = (stats_source_t *)snode->key;
|
||||||
|
source_t *source = source_find_mount_raw (src->source);
|
||||||
|
|
||||||
|
if (source == NULL)
|
||||||
|
{
|
||||||
|
/* no source_t is reserved so remove them now */
|
||||||
|
snode = avl_get_next (snode);
|
||||||
|
DEBUG1 ("releasing %s stats", src->source);
|
||||||
|
avl_delete (_stats.source_tree, src, _free_source_stats);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
snode = avl_get_next (snode);
|
||||||
|
}
|
||||||
|
thread_mutex_unlock (&_stats_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ void stats_shutdown(void);
|
|||||||
|
|
||||||
stats_t *stats_get_stats(void);
|
stats_t *stats_get_stats(void);
|
||||||
void stats_get_streamlist (char *buffer, size_t remaining);
|
void stats_get_streamlist (char *buffer, size_t remaining);
|
||||||
|
void stats_clear_virtual_mounts (void);
|
||||||
|
|
||||||
void stats_event(const char *source, const char *name, const char *value);
|
void stats_event(const char *source, const char *name, const char *value);
|
||||||
void stats_event_args(const char *source, char *name, char *format, ...);
|
void stats_event_args(const char *source, char *name, char *format, ...);
|
||||||
|
Loading…
Reference in New Issue
Block a user