summaryrefslogtreecommitdiffstats
path: root/src/test/test-path-lookup.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-08-26 08:58:41 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-08-27 18:12:20 +0200
commit581fef8d56a13390a331d4d404f178d7cc188ccf (patch)
tree56ef90d56e338a927519437c0c25928a3c1098a8 /src/test/test-path-lookup.c
parentMerge pull request #13382 from keszybz/network-ipv6-enable (diff)
downloadsystemd-581fef8d56a13390a331d4d404f178d7cc188ccf.tar.xz
systemd-581fef8d56a13390a331d4d404f178d7cc188ccf.zip
core: stop removing non-existent and duplicate lookup paths
When we would iterate over the lookup paths for each unit, making the list as short as possible was important for performance. With the current cache, it doesn't matter much. Two classes of paths were being removed: - paths which don't exist in the filesystem - paths which symlink to a path earlier in the search list Both of those points cause problems with the caching code: - if a user creates a directory that didn't exist before and puts units there, now we will notice the new mtime an properly load the unit. When the path was removed from list, we wouldn't. - we now properly detect whether a unit path is on the path or not. Before, if e.g. /lib/systemd/system, /usr/lib/systemd/systemd were both on the path, and /lib was a symlink to /usr/lib, the second directory would be pruned from the path. Then, the code would think that a symlink /etc/systemd/system/foo.service→/lib/systemd/system/foo.service is an alias, but /etc/systemd/system/foo.service→/usr/lib/systemd/system/foo.service would be considered a link (in the systemctl link sense). Removing the pruning has a slight negative performance impact in case of usr-merge systems which have systemd compiled with non-usr-merge paths. Non-usr-merge systems are deprecated, and this impact should be very small, so I think it's OK. If it turns out to be an issue, the loop in function that builds the cache could be improved to skip over "duplicate" directories with same logic that the cache pruning did before. I didn't want to add this, becuase it complicates the code to improve a corner case. Fixes #13272.
Diffstat (limited to 'src/test/test-path-lookup.c')
-rw-r--r--src/test/test-path-lookup.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/test/test-path-lookup.c b/src/test/test-path-lookup.c
index f208559358..62ebc9c923 100644
--- a/src/test/test-path-lookup.c
+++ b/src/test/test-path-lookup.c
@@ -22,15 +22,15 @@ static void test_paths(UnitFileScope scope) {
assert_se(unsetenv("SYSTEMD_UNIT_PATH") == 0);
assert_se(lookup_paths_init(&lp_without_env, scope, 0, NULL) >= 0);
assert_se(!strv_isempty(lp_without_env.search_path));
- assert_se(lookup_paths_reduce(&lp_without_env) >= 0);
+ lookup_paths_log(&lp_without_env);
systemd_unit_path = strjoina(template, "/systemd-unit-path");
assert_se(setenv("SYSTEMD_UNIT_PATH", systemd_unit_path, 1) == 0);
assert_se(lookup_paths_init(&lp_with_env, scope, 0, NULL) == 0);
assert_se(strv_length(lp_with_env.search_path) == 1);
assert_se(streq(lp_with_env.search_path[0], systemd_unit_path));
- assert_se(lookup_paths_reduce(&lp_with_env) >= 0);
- assert_se(strv_isempty(lp_with_env.search_path));
+ lookup_paths_log(&lp_with_env);
+ assert_se(strv_equal(lp_with_env.search_path, STRV_MAKE(systemd_unit_path)));
assert_se(rm_rf(template, REMOVE_ROOT|REMOVE_PHYSICAL) >= 0);
}