[xiph-cvs] cvs commit: icecast/src connection.c slave.c source.c
Michael Smith
msmith at xiph.org
Fri Aug 9 01:06:00 PDT 2002
msmith 02/08/09 04:06:00
Modified: conf icecast.xml
src connection.c slave.c source.c
Log:
Logging cleanups, and a config file fix.
Revision Changes Path
1.7 +1 -1 icecast/conf/icecast.xml
Index: icecast.xml
===================================================================
RCS file: /usr/local/cvsroot/icecast/conf/icecast.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- icecast.xml 9 Aug 2002 06:52:07 -0000 1.6
+++ icecast.xml 9 Aug 2002 08:06:00 -0000 1.7
@@ -32,7 +32,7 @@
<paths>
<basedir>/usr/local/icecast</basedir>
<logdir>/tmp</logdir>
- <webroot>/usr/local/icecast/webroot</basedir>
+ <webroot>/usr/local/icecast/webroot</webroot>
</paths>
<logging>
<p><p>1.15 +21 -18 icecast/src/connection.c
Index: connection.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/connection.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- connection.c 9 Aug 2002 06:52:07 -0000 1.14
+++ connection.c 9 Aug 2002 08:06:00 -0000 1.15
@@ -151,7 +151,6 @@
_queue = node;
thread_mutex_unlock(&_queue_mutex);
- printf("connection added....\n");
}
static void _signal_pool(void)
@@ -294,7 +293,6 @@
*/
global_lock();
if (global.sources >= config_get_config()->source_limit) {
- printf("TOO MANY SOURCE, KICKING THIS ONE\n");
INFO1("Source (%s) logged in, but there are too many sources", mount);
global_unlock();
return 0;
@@ -310,18 +308,26 @@
format_type_t format = format_get_type(contenttype);
if (format < 0) {
WARN1("Content-type \"%s\" not supported, dropping source", contenttype);
- return 0;
+ goto fail;
} else {
source = source_create(con, parser, mount, format);
}
} else {
WARN0("No content-type header, cannot handle source");
- return 0;
+ goto fail;
}
source->shutdown_rwlock = &_source_shutdown_rwlock;
sock_set_blocking(con->sock, SOCK_NONBLOCK);
thread_create("Source Thread", source_main, (void *)source, THREAD_DETACHED);
return 1;
+
+fail:
+ global_lock();
+ global.sources--;
+ global_unlock();
+
+ stats_event_dec(NULL, "sources");
+ return 0;
}
static void *_handle_connection(void *arg)
@@ -363,18 +369,18 @@
/* handle the connection or something */
if (strcmp("ICE", httpp_getvar(parser, HTTPP_VAR_PROTOCOL)) != 0 && strcmp("HTTP", httpp_getvar(parser, HTTPP_VAR_PROTOCOL)) != 0) {
- printf("DEBUG: bad protocol\n");
+ ERROR0("Bad HTTP protocol detected");
connection_close(con);
httpp_destroy(parser);
continue;
}
if (parser->req_type == httpp_req_source) {
- printf("DEBUG: source logging in\n");
+ INFO1("Source logging in at mountpoint \"%s\"",
+ httpp_getvar(parser, HTTPP_VAR_URI));
stats_event_inc(NULL, "source_connections");
if (strcmp((httpp_getvar(parser, "ice-password") != NULL) ? httpp_getvar(parser, "ice-password") : "", (config_get_config()->source_password != NULL) ? config_get_config()->source_password : "") != 0) {
- printf("DEBUG: bad password\n");
INFO1("Source (%s) attempted to login with bad password", httpp_getvar(parser, HTTPP_VAR_URI));
connection_close(con);
httpp_destroy(parser);
@@ -387,7 +393,6 @@
avl_tree_rlock(global.source_tree);
if (source_find_mount(httpp_getvar(parser, HTTPP_VAR_URI)) != NULL) {
- printf("Source attempted to connect with an already used mountpoint.\n");
INFO1("Source tried to log in as %s, but is already used", httpp_getvar(parser, HTTPP_VAR_URI));
connection_close(con);
httpp_destroy(parser);
@@ -403,11 +408,10 @@
continue;
} else if (parser->req_type == httpp_req_stats) {
- printf("DEBUG: stats connection...\n");
stats_event_inc(NULL, "stats_connections");
if (strcmp((httpp_getvar(parser, "ice-password") != NULL) ? httpp_getvar(parser, "ice-password") : "", (config_get_config()->source_password != NULL) ? config_get_config()->source_password : "") != 0) {
- printf("DEBUG: bad password\n");
+ ERROR0("Bad password for stats connection");
connection_close(con);
httpp_destroy(parser);
continue;
@@ -424,7 +428,7 @@
continue;
} else if (parser->req_type == httpp_req_play || parser->req_type == httpp_req_get) {
- printf("DEBUG: client coming in...\n");
+ DEBUG0("Client connected");
/* make a client */
client = client_create(con, parser);
@@ -439,7 +443,7 @@
*/
// TODO: add GUID-xxxxxx
if (strcmp(httpp_getvar(parser, HTTPP_VAR_URI), "/stats.xml") == 0) {
- printf("sending stats.xml\n");
+ DEBUG0("Stats request, sending xml stats");
stats_sendxml(client);
client_destroy(client);
continue;
@@ -454,6 +458,7 @@
/* If the file exists, then transform it, otherwise, write a 404 error */
if (stat(fullPath, &statbuf) == 0) {
+ DEBUG0("Stats request, sending XSL transformed stats");
sock_write(client->con->sock, "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n");
stats_transform_xslt(client, fullPath);
}
@@ -467,7 +472,6 @@
if (strcmp(httpp_getvar(parser, HTTPP_VAR_URI), "/allstreams.txt") == 0) {
if (strcmp((httpp_getvar(parser, "ice-password") != NULL) ? httpp_getvar(parser, "ice-password") : "", (config_get_config()->source_password != NULL) ? config_get_config()->source_password : "") != 0) {
- printf("DEBUG: bad password for allstreams.txt\n");
INFO0("Client attempted to fetch allstreams.txt with bad password");
if (parser->req_type == httpp_req_get) {
client->respcode = 404;
@@ -508,7 +512,7 @@
avl_tree_rlock(global.source_tree);
source = source_find_mount(httpp_getvar(parser, HTTPP_VAR_URI));
if (source) {
- printf("DEBUG: source found for client\n");
+ DEBUG0("Source found for client");
global_lock();
if (global.clients >= config_get_config()->client_limit) {
@@ -534,7 +538,6 @@
while (node) {
var = (http_var_t *)node->key;
if (strcasecmp(var->name, "ice-password") && !strncasecmp("ice-", var->name, 4)) {
- printf("DEBUG: sending %s: %s\n", var->name, var->value);
sock_write(client->con->sock, "%s: %s\r\n", var->name, var->value);
}
node = avl_get_next(node);
@@ -554,7 +557,7 @@
avl_tree_unlock(global.source_tree);
if (!source) {
- printf("DEBUG: source not found for client\n");
+ DEBUG0("Source not found for client");
if (parser->req_type == httpp_req_get) {
client->respcode = 404;
bytes = sock_write(client->con->sock, "HTTP/1.0 404 Source Not Found\r\nContent-Type: text/html\r\n\r\n"\
@@ -566,13 +569,13 @@
continue;
} else {
- printf("DEBUG: wrong request type\n");
+ ERROR0("Wrong request type from client");
connection_close(con);
httpp_destroy(parser);
continue;
}
} else {
- printf("DEBUG: parsing failed\n");
+ ERROR0("HTTP request parsing failed");
connection_close(con);
httpp_destroy(parser);
continue;
<p><p>1.2 +4 -3 icecast/src/slave.c
Index: slave.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/slave.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- slave.c 5 Aug 2002 14:48:01 -0000 1.1
+++ slave.c 9 Aug 2002 08:06:00 -0000 1.2
@@ -82,7 +82,7 @@
mastersock = sock_connect_wto(config_get_config()->master_server, config_get_config()->master_server_port, 0);
if (mastersock == SOCK_ERROR) {
- printf("DEBUG: failed to contact master server\n");
+ WARN0("Relay slave failed to contact master server to fetch stream list");
continue;
}
sock_write(mastersock, "GET /allstreams.txt HTTP/1.0\r\nice-password: %s\r\n\r\n", config_get_config()->source_password);
@@ -91,10 +91,11 @@
avl_tree_rlock(global.source_tree);
if (!source_find_mount(buf)) {
avl_tree_unlock(global.source_tree);
- printf("DEBUG: adding source for %s\n", buf);
+
+ DEBUG1("Adding source at mountpoint \"%s\"", buf);
streamsock = sock_connect_wto(config_get_config()->master_server, config_get_config()->master_server_port, 0);
if (streamsock == SOCK_ERROR) {
- printf("DEBUG: failed to get stream from master server\n");
+ WARN0("Failed to relay stream from master server");
continue;
}
con = create_connection(streamsock, NULL);
<p><p>1.17 +9 -12 icecast/src/source.c
Index: source.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/source.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- source.c 5 Aug 2002 14:48:01 -0000 1.16
+++ source.c 9 Aug 2002 08:06:00 -0000 1.17
@@ -173,8 +173,7 @@
}
if (bytes <= 0) {
- printf("DEBUG: got 0 bytes reading data, the source must have disconnected...\n");
- INFO0("Disconnecting lame source...");
+ INFO0("Removing source following disconnection");
break;
}
@@ -225,10 +224,10 @@
}
if (sbytes < 0) {
if (!sock_recoverable(sock_error())) {
- printf("SOURCE: Client had unrecoverable error catching up (%ld/%ld)\n", sbytes, bytes);
+ DEBUG0("Client has unrecoverable error catching up. Client has probably disconnected");
client->con->error = 1;
} else {
- printf("SOURCE: client had recoverable error...\n");
+ DEBUG1("Client had recoverable error %ld", sock_error());
/* put the refbuf back on top of the queue, since we didn't finish with it */
refbuf_queue_insert(&client->queue, abuf);
}
@@ -262,10 +261,10 @@
if (sbytes < 0) {
bytes = sock_error();
if (!sock_recoverable(bytes)) {
- printf("SOURCE: client had unrecoverable error %ld with new data (%ld/%ld)\n", bytes, sbytes, refbuf->len);
+ DEBUG0("Client had unrecoverable error with new data, probably due to client disconnection");
client->con->error = 1;
} else {
- printf("SOURCE: recoverable error %ld\n", bytes);
+ DEBUG1("Client had recoverable error %ld", bytes);
client->pos = 0;
refbuf_addref(refbuf);
refbuf_queue_insert(&client->queue, refbuf);
@@ -280,7 +279,7 @@
** TODO: put queue_limit in a config file
*/
if (refbuf_queue_size(&client->queue) > 25) {
- printf("SOURCE: client is too lagged... kicking\n");
+ DEBUG0("Client has fallen too far behind, removing");
client->con->error = 1;
}
@@ -311,7 +310,7 @@
global_unlock();
stats_event_dec(NULL, "clients");
stats_event_args(source->mount, "listeners", "%d", listeners);
- printf("DEBUG: Client dropped...\n");
+ DEBUG0("Client removed");
continue;
}
client_node = avl_get_next(client_node);
@@ -325,7 +324,7 @@
while (client_node) {
avl_insert(source->client_tree, client_node->key);
listeners++;
- printf("Client added\n");
+ DEBUG0("Client added");
stats_event_inc(NULL, "clients");
stats_event_inc(source->mount, "connections");
stats_event_args(source->mount, "listeners", "%d", listeners);
@@ -355,7 +354,7 @@
done:
- printf("DEBUG: we're going down...\n");
+ DEBUG0("Source exiting");
/* we need to empty the client and pending trees */
avl_tree_wlock(source->pending_tree);
@@ -372,8 +371,6 @@
/* delete this sources stats */
stats_event_dec(NULL, "sources");
stats_event(source->mount, "listeners", NULL);
-
- printf("DEBUG: source_main() is now exiting...\n");
global_lock();
global.sources--;
<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