summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6d8031d)
raw | patch | inline | side by side (parent: 6d8031d)
author | Florian Forster <octo@collectd.org> | |
Sat, 19 Nov 2016 07:10:47 +0000 (08:10 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Sat, 19 Nov 2016 07:10:47 +0000 (08:10 +0100) |
configure.ac | patch | blob | history | |
src/daemon/plugin.c | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index db1754345a5dbba4ffc829e0740cd0d2f9e5193c..9c5df839f67b40e86374292a54f4e1b2d84a621b 100644 (file)
--- a/configure.ac
+++ b/configure.ac
AC_HEADER_DIRENT
AC_HEADER_STDBOOL
-AC_CHECK_HEADERS(stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h sys/isa_defs.h fnmatch.h libgen.h)
+AC_CHECK_HEADERS(stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h sys/isa_defs.h fnmatch.h libgen.h pthread_np.h)
# For entropy plugin on newer NetBSD
AC_CHECK_HEADERS(sys/rndio.h, [], [],
@@ -1663,46 +1663,43 @@ AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, ks
])
# check for pthread_setname_np
-SAVE_LDFLAGS=$LDFLAGS
+SAVE_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -lpthread"
AC_MSG_CHECKING([if have pthread_setname_np])
have_pthread_setname_np="no"
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[
-#if HAVE_PTHREAD_H
+#define _GNU_SOURCE
#include <pthread.h>
-#endif
]],
[[
- pthread_setname_np(pthread_self(), "conftest");
+ pthread_setname_np((pthread_t) {0}, "conftest");
]]
)], [
have_pthread_setname_np="yes"
- AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [ pthread_setname_np() is available.])
+ AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [pthread_setname_np() is available.])
])
-AC_MSG_RESULT([$have_pthread_set_name_np])
+AC_MSG_RESULT([$have_pthread_setname_np])
-# check for pthread_set_name_np
+# check for pthread_set_name_np(3) (FreeBSD)
AC_MSG_CHECKING([if have pthread_set_name_np])
have_pthread_set_name_np="no"
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[
-#if HAVE_PTHREAD_H
-#include <pthread.h>
-#endif
+#include <pthread_np.h>
]],
[[
- pthread_set_name_np(pthread_self(), "conftest");
+ pthread_set_name_np((pthread_t) {0}, "conftest");
]]
)], [
have_pthread_set_name_np="yes"
- AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP, 1, [ pthread_set_name_np() is available.])
+ AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP, 1, [pthread_set_name_np() is available.])
])
AC_MSG_RESULT([$have_pthread_set_name_np])
-LDFLAGS=$SAVE_LDFLAGS
+LDFLAGS="$SAVE_LDFLAGS"
#
# Checks for libraries begin here
diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c
index 08c5199566a6a0134f1bf39a0042205d7ecdd588..ac9ce5bd16df5a40dc89a4543c3ccd89b344510d 100644 (file)
--- a/src/daemon/plugin.c
+++ b/src/daemon/plugin.c
#include "utils_time.h"
#include "utils_random.h"
+#if HAVE_PTHREAD_NP_H
+# include <pthread_np.h> /* for pthread_set_name_np(3) */
+#endif
+
#include <ltdl.h>
/*
plugin_read_thread, NULL) == 0)
{
#if defined(HAVE_PTHREAD_SETNAME_NP) || defined(HAVE_PTHREAD_SET_NAME_NP)
- char thread_name[16];
- sstrncpy (thread_name, "plugin reader", sizeof(thread_name));
+ char thread_name[32];
+ ssnprintf(thread_name, sizeof (thread_name),
+ "plugin reader#%d", i);
# if defined(HAVE_PTHREAD_SETNAME_NP)
pthread_setname_np (*(read_threads + read_threads_num),
thread_name);