summaryrefslogtreecommitdiff
path: root/src/shared/install.c
diff options
context:
space:
mode:
authorkayrus <kayrus@users.noreply.github.com>2016-04-29 15:59:51 +0200
committerLennart Poettering <lennart@poettering.net>2016-04-29 15:59:51 +0200
commit313fe66fbd0cd3d62566edece7944d6cf45b1b21 (patch)
tree5659eec8391c56f12133e136c406a010c07b694d /src/shared/install.c
parent3e39355a96f615f2cb1e805c7d74efbc272de1cd (diff)
core: Filter by unit name behind the D-Bus, instead on the client side (#3142)
This commit improves systemd performance on the systems which have thousands of units.
Diffstat (limited to 'src/shared/install.c')
-rw-r--r--src/shared/install.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/shared/install.c b/src/shared/install.c
index b74ff6de22..931d3e2907 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -2653,7 +2653,9 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(UnitFileList*, unit_file_list_free_one);
int unit_file_get_list(
UnitFileScope scope,
const char *root_dir,
- Hashmap *h) {
+ Hashmap *h,
+ char **states,
+ char **patterns) {
_cleanup_lookup_paths_free_ LookupPaths paths = {};
char **i;
@@ -2685,6 +2687,9 @@ int unit_file_get_list(
if (!unit_name_is_valid(de->d_name, UNIT_NAME_ANY))
continue;
+ if (!strv_fnmatch_or_empty(patterns, de->d_name, FNM_NOESCAPE))
+ continue;
+
if (hashmap_get(h, de->d_name))
continue;
@@ -2705,6 +2710,10 @@ int unit_file_get_list(
if (r < 0)
f->state = UNIT_FILE_BAD;
+ if (!strv_isempty(states) &&
+ !strv_contains(states, unit_file_state_to_string(f->state)))
+ continue;
+
r = hashmap_put(h, basename(f->path), f);
if (r < 0)
return r;