aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_netdev.c
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-06-17 06:23:43 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-06-17 06:23:43 +0000
commit1d354fd87d4c07906e82d104ba8614d30ae9cbbe (patch)
treeca9aafd446dda125df1411933930669d303c9a30 /plugin_netdev.c
parente8e56418dc7375b50f36e930fb6752fbe25b4ae1 (diff)
downloadlcd4linux-1d354fd87d4c07906e82d104ba8614d30ae9cbbe.tar.gz
[lcd4linux @ 2004-06-17 06:23:39 by reinelt]
hash handling rewritten to solve performance issues git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@473 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'plugin_netdev.c')
-rw-r--r--plugin_netdev.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/plugin_netdev.c b/plugin_netdev.c
index be2b411..c679ae1 100644
--- a/plugin_netdev.c
+++ b/plugin_netdev.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_netdev.c,v 1.8 2004/05/27 03:39:47 reinelt Exp $
+/* $Id: plugin_netdev.c,v 1.9 2004/06/17 06:23:43 reinelt Exp $
*
* plugin for /proc/net/dev parsing
*
@@ -23,6 +23,10 @@
*
*
* $Log: plugin_netdev.c,v $
+ * Revision 1.9 2004/06/17 06:23:43 reinelt
+ *
+ * hash handling rewritten to solve performance issues
+ *
* Revision 1.8 2004/05/27 03:39:47 reinelt
*
* changed function naming scheme to plugin::function
@@ -83,15 +87,17 @@
#include "hash.h"
-static HASH NetDev = { 0, };
+static HASH NetDev;
static FILE *stream = NULL;
-static void hash_set3 (char *key1, char *key2, char *key3, char *val)
+// Fixme: use new & fast hash code!!!
+
+static void hash_put3 (char *key1, char *key2, char *key3, char *val)
{
char key[32];
qprintf(key, sizeof(key), "%s.%s.%s", key1, key2, key3);
- hash_set_delta (&NetDev, key, val);
+ hash_put_delta (&NetDev, key, val);
}
@@ -102,7 +108,7 @@ static int parse_netdev (void)
int RxTx=0; // position of Receive/Transmit switch
// reread every 10 msec only
- age=hash_age(&NetDev, NULL, NULL);
+ age=hash_age(&NetDev, NULL);
if (age>0 && age<=10) return 0;
if (stream==NULL) stream=fopen("/proc/net/dev", "r");
@@ -148,7 +154,7 @@ static int parse_netdev (void)
if (col==0) {
iface=h;
} else {
- hash_set3 (iface, (h-buffer) < RxTx ? "Rx" : "Tx", head[col], h);
+ hash_put3 (iface, (h-buffer) < RxTx ? "Rx" : "Tx", head[col], h);
}
h=t?t+1:NULL;
col++;
@@ -173,7 +179,7 @@ static void my_netdev (RESULT *result, RESULT *arg1, RESULT *arg2)
key = R2S(arg1);
delay = R2N(arg2);
- value = hash_get_regex(&NetDev, key, delay);
+ value = hash_get_regex(&NetDev, key, NULL, delay);
SetResult(&result, R_NUMBER, &value);
}
@@ -192,7 +198,7 @@ static void my_netdev_fast(RESULT *result, RESULT *arg1, RESULT *arg2)
key = R2S(arg1);
delay = R2N(arg2);
- value = hash_get_delta(&NetDev, key, delay);
+ value = hash_get_delta(&NetDev, key, NULL, delay);
SetResult(&result, R_NUMBER, &value);
}
@@ -200,6 +206,7 @@ static void my_netdev_fast(RESULT *result, RESULT *arg1, RESULT *arg2)
int plugin_init_netdev (void)
{
+ hash_create(&NetDev);
AddFunction ("netdev", 2, my_netdev);
AddFunction ("netdev::fast", 2, my_netdev_fast);
return 0;