aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-12-02 15:42:25 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-12-02 15:42:25 +0000
commit946c6d5af333c78914a37ada3ace683c1b782988 (patch)
treeddc838f44c17df2666700f42efe2939c94f95487 /src
parent5f116f6edbeffd33ef0cbdbaf893c2587f4ae784 (diff)
downloadrspamd-946c6d5af333c78914a37ada3ace683c1b782988.tar.gz
rspamd-946c6d5af333c78914a37ada3ace683c1b782988.zip
[Minor] Lua_task: Allow to get a raw timestamp
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_task.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index aff6d8499..26ad15dec 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -4889,14 +4889,19 @@ lua_task_get_timeval (lua_State *L)
struct timeval tv;
if (task != NULL) {
- double_to_tv (task->task_timestamp, &tv);
- lua_createtable (L, 0, 2);
- lua_pushstring (L, "tv_sec");
- lua_pushinteger (L, (lua_Integer)tv.tv_sec);
- lua_settable (L, -3);
- lua_pushstring (L, "tv_usec");
- lua_pushinteger (L, (lua_Integer)tv.tv_usec);
- lua_settable (L, -3);
+ if (lua_isboolean (L, 2) && !!lua_toboolean (L, 2)) {
+ lua_pushnumber (L, task->task_timestamp);
+ }
+ else {
+ double_to_tv (task->task_timestamp, &tv);
+ lua_createtable (L, 0, 2);
+ lua_pushstring (L, "tv_sec");
+ lua_pushinteger (L, (lua_Integer) tv.tv_sec);
+ lua_settable (L, -3);
+ lua_pushstring (L, "tv_usec");
+ lua_pushinteger (L, (lua_Integer) tv.tv_usec);
+ lua_settable (L, -3);
+ }
}
else {
return luaL_error (L, "invalid arguments");