#ifdef PLATFORM_LINUX
#include <sys/prctl.h>
#endif
+#include <sys/resource.h>
#include <openssl/ssl.h>
#include <openssl/conf.h>
#include <openssl/err.h>
tsk_callback_t *tsk_cb;
void *opaque;
- tvhtread_renice(20);
+ tvhthread_renice(20);
pthread_mutex_lock(&tasklet_lock);
while (tvheadend_is_running()) {
struct timeval tv;
uint8_t ru[32];
} randseed;
+ struct rlimit rl;
extern int dvb_bouquets_parse;
main_tid = pthread_self();
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) */
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);
{
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';
/* linux style: -19 .. 20 */
int
-tvhtread_renice(int value)
+tvhthread_renice(int value)
{
int ret = 0;
#ifdef SYS_gettid