From 2cfc39ed3c1e94c46b2db2e99c15d3249add9ba2 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Tue, 18 Nov 2025 18:50:51 -0300 Subject: remove status string buffering I originally had planned for it to be a separate service but it make a lot more sense to have it bundled with the login server and avoiding spinning up yet another service. So instead of using the status string directly for output, we're now copying it into the connection's buffer. --- src/status.cc | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/status.cc b/src/status.cc index cb960b8..8399e98 100644 --- a/src/status.cc +++ b/src/status.cc @@ -1,13 +1,7 @@ #include "common.hh" -// IMPORTANT(fusion): We want connections to use the status string directly for -// output, but because it could be refreshed while connections are still using -// it, we need to have them buffered, to allow old versions to remain valid, at -// least for a couple refreshes. Note that ` - static int g_LastStatusRefresh = 0; -static int g_StatusStringIndex = 0; -static char g_StatusString[3][KB(2)]; +static char g_StatusString[KB(2)]; struct XMLBuffer{ char *Data; @@ -194,10 +188,9 @@ const char *GetStatusString(void){ Motd += 1; } - g_StatusStringIndex = (g_StatusStringIndex + 1) % NARRAY(g_StatusString); XMLBuffer Buffer = {}; - Buffer.Data = g_StatusString[g_StatusStringIndex]; - Buffer.Size = sizeof(g_StatusString[g_StatusStringIndex]); + Buffer.Data = g_StatusString; + Buffer.Size = sizeof(g_StatusString); XMLAppendString(&Buffer, ""); XMLAppendString(&Buffer, ""); XMLAppendStringF(&Buffer, @@ -217,6 +210,6 @@ const char *GetStatusString(void){ g_LastStatusRefresh = TimeNow; } - return g_StatusString[g_StatusStringIndex]; + return g_StatusString; } -- cgit v1.2.3