return 0;
}
+static void manager_free_unit_name_maps(Manager *m) {
+ m->unit_id_map = hashmap_free(m->unit_id_map);
+ m->unit_name_map = hashmap_free(m->unit_name_map);
+ m->unit_path_cache = set_free_free(m->unit_path_cache);
+ m->unit_cache_mtime = 0;
+}
+
static int manager_setup_run_queue(Manager *m) {
int r;
strv_free(m->client_environment);
hashmap_free(m->cgroup_unit);
- set_free_free(m->unit_path_cache);
+ manager_free_unit_name_maps(m);
free(m->switch_root);
free(m->switch_root_init);
}
}
-static void manager_build_unit_path_cache(Manager *m) {
- char **i;
- int r;
-
- assert(m);
-
- set_free_free(m->unit_path_cache);
-
- m->unit_path_cache = set_new(&path_hash_ops);
- if (!m->unit_path_cache) {
- r = -ENOMEM;
- goto fail;
- }
-
- /* This simply builds a list of files we know exist, so that
- * we don't always have to go to disk */
-
- STRV_FOREACH(i, m->lookup_paths.search_path) {
- _cleanup_closedir_ DIR *d = NULL;
- struct dirent *de;
-
- d = opendir(*i);
- if (!d) {
- if (errno != ENOENT)
- log_warning_errno(errno, "Failed to open directory %s, ignoring: %m", *i);
- continue;
- }
-
- FOREACH_DIRENT(de, d, r = -errno; goto fail) {
- char *p;
-
- p = path_join(*i, de->d_name);
- if (!p) {
- r = -ENOMEM;
- goto fail;
- }
-
- r = set_consume(m->unit_path_cache, p);
- if (r < 0)
- goto fail;
- }
- }
-
- return;
-
-fail:
- log_warning_errno(r, "Failed to build unit path cache, proceeding without: %m");
- m->unit_path_cache = set_free_free(m->unit_path_cache);
-}
-
static void manager_distribute_fds(Manager *m, FDSet *fds) {
Iterator i;
Unit *u;
if (r < 0)
log_warning_errno(r, "Failed to reduce unit file paths, ignoring: %m");
- manager_build_unit_path_cache(m);
-
{
/* This block is (optionally) done with the reloading counter bumped */
_cleanup_(manager_reloading_stopp) Manager *reloading = NULL;
assert(m);
assert(m->objective == MANAGER_OK); /* Ensure manager_startup() has been called */
- /* Release the path cache */
- m->unit_path_cache = set_free_free(m->unit_path_cache);
-
manager_check_finished(m);
/* There might still be some zombies hanging around from before we were exec()'ed. Let's reap them. */
if (r < 0)
log_warning_errno(r, "Failed to reduce unit file paths, ignoring: %m");
- manager_build_unit_path_cache(m);
+ /* We flushed out generated files, for which we don't watch mtime, so we should flush the old map. */
+ manager_free_unit_name_maps(m);
/* First, enumerate what we can from kernel and suchlike */
manager_enumerate_perpetual(m);