From dc83b9bf92439f0472333dca0bfa1f7edda689b4 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Mon, 22 Jun 2020 17:05:14 +0200 Subject: Add some minor fixes and the beginning of server autostart --- main.c | 1 + rcon.c | 1 + server-proxy.c | 4 ++++ server.h | 10 +++++----- systemd.c | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index 8b2e37a..6a8ab3a 100644 --- a/main.c +++ b/main.c @@ -465,6 +465,7 @@ cfg_init(int argc, char **argv) if (!debug_category_str[i].name) usage(argc, argv, true); + debug_mask |= DBG_VERBOSE; debug_mask |= debug_category_str[i].val; break; diff --git a/rcon.c b/rcon.c index 0588da0..ef46d44 100644 --- a/rcon.c +++ b/rcon.c @@ -333,6 +333,7 @@ rcon_free(struct uring_task *task) assert_return(task); debug(DBG_RCON, "task %p, idle %p", task, rcon); + rcon->server->rcon = NULL; xfree(rcon); } diff --git a/server-proxy.c b/server-proxy.c index 60f4b33..2e8bbd5 100644 --- a/server-proxy.c +++ b/server-proxy.c @@ -381,6 +381,10 @@ proxy_new(struct server *server, struct saddr *client, int fd) uring_task_set_buf(&proxy->servertask, &proxy->serverbuf); list_add(&proxy->list, &server->proxys); + if (server->state != SERVER_STATE_RUNNING) { + /* FIXME: We need to wait for the server to start */ + server_start(server); + } connect_any(&proxy->servertask, &server->remotes, &proxy->server_conn, proxy_connected_cb); diff --git a/server.h b/server.h index e5913ae..223c837 100644 --- a/server.h +++ b/server.h @@ -2,11 +2,11 @@ #define fooserverhfoo enum server_state { - SERVER_STATE_INIT, - SERVER_STATE_CFG_OK, - SERVER_STATE_RUNNING, - SERVER_STATE_STOPPED, - SERVER_STATE_DEAD, + SERVER_STATE_INIT = 0, + SERVER_STATE_CFG_OK = 1, + SERVER_STATE_RUNNING = 2, + SERVER_STATE_STOPPED = 3, + SERVER_STATE_DEAD = 4, }; enum server_type { diff --git a/systemd.c b/systemd.c index c5c62d3..a44b0d8 100644 --- a/systemd.c +++ b/systemd.c @@ -135,7 +135,7 @@ systemd_service_running(struct server *server) server->systemd_service, server->systemd_obj); out: - xfree(status); + free(status); sd_bus_error_free(&error); return running; } -- cgit v1.2.3