summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Hommel <wolfcw@users.noreply.github.com>2020-02-14 19:42:23 +0100
committerGitHub <noreply@github.com>2020-02-14 19:42:23 +0100
commita54f2042098193f4715c13659981d4cc8b8e751b (patch)
treeb2687cab39359046702dbd3a49224fa90a88c373
parent0efe7b3e3e4704edca44ec5cac9a82f25b44a326 (diff)
parent195888434a62f3327aecf316c5b22aede09ab5ed (diff)
downloadlibfaketime-a54f2042098193f4715c13659981d4cc8b8e751b.tar.gz
Merge pull request #227 from wolfcw/develop
Refresh the monotonic faketime setting envvar when cache expires.
-rw-r--r--src/libfaketime.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/libfaketime.c b/src/libfaketime.c
index 616e0c4..c3cbdf8 100644
--- a/src/libfaketime.c
+++ b/src/libfaketime.c
@@ -530,6 +530,30 @@ static void ft_cleanup (void)
/*
* =======================================================================
+ * Get monotonic faketime setting === GETENV
+ * =======================================================================
+ */
+
+static void get_fake_monotonic_setting(int* current_value)
+{
+ char *tmp_env;
+ if ((tmp_env = getenv("FAKETIME_DONT_FAKE_MONOTONIC")) != NULL
+ || (tmp_env = getenv("DONT_FAKE_MONOTONIC")) != NULL)
+ {
+ if (0 == strcmp(tmp_env, "1"))
+ {
+ (*current_value) = 0;
+ }
+ else
+ {
+ (*current_value) = 1;
+ }
+ }
+}
+
+
+/*
+ * =======================================================================
* Internal time retrieval === INTTIME
* =======================================================================
*/
@@ -2365,14 +2389,7 @@ static void ftpl_init(void)
cache_enabled = 0;
}
}
- if ((tmp_env = getenv("FAKETIME_DONT_FAKE_MONOTONIC")) != NULL
- || (tmp_env = getenv("DONT_FAKE_MONOTONIC")) != NULL)
- {
- if (0 == strcmp(tmp_env, "1"))
- {
- fake_monotonic_clock = 0;
- }
- }
+ get_fake_monotonic_setting(&fake_monotonic_clock);
/* Check whether we actually should be faking the returned timestamp. */
/* We can prevent faking time for specified commands */
@@ -2782,6 +2799,8 @@ int fake_clock_gettime(clockid_t clk_id, struct timespec *tp)
}
} /* read fake time from file */
parse_ft_string(user_faked_time);
+ /* read monotonic faketime setting from envar */
+ get_fake_monotonic_setting(&fake_monotonic_clock);
} /* cache had expired */
if (infile_set)