1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-06-16 06:15:24 +00:00

Fix: Corrected error code for mounts with max listeners reached

Closes: #738
This commit is contained in:
Philipp Schafft 2020-10-15 13:50:10 +00:00
parent 8fac31520c
commit 5f3efe5d52
3 changed files with 10 additions and 12 deletions

View File

@ -931,7 +931,7 @@ static void _handle_stats_request(client_t *client)
/* if 0 is returned then the client should not be touched, however if -1
* is returned then the caller is responsible for handling the client
*/
static int __add_listener_to_source(source_t *source, client_t *client)
static void __add_listener_to_source(source_t *source, client_t *client)
{
size_t loop = 10;
@ -948,7 +948,8 @@ static int __add_listener_to_source(source_t *source, client_t *client)
if (!next) {
ICECAST_LOG_ERROR("Fallback '%s' for full source '%s' not found",
source->mount, source->fallback_mount);
return -1;
client_send_error_by_id(client, ICECAST_ERROR_SOURCE_MAX_LISTENERS);
return;
}
ICECAST_LOG_INFO("stream full, trying %s", next->mount);
source = next;
@ -956,7 +957,8 @@ static int __add_listener_to_source(source_t *source, client_t *client)
continue;
}
/* now we fail the client */
return -1;
client_send_error_by_id(client, ICECAST_ERROR_SOURCE_MAX_LISTENERS);
return;
} while (1);
client->write_to_client = format_generic_write_to_client;
@ -975,7 +977,6 @@ static int __add_listener_to_source(source_t *source, client_t *client)
source->on_demand_req = 1;
}
ICECAST_LOG_DEBUG("Added client to %s", source->mount);
return 0;
}
/* count the number of clients on a mount with same username and same role as the given one */
@ -1084,10 +1085,7 @@ static void _handle_get_request(client_t *client) {
client->con->discon_time = connection_duration + time(NULL);
}
if (__add_listener_to_source(source, client) == -1) {
client_send_error_by_id(client, ICECAST_ERROR_CON_rejecting_client_for_whatever_reason);
break;
}
__add_listener_to_source(source, client);
} while (0);
avl_tree_unlock(global.source_tree);
} else {

View File

@ -84,9 +84,6 @@ static const icecast_error_t __errors[] = {
{.id = ICECAST_ERROR_CON_PER_CRED_CLIENT_LIMIT, .http_status = 429,
.uuid = "9c72c1ec-f638-4d33-a077-6acbbff25317",
.message = "Reached limit of concurrent connections on those credentials"},
{.id = ICECAST_ERROR_CON_rejecting_client_for_whatever_reason, .http_status = 403 /* XXX */,
.uuid = "534ee9af-8be5-4645-a839-501d22d541bd",
.message = "Rejecting client for whatever reason"},
{.id = ICECAST_ERROR_CON_SOURCE_CLIENT_LIMIT, .http_status = 503,
.uuid = "c770182d-c854-422a-a8e5-7142689234a3",
.message = "too many sources connected"},
@ -132,6 +129,9 @@ static const icecast_error_t __errors[] = {
{.id = ICECAST_ERROR_SOURCE_STREAM_PREPARATION_ERROR, .http_status = 500 /* XXX */,
.uuid = "9e50d94d-f03d-4515-8216-577bf8e9f70d",
.message = "Stream preparation error"},
{.id = ICECAST_ERROR_SOURCE_MAX_LISTENERS, .http_status = 503,
.uuid = "df147168-baaa-4959-82a4-746a1232927d",
.message = "Maximum listeners reached for this source"},
{.id = ICECAST_ERROR_XSLT_PARSE, .http_status = 404 /* XXX */,
.uuid = "f86b5b28-c1f8-49f6-a4cd-a18e2a6a44fd",
.message = "Could not parse XSLT file"},

View File

@ -32,7 +32,6 @@ typedef enum {
ICECAST_ERROR_CON_MOUNTPOINT_NOT_STARTING_WITH_SLASH,
ICECAST_ERROR_CON_NO_CONTENT_TYPE_GIVEN,
ICECAST_ERROR_CON_PER_CRED_CLIENT_LIMIT,
ICECAST_ERROR_CON_rejecting_client_for_whatever_reason, /* ??? */
ICECAST_ERROR_CON_SOURCE_CLIENT_LIMIT,
ICECAST_ERROR_CON_UNIMPLEMENTED,
ICECAST_ERROR_CON_UNKNOWN_REQUEST,
@ -48,6 +47,7 @@ typedef enum {
ICECAST_ERROR_GEN_MEMORY_EXHAUSTED,
ICECAST_ERROR_SOURCE_MOUNT_UNAVAILABLE,
ICECAST_ERROR_SOURCE_STREAM_PREPARATION_ERROR,
ICECAST_ERROR_SOURCE_MAX_LISTENERS,
ICECAST_ERROR_XSLT_PARSE,
ICECAST_ERROR_XSLT_problem,
ICECAST_ERROR_RECURSIVE_ERROR