From c35755fb878af58b80ac62a501a75f79c90a3763 Mon Sep 17 00:00:00 2001 From: Jouke Witteveen Date: Tue, 22 Nov 2016 17:39:56 +0100 Subject: service: introduce protocol error type Introduce a SERVICE_FAILURE_PROTOCOL error type for when a service does not follow the protocol. This error type is used when a pid file is expected, but not delivered. --- src/core/service.c | 9 +++++---- src/core/service.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/service.c b/src/core/service.c index 9ad4cf5070..47368edd0a 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -2585,9 +2585,9 @@ static void service_notify_cgroup_empty_event(Unit *u) { service_unwatch_pid_file(s); if (s->state == SERVICE_START) - service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_RESOURCES); + service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_PROTOCOL); else - service_enter_stop(s, SERVICE_FAILURE_RESOURCES); + service_enter_stop(s, SERVICE_FAILURE_PROTOCOL); } break; @@ -2825,7 +2825,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) { if (!has_start_post && r < 0) { r = service_demand_pid_file(s); if (r < 0 || !cgroup_good(s)) - service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_RESOURCES); + service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_PROTOCOL); break; } } else @@ -2847,7 +2847,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) { if (r < 0) { r = service_demand_pid_file(s); if (r < 0 || !cgroup_good(s)) - service_enter_stop(s, SERVICE_FAILURE_RESOURCES); + service_enter_stop(s, SERVICE_FAILURE_PROTOCOL); break; } } else @@ -3384,6 +3384,7 @@ DEFINE_STRING_TABLE_LOOKUP(notify_state, NotifyState); static const char* const service_result_table[_SERVICE_RESULT_MAX] = { [SERVICE_SUCCESS] = "success", [SERVICE_FAILURE_RESOURCES] = "resources", + [SERVICE_FAILURE_PROTOCOL] = "protocol", [SERVICE_FAILURE_TIMEOUT] = "timeout", [SERVICE_FAILURE_EXIT_CODE] = "exit-code", [SERVICE_FAILURE_SIGNAL] = "signal", diff --git a/src/core/service.h b/src/core/service.h index 2869144fcb..278cc1ceb8 100644 --- a/src/core/service.h +++ b/src/core/service.h @@ -81,6 +81,7 @@ typedef enum NotifyState { typedef enum ServiceResult { SERVICE_SUCCESS, SERVICE_FAILURE_RESOURCES, /* a bit of a misnomer, just our catch-all error for errnos we didn't expect */ + SERVICE_FAILURE_PROTOCOL, SERVICE_FAILURE_TIMEOUT, SERVICE_FAILURE_EXIT_CODE, SERVICE_FAILURE_SIGNAL, -- cgit v1.2.3-54-g00ecf