style: 整理远程桌面代码
This commit is contained in:
@@ -410,6 +410,8 @@ BOOL CMy2015RemoteDlg::OnInitDialog()
|
||||
ShowWindow(SW_SHOW);
|
||||
#endif
|
||||
|
||||
timeBeginPeriod(1);
|
||||
|
||||
return TRUE; // <20><><EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TRUE
|
||||
}
|
||||
|
||||
@@ -583,6 +585,7 @@ void CMy2015RemoteDlg::OnClose()
|
||||
delete m_iocpServer;
|
||||
m_iocpServer = NULL;
|
||||
}
|
||||
timeEndPeriod(1);
|
||||
CDialogEx::OnClose();
|
||||
}
|
||||
|
||||
|
||||
@@ -312,20 +312,20 @@ DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
|
||||
|
||||
InterlockedIncrement(&This->m_ulCurrentThread);
|
||||
InterlockedIncrement(&This->m_ulBusyThread);
|
||||
|
||||
timeBeginPeriod(1);
|
||||
while (This->m_bTimeToKill==FALSE)
|
||||
{
|
||||
InterlockedDecrement(&This->m_ulBusyThread);
|
||||
AUTO_TICK(40);
|
||||
InterlockedDecrement(&This->m_ulBusyThread);
|
||||
// GetQueuedCompletionStatus<75><73>ʱ<EFBFBD>Ƚϳ<C8BD><CFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿ͻ<C2BF><CDBB>˷<EFBFBD><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߲<EFBFBD><DFB2><EFBFBD>
|
||||
BOOL bOk = GetQueuedCompletionStatus(
|
||||
hCompletionPort,
|
||||
&dwTrans,
|
||||
(LPDWORD)&ContextObject,
|
||||
&Overlapped,INFINITE);
|
||||
|
||||
DWORD dwIOError = GetLastError();
|
||||
|
||||
&Overlapped, INFINITE);
|
||||
STOP_TICK;
|
||||
DWORD dwIOError = GetLastError();
|
||||
OverlappedPlus = CONTAINING_RECORD(Overlapped, OVERLAPPEDPLUS, m_ol);
|
||||
|
||||
ulBusyThread = InterlockedIncrement(&This->m_ulBusyThread); //1 1
|
||||
if ( !bOk && dwIOError != WAIT_TIMEOUT ) //<2F><><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD><EFBFBD><D7BB>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>˹ر<CBB9>
|
||||
{
|
||||
@@ -391,6 +391,7 @@ DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
|
||||
|
||||
SAFE_DELETE(OverlappedPlus);
|
||||
}
|
||||
timeEndPeriod(1);
|
||||
SAFE_DELETE(OverlappedPlus);
|
||||
|
||||
InterlockedDecrement(&This->m_ulWorkThreadCount);
|
||||
@@ -469,10 +470,15 @@ BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans
|
||||
ContextObject->InCompressedBuffer.ReadBuffer((PBYTE) &ulOriginalLength, sizeof(ULONG));
|
||||
ULONG ulCompressedLength = ulPackTotalLength - HDR_LENGTH; //461 - 13 448
|
||||
PBYTE CompressedBuffer = new BYTE[ulCompressedLength]; //û<>н<EFBFBD>ѹ
|
||||
PBYTE DeCompressedBuffer = new BYTE[ulOriginalLength]; //<2F><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD> 436
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD>ǰ<EFBFBD><C7B0>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>û<EFBFBD>н<EFBFBD>ѹ<EFBFBD><D1B9>ȡ<EFBFBD><C8A1>pData 448
|
||||
ContextObject->InCompressedBuffer.ReadBuffer(CompressedBuffer, ulCompressedLength);
|
||||
#if USING_COMPRESS
|
||||
PBYTE DeCompressedBuffer = new BYTE[ulOriginalLength]; //<2F><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD> 436
|
||||
int iRet = uncompress(DeCompressedBuffer, &ulOriginalLength, CompressedBuffer, ulCompressedLength);
|
||||
#else
|
||||
PBYTE DeCompressedBuffer = CompressedBuffer;
|
||||
int iRet = 0;
|
||||
#endif
|
||||
if (Z_SUCCESS(iRet))
|
||||
{
|
||||
ContextObject->InDeCompressedBuffer.ClearBuffer();
|
||||
@@ -482,11 +488,15 @@ BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans
|
||||
}else{
|
||||
OutputDebugStringA("[ERROR] uncompress failed \n");
|
||||
delete [] CompressedBuffer;
|
||||
#if USING_COMPRESS // <20>ͷ<EFBFBD><CDB7>ڴ<EFBFBD>
|
||||
delete [] DeCompressedBuffer;
|
||||
#endif
|
||||
throw "Bad Buffer";
|
||||
}
|
||||
delete [] CompressedBuffer;
|
||||
#if USING_COMPRESS // <20>ͷ<EFBFBD><CDB7>ڴ<EFBFBD>
|
||||
delete [] DeCompressedBuffer;
|
||||
#endif
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
// ʹ<><CAB9>ѹ<EFBFBD><D1B9><EFBFBD>㷨<EFBFBD><E3B7A8><EFBFBD>㷨<EFBFBD><E3B7A8>Ҫ<EFBFBD><D2AA>clien<65><6E>stdafx.hƥ<68><C6A5>
|
||||
#define USING_COMPRESS 1
|
||||
|
||||
// <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>ZLIB
|
||||
#define USING_ZLIB 1
|
||||
|
||||
@@ -234,19 +237,25 @@ class auto_tick
|
||||
{
|
||||
private:
|
||||
const char *func;
|
||||
int threshold;
|
||||
int span;
|
||||
clock_t tick;
|
||||
__inline clock_t now() const { return clock(); }
|
||||
__inline int time() const { return now() - tick; }
|
||||
|
||||
public:
|
||||
auto_tick(const char *func_name, int th=5) : func(func_name), threshold(th), tick(now()) { }
|
||||
~auto_tick(){int s(this->time());if(s>threshold)TRACE("[%s]ִ<><D6B4>ʱ<EFBFBD><CAB1>: [%d]ms.\n", func, s);}
|
||||
__inline int time() const { return now() - tick; }
|
||||
auto_tick(const char *func_name, int th = 5) : func(func_name), span(th), tick(now()) { }
|
||||
~auto_tick() { stop(); }
|
||||
|
||||
__inline void stop() {
|
||||
if (span != 0) { int s(this->time()); if (s > span)TRACE("[%s]ִ<><D6B4>ʱ<EFBFBD><CAB1>: [%d]ms.\n", func, s); span = 0; }
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _DEBUG
|
||||
// <20><><EFBFBD>ܼ<EFBFBD><DCBC>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ӡ
|
||||
#define AUTO_TICK(thresh) auto_tick TICK(__FUNCTION__, thresh)
|
||||
#define STOP_TICK TICK.stop()
|
||||
#else
|
||||
#define AUTO_TICK(thresh)
|
||||
#define STOP_TICK
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user