1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-09-22 04:15:54 -04:00

Add per mount queue size and source timeout, which can override the

general settings.

svn path=/trunk/icecast/; revision=5867
This commit is contained in:
Karl Heyes 2004-02-26 11:56:48 +00:00
parent b7fbcef133
commit aff756a4c7
5 changed files with 37 additions and 9 deletions

View File

@ -556,6 +556,19 @@ static void _parse_mount(xmlDocPtr doc, xmlNodePtr node,
option = option->next;
}
}
else if (strcmp(node->name, "queue-size") == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
mount->queue_size_limit = atoi (tmp);
if(tmp) xmlFree(tmp);
}
else if (strcmp(node->name, "source-timeout") == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
if (tmp)
{
mount->source_timeout = atoi (tmp);
xmlFree(tmp);
}
}
} while ((node = node->next));
}
@ -566,7 +579,7 @@ static void _parse_relay(xmlDocPtr doc, xmlNodePtr node,
relay_server *relay = calloc(1, sizeof(relay_server));
relay_server *current = configuration->relay;
relay_server *last=NULL;
while(current) {
last = current;
current = current->next;

View File

@ -54,6 +54,8 @@ typedef struct _mount_proxy {
clients from the fallback? */
int no_mount; /* Do we permit direct requests of this mountpoint? (or only
indirect, through fallbacks) */
unsigned queue_size_limit;
unsigned source_timeout; /* source timeout in seconds */
char *auth_type; /* Authentication type */
config_options_t *auth_options; /* Options for this type */

View File

@ -461,7 +461,7 @@ int connection_complete_source (source_t *source)
}
else
{
WARN0("No content-type header, falling back to backwards compatibility mode"
WARN0("No content-type header, falling back to backwards compatibility mode "
"for icecast 1.x relays. Assuming content is mp3.");
format_type = FORMAT_TYPE_MP3;
}
@ -480,6 +480,10 @@ int connection_complete_source (source_t *source)
global.sources++;
global_unlock();
/* set global settings first */
source->queue_size_limit = config->queue_size_limit;
source->timeout = config->source_timeout;
/* for relays, we don't yet have a client, however we do require one
* to retrieve the stream from. This is created here, quite late,
* because we can't use this client to return an error code/message,

View File

@ -351,7 +351,7 @@ void *source_main(void *arg)
source_t *fallback_source;
char buffer[4096];
long bytes, sbytes;
int ret, timeout;
int ret;
client_t *client;
avl_node *client_node;
@ -365,7 +365,6 @@ void *source_main(void *arg)
char *ai;
#endif
long queue_limit;
ice_config_t *config;
char *hostname;
char *listenurl;
@ -374,8 +373,6 @@ void *source_main(void *arg)
config = config_get_config();
queue_limit = config->queue_size_limit;
timeout = config->source_timeout;
hostname = strdup(config->hostname);
port = config->port;
@ -544,13 +541,13 @@ void *source_main(void *arg)
while (refbuf == NULL) {
bytes = 0;
while (bytes <= 0) {
ret = util_timed_wait_for_fd(source->con->sock, timeout*1000);
ret = util_timed_wait_for_fd(source->con->sock, source->timeout*1000);
if (ret < 0 && sock_recoverable (sock_error()))
continue;
if (ret <= 0) { /* timeout expired */
WARN1("Disconnecting source: socket timeout (%d s) expired",
timeout);
source->timeout);
bytes = 0;
break;
}
@ -678,7 +675,7 @@ void *source_main(void *arg)
** we need to make sure the client is keeping up with the
** data, so we'll kick any client who's queue gets to large.
*/
if (refbuf_queue_length(&client->queue) > queue_limit) {
if (refbuf_queue_length(&client->queue) > source->queue_size_limit) {
DEBUG0("Client has fallen too far behind, removing");
client->con->error = 1;
}
@ -900,6 +897,16 @@ void source_apply_mount (source_t *source, mount_proxy *mountinfo)
DEBUG1("Dumping stream to %s", mountinfo->dumpfile);
source->dumpfilename = strdup (mountinfo->dumpfile);
}
if (mountinfo->queue_size_limit)
{
source->queue_size_limit = mountinfo->queue_size_limit;
DEBUG1 ("queue size to %u", source->queue_size_limit);
}
if (mountinfo->source_timeout)
{
source->timeout = mountinfo->source_timeout;
DEBUG1 ("source timeout to %u", source->timeout);
}
}

View File

@ -56,6 +56,8 @@ typedef struct source_tag
struct auth_tag *authenticator;
int fallback_override;
int no_mount;
unsigned queue_size_limit;
unsigned timeout; /* source timeout in seconds */
} source_t;
source_t *source_reserve (const char *mount);