summaryrefslogtreecommitdiff
path: root/minecproxy
diff options
context:
space:
mode:
Diffstat (limited to 'minecproxy')
-rw-r--r--minecproxy/server-config.c22
-rw-r--r--minecproxy/server-config.h2
-rw-r--r--minecproxy/server.c12
-rw-r--r--minecproxy/server.h2
-rw-r--r--minecproxy/signal-handler.c13
5 files changed, 23 insertions, 28 deletions
diff --git a/minecproxy/server-config.c b/minecproxy/server-config.c
index 1bc3d38..aab9ffb 100644
--- a/minecproxy/server-config.c
+++ b/minecproxy/server-config.c
@@ -16,6 +16,18 @@
#include "server-config.h"
#include "config.h"
+void server_cfg_async_dns_result(struct server_config *scfg)
+{
+ struct server *server = container_of(scfg, struct server, scfg);
+
+ scfg_async_dns_result(scfg);
+
+ if (list_empty(&server->scfg.dnslookups)) {
+ uring_task_put(&server->task);
+ server_commit(server);
+ }
+}
+
static void scfg_read_cb(struct uring_task *task, int res)
{
struct server *server = container_of(task, struct server, task);
@@ -34,14 +46,20 @@ static void scfg_read_cb(struct uring_task *task, int res)
debug(DBG_CFG, "%s: parsing cfg (%i bytes)", server->name, res);
uring_task_close_fd(&server->task);
- if (!scfg_parse(&server->scfg, server->tbuf.buf,
- server_async_dns_update, &lineno, &error)) {
+ if (!scfg_parse(&server->scfg, server->tbuf.buf, true,
+ &lineno, &error)) {
error("%s: failed to parse config file, line %u: %s",
server->name, lineno, error);
server_delete(server);
return;
}
+ if (!list_empty(&server->scfg.dnslookups)) {
+ uring_task_get(&server->task);
+ scfg_async_dns_start(&server->scfg);
+ return;
+ }
+
server_commit(server);
}
diff --git a/minecproxy/server-config.h b/minecproxy/server-config.h
index 590dae0..4ccba19 100644
--- a/minecproxy/server-config.h
+++ b/minecproxy/server-config.h
@@ -1,6 +1,8 @@
#ifndef fooserverconfighfoo
#define fooserverconfighfoo
+void server_cfg_async_dns_result(struct server_config *scfg);
+
void server_cfg_monitor_delete();
void server_cfg_monitor_refdump();
diff --git a/minecproxy/server.c b/minecproxy/server.c
index f1f0006..13396ef 100644
--- a/minecproxy/server.c
+++ b/minecproxy/server.c
@@ -328,18 +328,6 @@ void server_update_active_players(struct server *server, int count)
}
}
-void server_async_dns_update(struct server_config *scfg, bool done)
-{
- struct server *server = container_of(scfg, struct server, scfg);
-
- if (done) {
- uring_task_put(&server->task);
- server_commit(server);
- } else {
- uring_task_get(&server->task);
- }
-}
-
static void server_idle_connected_cb(struct connection *conn, bool connected)
{
struct server *server = container_of(conn, struct server, idle_conn);
diff --git a/minecproxy/server.h b/minecproxy/server.h
index c6ea252..6545903 100644
--- a/minecproxy/server.h
+++ b/minecproxy/server.h
@@ -57,8 +57,6 @@ bool server_stop(struct server *server);
void server_update_active_players(struct server *server, int count);
-void server_async_dns_update(struct server_config *scfg, bool done);
-
bool server_idle_check(struct server *server);
bool server_announce(struct server *server, int fd);
diff --git a/minecproxy/signal-handler.c b/minecproxy/signal-handler.c
index 5369670..23d72fa 100644
--- a/minecproxy/signal-handler.c
+++ b/minecproxy/signal-handler.c
@@ -9,7 +9,6 @@
#include "uring.h"
#include "server.h"
#include "server-config.h"
-#include "config-parser.h"
#include "igmp.h"
#include "announce.h"
#include "idle.h"
@@ -46,23 +45,13 @@ static void signalfd_read(struct uring_task *task, int res)
si = &sia[i];
switch (si->si_signo) {
case SIGUSR1: {
- struct dns_async *dns;
-
debug(DBG_SIG, "Got a SIGUSR1");
if (si->si_code != SI_ASYNCNL || !si->si_ptr) {
error("SIGUSR1: unexpected values in siginfo");
goto out;
}
- dns = si->si_ptr;
- if (!dns->cb) {
- error("DNS callback not set (%p)", dns);
- goto out;
- }
-
- debug(DBG_DNS, "DNS lookup complete, dns: %p, dns->cb: %p", dns,
- dns->cb);
- dns->cb(dns);
+ server_cfg_async_dns_result(si->si_ptr);
break;
}