aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-02-24 15:12:40 +0000
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-02-24 15:12:40 +0000
commit1fda5cab9d18346e049cf84a9e791bbf89b7a861 (patch)
tree352c27f2040c392d64a130ee366c04618758a451 /NorthstarDedicatedTest
parent4f28a07d0562ca905bbcdb010b69604c330194bb (diff)
downloadNorthstarLauncher-1fda5cab9d18346e049cf84a9e791bbf89b7a861.tar.gz
NorthstarLauncher-1fda5cab9d18346e049cf84a9e791bbf89b7a861.zip
fix uncommon race condition that creates "phantom" servers
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r--NorthstarDedicatedTest/masterserver.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/masterserver.cpp b/NorthstarDedicatedTest/masterserver.cpp
index b08ebb90..b5f87274 100644
--- a/NorthstarDedicatedTest/masterserver.cpp
+++ b/NorthstarDedicatedTest/masterserver.cpp
@@ -897,6 +897,10 @@ void MasterServerManager::AddSelfToServerList(
{
Sleep(5000);
+ // defensive check, as m_ownServer could be set to null during the Sleep(5000) above
+ if (!*m_ownServerId)
+ return;
+
do
{
CURL* curl = curl_easy_init();
@@ -952,6 +956,11 @@ void MasterServerManager::AddSelfToServerList(
curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
CURLcode result = curl_easy_perform(curl);
+
+ // defensive check, as m_ownServerId could be set to null before this request gets processed
+ if (!*m_ownServerId)
+ return;
+
if (result == CURLcode::CURLE_OK)
{
rapidjson_document serverAddedJson;
@@ -1157,6 +1166,7 @@ void MasterServerManager::RemoveSelfFromServerList()
curl, CURLOPT_URL,
fmt::format("{}/server/remove_server?id={}", Cvar_ns_masterserver_hostname->GetString(), m_ownServerId).c_str());
+ *m_ownServerId = 0;
CURLcode result = curl_easy_perform(curl);
if (result == CURLcode::CURLE_OK)