Lines Matching refs:item

44 static WaitForItem *wait_for_item_free(WaitForItem *item) {  in wait_for_item_free()  argument
47 if (!item) in wait_for_item_free()
50 if (item->parent) { in wait_for_item_free()
51 … if (FLAGS_SET(item->flags, BUS_WAIT_REFFED) && item->bus_path && item->parent->bus) { in wait_for_item_free()
53 item->parent->bus, in wait_for_item_free()
56 item->bus_path, in wait_for_item_free()
63 … log_debug_errno(r, "Failed to drop reference to unit %s, ignoring: %m", item->bus_path); in wait_for_item_free()
66 assert_se(hashmap_remove(item->parent->items, item->bus_path) == item); in wait_for_item_free()
68 if (item->parent->current == item) in wait_for_item_free()
69 item->parent->current = NULL; in wait_for_item_free()
72 sd_bus_slot_unref(item->slot_properties_changed); in wait_for_item_free()
73 sd_bus_slot_unref(item->slot_get_all); in wait_for_item_free()
75 free(item->bus_path); in wait_for_item_free()
76 free(item->active_state); in wait_for_item_free()
77 free(item->clean_result); in wait_for_item_free()
79 return mfree(item); in wait_for_item_free()
84 static void call_unit_callback_and_wait(BusWaitForUnits *d, WaitForItem *item, bool good) { in call_unit_callback_and_wait() argument
85 d->current = item; in call_unit_callback_and_wait()
87 if (item->unit_callback) in call_unit_callback_and_wait()
88 item->unit_callback(d, item->bus_path, good, item->userdata); in call_unit_callback_and_wait()
90 wait_for_item_free(item); in call_unit_callback_and_wait()
94 WaitForItem *item; in bus_wait_for_units_clear() local
101 while ((item = hashmap_first(d->items))) in bus_wait_for_units_clear()
102 call_unit_callback_and_wait(d, item, false); in bus_wait_for_units_clear()
195 static void wait_for_item_check_ready(WaitForItem *item) { in wait_for_item_check_ready() argument
198 assert(item); in wait_for_item_check_ready()
199 assert_se(d = item->parent); in wait_for_item_check_ready()
201 if (FLAGS_SET(item->flags, BUS_WAIT_FOR_MAINTENANCE_END)) { in wait_for_item_check_ready()
203 if (item->clean_result && !streq(item->clean_result, "success")) in wait_for_item_check_ready()
206 if (!item->active_state || streq(item->active_state, "maintenance")) in wait_for_item_check_ready()
210 if (FLAGS_SET(item->flags, BUS_WAIT_NO_JOB) && item->job_id != 0) in wait_for_item_check_ready()
213 if (FLAGS_SET(item->flags, BUS_WAIT_FOR_INACTIVE)) { in wait_for_item_check_ready()
215 if (streq_ptr(item->active_state, "failed")) in wait_for_item_check_ready()
217 else if (!streq_ptr(item->active_state, "inactive")) in wait_for_item_check_ready()
221 call_unit_callback_and_wait(d, item, true); in wait_for_item_check_ready()
232 WaitForItem *item = userdata; in property_map_job() local
237 assert(item); in property_map_job()
243 item->job_id = id; in property_map_job()
247 static int wait_for_item_parse_properties(WaitForItem *item, sd_bus_message *m) { in wait_for_item_parse_properties() argument
258 assert(item); in wait_for_item_parse_properties()
261 r = bus_message_map_all_properties(m, map, BUS_MAP_STRDUP, NULL, item); in wait_for_item_parse_properties()
265 wait_for_item_check_ready(item); in wait_for_item_parse_properties()
270 WaitForItem *item = userdata; in on_properties_changed() local
274 assert(item); in on_properties_changed()
285 r = wait_for_item_parse_properties(item, m); in on_properties_changed()
293 WaitForItem *item = userdata; in on_get_all_properties() local
297 assert(item); in on_get_all_properties()
301 BusWaitForUnits *d = item->parent; in on_get_all_properties()
307 item->bus_path, bus_error_message(e, r)); in on_get_all_properties()
309 call_unit_callback_and_wait(d, item, false); in on_get_all_properties()
314 r = wait_for_item_parse_properties(item, m); in on_get_all_properties()
328 _cleanup_(wait_for_item_freep) WaitForItem *item = NULL; in bus_wait_for_units_add_unit()
340 item = new(WaitForItem, 1); in bus_wait_for_units_add_unit()
341 if (!item) in bus_wait_for_units_add_unit()
344 *item = (WaitForItem) { in bus_wait_for_units_add_unit()
352 if (!item->bus_path) in bus_wait_for_units_add_unit()
355 if (!FLAGS_SET(item->flags, BUS_WAIT_REFFED)) { in bus_wait_for_units_add_unit()
360 item->bus_path, in bus_wait_for_units_add_unit()
369 item->flags |= BUS_WAIT_REFFED; in bus_wait_for_units_add_unit()
374 &item->slot_properties_changed, in bus_wait_for_units_add_unit()
376 item->bus_path, in bus_wait_for_units_add_unit()
381 item); in bus_wait_for_units_add_unit()
387 &item->slot_get_all, in bus_wait_for_units_add_unit()
389 item->bus_path, in bus_wait_for_units_add_unit()
393 item, in bus_wait_for_units_add_unit()
394 …"s", FLAGS_SET(item->flags, BUS_WAIT_FOR_MAINTENANCE_END) ? NULL : "org.freedesktop.systemd1.Unit"… in bus_wait_for_units_add_unit()
398 r = hashmap_put(d->items, item->bus_path, item); in bus_wait_for_units_add_unit()
403 item->parent = d; in bus_wait_for_units_add_unit()
404 TAKE_PTR(item); in bus_wait_for_units_add_unit()