diff --git a/conf/icecast.xml b/conf/icecast.xml
index 136fabaa..b194e416 100644
--- a/conf/icecast.xml
+++ b/conf/icecast.xml
@@ -6,7 +6,9 @@
100
2
5
- 15
+ 30
+ 15
+ 10
hackme
diff --git a/src/config.c b/src/config.c
index a39e7233..15a3d12d 100644
--- a/src/config.c
+++ b/src/config.c
@@ -12,6 +12,7 @@
#define CONFIG_DEFAULT_THREADPOOL_SIZE 4
#define CONFIG_DEFAULT_CLIENT_TIMEOUT 30
#define CONFIG_DEFAULT_HEADER_TIMEOUT 15
+#define CONFIG_DEFAULT_SOURCE_TIMEOUT 10
#define CONFIG_DEFAULT_SOURCE_PASSWORD "changeme"
#define CONFIG_DEFAULT_TOUCH_FREQ 5
#define CONFIG_DEFAULT_HOSTNAME "localhost"
@@ -119,6 +120,7 @@ static void _set_defaults(void)
_configuration.threadpool_size = CONFIG_DEFAULT_THREADPOOL_SIZE;
_configuration.client_timeout = CONFIG_DEFAULT_CLIENT_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.touch_freq = CONFIG_DEFAULT_TOUCH_FREQ;
_configuration.dir_list = NULL;
@@ -198,6 +200,10 @@ static void _parse_limits(xmlDocPtr doc, xmlNodePtr node)
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
_configuration.header_timeout = atoi(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));
}
diff --git a/src/config.h b/src/config.h
index 8fc04256..a4c0c45c 100644
--- a/src/config.h
+++ b/src/config.h
@@ -22,6 +22,7 @@ typedef struct ice_config_tag
int threadpool_size;
int client_timeout;
int header_timeout;
+ int source_timeout;
char *source_password;
diff --git a/src/source.c b/src/source.c
index 5e0e81fb..87420af7 100644
--- a/src/source.c
+++ b/src/source.c
@@ -24,6 +24,7 @@
#include "stats.h"
#include "format.h"
#include "logging.h"
+#include "config.h"
#include "source.h"
@@ -106,6 +107,7 @@ void *source_main(void *arg)
source_t *source = (source_t *)arg;
char buffer[4096];
long bytes, sbytes;
+ int ret, timeout;
client_t *client;
avl_node *client_node;
@@ -117,6 +119,8 @@ void *source_main(void *arg)
int listeners = 0;
+ timeout = config_get_config()->source_timeout;
+
/* grab a read lock, to make sure we get a chance to cleanup */
thread_rwlock_rlock(source->shutdown_rwlock);
@@ -138,10 +142,15 @@ void *source_main(void *arg)
while (bytes <= 0) {
FD_ZERO(&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);
if (bytes == 0 || (bytes < 0 && !sock_recoverable(sock_error()))) break;