summaryrefslogtreecommitdiffstats
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:23:07 +0100
commitc2490604356e9a32f6be7c1eeac210d467eb6d89 (patch)
treeed0081c0f037cf510faffe87ecabc96ec0e3aaea
parenta6e6791f45941063b17a100a6d5d5c9e5cf250d3 (diff)
afb-session: Use clock insensitive to time changes
Bug-AGL: SPEC-1296 Bug-AGL: SPEC-1293 Change-Id: I1838175b48dff8fbf1fd65bd304f9cfe917ced80 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 17ca7af8..c312b46c 100644
--- a/src/afb-session.c
+++ b/src/afb-session.c
@@ -40,7 +40,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())
/* structure for a cookie added to sessions */
struct cookie
@@ -86,6 +86,14 @@ static struct {
.mutex = PTHREAD_MUTEX_INITIALIZER
};
+/* 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 new fresh 'uuid' */
static void new_uuid(char uuid[SIZEUUID])
{