diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-03-09 17:09:25 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-03-09 17:09:25 +0300 |
commit | 3e71b98b176fbaf54ff440e3831b5b1bd6d6e4f3 (patch) | |
tree | f9eceb3c7cabed463f4ed009484d77e05baaf2c8 /src/lua/lua_cdb.c | |
parent | 8cc93b54959dc754b70698a2b397b3406dd7928e (diff) | |
download | rspamd-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.c | 13 |
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; } |