From ed23cc08e3c1964da4f35187aed03d3552b2c045 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 9 May 2008 04:18:17 +0000 Subject: [PATCH] [SIGAR-102] do not attempt to filter LinuxThreads in 2.6+ kernels --- src/os/linux/linux_sigar.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index 5b1854f7..eeb2921a 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -95,7 +95,7 @@ static int get_proc_signal_offset(void) { char buffer[BUFSIZ], *ptr=buffer; int fields = 0; - int status = sigar_file2str("/proc/self/stat", + int status = sigar_file2str(PROCP_FS_ROOT "self/stat", buffer, sizeof(buffer)); if (status != SIGAR_OK) { @@ -210,6 +210,9 @@ char *sigar_os_error_string(sigar_t *sigar, int err) return NULL; } +/* Native POSIX Thread Library 2.6+ kernel */ +#define SIGAR_HAS_NPTL (sigar->iostat == IOSTAT_DISKSTATS) + static int sigar_cpu_total_count(sigar_t *sigar) { sigar->ncpu = (int)sysconf(_SC_NPROCESSORS_CONF); @@ -582,12 +585,13 @@ int sigar_os_proc_list_get(sigar_t *sigar, { DIR *dirp = opendir(PROCP_FS_ROOT); struct dirent *ent, dbuf; + register const int threadbadhack = !SIGAR_HAS_NPTL; if (!dirp) { return errno; } - if (sigar->proc_signal_offset == -1) { + if (threadbadhack && (sigar->proc_signal_offset == -1)) { sigar->proc_signal_offset = get_proc_signal_offset(); } @@ -600,7 +604,8 @@ int sigar_os_proc_list_get(sigar_t *sigar, continue; } - if (proc_isthread(sigar, ent->d_name, strlen(ent->d_name))) + if (threadbadhack && + proc_isthread(sigar, ent->d_name, strlen(ent->d_name))) { continue; }