mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Improve NetChan process time limit
* Check if m_MessageHandler is removed before running limit test. * Add warning DevMsg if client exceeds value. * Default 'net_processTimeBudget' value to '200'.
This commit is contained in:
parent
21756f8057
commit
dcc2c6224b
@ -216,12 +216,15 @@ void CNetChan::Clear(bool bStopProcessing)
|
|||||||
bool CNetChan::ProcessMessages(CNetChan* pChan, bf_read* pMsg)
|
bool CNetChan::ProcessMessages(CNetChan* pChan, bf_read* pMsg)
|
||||||
{
|
{
|
||||||
#ifndef CLIENT_DLL
|
#ifndef CLIENT_DLL
|
||||||
if (!ThreadInServerFrameThread() || !net_processLimit->GetInt())
|
if (!ThreadInServerFrameThread() || !net_processTimeBudget->GetInt())
|
||||||
return v_NetChan_ProcessMessages(pChan, pMsg);
|
return v_NetChan_ProcessMessages(pChan, pMsg);
|
||||||
|
|
||||||
const double flStartTime = Plat_FloatTime();
|
const double flStartTime = Plat_FloatTime();
|
||||||
const bool bResult = v_NetChan_ProcessMessages(pChan, pMsg);
|
const bool bResult = v_NetChan_ProcessMessages(pChan, pMsg);
|
||||||
|
|
||||||
|
if (!pChan->m_MessageHandler) // NetChannel removed?
|
||||||
|
return bResult;
|
||||||
|
|
||||||
CClient* pClient = reinterpret_cast<CClient*>(pChan->m_MessageHandler);
|
CClient* pClient = reinterpret_cast<CClient*>(pChan->m_MessageHandler);
|
||||||
ServerPlayer_t* pSlot = &g_ServerPlayer[pClient->GetUserID()];
|
ServerPlayer_t* pSlot = &g_ServerPlayer[pClient->GetUserID()];
|
||||||
|
|
||||||
@ -235,9 +238,12 @@ bool CNetChan::ProcessMessages(CNetChan* pChan, bf_read* pMsg)
|
|||||||
(Plat_FloatTime() * 1000) - (flStartTime * 1000);
|
(Plat_FloatTime() * 1000) - (flStartTime * 1000);
|
||||||
|
|
||||||
if (pSlot->m_flCurrentNetProcessTime >
|
if (pSlot->m_flCurrentNetProcessTime >
|
||||||
net_processLimit->GetDouble())
|
net_processTimeBudget->GetDouble())
|
||||||
{
|
{
|
||||||
pClient->Disconnect(REP_MARK, "#DISCONNECT_NETCHAN_OVERFLOW");
|
Warning(eDLL_T::ENGINE, "Removing netchannel '%s' ('%s' exceeded frame budget by '%3.1f'ms!)\n",
|
||||||
|
pChan->GetName(), pChan->GetAddress(), (pSlot->m_flCurrentNetProcessTime - net_processTimeBudget->GetDouble()));
|
||||||
|
pClient->Disconnect(Reputation_t::REP_MARK, "#DISCONNECT_NETCHAN_OVERFLOW");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ void ConVar::Init(void) const
|
|||||||
net_tracePayload = ConVar::Create("net_tracePayload" , "0", FCVAR_DEVELOPMENTONLY , "Log the payload of the send/recv datagram to a file on the disk.", false, 0.f, false, 0.f, nullptr, nullptr);
|
net_tracePayload = ConVar::Create("net_tracePayload" , "0", FCVAR_DEVELOPMENTONLY , "Log the payload of the send/recv datagram to a file on the disk.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||||
net_encryptionEnable = ConVar::Create("net_encryptionEnable" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED , "Use AES encryption on game packets.", false, 0.f, false, 0.f, nullptr, nullptr);
|
net_encryptionEnable = ConVar::Create("net_encryptionEnable" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED , "Use AES encryption on game packets.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||||
net_useRandomKey = ConVar::Create("net_useRandomKey" , "1" , FCVAR_RELEASE , "Use random AES encryption key for game packets.", false, 0.f, false, 0.f, &NET_UseRandomKeyChanged_f, nullptr);
|
net_useRandomKey = ConVar::Create("net_useRandomKey" , "1" , FCVAR_RELEASE , "Use random AES encryption key for game packets.", false, 0.f, false, 0.f, &NET_UseRandomKeyChanged_f, nullptr);
|
||||||
net_processLimit = ConVar::Create("net_processLimit" , "0" , FCVAR_RELEASE , "Net message process budget in milliseconds (removing netchannel if exceeded).", true, 0.f, false, 0.f, nullptr, "0 = disabled.");
|
net_processTimeBudget = ConVar::Create("net_processTimeBudget" ,"200" , FCVAR_RELEASE , "Net message process budget in milliseconds (removing netchannel if exceeded).", true, 0.f, false, 0.f, nullptr, "0 = disabled.");
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// NETWORKSYSTEM |
|
// NETWORKSYSTEM |
|
||||||
pylon_matchmaking_hostname = ConVar::Create("pylon_matchmaking_hostname", "ms.r5reloaded.com", FCVAR_RELEASE , "Holds the pylon matchmaking hostname.", false, 0.f, false, 0.f, &MP_HostName_Changed_f, nullptr);
|
pylon_matchmaking_hostname = ConVar::Create("pylon_matchmaking_hostname", "ms.r5reloaded.com", FCVAR_RELEASE , "Holds the pylon matchmaking hostname.", false, 0.f, false, 0.f, &MP_HostName_Changed_f, nullptr);
|
||||||
|
@ -172,7 +172,7 @@ ConVar* net_tracePayload = nullptr;
|
|||||||
ConVar* net_encryptionEnable = nullptr;
|
ConVar* net_encryptionEnable = nullptr;
|
||||||
ConVar* net_useRandomKey = nullptr;
|
ConVar* net_useRandomKey = nullptr;
|
||||||
ConVar* net_usesocketsforloopback = nullptr;
|
ConVar* net_usesocketsforloopback = nullptr;
|
||||||
ConVar* net_processLimit = nullptr;
|
ConVar* net_processTimeBudget = nullptr;
|
||||||
ConVar* pylon_matchmaking_hostname = nullptr;
|
ConVar* pylon_matchmaking_hostname = nullptr;
|
||||||
ConVar* pylon_host_update_interval = nullptr;
|
ConVar* pylon_host_update_interval = nullptr;
|
||||||
ConVar* pylon_showdebuginfo = nullptr;
|
ConVar* pylon_showdebuginfo = nullptr;
|
||||||
|
@ -167,7 +167,7 @@ extern ConVar* net_tracePayload;
|
|||||||
extern ConVar* net_encryptionEnable;
|
extern ConVar* net_encryptionEnable;
|
||||||
extern ConVar* net_useRandomKey;
|
extern ConVar* net_useRandomKey;
|
||||||
extern ConVar* net_usesocketsforloopback;
|
extern ConVar* net_usesocketsforloopback;
|
||||||
extern ConVar* net_processLimit;
|
extern ConVar* net_processTimeBudget;
|
||||||
extern ConVar* pylon_matchmaking_hostname;
|
extern ConVar* pylon_matchmaking_hostname;
|
||||||
extern ConVar* pylon_host_update_interval;
|
extern ConVar* pylon_host_update_interval;
|
||||||
extern ConVar* pylon_showdebuginfo;
|
extern ConVar* pylon_showdebuginfo;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user