fix: Max connection limit not applied
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user