[systemd-commits] 2 commits - src/core
Lennart Poettering
lennart at kemper.freedesktop.org
Mon Jul 7 08:03:39 PDT 2014
src/core/dbus-service.c | 1 +
src/core/service.c | 28 ++++++++++++++++++++--------
src/core/service.h | 1 +
3 files changed, 22 insertions(+), 8 deletions(-)
New commits:
commit 5e56b378b40dc4dc5557e653487b608fd91fcc26
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Jul 7 17:03:34 2014 +0200
service: minor modernization
diff --git a/src/core/service.c b/src/core/service.c
index ace45e2..5c54a34 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -2575,7 +2575,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 +2583,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);
commit 4774e357268e4a1e9fa82adb0563a538932a4c8e
Author: Miguel Angel Ajo <mangelajo at redhat.com>
Date: Mon Jul 7 14:20:36 2014 +0200
core: Added support for ERRNO NOTIFY_SOCKET message parsing, and added StatusErrno dbus property along StatusText to allow notification of numeric status condition while degraded service operation or any other special situation.
diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c
index 093289f..5a881e8 100644
--- a/src/core/dbus-service.c
+++ b/src/core/dbus-service.c
@@ -60,6 +60,7 @@ const sd_bus_vtable bus_service_vtable[] = {
SD_BUS_PROPERTY("ControlPID", "u", bus_property_get_pid, offsetof(Service, control_pid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("BusName", "s", NULL, offsetof(Service, bus_name), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("StatusText", "s", NULL, offsetof(Service, status_text), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
+ SD_BUS_PROPERTY("StatusErrno", "i", NULL, offsetof(Service, status_errno), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Service, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
BUS_EXEC_STATUS_VTABLE("ExecMain", offsetof(Service, main_exec_status), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
BUS_EXEC_COMMAND_LIST_VTABLE("ExecStartPre", offsetof(Service, exec_command[SERVICE_EXEC_START_PRE]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
diff --git a/src/core/service.c b/src/core/service.c
index 0b19767..ace45e2 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -2637,6 +2637,23 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
free(t);
}
+ /* Interpret ERRNO= */
+ e = strv_find_prefix(tags, "ERRNO=");
+ if (e) {
+ int status_errno;
+
+ if (safe_atoi(e + 6, &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);
+
+ if (s->status_errno != status_errno) {
+ s->status_errno = status_errno;
+ notify_dbus = true;
+ }
+ }
+ }
+
/* Interpret WATCHDOG= */
if (strv_find(tags, "WATCHDOG=1")) {
log_debug_unit(u->id, "%s: got WATCHDOG=1", u->id);
diff --git a/src/core/service.h b/src/core/service.h
index 7406d90..686cf4b 100644
--- a/src/core/service.h
+++ b/src/core/service.h
@@ -182,6 +182,7 @@ struct Service {
char *bus_name;
char *status_text;
+ int status_errno;
FailureAction failure_action;
More information about the systemd-commits
mailing list