1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2025-01-03 14:56:34 -05:00

Cleanup: Corrected code style

This commit is contained in:
Philipp Schafft 2020-09-29 23:55:13 +00:00
parent b2cd834db7
commit 55acb32b71

View File

@ -370,22 +370,20 @@ static inline void source_move_clients__single(source_t *source, avl_tree *from,
void source_move_clients(source_t *source, source_t *dest) void source_move_clients(source_t *source, source_t *dest)
{ {
unsigned long count = 0; unsigned long count = 0;
if (strcmp (source->mount, dest->mount) == 0) if (strcmp(source->mount, dest->mount) == 0) {
{
ICECAST_LOG_WARN("src and dst are the same \"%s\", skipping", source->mount); ICECAST_LOG_WARN("src and dst are the same \"%s\", skipping", source->mount);
return; return;
} }
/* we don't want the two write locks to deadlock in here */ /* we don't want the two write locks to deadlock in here */
thread_mutex_lock (&move_clients_mutex); thread_mutex_lock(&move_clients_mutex);
/* if the destination is not running then we can't move clients */ /* if the destination is not running then we can't move clients */
avl_tree_wlock (dest->pending_tree); avl_tree_wlock(dest->pending_tree);
if (dest->running == 0 && dest->on_demand == 0) if (dest->running == 0 && dest->on_demand == 0) {
{
ICECAST_LOG_WARN("destination mount %s not running, unable to move clients ", dest->mount); ICECAST_LOG_WARN("destination mount %s not running, unable to move clients ", dest->mount);
avl_tree_unlock (dest->pending_tree); avl_tree_unlock(dest->pending_tree);
thread_mutex_unlock (&move_clients_mutex); thread_mutex_unlock(&move_clients_mutex);
return; return;
} }
@ -394,24 +392,20 @@ void source_move_clients(source_t *source, source_t *dest)
avl_tree_wlock(source->pending_tree); avl_tree_wlock(source->pending_tree);
avl_tree_wlock(source->client_tree); avl_tree_wlock(source->client_tree);
do do {
{ if (source->on_demand == 0 && source->format == NULL) {
if (source->on_demand == 0 && source->format == NULL)
{
ICECAST_LOG_INFO("source mount %s is not available", source->mount); ICECAST_LOG_INFO("source mount %s is not available", source->mount);
break; break;
} }
if (source->format && dest->format)
{ if (source->format && dest->format) {
if (source->format->type != dest->format->type) if (source->format->type != dest->format->type) {
{
ICECAST_LOG_WARN("stream %s and %s are of different types, ignored", source->mount, dest->mount); ICECAST_LOG_WARN("stream %s and %s are of different types, ignored", source->mount, dest->mount);
break; break;
} }
} }
while (1) while (1) {
{
avl_node *node = avl_get_first(source->pending_tree); avl_node *node = avl_get_first(source->pending_tree);
if (node == NULL) if (node == NULL)
break; break;
@ -419,30 +413,29 @@ void source_move_clients(source_t *source, source_t *dest)
count++; count++;
} }
while (1) while (1) {
{
avl_node *node = avl_get_first(source->client_tree); avl_node *node = avl_get_first(source->client_tree);
if (node == NULL) if (node == NULL)
break; break;
source_move_clients__single(source, source->client_tree, dest->pending_tree, node); source_move_clients__single(source, source->client_tree, dest->pending_tree, node);
count++; count++;
} }
ICECAST_LOG_INFO("passing %lu listeners to \"%s\"", count, dest->mount); ICECAST_LOG_INFO("passing %lu listeners to \"%s\"", count, dest->mount);
source->listeners = 0; source->listeners = 0;
stats_event (source->mount, "listeners", "0"); stats_event(source->mount, "listeners", "0");
} while (0); } while (0);
avl_tree_unlock (source->pending_tree); avl_tree_unlock(source->pending_tree);
avl_tree_unlock (source->client_tree); avl_tree_unlock(source->client_tree);
/* 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;
avl_tree_unlock (dest->pending_tree); avl_tree_unlock(dest->pending_tree);
thread_mutex_unlock (&move_clients_mutex); thread_mutex_unlock(&move_clients_mutex);
} }