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