From 97f2d76d4f4dfab8b0629c09926a05a1e5621125 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Tue, 29 Oct 2013 15:15:53 +0100 Subject: path_check_timestamp: only keep the most recent timestamp There is no point in keeping one timestamp for each directory, as we only ever care about the most recent one. --- src/shared/path-util.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/shared/path-util.c') diff --git a/src/shared/path-util.c b/src/shared/path-util.c index def7a7409a..fcacf541ed 100644 --- a/src/shared/path-util.c +++ b/src/shared/path-util.c @@ -474,11 +474,13 @@ int find_binary(const char *name, char **filename) { } } -bool paths_check_timestamp(char **paths, usec_t *paths_ts_usec, bool update) +bool paths_check_timestamp(char **paths, usec_t *timestamp, bool update) { unsigned int i; bool changed = false; + assert(timestamp); + if (paths == NULL) goto out; @@ -488,18 +490,16 @@ bool paths_check_timestamp(char **paths, usec_t *paths_ts_usec, bool update) if (stat(paths[i], &stats) < 0) continue; - if (paths_ts_usec[i] == timespec_load(&stats.st_mtim)) + /* first check */ + if (*timestamp >= timespec_load(&stats.st_mtim)) continue; - /* first check */ - if (paths_ts_usec[i] != 0) { - log_debug("reload - timestamp of '%s' changed\n", paths[i]); - changed = true; - } + log_debug("timestamp of '%s' changed\n", paths[i]); + changed = true; /* update timestamp */ if (update) - paths_ts_usec[i] = timespec_load(&stats.st_mtim); + *timestamp = timespec_load(&stats.st_mtim); } out: return changed; -- cgit v1.2.3-54-g00ecf