aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_cdb.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-03-09 17:09:25 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-03-09 17:09:25 +0300
commit3e71b98b176fbaf54ff440e3831b5b1bd6d6e4f3 (patch)
treef9eceb3c7cabed463f4ed009484d77e05baaf2c8 /src/lua/lua_cdb.c
parent8cc93b54959dc754b70698a2b397b3406dd7928e (diff)
downloadrspamd-3e71b98b176fbaf54ff440e3831b5b1bd6d6e4f3.tar.gz
rspamd-3e71b98b176fbaf54ff440e3831b5b1bd6d6e4f3.zip
* Add monitoring for cdb
Diffstat (limited to 'src/lua/lua_cdb.c')
-rw-r--r--src/lua/lua_cdb.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/lua/lua_cdb.c b/src/lua/lua_cdb.c
index ef6041d7c..61bcf1df4 100644
--- a/src/lua/lua_cdb.c
+++ b/src/lua/lua_cdb.c
@@ -24,6 +24,8 @@
#include "lua_common.h"
#include "../cdb/cdb.h"
+#define CDB_REFRESH_TIME 60
+
LUA_FUNCTION_DEF (cdb, create);
LUA_FUNCTION_DEF (cdb, lookup);
LUA_FUNCTION_DEF (cdb, get_name);
@@ -102,6 +104,14 @@ lua_cdb_lookup (lua_State *L)
gsize vlen;
goffset vpos;
+ /*
+ * XXX: this code is placed here because event_loop is called inside workers, so start
+ * monitoring on first check, not on creation
+ */
+ if (cdb->check_timer_ev == NULL) {
+ cdb_add_timer (cdb, CDB_REFRESH_TIME);
+ }
+
what = luaL_checkstring (L, 2);
if (cdb_find (cdb, what, strlen (what)) > 0) {
/* Extract and push value to lua as string */
@@ -126,6 +136,7 @@ lua_cdb_destroy (lua_State *L)
if (cdb) {
cdb_free (cdb);
+ (void)close (cdb->cdb_fd);
g_free (cdb->filename);
g_free (cdb);
}
@@ -146,7 +157,7 @@ luaopen_cdb (lua_State * L)
lua_rawset (L, -3);
luaL_openlib (L, NULL, cdblib_m, 0);
- luaL_openlib(L, "cdb", cdblib_f, 0);
+ luaL_openlib (L, "cdb", cdblib_f, 0);
return 1;
}