diff --git a/src/core/load-dropin.c b/src/core/load-dropin.c index d1c85e23bfa..3bb48564ccd 100644 --- a/src/core/load-dropin.c +++ b/src/core/load-dropin.c @@ -112,6 +112,7 @@ int unit_load_dropin(Unit *u) { return log_oom(); } + u->dropin_mtime = 0; STRV_FOREACH(f, u->dropin_paths) (void) config_parse( u->id, *f, NULL, diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 64ed2571e9b..9dfa1907511 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -263,7 +263,7 @@ int config_parse( const void *table, ConfigParseFlags flags, void *userdata, - usec_t *ret_mtime) { + usec_t *latest_mtime) { _cleanup_free_ char *section = NULL, *continuation = NULL; _cleanup_fclose_ FILE *ours = NULL; @@ -275,6 +275,9 @@ int config_parse( assert(filename); assert(lookup); + /* latest_mtime is an input-output parameter: it will be updated if the mtime of the file we're + * looking at is later than the current *latest_mtime value. */ + if (!f) { f = ours = fopen(filename, "re"); if (!f) { @@ -417,8 +420,8 @@ int config_parse( } } - if (ret_mtime) - *ret_mtime = mtime; + if (latest_mtime) + *latest_mtime = MAX(*latest_mtime, mtime); return 1; } @@ -448,12 +451,9 @@ static int config_parse_many_files( /* Then read all the drop-ins. */ STRV_FOREACH(fn, files) { - usec_t t; - - r = config_parse(NULL, *fn, NULL, sections, lookup, table, flags, userdata, &t); + r = config_parse(NULL, *fn, NULL, sections, lookup, table, flags, userdata, &mtime); if (r < 0) return r; - mtime = MAX(mtime, t); /* Find the newest */ } if (ret_mtime) diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h index cd094911124..c4b9891428d 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -89,7 +89,7 @@ int config_parse( const void *table, ConfigParseFlags flags, void *userdata, - usec_t *ret_mtime); /* possibly NULL */ + usec_t *latest_mtime); /* input/output, possibly NULL */ int config_parse_many_nulstr( const char *conf_file, /* possibly NULL */