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