X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fservice.c;h=887b1c8514cfd35ed6e13ede49faeb1b05ee6719;hb=4c94096027f21d4ed0efe991534a926d39d52369;hp=ace45e29ec021d9202565b8b712c5ae7dac166df;hpb=4774e357268e4a1e9fa82adb0563a538932a4c8e;p=elogind.git diff --git a/src/core/service.c b/src/core/service.c index ace45e29e..887b1c851 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -463,16 +463,14 @@ static int service_load(Unit *u) { } static void service_dump(Unit *u, FILE *f, const char *prefix) { - ServiceExecCommand c; Service *s = SERVICE(u); const char *prefix2; - _cleanup_free_ char *p2 = NULL; assert(s); - p2 = strappend(prefix, "\t"); - prefix2 = p2 ? p2 : prefix; + prefix = strempty(prefix); + prefix2 = strappenda(prefix, "\t"); fprintf(f, "%sService State: %s\n" @@ -1699,6 +1697,10 @@ static int service_start(Unit *u) { s->main_pid_alien = false; s->forbid_restart = false; + free(s->status_text); + s->status_text = NULL; + s->status_errno = 0; + service_enter_start_pre(s); return 0; } @@ -2547,11 +2549,15 @@ static int service_dispatch_timer(sd_event_source *source, usec_t usec, void *us static int service_dispatch_watchdog(sd_event_source *source, usec_t usec, void *userdata) { Service *s = SERVICE(userdata); + char t[FORMAT_TIMESPAN_MAX]; assert(s); assert(source == s->watchdog_event_source); - log_error_unit(UNIT(s)->id, "%s watchdog timeout!", UNIT(s)->id); + log_error_unit(UNIT(s)->id, + "%s watchdog timeout (limit %s)!", + UNIT(s)->id, + format_timespan(t, sizeof(t), s->watchdog_usec, 1)); service_enter_signal(s, SERVICE_STOP_SIGTERM, SERVICE_FAILURE_WATCHDOG); return 0; @@ -2575,7 +2581,6 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) { } if (s->notify_access == NOTIFY_MAIN && pid != s->main_pid) { - if (s->main_pid != 0) log_warning_unit(u->id, "%s: Got notification message from PID "PID_FMT", but reception only permitted for main PID "PID_FMT, u->id, pid, s->main_pid); else @@ -2584,14 +2589,10 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) { } /* Interpret MAINPID= */ - if ((e = strv_find_prefix(tags, "MAINPID=")) && - (s->state == SERVICE_START || - s->state == SERVICE_START_POST || - s->state == SERVICE_RUNNING || - s->state == SERVICE_RELOAD)) { - + e = strv_find_prefix(tags, "MAINPID="); + if (e && IN_SET(s->state, SERVICE_START, SERVICE_START_POST, SERVICE_RUNNING, SERVICE_RELOAD)) { if (parse_pid(e + 8, &pid) < 0) - log_warning_unit(u->id, "Failed to parse notification message %s", e); + log_warning_unit(u->id, "Failed to parse MAINPID= field in notification message: %s", e); else { log_debug_unit(u->id, "%s: got %s", u->id, e); service_set_main_pid(s, pid); @@ -2642,7 +2643,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) { if (e) { int status_errno; - if (safe_atoi(e + 6, &status_errno) < 0) + if (safe_atoi(e + 6, &status_errno) < 0 || status_errno < 0) log_warning_unit(u->id, "Failed to parse ERRNO= field in notification message: %s", e); else { log_debug_unit(u->id, "%s: got %s", u->id, e);