[systemd-commits] 4 commits - src/dbus-job.c src/job.c src/manager.c src/systemctl.c src/unit.c src/unit.h TODO
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Feb 23 18:25:02 PST 2011
TODO | 2 ++
src/dbus-job.c | 2 +-
src/job.c | 13 ++++++++++---
src/manager.c | 2 +-
src/systemctl.c | 12 ++++++++++--
src/unit.c | 17 +++++++++++------
src/unit.h | 2 ++
7 files changed, 37 insertions(+), 13 deletions(-)
New commits:
commit 8e20e31a65ec9e637abf3821087946e9160001ac
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Feb 24 03:24:51 2011 +0100
systemctl: properly handle job results
diff --git a/src/systemctl.c b/src/systemctl.c
index 82741bc..b33a89f 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -1248,11 +1248,19 @@ static int wait_for_jobs(DBusConnection *bus, Set *s) {
log_error("Job canceled.");
else if (streq(d.result, "dependency"))
log_error("A dependency job failed. See system logs for details.");
- else
+ else if (!streq(d.result, "done"))
log_error("Job failed. See system logs and 'systemctl status' for details.");
}
- r = d.result ? -EIO : 0;
+ if (streq_ptr(d.result, "timeout"))
+ r = -ETIME;
+ else if (streq_ptr(d.result, "canceled"))
+ r = -ECANCELED;
+ else if (!streq_ptr(d.result, "done"))
+ r = -EIO;
+ else
+ r = 0;
+
free(d.result);
finish:
commit c0daa706d329d6cc593949b7d150d4972289ba93
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Feb 24 03:24:23 2011 +0100
job: also trigger on-failure dependencies when jobs faile due to dependencies, timeout
diff --git a/src/job.c b/src/job.c
index 54c204b..46577fd 100644
--- a/src/job.c
+++ b/src/job.c
@@ -549,6 +549,13 @@ int job_finish_and_invalidate(Job *j, JobResult result) {
}
}
+ /* Trigger OnFailure dependencies that are not generated by
+ * the unit itself. We don't tread JOB_CANCELED as failure in
+ * this context. And JOB_FAILURE is already handled by the
+ * unit itself. */
+ if (result == JOB_TIMEOUT || result == JOB_DEPENDENCY)
+ unit_trigger_on_failure(u);
+
/* Try to start the next jobs that can be started */
SET_FOREACH(other, u->meta.dependencies[UNIT_AFTER], i)
if (other->meta.job)
diff --git a/src/unit.c b/src/unit.c
index 1ca8e82..d75a06a 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -1071,6 +1071,16 @@ static void retroactively_stop_dependencies(Unit *u) {
unit_check_unneeded(other);
}
+void unit_trigger_on_failure(Unit *u) {
+ Unit *other;
+ Iterator i;
+
+ assert(u);
+
+ SET_FOREACH(other, u->meta.dependencies[UNIT_ON_FAILURE], i)
+ manager_add_job(u->meta.manager, JOB_START, other, JOB_REPLACE, true, NULL, NULL);
+}
+
void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_success) {
dual_timestamp ts;
bool unexpected;
@@ -1183,13 +1193,8 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
}
if (ns != os && ns == UNIT_FAILED) {
- Iterator i;
- Unit *other;
-
- SET_FOREACH(other, u->meta.dependencies[UNIT_ON_FAILURE], i)
- manager_add_job(u->meta.manager, JOB_START, other, JOB_REPLACE, true, NULL, NULL);
-
log_notice("Unit %s entered failed state.", u->meta.id);
+ unit_trigger_on_failure(u);
}
/* Some names are special */
diff --git a/src/unit.h b/src/unit.h
index e81cffc..bd60dcb 100644
--- a/src/unit.h
+++ b/src/unit.h
@@ -511,6 +511,8 @@ int unit_following_set(Unit *u, Set **s);
UnitType unit_name_to_type(const char *n);
bool unit_name_is_valid(const char *n, bool template_ok);
+void unit_trigger_on_failure(Unit *u);
+
const char *unit_load_state_to_string(UnitLoadState i);
UnitLoadState unit_load_state_from_string(const char *s);
commit a6a9a78d95e9ba302b259f6871433f510c606308
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Feb 24 03:23:43 2011 +0100
job: don't access j->type when j is already freed
diff --git a/src/job.c b/src/job.c
index 7470204..54c204b 100644
--- a/src/job.c
+++ b/src/job.c
@@ -502,11 +502,11 @@ int job_finish_and_invalidate(Job *j, JobResult result) {
t = j->type;
job_free(j);
- if (result == JOB_FAILED && j->type == JOB_START)
+ if (result == JOB_FAILED && t == JOB_START)
unit_status_printf(u, "Starting %s " ANSI_HIGHLIGHT_ON "failed" ANSI_HIGHLIGHT_OFF ", see 'systemctl status %s' for details.\n", unit_description(u), u->meta.id);
- else if (result == JOB_TIMEOUT && j->type == JOB_START)
+ else if (result == JOB_TIMEOUT && t == JOB_START)
unit_status_printf(u, "Starting %s " ANSI_HIGHLIGHT_ON "timed out" ANSI_HIGHLIGHT_OFF ".\n", unit_description(u), u->meta.id);
- else if (result == JOB_TIMEOUT && j->type == JOB_STOP)
+ else if (result == JOB_TIMEOUT && t == JOB_STOP)
unit_status_printf(u, "Stopping %s " ANSI_HIGHLIGHT_ON "timed out" ANSI_HIGHLIGHT_OFF ".\n", unit_description(u), u->meta.id);
/* Fail depending jobs on failure */
commit c77bc38d28b2da11dcd219635205e633b5c0cd28
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Feb 24 03:23:14 2011 +0100
job: when cancelling jobs, make sure to propagate this properly to depending jobs
diff --git a/TODO b/TODO
index c7ba9fe..0f64307 100644
--- a/TODO
+++ b/TODO
@@ -19,6 +19,8 @@ F15:
* Make systemd-cryptsetup cancellable
+* udev should be able to upgrade its database on its own
+
Features:
* introduce simple way to do mandatory conditions
diff --git a/src/dbus-job.c b/src/dbus-job.c
index 16aa8d0..2a33039 100644
--- a/src/dbus-job.c
+++ b/src/dbus-job.c
@@ -97,7 +97,7 @@ static DBusHandlerResult bus_job_message_dispatch(Job *j, DBusConnection *connec
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
- job_free(j);
+ job_finish_and_invalidate(j, JOB_CANCELED);
} else
return bus_default_message_handler(j->manager, connection, message, INTROSPECTION, properties);
diff --git a/src/manager.c b/src/manager.c
index f266aaa..d77dc09 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -1823,7 +1823,7 @@ void manager_clear_jobs(Manager *m) {
transaction_abort(m);
while ((j = hashmap_first(m->jobs)))
- job_free(j);
+ job_finish_and_invalidate(j, JOB_CANCELED);
}
unsigned manager_dispatch_run_queue(Manager *m) {
More information about the systemd-commits
mailing list