]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Lua_task: Allow to get a raw timestamp
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 2 Dec 2019 15:42:25 +0000 (15:42 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 2 Dec 2019 15:42:25 +0000 (15:42 +0000)
src/lua/lua_task.c

index aff6d8499c03b54d467c4b86e641d49a1a636ec1..26ad15dec018fe6d0b43542f95627025c9f0767f 100644 (file)
@@ -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");