From 16a678004a5aa6afafddc55bda1d05bfb0e8db22 Mon Sep 17 00:00:00 2001 From: reinelt Date: Wed, 21 Jan 2004 10:48:17 +0000 Subject: [lcd4linux @ 2004-01-21 10:48:17 by reinelt] hash_age function added git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@329 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- plugin_meminfo.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'plugin_meminfo.c') diff --git a/plugin_meminfo.c b/plugin_meminfo.c index ec8e611..b455f71 100644 --- a/plugin_meminfo.c +++ b/plugin_meminfo.c @@ -1,4 +1,4 @@ -/* $Id: plugin_meminfo.c,v 1.2 2004/01/16 07:26:25 reinelt Exp $ +/* $Id: plugin_meminfo.c,v 1.3 2004/01/21 10:48:17 reinelt Exp $ * * plugin for /proc/meminfo parsing * @@ -23,6 +23,9 @@ * * * $Log: plugin_meminfo.c,v $ + * Revision 1.3 2004/01/21 10:48:17 reinelt + * hash_age function added + * * Revision 1.2 2004/01/16 07:26:25 reinelt * moved various /proc parsing to own functions * made some progress with /proc/stat parsing @@ -49,7 +52,6 @@ #include #include #include -#include #include "debug.h" #include "plugin.h" @@ -57,18 +59,18 @@ #include "hash.h" -static HASH MemInfo = { 0, 0, NULL }; +static HASH MemInfo = { 0, }; static int parse_meminfo (void) { - static time_t now=0; - FILE *stream; + int age; int line; + FILE *stream; - // reread every second only - if (time(NULL)==now) return 0; - time(&now); + // reread every 100 msec only + age=hash_age(&MemInfo, NULL, NULL); + if (age>0 && age<=100) return 0; stream=fopen("/proc/meminfo", "r"); if (stream==NULL) { -- cgit v1.2.3