Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
Icecast-Server
Commits
19dda791
Commit
19dda791
authored
Jun 18, 2018
by
Philipp Schafft
🦁
Browse files
Update: Added timeout and size limit to client body queue handling
parent
669707d3
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/cfgfile.c
View file @
19dda791
...
...
@@ -49,11 +49,13 @@
#define CONFIG_DEFAULT_CLIENT_LIMIT 256
#define CONFIG_DEFAULT_SOURCE_LIMIT 16
#define CONFIG_DEFAULT_QUEUE_SIZE_LIMIT (500*1024)
#define CONFIG_DEFAULT_BODY_SIZE_LIMIT (4*1024)
#define CONFIG_DEFAULT_BURST_SIZE (64*1024)
#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_BODY_TIMEOUT (10 + CONFIG_DEFAULT_HEADER_TIMEOUT)
#define CONFIG_DEFAULT_MASTER_USERNAME "relay"
#define CONFIG_DEFAULT_SHOUTCAST_MOUNT "/stream"
#define CONFIG_DEFAULT_SHOUTCAST_USER "source"
...
...
@@ -801,12 +803,16 @@ static void _set_defaults(ice_config_t *configuration)
->
source_limit
=
CONFIG_DEFAULT_SOURCE_LIMIT
;
configuration
->
queue_size_limit
=
CONFIG_DEFAULT_QUEUE_SIZE_LIMIT
;
configuration
->
body_size_limit
=
CONFIG_DEFAULT_BODY_SIZE_LIMIT
;
configuration
->
client_timeout
=
CONFIG_DEFAULT_CLIENT_TIMEOUT
;
configuration
->
header_timeout
=
CONFIG_DEFAULT_HEADER_TIMEOUT
;
configuration
->
source_timeout
=
CONFIG_DEFAULT_SOURCE_TIMEOUT
;
configuration
->
source_timeout
=
CONFIG_DEFAULT_BODY_TIMEOUT
;
configuration
->
shoutcast_mount
=
(
char
*
)
xmlCharStrdup
(
CONFIG_DEFAULT_SHOUTCAST_MOUNT
);
configuration
...
...
@@ -1123,6 +1129,8 @@ static void _parse_limits(xmlDocPtr doc,
__read_int
(
doc
,
node
,
&
configuration
->
client_limit
,
"<clients> must not be empty."
);
}
else
if
(
xmlStrcmp
(
node
->
name
,
XMLSTR
(
"sources"
))
==
0
)
{
__read_int
(
doc
,
node
,
&
configuration
->
source_limit
,
"<sources> must not be empty."
);
}
else
if
(
xmlStrcmp
(
node
->
name
,
XMLSTR
(
"bodysize"
))
==
0
)
{
__read_int
(
doc
,
node
,
&
configuration
->
body_size_limit
,
"<bodysize> must not be empty."
);
}
else
if
(
xmlStrcmp
(
node
->
name
,
XMLSTR
(
"queue-size"
))
==
0
)
{
__read_unsigned_int
(
doc
,
node
,
&
configuration
->
queue_size_limit
,
"<queue-size> must not be empty."
);
}
else
if
(
xmlStrcmp
(
node
->
name
,
XMLSTR
(
"threadpool"
))
==
0
)
{
...
...
@@ -1134,6 +1142,8 @@ static void _parse_limits(xmlDocPtr doc,
__read_int
(
doc
,
node
,
&
configuration
->
header_timeout
,
"<header-timeout> must not be empty."
);
}
else
if
(
xmlStrcmp
(
node
->
name
,
XMLSTR
(
"source-timeout"
))
==
0
)
{
__read_int
(
doc
,
node
,
&
configuration
->
source_timeout
,
"<source-timeout> must not be empty."
);
}
else
if
(
xmlStrcmp
(
node
->
name
,
XMLSTR
(
"body-timeout"
))
==
0
)
{
__read_int
(
doc
,
node
,
&
configuration
->
body_timeout
,
"<body-timeout> must not be empty."
);
}
else
if
(
xmlStrcmp
(
node
->
name
,
XMLSTR
(
"burst-on-connect"
))
==
0
)
{
ICECAST_LOG_WARN
(
"<burst-on-connect> is deprecated, use <burst-size> instead."
);
tmp
=
(
char
*
)
xmlNodeListGetString
(
doc
,
node
->
xmlChildrenNode
,
1
);
...
...
src/cfgfile.h
View file @
19dda791
...
...
@@ -26,6 +26,7 @@
#include
"common/thread/thread.h"
#include
"common/avl/avl.h"
#include
"icecasttypes.h"
#include
"compat.h"
#define XMLSTR(str) ((xmlChar *)(str))
...
...
@@ -170,11 +171,13 @@ struct ice_config_tag {
int
client_limit
;
int
source_limit
;
int
body_size_limit
;
unsigned
int
queue_size_limit
;
unsigned
int
burst_size
;
int
client_timeout
;
int
header_timeout
;
int
source_timeout
;
int
body_timeout
;
int
fileserve
;
int
on_demand
;
/* global setting for all relays */
...
...
src/connection.c
View file @
19dda791
...
...
@@ -611,11 +611,19 @@ static void _add_body_client(client_queue_t *node)
static
void
process_request_body_queue
(
void
)
{
client_queue_t
**
node_ref
=
(
client_queue_t
**
)
&
_body_queue
;
ice_config_t
*
config
;
time_t
timeout
;
size_t
body_size_limit
;
ICECAST_LOG_DEBUG
(
"Processing body queue."
);
ICECAST_LOG_DEBUG
(
"_body_queue=%p, &_body_queue=%p, _body_queue_tail=%p"
,
_body_queue
,
&
_body_queue
,
_body_queue_tail
);
config
=
config_get_config
();
timeout
=
time
(
NULL
)
-
config
->
body_timeout
;
body_size_limit
=
config
->
body_size_limit
;
config_release_config
();
while
(
*
node_ref
)
{
client_queue_t
*
node
=
*
node_ref
;
client_t
*
client
=
node
->
client
;
...
...
@@ -625,7 +633,7 @@ static void process_request_body_queue (void)
res
=
client_body_skip
(
client
);
if
(
res
!=
CLIENT_SLURP_NEEDS_MORE_DATA
)
{
if
(
res
!=
CLIENT_SLURP_NEEDS_MORE_DATA
||
client
->
con
->
con_time
<=
timeout
||
client
->
request_body_read
>=
body_size_limit
)
{
ICECAST_LOG_DEBUG
(
"Putting client %p back in connection queue."
,
client
);
if
((
client_queue_t
**
)
_body_queue_tail
==
&
(
node
->
next
))
...
...
Write
Preview
Supports
Markdown
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