]> 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:17:44 +0000 (09:17 +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 7c2aac2a1d5fefc2d600934f36d5d6d90dc81706..53c6be4bd8fe290605f7a67316dc2ad697de0ade 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 ec8d8b92547ff0d1ab3378cb07b218c824ef42d1..da90eedd56ae5e12c364bdd7f5651cc234ab1e0d 100644 (file)
@@ -701,7 +701,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 a354f2ee7b0f5afbf8f31b554f399e2aa9fd7b6d..a2ba64f9b0af728bec7f38bf3bf2d1df413a54bf 100644 (file)
@@ -169,6 +169,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';
@@ -180,7 +186,7 @@ tvhthread_create
 
 /* linux style: -19 .. 20 */
 int
-tvhtread_renice(int value)
+tvhthread_renice(int value)
 {
   int ret = 0;
 #ifdef SYS_gettid