Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xiph.Org
Icecast-Server
Commits
63579360
Commit
63579360
authored
Aug 09, 2002
by
Michael Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various cleanups for accounting of sent bytes.
Crash bug in stats fixed. svn path=/trunk/icecast/; revision=3779
parent
5dd00e74
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
11 deletions
+26
-11
src/connection.c
src/connection.c
+16
-6
src/stats.c
src/stats.c
+0
-1
src/xslt.c
src/xslt.c
+10
-4
No files found.
src/connection.c
View file @
63579360
...
...
@@ -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\n
Content-Type: text/html
\r\n\r\n
"
);
bytes
=
sock_write
(
client
->
con
->
sock
,
"HTTP/1.0 200 OK
\r\n
Content-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\n
Content-Type: text/html
\r\n\r\n
"
\
bytes
=
sock_write
(
client
->
con
->
sock
,
"HTTP/1.0 404 File Not Found
\r\n
Content-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\n
Content-Type: %s
\r\n
"
,
format_get_mimetype
(
source
->
format
->
type
));
bytes
=
sock_write
(
client
->
con
->
sock
,
"HTTP/1.0 200 OK
\r\n
Content-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
);
}
...
...
src/stats.c
View file @
63579360
...
...
@@ -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
)
...
...
src/xslt.c
View file @
63579360
...
...
@@ -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
,
nB
ytes
;
size_t
count
,
b
ytes
;
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. */
nB
ytes
=
xmlOutputBufferWrite
(
outputBuffer
,
1
,
""
);
b
ytes
=
xmlOutputBufferWrite
(
outputBuffer
,
1
,
""
);
sock_write_string
(
client
->
con
->
sock
,
(
char
*
)
outputBuffer
->
buffer
->
content
);
if
(
sock_write_string
(
client
->
con
->
sock
,
(
char
*
)
outputBuffer
->
buffer
->
content
))
client
->
con
->
sent_bytes
+=
bytes
;
xmlFree
(
outputBuffer
);
xsltFreeStylesheet
(
cur
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment