mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
run: pin the unit we invoke continously while we are running
We read properties of the unit, hence it shouldn't be GC'ed as long as we run. Hence, let's just set AddRef unconditionally for the units we create.
This commit is contained in:
parent
7693661a84
commit
49a510eba2
@ -653,6 +653,8 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
static int transient_unit_set_properties(sd_bus_message *m, UnitType t, char **properties) {
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
||||
r = sd_bus_message_append(m, "(sv)", "Description", "s", arg_description);
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
@ -663,6 +665,17 @@ static int transient_unit_set_properties(sd_bus_message *m, UnitType t, char **p
|
||||
return bus_log_create_error(r);
|
||||
}
|
||||
|
||||
r = sd_bus_is_bus_client(sd_bus_message_get_bus(m));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Can't determine if bus connection is direct or to broker: %m");
|
||||
if (r > 0) {
|
||||
/* Pin the object as least as long as we are around. Note that AddRef (currently) only works
|
||||
* if we talk via the bus though. */
|
||||
r = sd_bus_message_append(m, "(sv)", "AddRef", "b", 1);
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
}
|
||||
|
||||
return bus_append_unit_property_assignment_many(m, t, properties);
|
||||
}
|
||||
|
||||
@ -754,12 +767,6 @@ static int transient_service_set_properties(sd_bus_message *m, const char *pty_p
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (arg_wait || arg_stdio != ARG_STDIO_NONE) {
|
||||
r = sd_bus_message_append(m, "(sv)", "AddRef", "b", 1);
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
}
|
||||
|
||||
if (arg_remain_after_exit) {
|
||||
r = sd_bus_message_append(m, "(sv)", "RemainAfterExit", "b", arg_remain_after_exit);
|
||||
if (r < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user