Merge pull request #15563 from keszybz/wait-callback-tweak

Add NULL callback check in one more place
This commit is contained in:
Lennart Poettering
2020-04-23 19:50:36 +02:00
committed by GitHub
2 changed files with 15 additions and 20 deletions
+2 -2
View File
@@ -1647,8 +1647,6 @@ static int apply_lock_personality(const Unit* u, const ExecContext *c) {
#endif
static int apply_protect_hostname(const Unit *u, const ExecContext *c, int *ret_exit_status) {
int r;
assert(u);
assert(c);
@@ -1668,6 +1666,8 @@ static int apply_protect_hostname(const Unit *u, const ExecContext *c, int *ret_
log_unit_warning(u, "ProtectHostname=yes is configured, but the kernel does not support UTS namespaces, ignoring namespace setup.");
#if HAVE_SECCOMP
int r;
if (skip_seccomp_unavailable(u, "ProtectHostname="))
return 0;
+13 -18
View File
@@ -80,6 +80,15 @@ static WaitForItem *wait_for_item_free(WaitForItem *item) {
DEFINE_TRIVIAL_CLEANUP_FUNC(WaitForItem*, wait_for_item_free);
static void call_unit_callback_and_wait(BusWaitForUnits *d, WaitForItem *item, bool good) {
d->current = item;
if (item->unit_callback)
item->unit_callback(d, item->bus_path, good, item->userdata);
wait_for_item_free(item);
}
static void bus_wait_for_units_clear(BusWaitForUnits *d) {
WaitForItem *item;
@@ -88,13 +97,8 @@ static void bus_wait_for_units_clear(BusWaitForUnits *d) {
d->slot_disconnected = sd_bus_slot_unref(d->slot_disconnected);
d->bus = sd_bus_unref(d->bus);
while ((item = hashmap_first(d->items))) {
d->current = item;
if (item->unit_callback)
item->unit_callback(d, item->bus_path, false, item->userdata);
wait_for_item_free(item);
}
while ((item = hashmap_first(d->items)))
call_unit_callback_and_wait(d, item, false);
d->items = hashmap_free(d->items);
}
@@ -213,13 +217,7 @@ static void wait_for_item_check_ready(WaitForItem *item) {
return;
}
if (item->unit_callback) {
d->current = item;
item->unit_callback(d, item->bus_path, true, item->userdata);
}
wait_for_item_free(item);
call_unit_callback_and_wait(d, item, true);
bus_wait_for_units_check_ready(d);
}
@@ -304,10 +302,7 @@ static int on_get_all_properties(sd_bus_message *m, void *userdata, sd_bus_error
log_debug_errno(sd_bus_error_get_errno(error), "GetAll() failed for %s: %s",
item->bus_path, error->message);
d->current = item;
item->unit_callback(d, item->bus_path, false, item->userdata);
wait_for_item_free(item);
call_unit_callback_and_wait(d, item, false);
bus_wait_for_units_check_ready(d);
return 0;
}