aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_ppp.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_ppp.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_ppp.c')
-rw-r--r--plugin_ppp.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/plugin_ppp.c b/plugin_ppp.c
index be51ff7..e77ed74 100644
--- a/plugin_ppp.c
+++ b/plugin_ppp.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_ppp.c,v 1.5 2004/05/29 15:53:28 reinelt Exp $
+/* $Id: plugin_ppp.c,v 1.6 2004/06/17 06:23:43 reinelt Exp $
*
* plugin for ppp throughput
*
@@ -23,6 +23,10 @@
*
*
* $Log: plugin_ppp.c,v $
+ * Revision 1.6 2004/06/17 06:23:43 reinelt
+ *
+ * hash handling rewritten to solve performance issues
+ *
* Revision 1.5 2004/05/29 15:53:28 reinelt
*
* M50530: reset parport signals on exit
@@ -77,7 +81,7 @@
#ifdef HAVE_NET_IF_PPP_H
-static HASH PPP = { 0, };
+static HASH PPP;
static int get_ppp_stats (void)
{
@@ -89,7 +93,7 @@ static int get_ppp_stats (void)
char key[16], val[16];
// reread every 10 msec only
- age=hash_age(&PPP, NULL, NULL);
+ age=hash_age(&PPP, NULL);
if (age>0 && age<=10) return 0;
// open socket only once
@@ -114,10 +118,10 @@ static int get_ppp_stats (void)
}
qprintf(key, sizeof(key), "Rx:%d", unit);
qprintf(val, sizeof(val), "%d", ibytes);
- hash_set_delta (&PPP, key, val);
+ hash_put_delta (&PPP, key, val);
qprintf(key, sizeof(key), "Tx:%d", unit);
qprintf(val, sizeof(val), "%d", obytes);
- hash_set_delta (&PPP, key, val);
+ hash_put_delta (&PPP, key, val);
}
return 0;
@@ -132,7 +136,7 @@ static void my_ppp (RESULT *result, RESULT *arg1, RESULT *arg2)
SetResult(&result, R_STRING, "");
return;
}
- value=hash_get_delta(&PPP, R2S(arg1), R2N(arg2));
+ value=hash_get_delta(&PPP, R2S(arg1), NULL, R2N(arg2));
SetResult(&result, R_NUMBER, &value);
}
@@ -141,6 +145,7 @@ static void my_ppp (RESULT *result, RESULT *arg1, RESULT *arg2)
int plugin_init_ppp (void)
{
+ hash_create(&PPP);
#ifdef HAVE_NET_IF_PPP_H
AddFunction ("ppp", 2, my_ppp);
#endif
@@ -149,5 +154,5 @@ int plugin_init_ppp (void)
void plugin_exit_ppp(void)
{
- hash_destroy(&PPP);
+ hash_destroy(&PPP);
}