core/service: drop unused bus_name_owner
authorMike Yuan <me@yhndnzj.com>
Sun, 16 Jun 2024 16:40:39 +0000 (18:40 +0200)
committerMike Yuan <me@yhndnzj.com>
Sun, 16 Jun 2024 17:00:39 +0000 (19:00 +0200)
Follow-up for fc67a943d989d5e74577adea9676cdc7928b08fc

After the mentioned comment, we no longer need to record
the owner to restore the previous bus owner state.
Therefore, bus_name_owner is effectively unused. Kill it.

src/core/service.c
src/core/service.h

index ac8735809504f86bea0f670e942098d7263e7549..f48ebc0bf8ae65034fb47d760be4d9e45df632d1 100644 (file)
@@ -489,8 +489,6 @@ static void service_done(Unit *u) {
                 s->bus_name = mfree(s->bus_name);
         }
 
-        s->bus_name_owner = mfree(s->bus_name_owner);
-
         s->usb_function_descriptors = mfree(s->usb_function_descriptors);
         s->usb_function_strings = mfree(s->usb_function_strings);
 
@@ -2967,7 +2965,6 @@ static int service_serialize(Unit *u, FILE *f, FDSet *fds) {
 
         (void) serialize_bool(f, "main-pid-known", s->main_pid_known);
         (void) serialize_bool(f, "bus-name-good", s->bus_name_good);
-        (void) serialize_bool(f, "bus-name-owner", s->bus_name_owner);
 
         (void) serialize_item_format(f, "n-restarts", "%u", s->n_restarts);
         (void) serialize_bool(f, "flush-n-restarts", s->flush_n_restarts);
@@ -3221,11 +3218,6 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
                         log_unit_debug(u, "Failed to parse bus-name-good value: %s", value);
                 else
                         s->bus_name_good = b;
-        } else if (streq(key, "bus-name-owner")) {
-                r = free_and_strdup(&s->bus_name_owner, value);
-                if (r < 0)
-                        log_unit_error_errno(u, r, "Unable to deserialize current bus owner %s: %m", value);
-
         } else if (streq(key, "accept-socket")) {
                 Unit *socket;
 
@@ -4708,17 +4700,8 @@ static void service_bus_name_owner_change(Unit *u, const char *new_owner) {
 
         s->bus_name_good = new_owner;
 
-        /* Track the current owner, so we can reconstruct changes after a daemon reload */
-        r = free_and_strdup(&s->bus_name_owner, new_owner);
-        if (r < 0) {
-                log_unit_error_errno(u, r, "Unable to set new bus name owner %s: %m", new_owner);
-                return;
-        }
-
         if (s->type == SERVICE_DBUS) {
-
-                /* service_enter_running() will figure out what to
-                 * do */
+                /* service_enter_running() will figure out what to do */
                 if (s->state == SERVICE_RUNNING)
                         service_enter_running(s, SERVICE_SUCCESS);
                 else if (s->state == SERVICE_START && new_owner)
index 59598f77de66f9e32a694d5eb2000b5120eec9b9..55ea413f40a30ff719e6c6e8d52a67a69a9e9d88 100644 (file)
@@ -196,7 +196,6 @@ struct Service {
         bool exec_fd_hot:1;
 
         char *bus_name;
-        char *bus_name_owner; /* unique name of the current owner */
 
         char *status_text;
         int status_errno;