|
|
ff479f |
From 3dc25568b15bff0c79ae6e136a73ffd18a69f525 Mon Sep 17 00:00:00 2001
|
|
|
ff479f |
From: =?UTF-8?q?Renaud=20M=C3=A9trich?= <rmetrich@redhat.com>
|
|
|
ff479f |
Date: Fri, 2 Oct 2020 17:30:35 +0200
|
|
|
ff479f |
Subject: [PATCH] unit: don't emit PropertiesChanged signal if adding a
|
|
|
ff479f |
dependency to a unit is a no-op
|
|
|
ff479f |
|
|
|
ff479f |
(cherry picked from commit 5177cb0a9add4ae568cff6e6f7c2b3c77760c343)
|
|
|
ff479f |
|
|
|
ff479f |
Resolves: #2091590
|
|
|
ff479f |
---
|
|
|
ff479f |
src/core/unit.c | 14 +++++++++++++-
|
|
|
ff479f |
1 file changed, 13 insertions(+), 1 deletion(-)
|
|
|
ff479f |
|
|
|
ff479f |
diff --git a/src/core/unit.c b/src/core/unit.c
|
|
|
ff479f |
index 68affa2c0e..e3e534ea2e 100644
|
|
|
ff479f |
--- a/src/core/unit.c
|
|
|
ff479f |
+++ b/src/core/unit.c
|
|
|
ff479f |
@@ -2818,6 +2818,9 @@ int unit_add_dependency(
|
|
|
ff479f |
};
|
|
|
ff479f |
Unit *original_u = u, *original_other = other;
|
|
|
ff479f |
int r;
|
|
|
ff479f |
+ /* Helper to know whether sending a notification is necessary or not:
|
|
|
ff479f |
+ * if the dependency is already there, no need to notify! */
|
|
|
ff479f |
+ bool noop = true;
|
|
|
ff479f |
|
|
|
ff479f |
assert(u);
|
|
|
ff479f |
assert(d >= 0 && d < _UNIT_DEPENDENCY_MAX);
|
|
|
ff479f |
@@ -2842,24 +2845,33 @@ int unit_add_dependency(
|
|
|
ff479f |
r = unit_add_dependency_hashmap(u->dependencies + d, other, mask, 0);
|
|
|
ff479f |
if (r < 0)
|
|
|
ff479f |
return r;
|
|
|
ff479f |
+ else if (r > 0)
|
|
|
ff479f |
+ noop = false;
|
|
|
ff479f |
|
|
|
ff479f |
if (inverse_table[d] != _UNIT_DEPENDENCY_INVALID && inverse_table[d] != d) {
|
|
|
ff479f |
r = unit_add_dependency_hashmap(other->dependencies + inverse_table[d], u, 0, mask);
|
|
|
ff479f |
if (r < 0)
|
|
|
ff479f |
return r;
|
|
|
ff479f |
+ else if (r > 0)
|
|
|
ff479f |
+ noop = false;
|
|
|
ff479f |
}
|
|
|
ff479f |
|
|
|
ff479f |
if (add_reference) {
|
|
|
ff479f |
r = unit_add_dependency_hashmap(u->dependencies + UNIT_REFERENCES, other, mask, 0);
|
|
|
ff479f |
if (r < 0)
|
|
|
ff479f |
return r;
|
|
|
ff479f |
+ else if (r > 0)
|
|
|
ff479f |
+ noop = false;
|
|
|
ff479f |
|
|
|
ff479f |
r = unit_add_dependency_hashmap(other->dependencies + UNIT_REFERENCED_BY, u, 0, mask);
|
|
|
ff479f |
if (r < 0)
|
|
|
ff479f |
return r;
|
|
|
ff479f |
+ else if (r > 0)
|
|
|
ff479f |
+ noop = false;
|
|
|
ff479f |
}
|
|
|
ff479f |
|
|
|
ff479f |
- unit_add_to_dbus_queue(u);
|
|
|
ff479f |
+ if (!noop)
|
|
|
ff479f |
+ unit_add_to_dbus_queue(u);
|
|
|
ff479f |
return 0;
|
|
|
ff479f |
}
|
|
|
ff479f |
|