summaryrefslogtreecommitdiff
path: root/minecproxy
diff options
context:
space:
mode:
Diffstat (limited to 'minecproxy')
-rw-r--r--minecproxy/server-config.c7
-rw-r--r--minecproxy/server.c7
-rw-r--r--minecproxy/systemd.c9
3 files changed, 18 insertions, 5 deletions
diff --git a/minecproxy/server-config.c b/minecproxy/server-config.c
index de9265d..1bc3d38 100644
--- a/minecproxy/server-config.c
+++ b/minecproxy/server-config.c
@@ -19,6 +19,8 @@
static void scfg_read_cb(struct uring_task *task, int res)
{
struct server *server = container_of(task, struct server, task);
+ const char *error;
+ unsigned lineno;
assert_return(task);
assert_task_alive(DBG_CFG, task);
@@ -33,8 +35,9 @@ static void scfg_read_cb(struct uring_task *task, int res)
uring_task_close_fd(&server->task);
if (!scfg_parse(&server->scfg, server->tbuf.buf,
- server_async_dns_update)) {
- error("%s: failed to parse config file", server->name);
+ server_async_dns_update, &lineno, &error)) {
+ error("%s: failed to parse config file, line %u: %s",
+ server->name, lineno, error);
server_delete(server);
return;
}
diff --git a/minecproxy/server.c b/minecproxy/server.c
index b06286b..f1f0006 100644
--- a/minecproxy/server.c
+++ b/minecproxy/server.c
@@ -423,6 +423,7 @@ bool server_announce(struct server *server, int fd)
bool server_commit(struct server *server)
{
+ const char *error;
struct saddr *saddr, *tmp;
int r;
@@ -445,8 +446,9 @@ bool server_commit(struct server *server)
return false;
}
- if (!scfg_validate(&server->scfg)) {
- error("%s: failed to validate config file", server->name);
+ if (!scfg_validate(&server->scfg, &error)) {
+ error("%s: failed to validate config file (%s)",
+ server->name, error);
server_delete(server);
return false;
}
@@ -468,7 +470,6 @@ bool server_commit(struct server *server)
list_for_each_entry_safe(saddr, tmp, &server->scfg.locals, list) {
struct server_local *local;
- /* FIXME: error checks */
list_del(&saddr->list);
local = local_new(server, saddr);
if (!local) {
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;