- Pthread stack size made adjustable (thread_stack_size)

This commit is contained in:
Thomas Ries 2011-06-12 18:45:17 +00:00
parent 44b6e65548
commit b0be9e3275
5 changed files with 40 additions and 1 deletions

View File

@ -2,6 +2,7 @@
=====
12-Jun-2011: - one-off in get_ip_by_ifname(), last interface in chain
was not considered in matching.
- Pthread stack size made adjustable (thread_stack_size)
11-Jun-2011: - other stun server in example config file and
reworked some stun code.
05-Jun-2011: - readconf: allow spaces within string values.

View File

@ -81,6 +81,20 @@ silence_log = 1
user = nobody
#chrootjail = /var/lib/siproxd/
######################################################################
# Memory settings
#
# THREAD_STACK_SIZE IS AN EXPERIMENTAL FEATURE!
# It may be used to reduce the stack size allocated
# by pthreads. This may reduce the overall memory footprint
# of siproxd and could be helpful on embedded systems.
# If you don't know what I'm saying above, do not enable this setting!
# USE AT YOUR OWN RISK!
# Too small stack size may lead to unexplainable crashes!
# Improper use may make siproxd eat your dog and vandalize
# your garden.
#thread_stack_size = 512
######################################################################
# Registration file:
# Where to store the current registrations.

View File

@ -92,6 +92,8 @@ int rtp_relay_init( void ) {
int sts;
int arg=0;
struct sigaction sigact;
pthread_attr_t attr;
size_t stacksize;
#ifdef USE_DEJITTER
dejitter_init();
@ -113,8 +115,28 @@ int rtp_relay_init( void ) {
sigact.sa_flags=0;
sigaction(SIGALRM, &sigact, NULL);
pthread_attr_init(&attr);
pthread_attr_init(&attr);
pthread_attr_getstacksize (&attr, &stacksize);
INFO("Current thread stacksize is %i kB",stacksize/1024);
/* experimental feature:
* reduce the thread stack size to reduce the overall
* memory footprint of siproxd on embedded systems
*
* Use at your own risk!
* Too small stack size may lead to unexplainable crashes!
* Improper use may make siproxd eat your dog and vandalize
* your garden.
*/
if (configuration.thread_stack_size > 0) {
stacksize = configuration.thread_stack_size*1024;
pthread_attr_setstacksize (&attr, stacksize);
INFO("Setting new thread stacksize to %i kB",stacksize/1024);
}
DEBUGC(DBCLASS_RTP,"create thread");
sts=pthread_create(&rtpproxy_tid, NULL, rtpproxy_main, (void *)&arg);
sts=pthread_create(&rtpproxy_tid, &attr, rtpproxy_main, (void *)&arg);
DEBUGC(DBCLASS_RTP,"created, sts=%i", sts);
/* set realtime scheduling - if started by root */

View File

@ -89,6 +89,7 @@ static cfgopts_t main_cfg_opts[] = {
{ "tcp_timeout", TYP_INT4, &configuration.tcp_timeout, {TCP_IDLE_TO, NULL} },
{ "tcp_connect_timeout", TYP_INT4, &configuration.tcp_connect_timeout, {TCP_CONNECT_TO, NULL} },
{ "tcp_keepalive", TYP_INT4, &configuration.tcp_keepalive, {0, NULL} },
{ "thread_stack_size", TYP_INT4, &configuration.thread_stack_size, {0, NULL} },
{0, 0, 0}
};

View File

@ -103,6 +103,7 @@ struct siproxd_config {
int tcp_timeout;
int tcp_connect_timeout;
int tcp_keepalive;
int thread_stack_size;
};
/*