summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-07-12 22:46:47 +0200
committerDavid Härdeman <david@hardeman.nu>2020-07-12 22:46:47 +0200
commit708f431db8dab6779dd090a1117e556340eca9cc (patch)
treed116ee0f2cf22b906b50bc8c1cb7db7884a7125c
parent809c4e0b2f4ced53f48b092f43b37c08eae18b75 (diff)
Some minor fixes, in particular, don't free scfg too early
-rw-r--r--minecproxy/server-proxy.c2
-rw-r--r--minecproxy/server.c9
-rw-r--r--shared/config-parser.c6
-rw-r--r--shared/config-parser.h2
4 files changed, 14 insertions, 5 deletions
diff --git a/minecproxy/server-proxy.c b/minecproxy/server-proxy.c
index d357396..056d0c5 100644
--- a/minecproxy/server-proxy.c
+++ b/minecproxy/server-proxy.c
@@ -517,7 +517,7 @@ bool local_open(struct server_local *local)
socket_set_low_latency(sfd, cfg->socket_keepalive, cfg->socket_iptos,
cfg->socket_nodelay);
- verbose("%s: attempting to bind to %s", local->server->scfg.name,
+ verbose("%s: listening to %s", local->server->scfg.name,
local->local.addrstr);
r = bind(sfd, (struct sockaddr *)&local->local.st,
local->local.addrlen);
diff --git a/minecproxy/server.c b/minecproxy/server.c
index 7e6aa84..258dfa8 100644
--- a/minecproxy/server.c
+++ b/minecproxy/server.c
@@ -47,6 +47,7 @@ static void server_free(struct uring_task *task)
assert_return(task);
debug(DBG_SRV, "freeing server (%p)", server);
+ scfg_delete(&server->scfg);
list_del(&server->list);
xfree(server);
}
@@ -74,7 +75,7 @@ void server_delete(struct server *server)
uring_task_put(&server->exec_task);
uring_task_destroy(&server->task);
uring_task_put(&server->ann_task);
- scfg_delete(&server->scfg);
+ scfg_cancel_adns(&server->scfg);
}
void server_delete_by_filename(const char *filename)
@@ -230,13 +231,15 @@ static bool server_check_running(struct server *server)
/* FIXME: other methods, rcon? */
if (server->scfg.systemd_service) {
- verbose("%s: checking if systemd service is running",
- server->scfg.name);
if (systemd_service_running(&server->scfg, &error)) {
server->state = SERVER_STATE_RUNNING;
+ verbose("%s: systemd service is running",
+ server->scfg.name);
return true;
} else {
server->state = SERVER_STATE_STOPPED;
+ verbose("%s: systemd service is not running",
+ server->scfg.name);
return false;
}
}
diff --git a/shared/config-parser.c b/shared/config-parser.c
index 00f9944..c3cccd6 100644
--- a/shared/config-parser.c
+++ b/shared/config-parser.c
@@ -575,7 +575,6 @@ bool scfg_parse(struct server_config *scfg, char *buf, bool async,
void scfg_delete(struct server_config *scfg)
{
struct saddr *saddr, *tmp;
- struct dns_async *dns;
xfree(scfg->name);
xfree(scfg->filename);
@@ -600,6 +599,11 @@ void scfg_delete(struct server_config *scfg)
list_del(&saddr->list);
xfree(saddr);
}
+}
+
+void scfg_cancel_adns(struct server_config *scfg)
+{
+ struct dns_async *dns;
list_for_each_entry(dns, &scfg->dnslookups, list) {
if (dns->pending)
diff --git a/shared/config-parser.h b/shared/config-parser.h
index ad7e4b2..5b44a46 100644
--- a/shared/config-parser.h
+++ b/shared/config-parser.h
@@ -108,6 +108,8 @@ bool scfg_parse(struct server_config *scfg, char *buf, bool async,
void scfg_delete(struct server_config *scfg);
+void scfg_cancel_adns(struct server_config *scfg);
+
bool scfg_init(struct server_config *scfg, const char *filename);
bool strtosockaddrs(const char *str, struct cfg_value *rvalue, bool async);