mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Various cleanups for accounting of sent bytes.
Crash bug in stats fixed. svn path=/trunk/icecast/; revision=3779
This commit is contained in:
parent
5dd00e7423
commit
6357936028
@ -459,12 +459,14 @@ static void *_handle_connection(void *arg)
|
||||
/* 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");
|
||||
bytes = sock_write(client->con->sock, "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n");
|
||||
if(bytes > 0) client->con->sent_bytes = bytes;
|
||||
stats_transform_xslt(client, fullPath);
|
||||
}
|
||||
else {
|
||||
sock_write(client->con->sock, "HTTP/1.0 404 File Not Found\r\nContent-Type: text/html\r\n\r\n"\
|
||||
bytes = sock_write(client->con->sock, "HTTP/1.0 404 File Not Found\r\nContent-Type: text/html\r\n\r\n"\
|
||||
"<b>The file you requested could not be found.</b>\r\n");
|
||||
if(bytes > 0) client->con->sent_bytes = bytes;
|
||||
}
|
||||
client_destroy(client);
|
||||
continue;
|
||||
@ -486,7 +488,12 @@ static void *_handle_connection(void *arg)
|
||||
node = avl_get_first(global.source_tree);
|
||||
while (node) {
|
||||
s = (source_t *)node->key;
|
||||
sock_write(client->con->sock, "%s\r\n", s->mount);
|
||||
bytes = sock_write(client->con->sock, "%s\r\n", s->mount);
|
||||
if(bytes > 0)
|
||||
client->con->sent_bytes += bytes;
|
||||
else
|
||||
break;
|
||||
|
||||
node = avl_get_next(node);
|
||||
}
|
||||
avl_tree_unlock(global.source_tree);
|
||||
@ -531,20 +538,23 @@ static void *_handle_connection(void *arg)
|
||||
|
||||
if (parser->req_type == httpp_req_get) {
|
||||
client->respcode = 200;
|
||||
sock_write(client->con->sock, "HTTP/1.0 200 OK\r\nContent-Type: %s\r\n", format_get_mimetype(source->format->type));
|
||||
bytes = sock_write(client->con->sock, "HTTP/1.0 200 OK\r\nContent-Type: %s\r\n", format_get_mimetype(source->format->type));
|
||||
if(bytes > 0) client->con->sent_bytes += bytes;
|
||||
/* iterate through source http headers and send to client */
|
||||
avl_tree_rlock(source->parser->vars);
|
||||
node = avl_get_first(source->parser->vars);
|
||||
while (node) {
|
||||
var = (http_var_t *)node->key;
|
||||
if (strcasecmp(var->name, "ice-password") && !strncasecmp("ice-", var->name, 4)) {
|
||||
sock_write(client->con->sock, "%s: %s\r\n", var->name, var->value);
|
||||
bytes = sock_write(client->con->sock, "%s: %s\r\n", var->name, var->value);
|
||||
if(bytes > 0) client->con->sent_bytes += bytes;
|
||||
}
|
||||
node = avl_get_next(node);
|
||||
}
|
||||
avl_tree_unlock(source->parser->vars);
|
||||
|
||||
sock_write(client->con->sock, "\r\n");
|
||||
bytes = sock_write(client->con->sock, "\r\n");
|
||||
if(bytes > 0) client->con->sent_bytes += bytes;
|
||||
|
||||
sock_set_blocking(client->con->sock, SOCK_NONBLOCK);
|
||||
}
|
||||
|
@ -823,7 +823,6 @@ void stats_sendxml(client_t *client)
|
||||
src_nodes = snd;
|
||||
}
|
||||
if (buff) free(buff);
|
||||
client_destroy(client);
|
||||
}
|
||||
|
||||
static int _compare_stats(void *arg, void *a, void *b)
|
||||
|
14
src/xslt.c
14
src/xslt.c
@ -32,7 +32,7 @@ void transformXSLT(xmlDocPtr doc, char *xslfilename, client_t *client)
|
||||
xmlDocPtr res;
|
||||
xsltStylesheetPtr cur;
|
||||
const char *params[16 + 1];
|
||||
size_t count,nBytes;
|
||||
size_t count,bytes;
|
||||
|
||||
params[0] = NULL;
|
||||
|
||||
@ -41,7 +41,10 @@ void transformXSLT(xmlDocPtr doc, char *xslfilename, client_t *client)
|
||||
|
||||
cur = xsltParseStylesheetFile(xslfilename);
|
||||
if (cur == NULL) {
|
||||
sock_write_string(client->con->sock, (char *)"Could not parse XSLT file");
|
||||
bytes = sock_write_string(client->con->sock,
|
||||
(char *)"Could not parse XSLT file");
|
||||
if(bytes > 0) client->con->sent_bytes += bytes;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -52,9 +55,12 @@ void transformXSLT(xmlDocPtr doc, char *xslfilename, client_t *client)
|
||||
count = xsltSaveResultTo(outputBuffer, res, cur);
|
||||
|
||||
/* Add null byte to end. */
|
||||
nBytes = xmlOutputBufferWrite(outputBuffer, 1, "");
|
||||
bytes = xmlOutputBufferWrite(outputBuffer, 1, "");
|
||||
|
||||
if(sock_write_string(client->con->sock,
|
||||
(char *)outputBuffer->buffer->content))
|
||||
client->con->sent_bytes += bytes;
|
||||
|
||||
sock_write_string(client->con->sock, (char *)outputBuffer->buffer->content);
|
||||
|
||||
xmlFree(outputBuffer);
|
||||
xsltFreeStylesheet(cur);
|
||||
|
Loading…
Reference in New Issue
Block a user