diff options
Diffstat (limited to '')
-rw-r--r-- | libnetdata/threads/threads.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/libnetdata/threads/threads.c b/libnetdata/threads/threads.c index adce0463c..ae3c7106d 100644 --- a/libnetdata/threads/threads.c +++ b/libnetdata/threads/threads.c @@ -123,10 +123,12 @@ size_t netdata_threads_init(void) { // -------------------------------------------------------------------- // get the required stack size of the threads of netdata - netdata_threads_attr = callocz(1, sizeof(pthread_attr_t)); - i = pthread_attr_init(netdata_threads_attr); - if(i != 0) - fatal("pthread_attr_init() failed with code %d.", i); + if(!netdata_threads_attr) { + netdata_threads_attr = callocz(1, sizeof(pthread_attr_t)); + i = pthread_attr_init(netdata_threads_attr); + if (i != 0) + fatal("pthread_attr_init() failed with code %d.", i); + } size_t stacksize = 0; i = pthread_attr_getstacksize(netdata_threads_attr, &stacksize); @@ -159,6 +161,17 @@ void netdata_threads_init_after_fork(size_t stacksize) { } // ---------------------------------------------------------------------------- +// threads init for external plugins + +void netdata_threads_init_for_external_plugins(size_t stacksize) { + size_t default_stacksize = netdata_threads_init(); + if(default_stacksize < 1 * 1024 * 1024) + default_stacksize = 1 * 1024 * 1024; + + netdata_threads_init_after_fork(stacksize ? stacksize : default_stacksize); +} + +// ---------------------------------------------------------------------------- // netdata_thread_create void rrdset_thread_rda_free(void); |