summaryrefslogtreecommitdiffstats
path: root/libnetdata/threads/threads.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-20 04:49:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-20 04:49:55 +0000
commitab1bb5b7f1c3c3a7b240ab7fc8661459ecd7decb (patch)
tree7a900833aad3ccc685712c6c2a7d87576d54f427 /libnetdata/threads/threads.c
parentAdding upstream version 1.40.1. (diff)
downloadnetdata-ab1bb5b7f1c3c3a7b240ab7fc8661459ecd7decb.tar.xz
netdata-ab1bb5b7f1c3c3a7b240ab7fc8661459ecd7decb.zip
Adding upstream version 1.41.0.upstream/1.41.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libnetdata/threads/threads.c')
-rw-r--r--libnetdata/threads/threads.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/libnetdata/threads/threads.c b/libnetdata/threads/threads.c
index a4591d5ac..adce0463c 100644
--- a/libnetdata/threads/threads.c
+++ b/libnetdata/threads/threads.c
@@ -133,7 +133,7 @@ size_t netdata_threads_init(void) {
if(i != 0)
fatal("pthread_attr_getstacksize() failed with code %d.", i);
else
- debug(D_OPTIONS, "initial pthread stack size is %zu bytes", stacksize);
+ netdata_log_debug(D_OPTIONS, "initial pthread stack size is %zu bytes", stacksize);
return stacksize;
}
@@ -150,12 +150,12 @@ void netdata_threads_init_after_fork(size_t stacksize) {
if(netdata_threads_attr && stacksize > (size_t)PTHREAD_STACK_MIN) {
i = pthread_attr_setstacksize(netdata_threads_attr, stacksize);
if(i != 0)
- error("pthread_attr_setstacksize() to %zu bytes, failed with code %d.", stacksize, i);
+ netdata_log_error("pthread_attr_setstacksize() to %zu bytes, failed with code %d.", stacksize, i);
else
- info("Set threads stack size to %zu bytes", stacksize);
+ netdata_log_info("Set threads stack size to %zu bytes", stacksize);
}
else
- error("Invalid pthread stacksize %zu", stacksize);
+ netdata_log_error("Invalid pthread stacksize %zu", stacksize);
}
// ----------------------------------------------------------------------------
@@ -169,11 +169,11 @@ void service_exits(void);
static void thread_cleanup(void *ptr) {
if(netdata_thread != ptr) {
NETDATA_THREAD *info = (NETDATA_THREAD *)ptr;
- error("THREADS: internal error - thread local variable does not match the one passed to this function. Expected thread '%s', passed thread '%s'", netdata_thread->tag, info->tag);
+ netdata_log_error("THREADS: internal error - thread local variable does not match the one passed to this function. Expected thread '%s', passed thread '%s'", netdata_thread->tag, info->tag);
}
if(!(netdata_thread->options & NETDATA_THREAD_OPTION_DONT_LOG_CLEANUP))
- info("thread with task id %d finished", gettid());
+ netdata_log_info("thread with task id %d finished", gettid());
sender_thread_buffer_free();
rrdset_thread_rda_free();
@@ -205,9 +205,9 @@ static void thread_set_name_np(NETDATA_THREAD *nt) {
#endif
if (ret != 0)
- error("cannot set pthread name of %d to %s. ErrCode: %d", gettid(), threadname, ret);
+ netdata_log_error("cannot set pthread name of %d to %s. ErrCode: %d", gettid(), threadname, ret);
else
- info("set name of thread %d to %s", gettid(), threadname);
+ netdata_log_info("set name of thread %d to %s", gettid(), threadname);
}
}
@@ -230,7 +230,7 @@ void uv_thread_set_name_np(uv_thread_t ut, const char* name) {
thread_name_get(true);
if (ret)
- info("cannot set libuv thread name to %s. Err: %d", threadname, ret);
+ netdata_log_info("cannot set libuv thread name to %s. Err: %d", threadname, ret);
}
void os_thread_get_current_name_np(char threadname[NETDATA_THREAD_NAME_MAX + 1])
@@ -247,13 +247,13 @@ static void *netdata_thread_init(void *ptr) {
netdata_thread = (NETDATA_THREAD *)ptr;
if(!(netdata_thread->options & NETDATA_THREAD_OPTION_DONT_LOG_STARTUP))
- info("thread created with task id %d", gettid());
+ netdata_log_info("thread created with task id %d", gettid());
if(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) != 0)
- error("cannot set pthread cancel type to DEFERRED.");
+ netdata_log_error("cannot set pthread cancel type to DEFERRED.");
if(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0)
- error("cannot set pthread cancel state to ENABLE.");
+ netdata_log_error("cannot set pthread cancel state to ENABLE.");
thread_set_name_np(ptr);
@@ -275,13 +275,13 @@ int netdata_thread_create(netdata_thread_t *thread, const char *tag, NETDATA_THR
int ret = pthread_create(thread, netdata_threads_attr, netdata_thread_init, info);
if(ret != 0)
- error("failed to create new thread for %s. pthread_create() failed with code %d", tag, ret);
+ netdata_log_error("failed to create new thread for %s. pthread_create() failed with code %d", tag, ret);
else {
if (!(options & NETDATA_THREAD_OPTION_JOINABLE)) {
int ret2 = pthread_detach(*thread);
if (ret2 != 0)
- error("cannot request detach of newly created %s thread. pthread_detach() failed with code %d", tag, ret2);
+ netdata_log_error("cannot request detach of newly created %s thread. pthread_detach() failed with code %d", tag, ret2);
}
}
@@ -298,9 +298,9 @@ int netdata_thread_cancel(netdata_thread_t thread) {
int ret = pthread_cancel(thread);
if(ret != 0)
#ifdef NETDATA_INTERNAL_CHECKS
- error("cannot cancel thread. pthread_cancel() failed with code %d at %d@%s, function %s()", ret, line, file, function);
+ netdata_log_error("cannot cancel thread. pthread_cancel() failed with code %d at %d@%s, function %s()", ret, line, file, function);
#else
- error("cannot cancel thread. pthread_cancel() failed with code %d.", ret);
+ netdata_log_error("cannot cancel thread. pthread_cancel() failed with code %d.", ret);
#endif
return ret;
@@ -312,7 +312,7 @@ int netdata_thread_cancel(netdata_thread_t thread) {
int netdata_thread_join(netdata_thread_t thread, void **retval) {
int ret = pthread_join(thread, retval);
if(ret != 0)
- error("cannot join thread. pthread_join() failed with code %d.", ret);
+ netdata_log_error("cannot join thread. pthread_join() failed with code %d.", ret);
return ret;
}
@@ -320,7 +320,7 @@ int netdata_thread_join(netdata_thread_t thread, void **retval) {
int netdata_thread_detach(pthread_t thread) {
int ret = pthread_detach(thread);
if(ret != 0)
- error("cannot detach thread. pthread_detach() failed with code %d.", ret);
+ netdata_log_error("cannot detach thread. pthread_detach() failed with code %d.", ret);
return ret;
}