aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libutil/util.c16
-rw-r--r--src/libutil/util.h6
2 files changed, 22 insertions, 0 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c
index b537643ca..983accf62 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -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)
diff --git a/src/libutil/util.h b/src/libutil/util.h
index 536caed2c..b0a165004 100644
--- a/src/libutil/util.h
+++ b/src/libutil/util.h
@@ -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