661545
From c460203ad5165dfb095fcfaa6646708e39d2080e Mon Sep 17 00:00:00 2001
661545
From: Jouke Witteveen <j.witteveen@gmail.com>
661545
Date: Tue, 22 Nov 2016 17:39:56 +0100
661545
Subject: [PATCH] service: introduce protocol error type
661545
661545
Introduce a SERVICE_FAILURE_PROTOCOL error type for when a service does
661545
not follow the protocol.
661545
This error type is used when a pid file is expected, but not delivered.
661545
661545
(cherry picked from commit c35755fb878af58b80ac62a501a75f79c90a3763)
661545
661545
Related: #1733998
661545
---
661545
 src/core/service.c | 9 +++++----
661545
 src/core/service.h | 1 +
661545
 2 files changed, 6 insertions(+), 4 deletions(-)
661545
661545
diff --git a/src/core/service.c b/src/core/service.c
661545
index ea71c9e237..84a5aeb072 100644
661545
--- a/src/core/service.c
661545
+++ b/src/core/service.c
661545
@@ -2568,9 +2568,9 @@ static void service_notify_cgroup_empty_event(Unit *u) {
661545
 
661545
                         service_unwatch_pid_file(s);
661545
                         if (s->state == SERVICE_START)
661545
-                                service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_RESOURCES);
661545
+                                service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_PROTOCOL);
661545
                         else
661545
-                                service_enter_stop(s, SERVICE_FAILURE_RESOURCES);
661545
+                                service_enter_stop(s, SERVICE_FAILURE_PROTOCOL);
661545
                 }
661545
                 break;
661545
 
661545
@@ -2804,7 +2804,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
661545
                                         if (!has_start_post && r < 0) {
661545
                                                 r = service_demand_pid_file(s);
661545
                                                 if (r < 0 || !cgroup_good(s))
661545
-                                                        service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_RESOURCES);
661545
+                                                        service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_PROTOCOL);
661545
                                                 break;
661545
                                         }
661545
                                 } else
661545
@@ -2826,7 +2826,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
661545
                                         if (r < 0) {
661545
                                                 r = service_demand_pid_file(s);
661545
                                                 if (r < 0 || !cgroup_good(s))
661545
-                                                        service_enter_stop(s, SERVICE_FAILURE_RESOURCES);
661545
+                                                        service_enter_stop(s, SERVICE_FAILURE_PROTOCOL);
661545
                                                 break;
661545
                                         }
661545
                                 } else
661545
@@ -3428,6 +3428,7 @@ DEFINE_STRING_TABLE_LOOKUP(notify_state, NotifyState);
661545
 static const char* const service_result_table[_SERVICE_RESULT_MAX] = {
661545
         [SERVICE_SUCCESS] = "success",
661545
         [SERVICE_FAILURE_RESOURCES] = "resources",
661545
+        [SERVICE_FAILURE_PROTOCOL] = "protocol",
661545
         [SERVICE_FAILURE_TIMEOUT] = "timeout",
661545
         [SERVICE_FAILURE_EXIT_CODE] = "exit-code",
661545
         [SERVICE_FAILURE_SIGNAL] = "signal",
661545
diff --git a/src/core/service.h b/src/core/service.h
661545
index e0547a464e..82938a1fc4 100644
661545
--- a/src/core/service.h
661545
+++ b/src/core/service.h
661545
@@ -108,6 +108,7 @@ typedef enum NotifyState {
661545
 typedef enum ServiceResult {
661545
         SERVICE_SUCCESS,
661545
         SERVICE_FAILURE_RESOURCES,
661545
+        SERVICE_FAILURE_PROTOCOL,
661545
         SERVICE_FAILURE_TIMEOUT,
661545
         SERVICE_FAILURE_EXIT_CODE,
661545
         SERVICE_FAILURE_SIGNAL,