[systemd-commits] 2 commits - src/core
Michal Schmidt
michich at kemper.freedesktop.org
Tue Jun 26 02:46:33 PDT 2012
src/core/service.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
New commits:
commit 0c7f15b3a95c3596a4756de5c44eb1fdcd0034fc
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Tue Jun 26 11:42:52 2012 +0200
service: pass via FAILED/DEAD before going to AUTO_RESTART
With misconfigured mysql, which uses Restart=always, the following two
messages would loop indefinitely and the "systemctl start" would never
finish:
Job pending for unit, delaying automatic restart.
mysqld.service holdoff time over, scheduling restart.
In service_enter_dead() always set the state to SERVICE_FAILED/DEAD first
before setting SERVICE_AUTO_RESTART. This is to allow running jobs to
complete. OnFailure will be also triggered at this point, so there's no
need to do it again from service_stop() (where it was added in commit
f0c7b229).
Note that OnFailure units should better trigger only after giving up
auto-restarting, but that's for another patch to solve.
https://bugzilla.redhat.com/show_bug.cgi?id=832039
diff --git a/src/core/service.c b/src/core/service.c
index e598f9b..d82803d 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1888,6 +1888,8 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
if (f != SERVICE_SUCCESS)
s->result = f;
+ service_set_state(s, s->result != SERVICE_SUCCESS ? SERVICE_FAILED : SERVICE_DEAD);
+
if (allow_restart &&
!s->forbid_restart &&
(s->restart == SERVICE_RESTART_ALWAYS ||
@@ -1901,8 +1903,7 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
goto fail;
service_set_state(s, SERVICE_AUTO_RESTART);
- } else
- service_set_state(s, s->result != SERVICE_SUCCESS ? SERVICE_FAILED : SERVICE_DEAD);
+ }
s->forbid_restart = false;
@@ -2509,7 +2510,7 @@ static int service_stop(Unit *u) {
/* A restart will be scheduled or is in progress. */
if (s->state == SERVICE_AUTO_RESTART) {
- service_enter_dead(s, SERVICE_SUCCESS, false);
+ service_set_state(s, SERVICE_DEAD);
return 0;
}
commit e201a0384da94f57f65c951a97d8ddaf990d6240
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Tue Jun 26 11:32:30 2012 +0200
service: fix incorrect argument
The last argument to service_enter_dead() is bool allow_restart, not
a service result.
diff --git a/src/core/service.c b/src/core/service.c
index ec6aaa5..e598f9b 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -3227,7 +3227,7 @@ static void service_cgroup_notify_event(Unit *u) {
case SERVICE_FINAL_SIGTERM:
case SERVICE_FINAL_SIGKILL:
if (main_pid_good(s) <= 0 && !control_pid_good(s))
- service_enter_dead(s, SERVICE_SUCCESS, SERVICE_SUCCESS);
+ service_enter_dead(s, SERVICE_SUCCESS, true);
break;
More information about the systemd-commits
mailing list