|
|
c2dfb7 |
From 48ab0db62ab23307e9f35a862a9c9b33ba3ef261 Mon Sep 17 00:00:00 2001
|
|
|
c2dfb7 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
|
c2dfb7 |
Date: Thu, 23 Apr 2020 14:53:54 +0200
|
|
|
c2dfb7 |
Subject: [PATCH] shared: add NULL callback check in one more place
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
Follow-up for 9f65637308.
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
(cherry picked from commit d3d53e5cd143bf96d1eb0e254f16fa8d458d38ce)
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
Related: #1830861
|
|
|
c2dfb7 |
---
|
|
|
c2dfb7 |
src/shared/bus-wait-for-units.c | 31 +++++++++++++------------------
|
|
|
c2dfb7 |
1 file changed, 13 insertions(+), 18 deletions(-)
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
diff --git a/src/shared/bus-wait-for-units.c b/src/shared/bus-wait-for-units.c
|
|
|
c2dfb7 |
index 63ba3fd422..ba97922764 100644
|
|
|
c2dfb7 |
--- a/src/shared/bus-wait-for-units.c
|
|
|
c2dfb7 |
+++ b/src/shared/bus-wait-for-units.c
|
|
|
c2dfb7 |
@@ -80,6 +80,15 @@ static WaitForItem *wait_for_item_free(WaitForItem *item) {
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
DEFINE_TRIVIAL_CLEANUP_FUNC(WaitForItem*, wait_for_item_free);
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
+static void call_unit_callback_and_wait(BusWaitForUnits *d, WaitForItem *item, bool good) {
|
|
|
c2dfb7 |
+ d->current = item;
|
|
|
c2dfb7 |
+
|
|
|
c2dfb7 |
+ if (item->unit_callback)
|
|
|
c2dfb7 |
+ item->unit_callback(d, item->bus_path, good, item->userdata);
|
|
|
c2dfb7 |
+
|
|
|
c2dfb7 |
+ wait_for_item_free(item);
|
|
|
c2dfb7 |
+}
|
|
|
c2dfb7 |
+
|
|
|
c2dfb7 |
static void bus_wait_for_units_clear(BusWaitForUnits *d) {
|
|
|
c2dfb7 |
WaitForItem *item;
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
@@ -88,13 +97,8 @@ static void bus_wait_for_units_clear(BusWaitForUnits *d) {
|
|
|
c2dfb7 |
d->slot_disconnected = sd_bus_slot_unref(d->slot_disconnected);
|
|
|
c2dfb7 |
d->bus = sd_bus_unref(d->bus);
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
- while ((item = hashmap_first(d->items))) {
|
|
|
c2dfb7 |
- d->current = item;
|
|
|
c2dfb7 |
-
|
|
|
c2dfb7 |
- if (item->unit_callback)
|
|
|
c2dfb7 |
- item->unit_callback(d, item->bus_path, false, item->userdata);
|
|
|
c2dfb7 |
- wait_for_item_free(item);
|
|
|
c2dfb7 |
- }
|
|
|
c2dfb7 |
+ while ((item = hashmap_first(d->items)))
|
|
|
c2dfb7 |
+ call_unit_callback_and_wait(d, item, false);
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
d->items = hashmap_free(d->items);
|
|
|
c2dfb7 |
}
|
|
|
c2dfb7 |
@@ -213,13 +217,7 @@ static void wait_for_item_check_ready(WaitForItem *item) {
|
|
|
c2dfb7 |
return;
|
|
|
c2dfb7 |
}
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
- if (item->unit_callback) {
|
|
|
c2dfb7 |
- d->current = item;
|
|
|
c2dfb7 |
- item->unit_callback(d, item->bus_path, true, item->userdata);
|
|
|
c2dfb7 |
- }
|
|
|
c2dfb7 |
-
|
|
|
c2dfb7 |
- wait_for_item_free(item);
|
|
|
c2dfb7 |
-
|
|
|
c2dfb7 |
+ call_unit_callback_and_wait(d, item, true);
|
|
|
c2dfb7 |
bus_wait_for_units_check_ready(d);
|
|
|
c2dfb7 |
}
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
@@ -304,10 +302,7 @@ static int on_get_all_properties(sd_bus_message *m, void *userdata, sd_bus_error
|
|
|
c2dfb7 |
log_debug_errno(sd_bus_error_get_errno(error), "GetAll() failed for %s: %s",
|
|
|
c2dfb7 |
item->bus_path, error->message);
|
|
|
c2dfb7 |
|
|
|
c2dfb7 |
- d->current = item;
|
|
|
c2dfb7 |
- item->unit_callback(d, item->bus_path, false, item->userdata);
|
|
|
c2dfb7 |
- wait_for_item_free(item);
|
|
|
c2dfb7 |
-
|
|
|
c2dfb7 |
+ call_unit_callback_and_wait(d, item, false);
|
|
|
c2dfb7 |
bus_wait_for_units_check_ready(d);
|
|
|
c2dfb7 |
return 0;
|
|
|
c2dfb7 |
}
|