1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-12-04 14:46:30 -05:00

Cleanup: Move client queue node creation into function.

This adds the function create_client_node() taking care of
client queue node creation.
This commit is contained in:
Philipp Schafft 2015-02-01 21:01:01 +00:00
parent 8941de3273
commit 78213fe30a

View File

@ -657,6 +657,33 @@ static void _add_request_queue(client_queue_t *node)
_req_queue_tail = (volatile client_queue_t **)&node->next; _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) void connection_accept_loop(void)
{ {
@ -673,9 +700,7 @@ void connection_accept_loop(void)
if (con) { if (con) {
client_queue_t *node; client_queue_t *node;
ice_config_t *config;
client_t *client = NULL; client_t *client = NULL;
listener_t *listener;
global_lock(); global_lock();
if (client_create (&client, con, NULL) < 0) { if (client_create (&client, con, NULL) < 0) {
@ -696,27 +721,13 @@ void connection_accept_loop(void)
continue; continue;
} }
node = calloc (1, sizeof (client_queue_t)); node = create_client_node(client);
if (node == NULL) {
global_unlock(); global_unlock();
if (node == NULL) {
client_destroy(client); client_destroy(client);
continue; 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); _add_request_queue(node);
stats_event_inc(NULL, "connections"); stats_event_inc(NULL, "connections");