summaryrefslogtreecommitdiff
path: root/minecproxy/systemd.c
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-07-01 08:07:18 +0200
committerDavid Härdeman <david@hardeman.nu>2020-07-01 08:07:18 +0200
commit86727730b8e4cfce2a4ecf2e787c8bf7f57af924 (patch)
tree9a2f5c93474600f85aa35606ae2b3856f8a08165 /minecproxy/systemd.c
parentff9d60b0d5b27369073a329cd5ceb5d6c94bdf84 (diff)
Improve line/error reporting in server config parsing
Diffstat (limited to 'minecproxy/systemd.c')
-rw-r--r--minecproxy/systemd.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/minecproxy/systemd.c b/minecproxy/systemd.c
index 96ff50f..3351f1c 100644
--- a/minecproxy/systemd.c
+++ b/minecproxy/systemd.c
@@ -1,6 +1,7 @@
#include <string.h>
#include <stdlib.h>
#include <systemd/sd-bus.h>
+#include <errno.h>
#include "main.h"
#include "server.h"
@@ -58,11 +59,15 @@ bool systemd_service_running(struct server *server)
server->scfg.systemd_obj,
false);
+again:
r = sd_bus_get_property_string(bus, SYSTEMD_DBUS_SERVICE,
server->scfg.systemd_obj,
SYSTEMD_DBUS_INTERFACE, "ActiveState",
&error, &status);
if (r < 0) {
+ if (sd_bus_error_get_errno(&error) == EINTR)
+ goto again;
+
error("failed to get status for service %s (%s): %s",
server->scfg.systemd_service, server->scfg.systemd_obj,
error.message);
@@ -96,10 +101,14 @@ static bool systemd_service_action(struct server *server, const char *action)
server->scfg.systemd_obj && action,
false);
+again:
r = sd_bus_call_method(bus, SYSTEMD_DBUS_SERVICE, server->scfg.systemd_obj,
SYSTEMD_DBUS_INTERFACE, action, &error, &m, "s",
"fail");
if (r < 0) {
+ if (sd_bus_error_get_errno(&error) == EINTR)
+ goto again;
+
error("failed to perform action %s on systemd service %s: %s",
action, server->scfg.systemd_service, error.message);
goto out;