From eda3cf87d1049a7fb8fd7e0512d0e0a70b444245 Mon Sep 17 00:00:00 2001 From: DcruBro Date: Tue, 11 Nov 2025 15:26:05 +0100 Subject: [PATCH] misc. --- src/client/main.cpp | 4 ++-- src/server/main.cpp | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/client/main.cpp b/src/client/main.cpp index c182fe0..b832efb 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -54,7 +54,7 @@ int main(int argc, char** argv) { try { log("ColumnLynx Client, Version " + getVersion()); - log("This software is licensed under the GPLv2 only OR the GPLv3. See LICENSE for details."); + log("This software is licensed under the GPLv2 only OR the GPLv3. See LICENSES/ for details."); LibSodiumWrapper sodiumWrapper = LibSodiumWrapper(); @@ -78,7 +78,7 @@ int main(int argc, char** argv) { // Client is running // TODO: SIGINT or SIGTERM seems to not kill this instantly! - while (client->isConnected() || !client->isHandshakeComplete() || !done) { + while ((client->isConnected() || !client->isHandshakeComplete()) && !done) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Temp wait if (client->isHandshakeComplete()) { diff --git a/src/server/main.cpp b/src/server/main.cpp index fdddac3..385dde9 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -18,26 +18,27 @@ using namespace ColumnLynx::Net::UDP; volatile sig_atomic_t done = 0; -/*void signalHandler(int signum) { +void signalHandler(int signum) { if (signum == SIGINT || signum == SIGTERM) { log("Received termination signal. Shutting down server gracefully."); done = 1; } -}*/ +} int main(int argc, char** argv) { + // Capture SIGINT and SIGTERM for graceful shutdown + struct sigaction action; + memset(&action, 0, sizeof(struct sigaction)); + action.sa_handler = signalHandler; + sigaction(SIGINT, &action, nullptr); + sigaction(SIGTERM, &action, nullptr); + PanicHandler::init(); try { - // Catch SIGINT and SIGTERM for graceful shutdown - /*struct sigaction action; - memset(&action, 0, sizeof(struct sigaction)); - action.sa_handler = signalHandler; - sigaction(SIGINT, &action, nullptr); - sigaction(SIGTERM, &action, nullptr);*/ log("ColumnLynx Server, Version " + getVersion()); - log("This software is licensed under the GPLv2 only OR the GPLv3. See LICENSE for details."); + log("This software is licensed under the GPLv2 only OR the GPLv3. See LICENSES/ for details."); // Generate a temporary keypair, replace with actual CA signed keys later (Note, these are stored in memory) LibSodiumWrapper sodiumWrapper = LibSodiumWrapper();