aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_exec.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_exec.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_exec.c')
-rw-r--r--plugin_exec.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/plugin_exec.c b/plugin_exec.c
index 565ace1..a9a37c8 100644
--- a/plugin_exec.c
+++ b/plugin_exec.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_exec.c,v 1.2 2004/04/08 10:48:25 reinelt Exp $
+/* $Id: plugin_exec.c,v 1.3 2004/06/17 06:23:43 reinelt Exp $
*
* plugin for external processes
*
@@ -27,6 +27,10 @@
*
*
* $Log: plugin_exec.c,v $
+ * Revision 1.3 2004/06/17 06:23:43 reinelt
+ *
+ * hash handling rewritten to solve performance issues
+ *
* Revision 1.2 2004/04/08 10:48:25 reinelt
* finished plugin_exec
* modified thread handling
@@ -78,7 +82,7 @@ typedef struct {
static EXEC_THREAD Thread[NUM_THREADS];
static int max_thread = -1;
-static HASH EXEC = { 0, };
+static HASH EXEC;
// x^0 + x^5 + x^12
@@ -208,10 +212,10 @@ static int do_exec (char *cmd, char *key, int delay)
{
int i, age;
- age = hash_age(&EXEC, key, NULL);
+ age = hash_age(&EXEC, key);
if (age < 0) {
- hash_set (&EXEC, key, "");
+ hash_put (&EXEC, key, "");
// first-time call: create thread
if (delay < 10) {
error ("exec(%s): delay %d is too short! using 10 msec", cmd, delay);
@@ -232,7 +236,7 @@ static int do_exec (char *cmd, char *key, int delay)
// lock shared memory
mutex_lock(Thread[i].mutex);
// copy data
- hash_set (&EXEC, key, Thread[i].ret);
+ hash_put (&EXEC, key, Thread[i].ret);
// unlock shared memory
mutex_unlock(Thread[i].mutex);
return 0;
@@ -258,7 +262,7 @@ static void my_exec (RESULT *result, RESULT *arg1, RESULT *arg2)
return;
}
- val = hash_get(&EXEC, key);
+ val = hash_get(&EXEC, key, NULL);
if (val == NULL) val = "";
SetResult(&result, R_STRING, val);
@@ -267,6 +271,7 @@ static void my_exec (RESULT *result, RESULT *arg1, RESULT *arg2)
int plugin_init_exec (void)
{
+ hash_create(&EXEC);
AddFunction ("exec", 2, my_exec);
return 0;
}