mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-11-03 04:17:17 -05:00
Add a source-timeout config option and implement it. This prevents lame
sources from sticking around way too long. Default is 10 seconds. svn path=/trunk/icecast/; revision=2968
This commit is contained in:
parent
4d079ba4cc
commit
34c6203669
@ -6,7 +6,9 @@
|
|||||||
<clients>100</clients>
|
<clients>100</clients>
|
||||||
<sources>2</sources>
|
<sources>2</sources>
|
||||||
<threadpool>5</threadpool>
|
<threadpool>5</threadpool>
|
||||||
<client-timeout>15</client-timeout>
|
<client-timeout>30</client-timeout>
|
||||||
|
<header-timeout>15</header-timeout>
|
||||||
|
<source-timeout>10</source-timeout>
|
||||||
</limits>
|
</limits>
|
||||||
|
|
||||||
<source-password>hackme</source-password>
|
<source-password>hackme</source-password>
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#define CONFIG_DEFAULT_THREADPOOL_SIZE 4
|
#define CONFIG_DEFAULT_THREADPOOL_SIZE 4
|
||||||
#define CONFIG_DEFAULT_CLIENT_TIMEOUT 30
|
#define CONFIG_DEFAULT_CLIENT_TIMEOUT 30
|
||||||
#define CONFIG_DEFAULT_HEADER_TIMEOUT 15
|
#define CONFIG_DEFAULT_HEADER_TIMEOUT 15
|
||||||
|
#define CONFIG_DEFAULT_SOURCE_TIMEOUT 10
|
||||||
#define CONFIG_DEFAULT_SOURCE_PASSWORD "changeme"
|
#define CONFIG_DEFAULT_SOURCE_PASSWORD "changeme"
|
||||||
#define CONFIG_DEFAULT_TOUCH_FREQ 5
|
#define CONFIG_DEFAULT_TOUCH_FREQ 5
|
||||||
#define CONFIG_DEFAULT_HOSTNAME "localhost"
|
#define CONFIG_DEFAULT_HOSTNAME "localhost"
|
||||||
@ -119,6 +120,7 @@ static void _set_defaults(void)
|
|||||||
_configuration.threadpool_size = CONFIG_DEFAULT_THREADPOOL_SIZE;
|
_configuration.threadpool_size = CONFIG_DEFAULT_THREADPOOL_SIZE;
|
||||||
_configuration.client_timeout = CONFIG_DEFAULT_CLIENT_TIMEOUT;
|
_configuration.client_timeout = CONFIG_DEFAULT_CLIENT_TIMEOUT;
|
||||||
_configuration.header_timeout = CONFIG_DEFAULT_HEADER_TIMEOUT;
|
_configuration.header_timeout = CONFIG_DEFAULT_HEADER_TIMEOUT;
|
||||||
|
_configuration.source_timeout = CONFIG_DEFAULT_SOURCE_TIMEOUT;
|
||||||
_configuration.source_password = (char *)strdup(CONFIG_DEFAULT_SOURCE_PASSWORD);
|
_configuration.source_password = (char *)strdup(CONFIG_DEFAULT_SOURCE_PASSWORD);
|
||||||
_configuration.touch_freq = CONFIG_DEFAULT_TOUCH_FREQ;
|
_configuration.touch_freq = CONFIG_DEFAULT_TOUCH_FREQ;
|
||||||
_configuration.dir_list = NULL;
|
_configuration.dir_list = NULL;
|
||||||
@ -198,6 +200,10 @@ static void _parse_limits(xmlDocPtr doc, xmlNodePtr node)
|
|||||||
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
|
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
|
||||||
_configuration.header_timeout = atoi(tmp);
|
_configuration.header_timeout = atoi(tmp);
|
||||||
if (tmp) free(tmp);
|
if (tmp) free(tmp);
|
||||||
|
} else if (strcmp(node->name, "source-timeout") == 0) {
|
||||||
|
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
|
||||||
|
_configuration.source_timeout = atoi(tmp);
|
||||||
|
if (tmp) free(tmp);
|
||||||
}
|
}
|
||||||
} while ((node = node->next));
|
} while ((node = node->next));
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ typedef struct ice_config_tag
|
|||||||
int threadpool_size;
|
int threadpool_size;
|
||||||
int client_timeout;
|
int client_timeout;
|
||||||
int header_timeout;
|
int header_timeout;
|
||||||
|
int source_timeout;
|
||||||
|
|
||||||
char *source_password;
|
char *source_password;
|
||||||
|
|
||||||
|
15
src/source.c
15
src/source.c
@ -24,6 +24,7 @@
|
|||||||
#include "stats.h"
|
#include "stats.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "source.h"
|
#include "source.h"
|
||||||
|
|
||||||
@ -106,6 +107,7 @@ void *source_main(void *arg)
|
|||||||
source_t *source = (source_t *)arg;
|
source_t *source = (source_t *)arg;
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
long bytes, sbytes;
|
long bytes, sbytes;
|
||||||
|
int ret, timeout;
|
||||||
client_t *client;
|
client_t *client;
|
||||||
avl_node *client_node;
|
avl_node *client_node;
|
||||||
|
|
||||||
@ -117,6 +119,8 @@ void *source_main(void *arg)
|
|||||||
|
|
||||||
int listeners = 0;
|
int listeners = 0;
|
||||||
|
|
||||||
|
timeout = config_get_config()->source_timeout;
|
||||||
|
|
||||||
/* grab a read lock, to make sure we get a chance to cleanup */
|
/* grab a read lock, to make sure we get a chance to cleanup */
|
||||||
thread_rwlock_rlock(source->shutdown_rwlock);
|
thread_rwlock_rlock(source->shutdown_rwlock);
|
||||||
|
|
||||||
@ -138,10 +142,15 @@ void *source_main(void *arg)
|
|||||||
while (bytes <= 0) {
|
while (bytes <= 0) {
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO(&rfds);
|
||||||
FD_SET(source->con->sock, &rfds);
|
FD_SET(source->con->sock, &rfds);
|
||||||
tv.tv_sec = 0;
|
|
||||||
tv.tv_usec = 30000;
|
|
||||||
|
|
||||||
select(source->con->sock + 1, &rfds, NULL, NULL, &tv);
|
tv.tv_sec = timeout;
|
||||||
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
|
ret = select(source->con->sock + 1, &rfds, NULL, NULL, &tv);
|
||||||
|
if (ret == 0) { /* timeout expired */
|
||||||
|
bytes = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
bytes = sock_read_bytes(source->con->sock, buffer, 4096);
|
bytes = sock_read_bytes(source->con->sock, buffer, 4096);
|
||||||
if (bytes == 0 || (bytes < 0 && !sock_recoverable(sock_error()))) break;
|
if (bytes == 0 || (bytes < 0 && !sock_recoverable(sock_error()))) break;
|
||||||
|
Loading…
Reference in New Issue
Block a user