From 466a253a8c6bb7612757211a4d17deeac288840c Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 8 Sep 2009 22:15:09 +0200 Subject: [PATCH] update machinery: fix for update_stat() on linux --- src/linux.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/linux.c b/src/linux.c index cc15b3f9..60360d5e 100644 --- a/src/linux.c +++ b/src/linux.c @@ -616,6 +616,14 @@ inline static void update_stat(void) const char *stat_template = NULL; unsigned int malloc_cpu_size = 0; extern void* global_cpu; + static double last_stat_update = 0.0; + + /* since we use wrappers for this function, the update machinery + * can't eliminate double invocations of this function. Check for + * them here, otherwise cpu_usage counters are freaking out. */ + if (last_stat_update == current_update_time) + return; + last_stat_update = current_update_time; /* add check for !info.cpu_usage since that mem is freed on a SIGUSR1 */ if (!cpu_setup || !info.cpu_usage) {