aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2018-02-15 16:23:54 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2018-02-15 17:30:41 +0100
commit350ee3c6323d2f939a6416d38ec3154b370ce5a5 (patch)
tree7e992078719aa73c473b00067582b6e4c605f3b3
parent3d553f21344e68055a55a3c30d7933af1572da33 (diff)
afb-session: Use clock insensitive to time changes
Bug-AGL: SPEC-1296 Bug-AGL: SPEC-1293 Change-Id: I77ccb79975c6f2ac1a276031d9fd1c03839c3b91 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-session.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/afb-session.c b/src/afb-session.c
index 6b6ad634..01e9bfcf 100644
--- a/src/afb-session.c
+++ b/src/afb-session.c
@@ -39,7 +39,7 @@
#define _MAXEXP_ ((time_t)(~(time_t)0))
#define _MAXEXP2_ ((time_t)((((unsigned long long)_MAXEXP_) >> 1)))
#define MAX_EXPIRATION (_MAXEXP_ >= 0 ? _MAXEXP_ : _MAXEXP2_)
-#define NOW (time(NULL))
+#define NOW (time_now())
struct cookie
{
@@ -73,6 +73,14 @@ static struct {
char initok[SIZEUUID];
} sessions;
+/* Get the actual raw time */
+static inline time_t time_now()
+{
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
+ return ts.tv_sec;
+}
+
/* generate a uuid */
static void new_uuid(char uuid[SIZEUUID])
{