aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-12-18 12:19:10 +0100
committerShauren <shauren.trinity@gmail.com>2023-12-18 12:19:10 +0100
commit15fce17c1a5dea8c1d6153d2ce33a8812ffb209b (patch)
tree4b160dc5cf270abe4dd0f981b6fe389290632a4e /src/server/shared
parentacb5fbd48b5bd911dd0da6016a3d86d4c64724b6 (diff)
Core/Bnet: Add new loggers to config file template, fixed request/response content logging and fixed setting keep_alive on responses
Diffstat (limited to 'src/server/shared')
-rw-r--r--src/server/shared/Networking/Http/BaseHttpSocket.h4
-rw-r--r--src/server/shared/Networking/Http/HttpService.cpp7
2 files changed, 7 insertions, 4 deletions
diff --git a/src/server/shared/Networking/Http/BaseHttpSocket.h b/src/server/shared/Networking/Http/BaseHttpSocket.h
index 330287252d2..c02b13e6463 100644
--- a/src/server/shared/Networking/Http/BaseHttpSocket.h
+++ b/src/server/shared/Networking/Http/BaseHttpSocket.h
@@ -126,9 +126,9 @@ public:
ToStdStringView(context.request.target()), context.response.result_int());
if (sLog->ShouldLog("server.http", LOG_LEVEL_TRACE))
{
- sLog->OutMessage("server.http", LOG_LEVEL_TRACE, "{} Request: ", this->GetClientInfo(),
+ sLog->OutMessage("server.http", LOG_LEVEL_TRACE, "{} Request: {}", this->GetClientInfo(),
CanLogRequestContent(context) ? SerializeRequest(context.request) : "<REDACTED>");
- sLog->OutMessage("server.http", LOG_LEVEL_TRACE, "{} Response: ", this->GetClientInfo(),
+ sLog->OutMessage("server.http", LOG_LEVEL_TRACE, "{} Response: {}", this->GetClientInfo(),
CanLogResponseContent(context) ? std::string_view(reinterpret_cast<char const*>(buffer.GetBasePointer()), buffer.GetActiveSize()) : "<REDACTED>");
}
diff --git a/src/server/shared/Networking/Http/HttpService.cpp b/src/server/shared/Networking/Http/HttpService.cpp
index 8995b65612a..3e80d08959c 100644
--- a/src/server/shared/Networking/Http/HttpService.cpp
+++ b/src/server/shared/Networking/Http/HttpService.cpp
@@ -73,7 +73,7 @@ RequestHandlerResult DispatcherService::HandleRequest(std::shared_ptr<AbstractSo
SystemTimePoint responseDate = SystemTimePoint::clock::now();
context.response.set(boost::beast::http::field::date, StringFormat("{:%a, %d %b %Y %T GMT}", responseDate - Timezone::GetSystemZoneOffsetAt(responseDate)));
context.response.set(boost::beast::http::field::server, BOOST_BEAST_VERSION_STRING);
- context.response.keep_alive(context.response.keep_alive());
+ context.response.keep_alive(context.request.keep_alive());
if (!context.handler)
return HandlePathNotFound(std::move(session), context);
@@ -192,12 +192,15 @@ std::shared_ptr<SessionState> SessionService::FindAndRefreshSessionState(std::st
void SessionService::MarkSessionInactive(boost::uuids::uuid const& id)
{
+ bool wasActive = true;
{
std::unique_lock inactiveSessionsLock{ _inactiveSessionsMutex };
- _inactiveSessions.insert(id);
+ wasActive = _inactiveSessions.insert(id).second;
}
+ if (wasActive)
{
+ std::shared_lock lock{ _sessionsMutex };
auto itr = _sessions.find(id);
if (itr != _sessions.end())
{