Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't log masterserver registration errors in the lobby #543

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions NorthstarDLL/masterserver/masterserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ void MasterServerPresenceReporter::InternalAddServer(const ServerPresence* pServ

addServerFuture = std::async(
std::launch::async,
[threadedPresence, modInfo, hostname]
[threadedPresence, modInfo, hostname, pServerPresence]
{
CURL* curl = curl_easy_init();
SetCommonHttpClientOptions(curl);
Expand Down Expand Up @@ -1188,6 +1188,10 @@ void MasterServerPresenceReporter::InternalAddServer(const ServerPresence* pServ
return data;
};

// don't log errors if we wouldn't actually show up in the server list anyway (stop tickets)
bool shouldLogError =
!strstr(pServerPresence->m_MapName, "mp_lobby") && strstr(pServerPresence->m_PlaylistName, "private_match");
ASpoonPlaysGames marked this conversation as resolved.
Show resolved Hide resolved

curl_mime_data(part, modInfo.c_str(), modInfo.size());
curl_mime_name(part, "modinfo");
curl_mime_filename(part, "modinfo.json");
Expand Down Expand Up @@ -1237,22 +1241,27 @@ void MasterServerPresenceReporter::InternalAddServer(const ServerPresence* pServ
// No retry.
if (serverAddedJson.HasParseError())
{
spdlog::error(
"Failed reading masterserver authentication response: encountered parse error \"{}\"",
rapidjson::GetParseError_En(serverAddedJson.GetParseError()));
if (shouldLogError)
spdlog::error(
"Failed reading masterserver authentication response: encountered parse error \"{}\"",
rapidjson::GetParseError_En(serverAddedJson.GetParseError()));
return ReturnCleanup(MasterServerReportPresenceResult::FailedNoRetry);
}

if (!serverAddedJson.IsObject())
{
spdlog::error("Failed reading masterserver authentication response: root object is not an object");
if (shouldLogError)
spdlog::error("Failed reading masterserver authentication response: root object is not an object");
return ReturnCleanup(MasterServerReportPresenceResult::FailedNoRetry);
}

if (serverAddedJson.HasMember("error"))
{
spdlog::error("Failed reading masterserver response: got fastify error response");
spdlog::error(readBuffer);
if (shouldLogError)
{
spdlog::error("Failed reading masterserver response: got fastify error response");
spdlog::error(readBuffer);
}

// If this is DUPLICATE_SERVER, we'll retry adding the server every 20 seconds.
// The master server will only update its internal server list and clean up dead servers on certain events.
Expand All @@ -1261,7 +1270,8 @@ void MasterServerPresenceReporter::InternalAddServer(const ServerPresence* pServ
if (serverAddedJson["error"].HasMember("enum") &&
strcmp(serverAddedJson["error"]["enum"].GetString(), "DUPLICATE_SERVER") == 0)
{
spdlog::error("Cooling down while the master server cleans the dead server entry, if any.");
if (shouldLogError)
spdlog::error("Cooling down while the master server cleans the dead server entry, if any.");
return ReturnCleanup(MasterServerReportPresenceResult::FailedDuplicateServer);
}

Expand All @@ -1271,14 +1281,16 @@ void MasterServerPresenceReporter::InternalAddServer(const ServerPresence* pServ

if (!serverAddedJson["success"].IsTrue())
{
spdlog::error("Adding server to masterserver failed: \"success\" is not true");
if (shouldLogError)
spdlog::error("Adding server to masterserver failed: \"success\" is not true");
return ReturnCleanup(MasterServerReportPresenceResult::FailedNoRetry);
}

if (!serverAddedJson.HasMember("id") || !serverAddedJson["id"].IsString() ||
!serverAddedJson.HasMember("serverAuthToken") || !serverAddedJson["serverAuthToken"].IsString())
{
spdlog::error("Failed reading masterserver response: malformed json object");
if (shouldLogError)
spdlog::error("Failed reading masterserver response: malformed json object");
return ReturnCleanup(MasterServerReportPresenceResult::FailedNoRetry);
}

Expand All @@ -1290,7 +1302,8 @@ void MasterServerPresenceReporter::InternalAddServer(const ServerPresence* pServ
}
else
{
spdlog::error("Failed adding self to server list: error {}", curl_easy_strerror(result));
if (shouldLogError)
spdlog::error("Failed adding self to server list: error {}", curl_easy_strerror(result));
return ReturnCleanup(MasterServerReportPresenceResult::FailedNoConnect);
}
});
Expand Down