|
|
572a44 |
From b659126834756a4476a5b020bcece486be1edb85 Mon Sep 17 00:00:00 2001
|
|
|
572a44 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
|
572a44 |
Date: Mon, 2 Dec 2013 21:52:51 -0500
|
|
|
572a44 |
Subject: [PATCH] systemd: treat reload failure as failure
|
|
|
572a44 |
|
|
|
572a44 |
systemctl reload "suceeded" on stopped units, but it is documented
|
|
|
572a44 |
to fail in this case.
|
|
|
572a44 |
|
|
|
572a44 |
https://bugzilla.redhat.com/show_bug.cgi?id=1036845
|
|
|
572a44 |
---
|
|
|
572a44 |
src/core/job.c | 11 +++++++----
|
|
|
572a44 |
src/core/job.h | 3 ++-
|
|
|
572a44 |
src/core/unit.c | 5 ++++-
|
|
|
572a44 |
3 files changed, 13 insertions(+), 6 deletions(-)
|
|
|
572a44 |
|
|
|
572a44 |
diff --git a/src/core/job.c b/src/core/job.c
|
|
|
572a44 |
index bf1d956..5ea9803 100644
|
|
|
572a44 |
--- a/src/core/job.c
|
|
|
572a44 |
+++ b/src/core/job.c
|
|
|
572a44 |
@@ -528,7 +528,7 @@ int job_run_and_invalidate(Job *j) {
|
|
|
572a44 |
else if (t == UNIT_ACTIVATING)
|
|
|
572a44 |
r = -EAGAIN;
|
|
|
572a44 |
else
|
|
|
572a44 |
- r = -ENOEXEC;
|
|
|
572a44 |
+ r = -EBADR;
|
|
|
572a44 |
break;
|
|
|
572a44 |
}
|
|
|
572a44 |
|
|
|
572a44 |
@@ -557,8 +557,10 @@ int job_run_and_invalidate(Job *j) {
|
|
|
572a44 |
if (j) {
|
|
|
572a44 |
if (r == -EALREADY)
|
|
|
572a44 |
r = job_finish_and_invalidate(j, JOB_DONE, true);
|
|
|
572a44 |
- else if (r == -ENOEXEC)
|
|
|
572a44 |
+ else if (r == -EBADR)
|
|
|
572a44 |
r = job_finish_and_invalidate(j, JOB_SKIPPED, true);
|
|
|
572a44 |
+ else if (r == -ENOEXEC)
|
|
|
572a44 |
+ r = job_finish_and_invalidate(j, JOB_INVALID, true);
|
|
|
572a44 |
else if (r == -EAGAIN) {
|
|
|
572a44 |
j->state = JOB_WAITING;
|
|
|
572a44 |
m->n_running_jobs--;
|
|
|
572a44 |
@@ -784,7 +786,7 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive) {
|
|
|
572a44 |
goto finish;
|
|
|
572a44 |
}
|
|
|
572a44 |
|
|
|
572a44 |
- if (result == JOB_FAILED)
|
|
|
572a44 |
+ if (result == JOB_FAILED || result == JOB_INVALID)
|
|
|
572a44 |
j->manager->n_failed_jobs ++;
|
|
|
572a44 |
|
|
|
572a44 |
job_uninstall(j);
|
|
|
572a44 |
@@ -1140,7 +1142,8 @@ static const char* const job_result_table[_JOB_RESULT_MAX] = {
|
|
|
572a44 |
[JOB_TIMEOUT] = "timeout",
|
|
|
572a44 |
[JOB_FAILED] = "failed",
|
|
|
572a44 |
[JOB_DEPENDENCY] = "dependency",
|
|
|
572a44 |
- [JOB_SKIPPED] = "skipped"
|
|
|
572a44 |
+ [JOB_SKIPPED] = "skipped",
|
|
|
572a44 |
+ [JOB_INVALID] = "invalid",
|
|
|
572a44 |
};
|
|
|
572a44 |
|
|
|
572a44 |
DEFINE_STRING_TABLE_LOOKUP(job_result, JobResult);
|
|
|
572a44 |
diff --git a/src/core/job.h b/src/core/job.h
|
|
|
572a44 |
index d90bc96..4237529 100644
|
|
|
572a44 |
--- a/src/core/job.h
|
|
|
572a44 |
+++ b/src/core/job.h
|
|
|
572a44 |
@@ -97,7 +97,8 @@ enum JobResult {
|
|
|
572a44 |
JOB_TIMEOUT, /* JobTimeout elapsed */
|
|
|
572a44 |
JOB_FAILED, /* Job failed */
|
|
|
572a44 |
JOB_DEPENDENCY, /* A required dependency job did not result in JOB_DONE */
|
|
|
572a44 |
- JOB_SKIPPED, /* JOB_RELOAD of inactive unit; negative result of JOB_VERIFY_ACTIVE */
|
|
|
572a44 |
+ JOB_SKIPPED, /* Negative result of JOB_VERIFY_ACTIVE */
|
|
|
572a44 |
+ JOB_INVALID, /* JOB_RELOAD of inactive unit */
|
|
|
572a44 |
_JOB_RESULT_MAX,
|
|
|
572a44 |
_JOB_RESULT_INVALID = -1
|
|
|
572a44 |
};
|
|
|
572a44 |
diff --git a/src/core/unit.c b/src/core/unit.c
|
|
|
572a44 |
index 1db7d06..0f57b06 100644
|
|
|
572a44 |
--- a/src/core/unit.c
|
|
|
572a44 |
+++ b/src/core/unit.c
|
|
|
572a44 |
@@ -1239,8 +1239,11 @@ int unit_reload(Unit *u) {
|
|
|
572a44 |
if (state == UNIT_RELOADING)
|
|
|
572a44 |
return -EALREADY;
|
|
|
572a44 |
|
|
|
572a44 |
- if (state != UNIT_ACTIVE)
|
|
|
572a44 |
+ if (state != UNIT_ACTIVE) {
|
|
|
572a44 |
+ log_warning_unit(u->id, "Unit %s cannot be reloaded because it is inactive.",
|
|
|
572a44 |
+ u->id);
|
|
|
572a44 |
return -ENOEXEC;
|
|
|
572a44 |
+ }
|
|
|
572a44 |
|
|
|
572a44 |
if ((following = unit_following(u))) {
|
|
|
572a44 |
log_debug_unit(u->id, "Redirecting reload request from %s to %s.",
|