aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-10-26 13:20:41 +0200
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-10-26 13:20:41 +0200
commit903bd56c0a6ef2d503dd64d39f0eac00d14faa98 (patch)
tree4e458f9023c5d6c570fd74e27f8bf9a01e31c7f1 /src
parenta00b17d54e8fa92fb9e2f03df90d3089608bcf1a (diff)
downloadrspamd-903bd56c0a6ef2d503dd64d39f0eac00d14faa98.tar.gz
rspamd-903bd56c0a6ef2d503dd64d39f0eac00d14faa98.zip
[Feature] Allow to plan new periodics at different time
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_config.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 10b64a8d0..915666a7d 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -2060,15 +2060,21 @@ lua_periodic_callback (gint unused_fd, short what, gpointer ud)
lua_pop (L, 1);
}
else {
- plan_more = lua_toboolean (L, -1);
+ if (lua_type (L, -1) == LUA_TBOOLEAN) {
+ plan_more = lua_toboolean (L, -1);
+ timeout = periodic->timeout;
+ }
+ else if (lua_type (L, -1) == LUA_TNUMBER) {
+ timeout = lua_tonumber (L, -1);
+ plan_more = timeout > 0 ? TRUE : FALSE;
+ }
+
lua_pop (L, 1);
}
event_del (&periodic->ev);
if (plan_more) {
- timeout = periodic->timeout;
-
if (periodic->need_jitter) {
timeout = rspamd_time_jitter (timeout, 0.0);
}
@@ -2092,7 +2098,7 @@ lua_config_add_periodic (lua_State *L)
struct rspamd_lua_periodic *periodic;
gboolean need_jitter = FALSE;
- if (cfg == NULL || timeout <= 0 || lua_type (L, 4) != LUA_TFUNCTION) {
+ if (cfg == NULL || timeout < 0 || lua_type (L, 4) != LUA_TFUNCTION) {
return luaL_error (L, "invalid arguments");
}