* make configure check for getloadavg()
authorWilfried Göesgens <willi@citadel.org>
Mon, 30 Nov 2009 19:33:48 +0000 (19:33 +0000)
committerWilfried Göesgens <willi@citadel.org>
Mon, 30 Nov 2009 19:33:48 +0000 (19:33 +0000)
citadel/configure.ac
citadel/threads.c

index bd25624195de30b8a834ecbbd1563d32c939fbf1..362e6496696f178726da24c3920c2065511cdf49 100644 (file)
@@ -165,7 +165,7 @@ if test "x$with_zlib" != xno ; then
 fi
 
 if test "x$ok_zlib" = xyes ; then
-dnl  libcitadel will bring libz, so we don't need it here.     LDFLAGS="-lz $LDFLAGS" 
+       LDFLAGS="-lz $LDFLAGS" 
        AC_DEFINE(HAVE_ZLIB, [], [define this if you have zlib compression available])
 fi
 
@@ -406,7 +406,7 @@ dnl Checks for libraries.
 dnl We want to test for the following in libc before checking for their
 dnl respective libraries, because some systems (like Irix) have both, and the
 dnl non-libc versions may be broken.
-AC_CHECK_FUNCS(crypt gethostbyname connect flock getpwnam_r getpwuid_r)
+AC_CHECK_FUNCS(crypt gethostbyname connect flock getpwnam_r getpwuid_r getloadavg)
 
 
 dnl disable backtrace if we don't want it.
index e115306a2e1ed640719304008ec6f7d3fefd6c2d..2b419848b5a8f853a8471431c05ae7a7aba64c76 100644 (file)
@@ -410,16 +410,18 @@ double CtdlThreadGetWorkerAvg(void)
 
 double CtdlThreadGetLoadAvg(void)
 {
-       double load_avg[3] ;
+       double load_avg[3] = {0.0, 0.0, 0.0};
 
-       int ret;
+       int ret = 0;
        int smp_num_cpus;
 
        /* Borrowed this straight from procps */
        smp_num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
        if(smp_num_cpus<1) smp_num_cpus=1; /* SPARC glibc is buggy */
 
+#ifdef HAVE_GETLOADAVG
        ret = getloadavg(load_avg, 3);
+#endif
        if (ret < 0)
                return 0;
        return load_avg[0] / smp_num_cpus;