X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fservice.c;h=bf2e0a9d98f99979b8881f6209a20f3727635b72;hb=cc527a4734d636f1ab5a66576cb7e232af3cc261;hp=ec2725a7badb39c98159d22cbbfe960ba5c48d85;hpb=02c4ef9c35e90ad562dc70fae25c81a8fd7f40f8;p=elogind.git diff --git a/src/service.c b/src/service.c index ec2725a7b..bf2e0a9d9 100644 --- a/src/service.c +++ b/src/service.c @@ -39,6 +39,7 @@ #include "exit-status.h" #include "def.h" #include "util.h" +#include "utf8.h" #ifdef HAVE_SYSV_COMPAT @@ -1436,7 +1437,7 @@ static int service_search_main_pid(Service *s) { return 0; } -static void service_notify_sockets_dead(Service *s) { +static void service_notify_sockets_dead(Service *s, bool failed_permanent) { Iterator i; Unit *u; @@ -1449,7 +1450,7 @@ static void service_notify_sockets_dead(Service *s) { SET_FOREACH(u, UNIT(s)->dependencies[UNIT_TRIGGERED_BY], i) if (u->type == UNIT_SOCKET) - socket_notify_service_dead(SOCKET(u)); + socket_notify_service_dead(SOCKET(u), failed_permanent); return; } @@ -1511,7 +1512,7 @@ static void service_set_state(Service *s, ServiceState state) { state == SERVICE_FINAL_SIGKILL || state == SERVICE_FAILED || state == SERVICE_AUTO_RESTART) - service_notify_sockets_dead(s); + service_notify_sockets_dead(s, false); if (state != SERVICE_START_PRE && state != SERVICE_START && @@ -2207,9 +2208,12 @@ static void service_enter_restart(Service *s) { goto fail; } - service_enter_dead(s, SERVICE_SUCCESS, false); - - if ((r = manager_add_job(UNIT(s)->manager, JOB_START, UNIT(s), JOB_FAIL, false, &error, NULL)) < 0) + /* Any units that are bound to this service must also be + * restarted. We use JOB_RESTART (instead of the more obvious + * JOB_START) here so that those dependency jobs will be added + * as well. */ + r = manager_add_job(UNIT(s)->manager, JOB_RESTART, UNIT(s), JOB_FAIL, false, &error, NULL); + if (r < 0) goto fail; log_debug("%s scheduled restart job.", UNIT(s)->id); @@ -2359,7 +2363,7 @@ static int service_start_limit_test(Service *s) { } case SERVICE_START_LIMIT_REBOOT_FORCE: - log_warning("%s start request repeated too quickly, force rebooting.", UNIT(s)->id); + log_warning("%s start request repeated too quickly, forcibly rebooting.", UNIT(s)->id); UNIT(s)->manager->exit_code = MANAGER_REBOOT; break; @@ -2402,8 +2406,10 @@ static int service_start(Unit *u) { /* Make sure we don't enter a busy loop of some kind. */ r = service_start_limit_test(s); - if (r < 0) + if (r < 0) { + service_notify_sockets_dead(s, true); return r; + } s->result = SERVICE_SUCCESS; s->reload_result = SERVICE_SUCCESS; @@ -3198,11 +3204,19 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) { } /* Interpret STATUS= */ - if ((e = strv_find_prefix(tags, "STATUS="))) { + e = strv_find_prefix(tags, "STATUS="); + if (e) { char *t; if (e[7]) { - if (!(t = strdup(e+7))) { + + if (!utf8_is_valid(e+7)) { + log_warning("Status message in notification is not UTF-8 clean."); + return; + } + + t = strdup(e+7); + if (!t) { log_error("Failed to allocate string."); return; }