]> source.dussan.org Git - rspamd.git/commitdiff
Add utility to get calendar ticks.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 15 Sep 2015 12:38:30 +0000 (13:38 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 15 Sep 2015 12:38:30 +0000 (13:38 +0100)
src/libutil/util.c
src/libutil/util.h

index b537643cac4938242f88612cb56a2777046196d8..983accf62b96d5cb58eb1d9aa0791379dec0bf71 100644 (file)
@@ -1856,6 +1856,22 @@ rspamd_get_virtual_ticks (void)
        return res;
 }
 
+gdouble
+rspamd_get_calendar_ticks (void)
+{
+       gdouble res;
+       struct timeval tv;
+
+       if (gettimeofday (&tv, NULL) == 0) {
+               res = (gdouble)tv.tv_sec + tv.tv_usec / 1e6f;
+       }
+       else {
+               res = time (NULL);
+       }
+
+       return res;
+}
+
 /* Required for tweetnacl */
 void
 randombytes (guchar *buf, guint64 len)
index 536caed2c1ee6429f7218c99618a8c768f2670e1..b0a1650043fb46ce75c67d6f61aa051937c5d13e 100644 (file)
@@ -357,6 +357,12 @@ gdouble rspamd_get_ticks (void);
  */
 gdouble rspamd_get_virtual_ticks (void);
 
+
+/**
+ * Return the real timestamp as unixtime
+ */
+gdouble rspamd_get_calendar_ticks (void);
+
 /**
  * Special utility to help array freeing in rspamd_mempool
  * @param p