]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
set the default stack size to 2MB
authorJaroslav Kysela <perex@perex.cz>
Wed, 31 May 2017 07:16:34 +0000 (09:16 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 31 May 2017 07:16:34 +0000 (09:16 +0200)
src/idnode.c
src/main.c
src/tvheadend.h
src/wrappers.c

index 17c0dffa99ea9476a122e8980087b39f212cf146..91c4747c9afaa279bad1a3c753c38e4a4f2e6900 100644 (file)
@@ -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);
 
index 1a918097df614c7513531af0f12d76905eea80e0..769859ce0c6507bbfbd8939484139c2f6b3b8cff 100644 (file)
@@ -78,6 +78,7 @@
 #ifdef PLATFORM_LINUX
 #include <sys/prctl.h>
 #endif
+#include <sys/resource.h>
 #include <openssl/ssl.h>
 #include <openssl/conf.h>
 #include <openssl/err.h>
@@ -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) */
index d0f55a18b6f53df30e99008dceef3e6840e90d60..49954c393ada4e3da9b6fdbb9838c1a83c889253 100644 (file)
@@ -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);
 
index 072313872c55214be23b4ce25d5b0321068da780..39e9b97168be009924f3e4d7c4a48951c0ab1e9b 100644 (file)
@@ -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