diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-04-06 20:47:44 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-04-12 13:43:31 +0200 |
commit | 07a7864324e146662cb06f49fc3cd666788e2e2f (patch) | |
tree | b568cd995b905b332616ee7f496403a774f6633d | |
parent | d8d410f4455238e30daa1775b469e31f34371f87 (diff) |
core: move flushing of generated unit files to path-lookup.c
It's very similar to the mkdir and trim operations for the generator dirs,
hence let's unify this at a single place.
-rw-r--r-- | src/core/manager.c | 16 | ||||
-rw-r--r-- | src/shared/path-lookup.c | 11 | ||||
-rw-r--r-- | src/shared/path-lookup.h | 1 |
3 files changed, 14 insertions, 14 deletions
diff --git a/src/core/manager.c b/src/core/manager.c index b1f79e014e..6ce3e404c9 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -100,7 +100,6 @@ static int manager_dispatch_idle_pipe_fd(sd_event_source *source, int fd, uint32 static int manager_dispatch_jobs_in_progress(sd_event_source *source, usec_t usec, void *userdata); static int manager_dispatch_run_queue(sd_event_source *source, void *userdata); static int manager_run_generators(Manager *m); -static void manager_undo_generators(Manager *m); static void manager_watch_jobs_in_progress(Manager *m) { usec_t next; @@ -930,7 +929,7 @@ Manager* manager_free(Manager *m) { * around */ manager_shutdown_cgroup(m, m->exit_code != MANAGER_REEXECUTE); - manager_undo_generators(m); + lookup_paths_flush_generator(&m->lookup_paths); bus_done(m); @@ -2522,7 +2521,7 @@ int manager_reload(Manager *m) { /* From here on there is no way back. */ manager_clear_jobs_and_units(m); - manager_undo_generators(m); + lookup_paths_flush_generator(&m->lookup_paths); lookup_paths_free(&m->lookup_paths); q = lookup_paths_init(&m->lookup_paths, m->unit_file_scope, NULL); @@ -2750,17 +2749,6 @@ finish: return r; } -static void manager_undo_generators(Manager *m) { - assert(m); - - if (m->lookup_paths.generator) - (void) rm_rf(m->lookup_paths.generator, REMOVE_ROOT); - if (m->lookup_paths.generator_early) - (void) rm_rf(m->lookup_paths.generator_early, REMOVE_ROOT); - if (m->lookup_paths.generator_late) - (void) rm_rf(m->lookup_paths.generator_late, REMOVE_ROOT); -} - int manager_environment_add(Manager *m, char **minus, char **plus) { char **a = NULL, **b = NULL, **l; assert(m); diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c index 0735e3b4f5..685ae895d2 100644 --- a/src/shared/path-lookup.c +++ b/src/shared/path-lookup.c @@ -726,3 +726,14 @@ void lookup_paths_trim_generator(LookupPaths *p) { if (p->generator_late) (void) rmdir(p->generator_late); } + +void lookup_paths_flush_generator(LookupPaths *p) { + assert(p); + + if (p->generator) + (void) rm_rf(p->generator, REMOVE_ROOT); + if (p->generator_early) + (void) rm_rf(p->generator_early, REMOVE_ROOT); + if (p->generator_late) + (void) rm_rf(p->generator_late, REMOVE_ROOT); +} diff --git a/src/shared/path-lookup.h b/src/shared/path-lookup.h index 03f103dcc0..d151347a1b 100644 --- a/src/shared/path-lookup.h +++ b/src/shared/path-lookup.h @@ -53,6 +53,7 @@ int lookup_paths_reduce(LookupPaths *p); int lookup_paths_mkdir_generator(LookupPaths *p); void lookup_paths_trim_generator(LookupPaths *p); +void lookup_paths_flush_generator(LookupPaths *p); void lookup_paths_free(LookupPaths *p); #define _cleanup_lookup_paths_free_ _cleanup_(lookup_paths_free) |