fix: Max connection limit not applied
This commit is contained in:
@@ -319,6 +319,8 @@ DWORD WINAPI StartClient(LPVOID lParam)
|
|||||||
bIsRun = ClientObject->IsRunning();
|
bIsRun = ClientObject->IsRunning();
|
||||||
|
|
||||||
} while (bIsRun && ClientObject->IsConnected() && !g_bExit);
|
} while (bIsRun && ClientObject->IsConnected() && !g_bExit);
|
||||||
|
while (GetTickCount64() - dwTickCount < 5000 && !g_bExit)
|
||||||
|
Sleep(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
cout<<"StartClient end\n";
|
cout<<"StartClient end\n";
|
||||||
|
|||||||
@@ -860,9 +860,14 @@ void CMy2015RemoteDlg::OnNotifyExit()
|
|||||||
//<2F><>̬<EFBFBD>˵<EFBFBD>
|
//<2F><>̬<EFBFBD>˵<EFBFBD>
|
||||||
void CMy2015RemoteDlg::OnMainSet()
|
void CMy2015RemoteDlg::OnMainSet()
|
||||||
{
|
{
|
||||||
|
int nMaxConnection = ((CMy2015RemoteApp*)AfxGetApp())->m_iniFile.GetInt("settings", "MaxConnection");
|
||||||
CSettingDlg Dlg;
|
CSettingDlg Dlg;
|
||||||
|
|
||||||
Dlg.DoModal(); //ģ̬ <20><><EFBFBD><EFBFBD>
|
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;
|
return buf;
|
||||||
}
|
}
|
||||||
~Buffer() {
|
~Buffer() {
|
||||||
(*ref)--;
|
DelRef();
|
||||||
if (*ref == 0) {
|
if (*ref == 0) {
|
||||||
if (buf!=NULL)
|
if (buf!=NULL)
|
||||||
{
|
{
|
||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
buf = o.buf;
|
buf = o.buf;
|
||||||
len = o.len;
|
len = o.len;
|
||||||
ref = o.ref;
|
ref = o.ref;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
char* c_str() const {
|
char* c_str() const {
|
||||||
return (char*)buf;
|
return (char*)buf;
|
||||||
|
|||||||
@@ -761,6 +761,10 @@ PCONTEXT_OBJECT IOCPServer::AllocateContext()
|
|||||||
|
|
||||||
CLock cs(m_cs);
|
CLock cs(m_cs);
|
||||||
|
|
||||||
|
if (m_ContextConnectionList.GetCount() >= m_ulMaxConnections) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ContextObject = !m_ContextFreePoolList.IsEmpty() ? m_ContextFreePoolList.RemoveHead() : new CONTEXT_OBJECT;
|
ContextObject = !m_ContextFreePoolList.IsEmpty() ? m_ContextFreePoolList.RemoveHead() : new CONTEXT_OBJECT;
|
||||||
|
|
||||||
if (ContextObject != NULL)
|
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>
|
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);
|
BOOL OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans);
|
||||||
VOID OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffer , ULONG ulOriginalLength);
|
VOID OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffer , ULONG ulOriginalLength);
|
||||||
BOOL OnClientPostSending(CONTEXT_OBJECT* ContextObject,ULONG ulCompressedLength);
|
BOOL OnClientPostSending(CONTEXT_OBJECT* ContextObject,ULONG ulCompressedLength);
|
||||||
|
void UpdateMaxConnection(int maxConn);
|
||||||
IOCPServer(void);
|
IOCPServer(void);
|
||||||
~IOCPServer(void);
|
~IOCPServer(void);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user