From 78213fe30ae4239861c41c4da37217e25231cc68 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Sun, 1 Feb 2015 21:01:01 +0000 Subject: [PATCH] Cleanup: Move client queue node creation into function. This adds the function create_client_node() taking care of client queue node creation. --- src/connection.c | 49 +++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/src/connection.c b/src/connection.c index 35fc3b46..fdcce8e7 100644 --- a/src/connection.c +++ b/src/connection.c @@ -657,6 +657,33 @@ static void _add_request_queue(client_queue_t *node) _req_queue_tail = (volatile client_queue_t **)&node->next; } +static client_queue_t *create_client_node(client_t *client) +{ + client_queue_t *node = calloc (1, sizeof (client_queue_t)); + ice_config_t *config; + listener_t *listener; + + if (!node) + return NULL; + + node->client = client; + + config = config_get_config(); + listener = config_get_listen_sock(config, client->con); + + if (listener) { + if (listener->shoutcast_compat) + node->shoutcast = 1; + if (listener->ssl && ssl_ok) + connection_uses_ssl(client->con); + if (listener->shoutcast_mount) + node->shoutcast_mount = strdup(listener->shoutcast_mount); + } + + config_release_config(); + + return node; +} void connection_accept_loop(void) { @@ -673,9 +700,7 @@ void connection_accept_loop(void) if (con) { client_queue_t *node; - ice_config_t *config; client_t *client = NULL; - listener_t *listener; global_lock(); if (client_create (&client, con, NULL) < 0) { @@ -696,27 +721,13 @@ void connection_accept_loop(void) continue; } - node = calloc (1, sizeof (client_queue_t)); + node = create_client_node(client); + global_unlock(); + if (node == NULL) { - global_unlock(); client_destroy(client); continue; } - node->client = client; - - config = config_get_config(); - listener = config_get_listen_sock(config, client->con); - - if (listener) { - if (listener->shoutcast_compat) - node->shoutcast = 1; - if (listener->ssl && ssl_ok) - connection_uses_ssl(client->con); - if (listener->shoutcast_mount) - node->shoutcast_mount = strdup(listener->shoutcast_mount); - } - global_unlock(); - config_release_config(); _add_request_queue(node); stats_event_inc(NULL, "connections");