diff options
author | Rozhuk Ivan <rozhuk.im@gmail.com> | 2016-06-16 22:40:22 +0000 |
---|---|---|
committer | Rozhuk Ivan <rozhuk.im@gmail.com> | 2016-06-16 22:40:22 +0000 |
commit | 2f30a747ab285281620417f8848f40478d3e1705 (patch) | |
tree | de95449fd1fa2a793b5aeb50ff959e57963dcfe0 /protocols | |
parent | eb774f8437753724bda816f0d274b7639a6706d0 (diff) |
MRA: reduce CPU usage
git-svn-id: http://svn.miranda-ng.org/main/trunk@16995 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/MRA/src/MraAvatars.cpp | 2 | ||||
-rw-r--r-- | protocols/MRA/src/MraConstans.h | 2 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_proto.cpp | 6 |
3 files changed, 5 insertions, 5 deletions
diff --git a/protocols/MRA/src/MraAvatars.cpp b/protocols/MRA/src/MraAvatars.cpp index 3813da9741..1d4acdf0b7 100644 --- a/protocols/MRA/src/MraAvatars.cpp +++ b/protocols/MRA/src/MraAvatars.cpp @@ -170,7 +170,7 @@ void CMraProto::MraAvatarsThreadProc(LPVOID lpParameter) while (!g_bShutdown) {
if (FifoMTItemPop(pmraaqAvatarsQueue, NULL, (LPVOID*)&pmraaqiAvatarsQueueItem) != NO_ERROR) { // waiting until service stop or new task
NETLIB_CLOSEHANDLE(hConnection);
- WaitForSingleObjectEx(hThreadEvent, MRA_AVT_DEFAULT_QE_CHK_INTERVAL, FALSE);
+ WaitForSingleObjectEx(hThreadEvent, INFINITE, FALSE);
continue;
}
diff --git a/protocols/MRA/src/MraConstans.h b/protocols/MRA/src/MraConstans.h index 6b8b391e66..9c897cdb8b 100644 --- a/protocols/MRA/src/MraConstans.h +++ b/protocols/MRA/src/MraConstans.h @@ -31,7 +31,6 @@ static const LPSTR lpcszMailRuDomains[] = #define BUFF_SIZE_RCV_MIN_FREE (16 * 1024) //internal
#define BUFF_SIZE_BLOB 16384 //internal
#define BUFF_SIZE_URL 4096 //internal
-#define NETLIB_SELECT_TIMEOUT 250 //internal // время ожидания событий на сокете
#define WAIT_FOR_THREAD_TIMEOUT 15 //internal // время ожидания завершения потока
#define THREAD_SLEEP_TIME 100 //internal
#define THREAD_MAX_PING_TIME 20 // sec, internal
@@ -195,7 +194,6 @@ static const LPSTR lpcszMailRuDomains[] = #define MRA_AVT_DEFAULT_AVT_FILENAME _T("_default.jpg")
#define MRA_AVT_DEFAULT_RET_ABC_PATH TRUE
#define MRA_DELETE_AVT_ON_CONTACT_DELETE TRUE
-#define MRA_AVT_DEFAULT_QE_CHK_INTERVAL 1000 //internal
#define MRA_FILES_QUEUE_PROGRESS_INTERVAL 250 //internal
#define MRA_FILES_NULL_ADDRR "192.168.0.1:26666;"
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp index df1b11d455..7ad1e79e70 100644 --- a/protocols/MRA/src/Mra_proto.cpp +++ b/protocols/MRA/src/Mra_proto.cpp @@ -209,7 +209,7 @@ DWORD CMraProto::MraNetworkDispatcher() mrim_packet_header_t *pmaHeader;
NETLIBSELECT nls = { sizeof(nls) };
- nls.dwTimeout = NETLIB_SELECT_TIMEOUT;
+ nls.dwTimeout = 1000;
nls.hReadConns[0] = m_hConnection;
lpbBufferRcv = (LPBYTE)mir_calloc(dwRcvBuffSize);
@@ -219,6 +219,7 @@ DWORD CMraProto::MraNetworkDispatcher() MraSendCMD(MRIM_CS_HELLO, NULL, 0);
m_dwThreadWorkerLastPingTime = GetTickCount();
while (m_iStatus != ID_STATUS_OFFLINE && bContinue) {
+ nls.dwTimeout = (m_dwPingPeriod * 1000);
DWORD dwSelectRet = CallService(MS_NETLIB_SELECT, 0, (LPARAM)&nls);
if (SOCKET_ERROR == dwSelectRet) {
if (m_iStatus != ID_STATUS_OFFLINE) {
@@ -231,7 +232,8 @@ DWORD CMraProto::MraNetworkDispatcher() m_dwThreadWorkerLastPingTime = GetTickCount();
/* Server ping. */
if (m_dwNextPingSendTickTime <= m_dwThreadWorkerLastPingTime) {
- m_dwNextPingSendTickTime = (m_dwThreadWorkerLastPingTime + (m_dwPingPeriod * 1000));
+ nls.dwTimeout = (m_dwPingPeriod * 1000);
+ m_dwNextPingSendTickTime = (m_dwThreadWorkerLastPingTime + nls.dwTimeout);
MraSendCMD(MRIM_CS_PING, NULL, 0);
}
{ /* Remove old items from send queue. */
|