From: Jaroslav Kysela Date: Wed, 31 May 2017 07:16:34 +0000 (+0200) Subject: set the default stack size to 2MB X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=492eb334a8e13bbcc9c1e86acc22ddd83c0fa326;p=thirdparty%2Ftvheadend.git set the default stack size to 2MB --- diff --git a/src/idnode.c b/src/idnode.c index 17c0dffa9..91c4747c9 100644 --- a/src/idnode.c +++ b/src/idnode.c @@ -1886,7 +1886,7 @@ save_thread ( void *aux ) htsmsg_t *m; char filename[PATH_MAX]; - tvhtread_renice(15); + tvhthread_renice(15); pthread_mutex_lock(&global_lock); diff --git a/src/main.c b/src/main.c index 1a918097d..769859ce0 100644 --- a/src/main.c +++ b/src/main.c @@ -78,6 +78,7 @@ #ifdef PLATFORM_LINUX #include #endif +#include #include #include #include @@ -446,7 +447,7 @@ tasklet_thread ( void *aux ) tsk_callback_t *tsk_cb; void *opaque; - tvhtread_renice(20); + tvhthread_renice(20); pthread_mutex_lock(&tasklet_lock); while (tvheadend_is_running()) { @@ -740,6 +741,7 @@ main(int argc, char **argv) struct timeval tv; uint8_t ru[32]; } randseed; + struct rlimit rl; extern int dvb_bouquets_parse; main_tid = pthread_self(); @@ -1122,6 +1124,16 @@ main(int argc, char **argv) umask(0); } + memset(&rl, 0, sizeof(rl)); + if (getrlimit(RLIMIT_STACK, &rl) || rl.rlim_cur < 2*1024*1024) { + rlim_t rl2 = rl.rlim_cur; + rl.rlim_cur = 2*1024*1024; + if (setrlimit(RLIMIT_STACK, &rl)) { + tvhlog(LOG_ALERT, LS_START, "too small stack size - %ld", (long)rl2); + return 1; + } + } + atomic_set(&tvheadend_running, 1); /* Start log thread (must be done post fork) */ diff --git a/src/tvheadend.h b/src/tvheadend.h index d0f55a18b..49954c393 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -703,7 +703,7 @@ int tvhthread_create void *(*start_routine) (void *), void *arg, const char *name); -int tvhtread_renice(int value); +int tvhthread_renice(int value); int tvh_mutex_timedlock(pthread_mutex_t *mutex, int64_t usec); diff --git a/src/wrappers.c b/src/wrappers.c index 072313872..39e9b9716 100644 --- a/src/wrappers.c +++ b/src/wrappers.c @@ -171,6 +171,12 @@ tvhthread_create { int r; struct thread_state *ts = calloc(1, sizeof(struct thread_state)); + pthread_attr_t _attr; + if (attr == NULL) { + pthread_attr_init(&_attr); + pthread_attr_setstacksize(&_attr, 2*1024*1024); + attr = &_attr; + } strncpy(ts->name, "tvh:", 4); strncpy(ts->name+4, name, sizeof(ts->name)-4); ts->name[sizeof(ts->name)-1] = '\0'; @@ -182,7 +188,7 @@ tvhthread_create /* linux style: -19 .. 20 */ int -tvhtread_renice(int value) +tvhthread_renice(int value) { int ret = 0; #ifdef SYS_gettid