From: Zbigniew Jędrzejewski-Szmek Date: Thu, 28 May 2020 12:09:43 +0000 (+0200) Subject: core: make unit_set_invocation_id static X-Git-Tag: v246-rc1~248^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=db868d45f9a50a63a03231e0f475baebd87dab82;p=thirdparty%2Fsystemd.git core: make unit_set_invocation_id static No functional change. --- diff --git a/src/core/unit.c b/src/core/unit.c index b287c77117c..bfdac7842bc 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -3205,6 +3205,43 @@ char *unit_dbus_path_invocation_id(Unit *u) { return unit_dbus_path_from_name(u->invocation_id_string); } +static int unit_set_invocation_id(Unit *u, sd_id128_t id) { + int r; + + assert(u); + + /* Set the invocation ID for this unit. If we cannot, this will not roll back, but reset the whole thing. */ + + if (sd_id128_equal(u->invocation_id, id)) + return 0; + + if (!sd_id128_is_null(u->invocation_id)) + (void) hashmap_remove_value(u->manager->units_by_invocation_id, &u->invocation_id, u); + + if (sd_id128_is_null(id)) { + r = 0; + goto reset; + } + + r = hashmap_ensure_allocated(&u->manager->units_by_invocation_id, &id128_hash_ops); + if (r < 0) + goto reset; + + u->invocation_id = id; + sd_id128_to_string(id, u->invocation_id_string); + + r = hashmap_put(u->manager->units_by_invocation_id, &u->invocation_id, u); + if (r < 0) + goto reset; + + return 0; + +reset: + u->invocation_id = SD_ID128_NULL; + u->invocation_id_string[0] = 0; + return r; +} + int unit_set_slice(Unit *u, Unit *slice) { assert(u); assert(slice); @@ -5344,43 +5381,6 @@ void unit_notify_user_lookup(Unit *u, uid_t uid, gid_t gid) { unit_add_to_dbus_queue(u); } -int unit_set_invocation_id(Unit *u, sd_id128_t id) { - int r; - - assert(u); - - /* Set the invocation ID for this unit. If we cannot, this will not roll back, but reset the whole thing. */ - - if (sd_id128_equal(u->invocation_id, id)) - return 0; - - if (!sd_id128_is_null(u->invocation_id)) - (void) hashmap_remove_value(u->manager->units_by_invocation_id, &u->invocation_id, u); - - if (sd_id128_is_null(id)) { - r = 0; - goto reset; - } - - r = hashmap_ensure_allocated(&u->manager->units_by_invocation_id, &id128_hash_ops); - if (r < 0) - goto reset; - - u->invocation_id = id; - sd_id128_to_string(id, u->invocation_id_string); - - r = hashmap_put(u->manager->units_by_invocation_id, &u->invocation_id, u); - if (r < 0) - goto reset; - - return 0; - -reset: - u->invocation_id = SD_ID128_NULL; - u->invocation_id_string[0] = 0; - return r; -} - int unit_acquire_invocation_id(Unit *u) { sd_id128_t id; int r; diff --git a/src/core/unit.h b/src/core/unit.h index 6659406c2d0..252a98eaffb 100644 --- a/src/core/unit.h +++ b/src/core/unit.h @@ -829,7 +829,6 @@ void unit_unref_uid_gid(Unit *u, bool destroy_now); void unit_notify_user_lookup(Unit *u, uid_t uid, gid_t gid); -int unit_set_invocation_id(Unit *u, sd_id128_t id); int unit_acquire_invocation_id(Unit *u); bool unit_shall_confirm_spawn(Unit *u);