aboutsummaryrefslogtreecommitdiff
path: root/src/status.cc
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-11-18 18:50:51 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-11-18 18:50:51 -0300
commit2cfc39ed3c1e94c46b2db2e99c15d3249add9ba2 (patch)
treeef479e28e7d996ea422751031ee812bb4476a263 /src/status.cc
parent6036d4f37ad97ee1a9a830b36fb2edf9b82e3a3b (diff)
downloadlogin-2cfc39ed3c1e94c46b2db2e99c15d3249add9ba2.tar.gz
login-2cfc39ed3c1e94c46b2db2e99c15d3249add9ba2.zip
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.
Diffstat (limited to 'src/status.cc')
-rw-r--r--src/status.cc15
1 files 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, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
XMLAppendString(&Buffer, "<tsqp version=\"1.0\">");
XMLAppendStringF(&Buffer,
@@ -217,6 +210,6 @@ const char *GetStatusString(void){
g_LastStatusRefresh = TimeNow;
}
- return g_StatusString[g_StatusStringIndex];
+ return g_StatusString;
}