]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Refrain from gettimeofday direct usage
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 1 Jul 2019 13:28:08 +0000 (14:28 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 1 Jul 2019 13:28:08 +0000 (14:28 +0100)
src/lua/lua_util.c

index 4eaf7b67237616f4abf7496ed7d54aeaac749d51..f385b3ef289b21d7ec080248e9f071574e5468f8 100644 (file)
@@ -1739,17 +1739,8 @@ static gint
 lua_util_get_time (lua_State *L)
 {
        LUA_TRACE_POINT;
-       gdouble seconds;
-       struct timeval tv;
-
-       if (gettimeofday (&tv, NULL) == 0) {
-               seconds = tv_to_double (&tv);
-       }
-       else {
-               seconds = time (NULL);
-       }
 
-       lua_pushnumber (L, seconds);
+       lua_pushnumber (L, ev_time ());
 
        return 1;
 }
@@ -1759,19 +1750,13 @@ lua_util_time_to_string (lua_State *L)
 {
        LUA_TRACE_POINT;
        gdouble seconds;
-       struct timeval tv;
        char timebuf[128];
 
        if (lua_isnumber (L, 1)) {
                seconds = lua_tonumber (L, 1);
        }
        else {
-               if (gettimeofday (&tv, NULL) == 0) {
-                       seconds = tv_to_double (&tv);
-               }
-               else {
-                       seconds = time (NULL);
-               }
+               seconds = ev_time ();
        }
 
        rspamd_http_date_format (timebuf, sizeof (timebuf), seconds);