summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenaud Métrich <rmetrich@redhat.com>2020-10-02 17:30:35 +0200
committerThe Plumber <50238977+systemd-rhel-bot@users.noreply.github.com>2021-04-12 16:25:18 +0200
commit47eb3a4f5cff7c2986112659e9b2a0ae7f8d6d08 (patch)
tree3ff18a00cd42c7678a5c7840695329da0aad4e6e
parent2fae186907b27b0c4a6d8d65d6e545f50dbda5e2 (diff)
downloadsystemd-47eb3a4f5cff7c2986112659e9b2a0ae7f8d6d08.tar.gz
unit: don't emit PropertiesChanged signal if adding a dependency to a unit is a no-opv239-31.3
(cherry picked from commit 5177cb0a9add4ae568cff6e6f7c2b3c77760c343) Related: #1946671
-rw-r--r--src/core/unit.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index e1f5e6f7bd..32d669d87a 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -2831,6 +2831,9 @@ int unit_add_dependency(
};
Unit *original_u = u, *original_other = other;
int r;
+ /* Helper to know whether sending a notification is necessary or not:
+ * if the dependency is already there, no need to notify! */
+ bool noop = true;
assert(u);
assert(d >= 0 && d < _UNIT_DEPENDENCY_MAX);
@@ -2855,24 +2858,33 @@ int unit_add_dependency(
r = unit_add_dependency_hashmap(u->dependencies + d, other, mask, 0);
if (r < 0)
return r;
+ else if (r > 0)
+ noop = false;
if (inverse_table[d] != _UNIT_DEPENDENCY_INVALID && inverse_table[d] != d) {
r = unit_add_dependency_hashmap(other->dependencies + inverse_table[d], u, 0, mask);
if (r < 0)
return r;
+ else if (r > 0)
+ noop = false;
}
if (add_reference) {
r = unit_add_dependency_hashmap(u->dependencies + UNIT_REFERENCES, other, mask, 0);
if (r < 0)
return r;
+ else if (r > 0)
+ noop = false;
r = unit_add_dependency_hashmap(other->dependencies + UNIT_REFERENCED_BY, u, 0, mask);
if (r < 0)
return r;
+ else if (r > 0)
+ noop = false;
}
- unit_add_to_dbus_queue(u);
+ if (!noop)
+ unit_add_to_dbus_queue(u);
return 0;
}