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
8d75eb0b
Commit
8d75eb0b
authored
Aug 09, 2002
by
Michael Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Logging cleanups, and a config file fix.
svn path=/trunk/icecast/; revision=3773
parent
9b6b2afe
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
34 deletions
+35
-34
conf/icecast.xml
conf/icecast.xml
+1
-1
src/connection.c
src/connection.c
+21
-18
src/slave.c
src/slave.c
+4
-3
src/source.c
src/source.c
+9
-12
No files found.
conf/icecast.xml
View file @
8d75eb0b
...
...
@@ -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>
...
...
src/connection.c
View file @
8d75eb0b
...
...
@@ -151,7 +151,6 @@ static void _add_connection(connection_t *con)
_queue
=
node
;
thread_mutex_unlock
(
&
_queue_mutex
);
printf
(
"connection added....
\n
"
);
}
static
void
_signal_pool
(
void
)
...
...
@@ -294,7 +293,6 @@ int connection_create_source(connection_t *con, http_parser_t *parser, char *mou
*/
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 @@ int connection_create_source(connection_t *con, http_parser_t *parser, char *mou
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 @@ static void *_handle_connection(void *arg)
/* 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 @@ static void *_handle_connection(void *arg)
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 @@ static void *_handle_connection(void *arg)
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 connectio
n"
);
connection_close
(
con
);
httpp_destroy
(
parser
);
continue
;
...
...
@@ -424,7 +428,7 @@ static void *_handle_connection(void *arg)
continue
;
}
else
if
(
parser
->
req_type
==
httpp_req_play
||
parser
->
req_type
==
httpp_req_get
)
{
printf
(
"
DEBUG
: c
lient co
ming in...
\n
"
);
DEBUG
0
(
"C
lient co
nnected
"
);
/* make a client */
client
=
client_create
(
con
,
parser
);
...
...
@@ -439,7 +443,7 @@ static void *_handle_connection(void *arg)
*/
// 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 @@ 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
"
);
stats_transform_xslt
(
client
,
fullPath
);
}
...
...
@@ -467,7 +472,6 @@ static void *_handle_connection(void *arg)
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 @@ static void *_handle_connection(void *arg)
avl_tree_rlock
(
global
.
source_tree
);
source
=
source_find_mount
(
httpp_getvar
(
parser
,
HTTPP_VAR_URI
));
if
(
source
)
{
printf
(
"
DEBUG
: s
ource found for client
\n
"
);
DEBUG
0
(
"S
ource found for client"
);
global_lock
();
if
(
global
.
clients
>=
config_get_config
()
->
client_limit
)
{
...
...
@@ -534,7 +538,6 @@ static void *_handle_connection(void *arg)
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 @@ static void *_handle_connection(void *arg)
avl_tree_unlock
(
global
.
source_tree
);
if
(
!
source
)
{
printf
(
"
DEBUG
: s
ource not found for client
\n
"
);
DEBUG
0
(
"S
ource 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\n
Content-Type: text/html
\r\n\r\n
"
\
...
...
@@ -566,13 +569,13 @@ static void *_handle_connection(void *arg)
continue
;
}
else
{
printf
(
"DEBUG: w
rong request type
\n
"
);
ERROR0
(
"W
rong 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
;
...
...
src/slave.c
View file @
8d75eb0b
...
...
@@ -82,7 +82,7 @@ static void *_slave_thread(void *arg) {
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\n
ice-password: %s
\r\n\r\n
"
,
config_get_config
()
->
source_password
);
...
...
@@ -91,10 +91,11 @@ static void *_slave_thread(void *arg) {
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: f
ailed to
get
stream from master server
\n
"
);
WARN0
(
"F
ailed to
relay
stream from master server"
);
continue
;
}
con
=
create_connection
(
streamsock
,
NULL
);
...
...
src/source.c
View file @
8d75eb0b
...
...
@@ -173,8 +173,7 @@ void *source_main(void *arg)
}
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 @@ void *source_main(void *arg)
}
if
(
sbytes
<
0
)
{
if
(
!
sock_recoverable
(
sock_error
()))
{
printf
(
"SOURCE:
Client ha
d
unrecoverable error catching up
(%ld/%ld)
\n
"
,
sbytes
,
bytes
);
DEBUG0
(
"
Client ha
s
unrecoverable error catching up
. Client has probably disconnected"
);
client
->
con
->
error
=
1
;
}
else
{
printf
(
"SOURCE: c
lient had recoverable error
...
\n
"
);
DEBUG1
(
"C
lient 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 @@ void *source_main(void *arg)
if
(
sbytes
<
0
)
{
bytes
=
sock_error
();
if
(
!
sock_recoverable
(
bytes
))
{
printf
(
"SOURCE: c
lient had unrecoverable error
%ld
with new data
(%ld/%ld)
\n
"
,
bytes
,
sbytes
,
refbuf
->
len
);
DEBUG0
(
"C
lient 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 @@ void *source_main(void *arg)
** TODO: put queue_limit in a config file
*/
if
(
refbuf_queue_size
(
&
client
->
queue
)
>
25
)
{
printf
(
"SOURCE: client is too lagged... kick
ing
\n
"
);
DEBUG0
(
"Client has fallen too far behind, remov
ing"
);
client
->
con
->
error
=
1
;
}
...
...
@@ -311,7 +310,7 @@ void *source_main(void *arg)
global_unlock
();
stats_event_dec
(
NULL
,
"clients"
);
stats_event_args
(
source
->
mount
,
"listeners"
,
"%d"
,
listeners
);
printf
(
"
DEBUG
:
Client
dropped...
\n
"
);
DEBUG
0
(
"
Client
removed
"
);
continue
;
}
client_node
=
avl_get_next
(
client_node
);
...
...
@@ -325,7 +324,7 @@ void *source_main(void *arg)
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 @@ void *source_main(void *arg)
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
);
...
...
@@ -373,8 +372,6 @@ done:
stats_event_dec
(
NULL
,
"sources"
);
stats_event
(
source
->
mount
,
"listeners"
,
NULL
);
printf
(
"DEBUG: source_main() is now exiting...
\n
"
);
global_lock
();
global
.
sources
--
;
global_unlock
();
...
...
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