summaryrefslogtreecommitdiffstats
path: root/src/lua/lua_cdb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/lua_cdb.c')
-rw-r--r--src/lua/lua_cdb.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/lua/lua_cdb.c b/src/lua/lua_cdb.c
index a7292da03..5d4c499a7 100644
--- a/src/lua/lua_cdb.c
+++ b/src/lua/lua_cdb.c
@@ -50,6 +50,7 @@ lua_cdb_create (lua_State *L)
struct cdb *cdb, **pcdb;
const gchar *filename;
gint fd;
+ struct ev_loop *ev_base = lua_check_ev_base (L, 2);
filename = luaL_checkstring (L, 1);
/* If file begins with cdb://, just skip it */
@@ -64,13 +65,12 @@ lua_cdb_create (lua_State *L)
else {
cdb = g_malloc (sizeof (struct cdb));
cdb->filename = g_strdup (filename);
- cdb->check_timer_ev = NULL;
- cdb->check_timer_tv = NULL;
if (cdb_init (cdb, fd) == -1) {
msg_warn ("cannot open cdb: %s, %s", filename, strerror (errno));
lua_pushnil (L);
}
else {
+ cdb_add_timer (cdb, ev_base, CDB_REFRESH_TIME);
pcdb = lua_newuserdata (L, sizeof (struct cdb *));
rspamd_lua_setclass (L, "rspamd{cdb}", -1);
*pcdb = cdb;
@@ -106,13 +106,6 @@ lua_cdb_lookup (lua_State *L)
lua_error (L);
return 1;
}
- /*
- * 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) {