aboutsummaryrefslogtreecommitdiff
path: root/src/server/authserver/Server/AuthSocket.cpp
diff options
context:
space:
mode:
authorSpp <spp@jorge.gr>2013-05-13 15:07:36 +0200
committerSpp <spp@jorge.gr>2013-05-13 15:07:36 +0200
commitd1677b2db08f71a5bddedd9659cc5a66f325f47f (patch)
treeafb68e15d84d4e64de9f80b9bbbeb126c4aa8c54 /src/server/authserver/Server/AuthSocket.cpp
parent243c325ca4323feb4f7f80c0ecd3873c78cbf887 (diff)
Core/Logging: Performance-related tweaks to logging system
All sLog->out* functions (except outCommand atm) are replaced with TC_LOG_* macros. Memleak fix
Diffstat (limited to 'src/server/authserver/Server/AuthSocket.cpp')
-rw-r--r--src/server/authserver/Server/AuthSocket.cpp92
1 files changed, 46 insertions, 46 deletions
diff --git a/src/server/authserver/Server/AuthSocket.cpp b/src/server/authserver/Server/AuthSocket.cpp
index a080a038314..2e73498eb52 100644
--- a/src/server/authserver/Server/AuthSocket.cpp
+++ b/src/server/authserver/Server/AuthSocket.cpp
@@ -210,12 +210,12 @@ AuthSocket::~AuthSocket(void) {}
// Accept the connection
void AuthSocket::OnAccept(void)
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "'%s:%d' Accepting connection", socket().getRemoteAddress().c_str(), socket().getRemotePort());
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "'%s:%d' Accepting connection", socket().getRemoteAddress().c_str(), socket().getRemotePort());
}
void AuthSocket::OnClose(void)
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "AuthSocket::OnClose");
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "AuthSocket::OnClose");
}
// Read the packet from the client
@@ -234,11 +234,11 @@ void AuthSocket::OnRead()
{
if ((uint8)table[i].cmd == _cmd && (table[i].status == STATUS_CONNECTED || (_authed && table[i].status == STATUS_AUTHED)))
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "Got data for cmd %u recv length %u", (uint32)_cmd, (uint32)socket().recv_len());
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "Got data for cmd %u recv length %u", (uint32)_cmd, (uint32)socket().recv_len());
if (!(*this.*table[i].handler)())
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "Command handler failed for cmd %u recv length %u", (uint32)_cmd, (uint32)socket().recv_len());
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "Command handler failed for cmd %u recv length %u", (uint32)_cmd, (uint32)socket().recv_len());
return;
}
break;
@@ -248,7 +248,7 @@ void AuthSocket::OnRead()
// Report unknown packets in the error log
if (i == AUTH_TOTAL_COMMANDS)
{
- sLog->outError(LOG_FILTER_AUTHSERVER, "Got unknown packet from '%s'", socket().getRemoteAddress().c_str());
+ TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Got unknown packet from '%s'", socket().getRemoteAddress().c_str());
socket().shutdown();
return;
}
@@ -297,7 +297,7 @@ void AuthSocket::_SetVSFields(const std::string& rI)
// Logon Challenge command handler
bool AuthSocket::_HandleLogonChallenge()
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "Entering _HandleLogonChallenge");
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "Entering _HandleLogonChallenge");
if (socket().recv_len() < sizeof(sAuthLogonChallenge_C))
return false;
@@ -312,7 +312,7 @@ bool AuthSocket::_HandleLogonChallenge()
#endif
uint16 remaining = ((sAuthLogonChallenge_C *)&buf[0])->size;
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "[AuthChallenge] got header, body is %#04x bytes", remaining);
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[AuthChallenge] got header, body is %#04x bytes", remaining);
if ((remaining < sizeof(sAuthLogonChallenge_C) - buf.size()) || (socket().recv_len() < remaining))
return false;
@@ -324,8 +324,8 @@ bool AuthSocket::_HandleLogonChallenge()
// Read the remaining of the packet
socket().recv((char *)&buf[4], remaining);
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "[AuthChallenge] got full packet, %#04x bytes", ch->size);
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "[AuthChallenge] name(%d): '%s'", ch->I_len, ch->I);
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[AuthChallenge] got full packet, %#04x bytes", ch->size);
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[AuthChallenge] name(%d): '%s'", ch->I_len, ch->I);
// BigEndian code, nop in little endian case
// size already converted
@@ -365,7 +365,7 @@ bool AuthSocket::_HandleLogonChallenge()
if (result)
{
pkt << uint8(WOW_FAIL_BANNED);
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] Banned ip tries to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort());
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] Banned ip tries to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort());
}
else
{
@@ -383,24 +383,24 @@ bool AuthSocket::_HandleLogonChallenge()
bool locked = false;
if (fields[2].GetUInt8() == 1) // if ip is locked
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Account '%s' is locked to IP - '%s'", _login.c_str(), fields[3].GetCString());
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Player address is '%s'", ip_address.c_str());
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Account '%s' is locked to IP - '%s'", _login.c_str(), fields[3].GetCString());
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Player address is '%s'", ip_address.c_str());
if (strcmp(fields[4].GetCString(), ip_address.c_str()))
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Account IP differs");
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Account IP differs");
pkt << uint8(WOW_FAIL_LOCKED_ENFORCED);
locked = true;
}
else
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Account IP matches");
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Account IP matches");
}
else
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Account '%s' is not locked to ip", _login.c_str());
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Account '%s' is not locked to ip", _login.c_str());
std::string accountCountry = fields[3].GetString();
if (accountCountry.empty() || accountCountry == "00")
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Account '%s' is not locked to country", _login.c_str());
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Account '%s' is not locked to country", _login.c_str());
else if (!accountCountry.empty())
{
uint32 ip = inet_addr(ip_address.c_str());
@@ -411,18 +411,18 @@ bool AuthSocket::_HandleLogonChallenge()
if (PreparedQueryResult sessionCountryQuery = LoginDatabase.Query(stmt))
{
std::string loginCountry = (*sessionCountryQuery)[0].GetString();
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Account '%s' is locked to country: '%s' Player country is '%s'", _login.c_str(), accountCountry.c_str(), loginCountry.c_str());
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Account '%s' is locked to country: '%s' Player country is '%s'", _login.c_str(), accountCountry.c_str(), loginCountry.c_str());
if (loginCountry != accountCountry)
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Account country differs.");
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Account country differs.");
pkt << uint8(WOW_FAIL_UNLOCKABLE_LOCK);
locked = true;
}
else
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Account country matches");
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[AuthChallenge] Account country matches");
}
else
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "[AuthChallenge] IP2NATION Table empty");
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[AuthChallenge] IP2NATION Table empty");
}
}
@@ -440,12 +440,12 @@ bool AuthSocket::_HandleLogonChallenge()
if ((*banresult)[0].GetUInt32() == (*banresult)[1].GetUInt32())
{
pkt << uint8(WOW_FAIL_BANNED);
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] Banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] Banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
}
else
{
pkt << uint8(WOW_FAIL_SUSPENDED);
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] Temporarily banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] Temporarily banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
}
}
else
@@ -457,7 +457,7 @@ bool AuthSocket::_HandleLogonChallenge()
std::string databaseV = fields[6].GetString();
std::string databaseS = fields[7].GetString();
- sLog->outDebug(LOG_FILTER_NETWORKIO, "database authentication values: v='%s' s='%s'", databaseV.c_str(), databaseS.c_str());
+ TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "database authentication values: v='%s' s='%s'", databaseV.c_str(), databaseS.c_str());
// multiply with 2 since bytes are stored as hexstring
if (databaseV.size() != s_BYTE_SIZE * 2 || databaseS.size() != s_BYTE_SIZE * 2)
@@ -519,7 +519,7 @@ bool AuthSocket::_HandleLogonChallenge()
for (int i = 0; i < 4; ++i)
_localizationName[i] = ch->country[4-i-1];
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] account %s is using '%c%c%c%c' locale (%u)", socket().getRemoteAddress().c_str(), socket().getRemotePort(),
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] account %s is using '%c%c%c%c' locale (%u)", socket().getRemoteAddress().c_str(), socket().getRemotePort(),
_login.c_str (), ch->country[3], ch->country[2], ch->country[1], ch->country[0], GetLocaleByName(_localizationName)
);
}
@@ -536,7 +536,7 @@ bool AuthSocket::_HandleLogonChallenge()
// Logon Proof command handler
bool AuthSocket::_HandleLogonProof()
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "Entering _HandleLogonProof");
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "Entering _HandleLogonProof");
// Read the packet
sAuthLogonProof_C lp;
@@ -547,7 +547,7 @@ bool AuthSocket::_HandleLogonProof()
if (_expversion == NO_VALID_EXP_FLAG)
{
// Check if we have the appropriate patch on the disk
- sLog->outDebug(LOG_FILTER_NETWORKIO, "Client with invalid version, patching is not implemented");
+ TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "Client with invalid version, patching is not implemented");
socket().shutdown();
return true;
}
@@ -631,7 +631,7 @@ bool AuthSocket::_HandleLogonProof()
// Check if SRP6 results match (password is correct), else send an error
if (!memcmp(M.AsByteArray(), lp.M1, 20))
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "'%s:%d' User '%s' successfully authenticated", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "'%s:%d' User '%s' successfully authenticated", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
// Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account
// No SQL injection (escaped user name) and IP address as received by socket
@@ -680,7 +680,7 @@ bool AuthSocket::_HandleLogonProof()
char data[4] = { AUTH_LOGON_PROOF, WOW_FAIL_UNKNOWN_ACCOUNT, 3, 0 };
socket().send(data, sizeof(data));
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] account %s tried to login with invalid password!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] account %s tried to login with invalid password!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
uint32 MaxWrongPassCount = ConfigMgr::GetIntDefault("WrongPass.MaxCount", 0);
if (MaxWrongPassCount > 0)
@@ -710,7 +710,7 @@ bool AuthSocket::_HandleLogonProof()
stmt->setUInt32(1, WrongPassBanTime);
LoginDatabase.Execute(stmt);
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] account %s got banned for '%u' seconds because it failed to authenticate '%u' times",
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] account %s got banned for '%u' seconds because it failed to authenticate '%u' times",
socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str(), WrongPassBanTime, failed_logins);
}
else
@@ -720,7 +720,7 @@ bool AuthSocket::_HandleLogonProof()
stmt->setUInt32(1, WrongPassBanTime);
LoginDatabase.Execute(stmt);
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] IP %s got banned for '%u' seconds because account %s failed to authenticate '%u' times",
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] IP %s got banned for '%u' seconds because account %s failed to authenticate '%u' times",
socket().getRemoteAddress().c_str(), socket().getRemotePort(), socket().getRemoteAddress().c_str(), WrongPassBanTime, _login.c_str(), failed_logins);
}
}
@@ -734,7 +734,7 @@ bool AuthSocket::_HandleLogonProof()
// Reconnect Challenge command handler
bool AuthSocket::_HandleReconnectChallenge()
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "Entering _HandleReconnectChallenge");
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "Entering _HandleReconnectChallenge");
if (socket().recv_len() < sizeof(sAuthLogonChallenge_C))
return false;
@@ -749,7 +749,7 @@ bool AuthSocket::_HandleReconnectChallenge()
#endif
uint16 remaining = ((sAuthLogonChallenge_C *)&buf[0])->size;
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "[ReconnectChallenge] got header, body is %#04x bytes", remaining);
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[ReconnectChallenge] got header, body is %#04x bytes", remaining);
if ((remaining < sizeof(sAuthLogonChallenge_C) - buf.size()) || (socket().recv_len() < remaining))
return false;
@@ -761,8 +761,8 @@ bool AuthSocket::_HandleReconnectChallenge()
// Read the remaining of the packet
socket().recv((char *)&buf[4], remaining);
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "[ReconnectChallenge] got full packet, %#04x bytes", ch->size);
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "[ReconnectChallenge] name(%d): '%s'", ch->I_len, ch->I);
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[ReconnectChallenge] got full packet, %#04x bytes", ch->size);
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "[ReconnectChallenge] name(%d): '%s'", ch->I_len, ch->I);
_login = (const char*)ch->I;
@@ -773,7 +773,7 @@ bool AuthSocket::_HandleReconnectChallenge()
// Stop if the account is not found
if (!result)
{
- sLog->outError(LOG_FILTER_AUTHSERVER, "'%s:%d' [ERROR] user %s tried to login and we cannot find his session key in the database.", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
+ TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "'%s:%d' [ERROR] user %s tried to login and we cannot find his session key in the database.", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
socket().shutdown();
return false;
}
@@ -809,7 +809,7 @@ bool AuthSocket::_HandleReconnectChallenge()
// Reconnect Proof command handler
bool AuthSocket::_HandleReconnectProof()
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "Entering _HandleReconnectProof");
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "Entering _HandleReconnectProof");
// Read the packet
sAuthReconnectProof_C lp;
if (!socket().recv((char *)&lp, sizeof(sAuthReconnectProof_C)))
@@ -840,7 +840,7 @@ bool AuthSocket::_HandleReconnectProof()
}
else
{
- sLog->outError(LOG_FILTER_AUTHSERVER, "'%s:%d' [ERROR] user %s tried to login, but session is invalid.", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
+ TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "'%s:%d' [ERROR] user %s tried to login, but session is invalid.", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
socket().shutdown();
return false;
}
@@ -871,7 +871,7 @@ ACE_INET_Addr const& AuthSocket::GetAddressForClient(Realm const& realm, ACE_INE
// Realm List command handler
bool AuthSocket::_HandleRealmList()
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "Entering _HandleRealmList");
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "Entering _HandleRealmList");
if (socket().recv_len() < 5)
return false;
@@ -884,7 +884,7 @@ bool AuthSocket::_HandleRealmList()
PreparedQueryResult result = LoginDatabase.Query(stmt);
if (!result)
{
- sLog->outError(LOG_FILTER_AUTHSERVER, "'%s:%d' [ERROR] user %s tried to login but we cannot find him in the database.", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
+ TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "'%s:%d' [ERROR] user %s tried to login but we cannot find him in the database.", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str());
socket().shutdown();
return false;
}
@@ -1000,11 +1000,11 @@ bool AuthSocket::_HandleRealmList()
// Resume patch transfer
bool AuthSocket::_HandleXferResume()
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "Entering _HandleXferResume");
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "Entering _HandleXferResume");
// Check packet length and patch existence
if (socket().recv_len() < 9 || !pPatch) // FIXME: pPatch is never used
{
- sLog->outError(LOG_FILTER_AUTHSERVER, "Error while resuming patch transfer (wrong packet)");
+ TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Error while resuming patch transfer (wrong packet)");
return false;
}
@@ -1021,7 +1021,7 @@ bool AuthSocket::_HandleXferResume()
// Cancel patch transfer
bool AuthSocket::_HandleXferCancel()
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "Entering _HandleXferCancel");
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "Entering _HandleXferCancel");
// Close and delete the socket
socket().recv_skip(1); //clear input buffer
@@ -1033,12 +1033,12 @@ bool AuthSocket::_HandleXferCancel()
// Accept patch transfer
bool AuthSocket::_HandleXferAccept()
{
- sLog->outDebug(LOG_FILTER_AUTHSERVER, "Entering _HandleXferAccept");
+ TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "Entering _HandleXferAccept");
// Check packet length and patch existence
if (!pPatch)
{
- sLog->outError(LOG_FILTER_AUTHSERVER, "Error while accepting patch transfer (wrong packet)");
+ TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Error while accepting patch transfer (wrong packet)");
return false;
}
@@ -1121,11 +1121,11 @@ void Patcher::LoadPatchMD5(char *szFileName)
std::string path = "./patches/";
path += szFileName;
FILE* pPatch = fopen(path.c_str(), "rb");
- sLog->outDebug(LOG_FILTER_NETWORKIO, "Loading patch info from %s\n", path.c_str());
+ TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "Loading patch info from %s\n", path.c_str());
if (!pPatch)
{
- sLog->outError(LOG_FILTER_AUTHSERVER, "Error loading patch %s\n", path.c_str());
+ TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Error loading patch %s\n", path.c_str());
return;
}