mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Feature: Prepare for support to move single clients
This commit is contained in:
parent
e86a46ee4a
commit
d92c9758a6
@ -659,7 +659,7 @@ static void command_move_clients(client_t *client,
|
|||||||
node = admin_build_rootnode(doc, "iceresponse");
|
node = admin_build_rootnode(doc, "iceresponse");
|
||||||
xmlDocSetRootElement(doc, node);
|
xmlDocSetRootElement(doc, node);
|
||||||
|
|
||||||
source_move_clients(source, dest);
|
source_move_clients(source, dest, NULL);
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "Clients moved from %s to %s",
|
snprintf(buf, sizeof(buf), "Clients moved from %s to %s",
|
||||||
source->mount, dest_source);
|
source->mount, dest_source);
|
||||||
|
@ -467,7 +467,7 @@ static void *start_relay_stream (void *arg)
|
|||||||
fallback_source = source_find_mount(relay->source->fallback_mount);
|
fallback_source = source_find_mount(relay->source->fallback_mount);
|
||||||
|
|
||||||
if (fallback_source != NULL)
|
if (fallback_source != NULL)
|
||||||
source_move_clients(relay->source, fallback_source);
|
source_move_clients(relay->source, fallback_source, NULL);
|
||||||
|
|
||||||
avl_tree_unlock(global.source_tree);
|
avl_tree_unlock(global.source_tree);
|
||||||
}
|
}
|
||||||
|
46
src/source.c
46
src/source.c
@ -367,7 +367,7 @@ static inline void source_move_clients__single(source_t *source, avl_tree *from,
|
|||||||
* The only lock that should be held when this is called is the
|
* The only lock that should be held when this is called is the
|
||||||
* source tree lock
|
* source tree lock
|
||||||
*/
|
*/
|
||||||
void source_move_clients(source_t *source, source_t *dest)
|
void source_move_clients(source_t *source, source_t *dest, connection_id_t *id)
|
||||||
{
|
{
|
||||||
unsigned long count = 0;
|
unsigned long count = 0;
|
||||||
if (strcmp(source->mount, dest->mount) == 0) {
|
if (strcmp(source->mount, dest->mount) == 0) {
|
||||||
@ -405,20 +405,34 @@ void source_move_clients(source_t *source, source_t *dest)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
if (id) {
|
||||||
avl_node *node = avl_get_first(source->pending_tree);
|
client_t fakeclient;
|
||||||
if (node == NULL)
|
connection_t fakecon;
|
||||||
break;
|
void *result;
|
||||||
source_move_clients__single(source, source->pending_tree, dest->pending_tree, node);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
fakeclient.con = &fakecon;
|
||||||
avl_node *node = avl_get_first(source->client_tree);
|
fakeclient.con->id = *id;
|
||||||
if (node == NULL)
|
|
||||||
break;
|
if (avl_get_by_key(source->client_tree, &fakeclient, &result) == 0) {
|
||||||
source_move_clients__single(source, source->client_tree, dest->pending_tree, node);
|
source_move_clients__single(source, source->client_tree, dest->pending_tree, result);
|
||||||
count++;
|
count++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (1) {
|
||||||
|
avl_node *node = avl_get_first(source->pending_tree);
|
||||||
|
if (node == NULL)
|
||||||
|
break;
|
||||||
|
source_move_clients__single(source, source->pending_tree, dest->pending_tree, node);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
avl_node *node = avl_get_first(source->client_tree);
|
||||||
|
if (node == NULL)
|
||||||
|
break;
|
||||||
|
source_move_clients__single(source, source->client_tree, dest->pending_tree, node);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ICECAST_LOG_INFO("passing %lu listeners to \"%s\"", count, dest->mount);
|
ICECAST_LOG_INFO("passing %lu listeners to \"%s\"", count, dest->mount);
|
||||||
@ -653,7 +667,7 @@ static void source_init (source_t *source)
|
|||||||
fallback_source = source_find_mount(source->fallback_mount);
|
fallback_source = source_find_mount(source->fallback_mount);
|
||||||
|
|
||||||
if (fallback_source)
|
if (fallback_source)
|
||||||
source_move_clients (fallback_source, source);
|
source_move_clients(fallback_source, source, NULL);
|
||||||
|
|
||||||
avl_tree_unlock(global.source_tree);
|
avl_tree_unlock(global.source_tree);
|
||||||
}
|
}
|
||||||
@ -852,7 +866,7 @@ static void source_shutdown (source_t *source)
|
|||||||
fallback_source = source_find_mount(source->fallback_mount);
|
fallback_source = source_find_mount(source->fallback_mount);
|
||||||
|
|
||||||
if (fallback_source != NULL)
|
if (fallback_source != NULL)
|
||||||
source_move_clients(source, fallback_source);
|
source_move_clients(source, fallback_source, NULL);
|
||||||
|
|
||||||
avl_tree_unlock(global.source_tree);
|
avl_tree_unlock(global.source_tree);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ source_t *source_find_mount_raw(const char *mount);
|
|||||||
client_t *source_find_client(source_t *source, connection_id_t id);
|
client_t *source_find_client(source_t *source, connection_id_t id);
|
||||||
int source_compare_sources(void *arg, void *a, void *b);
|
int source_compare_sources(void *arg, void *a, void *b);
|
||||||
void source_free_source(source_t *source);
|
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, connection_id_t *id);
|
||||||
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 (int update_all);
|
void source_recheck_mounts (int update_all);
|
||||||
|
Loading…
Reference in New Issue
Block a user