From c5a97ed132b400ad82f7939d55fe1027a2b13f6e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 15 Nov 2016 19:32:50 +0100 Subject: core: GC redundant device jobs from the run queue In contrast to all other unit types device units when queued just track external state, they cannot effect state changes on their own. Hence unless a client or other job waits for them there's no reason to keep them in the job queue. This adds a concept of GC'ing jobs of this type as soon as no client or other job waits for them anymore. To ensure this works correctly we need to track which clients actually reference a job (i.e. which ones enqueued it). Unfortunately that's pretty nasty to do for direct connections, as sd_bus_track doesn't work for them. For now, work around this, by simply remembering in a boolean that a job was requested by a direct connection, and reset it when we notice the direct connection is gone. This means the GC logic works fine, except that jobs are not immediately removed when direct connections disconnect. In the longer term, a rework of the bus logic should fix this properly. For now this should be good enough, as GC works for fine all cases except this one, and thus is a clear improvement over the previous behaviour. Fixes: #1921 --- src/shared/bus-unit-util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/shared/bus-unit-util.c') diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index 4f66497f3a..a7702602eb 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -838,6 +838,8 @@ static int check_wait_response(BusWaitForJobs *d, bool quiet, const char* const* log_error("Assertion failed on job for %s.", strna(d->name)); else if (streq(d->result, "unsupported")) log_error("Operation on or unit type of %s not supported on this system.", strna(d->name)); + else if (streq(d->result, "collected")) + log_error("Queued job for %s was garbage collected.", strna(d->name)); else if (!streq(d->result, "done") && !streq(d->result, "skipped")) { if (d->name) { int q; @@ -853,7 +855,7 @@ static int check_wait_response(BusWaitForJobs *d, bool quiet, const char* const* } } - if (streq(d->result, "canceled")) + if (STR_IN_SET(d->result, "canceled", "collected")) r = -ECANCELED; else if (streq(d->result, "timeout")) r = -ETIME; -- cgit v1.2.3-54-g00ecf From 289188ca7dcbb2a1193d06349b73e5d7f5473755 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 16 Nov 2016 14:44:04 +0100 Subject: system-run: add support for configuring unit dependencies with --property= Support on the server side has already been in place for quite some time, let's also add support on the client side for this. --- src/shared/bus-unit-util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/shared/bus-unit-util.c') diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index a7702602eb..388b391342 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -62,6 +62,7 @@ int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u) { int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignment) { const char *eq, *field; + UnitDependency dep; int r, rl; assert(m); @@ -572,7 +573,9 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen flags = (~flags) & NAMESPACE_FLAGS_ALL; r = sd_bus_message_append(m, "v", "t", flags); - } else { + } else if ((dep = unit_dependency_from_string(field)) >= 0) + r = sd_bus_message_append(m, "v", "as", 1, eq); + else { log_error("Unknown assignment %s.", assignment); return -EINVAL; } -- cgit v1.2.3-54-g00ecf