fix: Max connection limit not applied

This commit is contained in:
yuanyuanxiang
2024-12-31 03:11:26 +08:00
parent 943c269700
commit 9561a5d09d
5 changed files with 19 additions and 1 deletions

View File

@@ -860,9 +860,14 @@ void CMy2015RemoteDlg::OnNotifyExit()
//<2F><>̬<EFBFBD>˵<EFBFBD>
void CMy2015RemoteDlg::OnMainSet()
{
int nMaxConnection = ((CMy2015RemoteApp*)AfxGetApp())->m_iniFile.GetInt("settings", "MaxConnection");
CSettingDlg Dlg;
Dlg.DoModal(); //ģ̬ <20><><EFBFBD><EFBFBD>
if (nMaxConnection != Dlg.m_nMax_Connect)
{
m_iocpServer->UpdateMaxConnection(Dlg.m_nMax_Connect);
}
}

View File

@@ -19,7 +19,7 @@ public:
return buf;
}
~Buffer() {
(*ref)--;
DelRef();
if (*ref == 0) {
if (buf!=NULL)
{
@@ -48,6 +48,7 @@ public:
buf = o.buf;
len = o.len;
ref = o.ref;
return *this;
}
char* c_str() const {
return (char*)buf;

View File

@@ -761,6 +761,10 @@ PCONTEXT_OBJECT IOCPServer::AllocateContext()
CLock cs(m_cs);
if (m_ContextConnectionList.GetCount() >= m_ulMaxConnections) {
return NULL;
}
ContextObject = !m_ContextFreePoolList.IsEmpty() ? m_ContextFreePoolList.RemoveHead() : new CONTEXT_OBJECT;
if (ContextObject != NULL)
@@ -807,3 +811,8 @@ VOID IOCPServer::MoveContextToFreePoolList(CONTEXT_OBJECT* ContextObject)
m_ContextConnectionList.RemoveAt(Pos); //<2F><><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><E1B9B9><EFBFBD>Ƴ<EFBFBD>
}
}
void IOCPServer::UpdateMaxConnection(int maxConn) {
CLock cs(m_cs);
m_ulMaxConnections = maxConn;
}

View File

@@ -104,6 +104,7 @@ public:
BOOL OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans);
VOID OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffer , ULONG ulOriginalLength);
BOOL OnClientPostSending(CONTEXT_OBJECT* ContextObject,ULONG ulCompressedLength);
void UpdateMaxConnection(int maxConn);
IOCPServer(void);
~IOCPServer(void);