[xiph-cvs] cvs commit: icecast/src config.c config.h source.c
Jack Moffitt
jack at xiph.org
Sun Jan 20 20:28:31 PST 2002
jack 02/01/20 20:28:31
Modified: conf icecast.xml
src config.c config.h source.c
Log:
Add a source-timeout config option and implement it. This prevents lame
sources from sticking around way too long. Default is 10 seconds.
Revision Changes Path
1.2 +3 -1 icecast/conf/icecast.xml
Index: icecast.xml
===================================================================
RCS file: /usr/local/cvsroot/icecast/conf/icecast.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- icecast.xml 2001/09/10 02:21:52 1.1
+++ icecast.xml 2002/01/21 04:28:30 1.2
@@ -6,7 +6,9 @@
<clients>100</clients>
<sources>2</sources>
<threadpool>5</threadpool>
- <client-timeout>15</client-timeout>
+ <client-timeout>30</client-timeout>
+ <header-timeout>15</header-timeout>
+ <source-timeout>10</source-timeout>
</limits>
<source-password>hackme</source-password>
<p><p>1.3 +6 -0 icecast/src/config.c
Index: config.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/config.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- config.c 2001/10/20 06:43:04 1.2
+++ config.c 2002/01/21 04:28:30 1.3
@@ -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 @@
_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;
@@ -197,6 +199,10 @@
} else if (strcmp(node->name, "header-timeout") == 0) {
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));
<p><p>1.2 +1 -0 icecast/src/config.h
Index: config.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/config.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- config.h 2001/09/10 02:21:48 1.1
+++ config.h 2002/01/21 04:28:30 1.2
@@ -22,6 +22,7 @@
int threadpool_size;
int client_timeout;
int header_timeout;
+ int source_timeout;
char *source_password;
<p><p>1.6 +12 -3 icecast/src/source.c
Index: source.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/source.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- source.c 2002/01/21 03:56:16 1.5
+++ source.c 2002/01/21 04:28:30 1.6
@@ -24,6 +24,7 @@
#include "stats.h"
#include "format.h"
#include "logging.h"
+#include "config.h"
#include "source.h"
@@ -106,6 +107,7 @@
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 @@
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 @@
while (bytes <= 0) {
FD_ZERO(&rfds);
FD_SET(source->con->sock, &rfds);
- tv.tv_sec = 0;
- tv.tv_usec = 30000;
+
+ tv.tv_sec = timeout;
+ tv.tv_usec = 0;
- select(source->con->sock + 1, &rfds, NULL, NULL, &tv);
+ 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;
<p><p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list