summaryrefslogtreecommitdiff
path: root/protocols/MRA/src/MraAvatars.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-03-21 18:36:10 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-03-21 18:36:10 +0000
commit01b1b443b89cdff245c23c03af37718c7d0c90cd (patch)
tree2f058638ff8890cddf46373ef2cd624962fadc84 /protocols/MRA/src/MraAvatars.cpp
parent530ca4410d99e166f4bbf1d6ba23e348a53d4743 (diff)
fix for closing thread handles in MRA
git-svn-id: http://svn.miranda-ng.org/main/trunk@4152 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MRA/src/MraAvatars.cpp')
-rw-r--r--protocols/MRA/src/MraAvatars.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/protocols/MRA/src/MraAvatars.cpp b/protocols/MRA/src/MraAvatars.cpp
index 2fb7581f0c..949395eb0a 100644
--- a/protocols/MRA/src/MraAvatars.cpp
+++ b/protocols/MRA/src/MraAvatars.cpp
@@ -33,7 +33,7 @@ struct MRA_AVATARS_QUEUE : public FIFO_MT
BOOL bIsRunning;
HANDLE hNetlibUser;
HANDLE hThreadEvent;
- DWORD dwThreadsCount;
+ int iThreadsCount;
HANDLE hThread[MAXIMUM_WAIT_OBJECTS];
LONG lThreadsRunningCount;
HANDLE hAvatarsPath;
@@ -94,12 +94,12 @@ DWORD CMraProto::MraAvatarsQueueInitialize(HANDLE *phAvatarsQueueHandle)
InterlockedExchange((volatile LONG*)&pmraaqAvatarsQueue->bIsRunning, TRUE);
pmraaqAvatarsQueue->hThreadEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- pmraaqAvatarsQueue->dwThreadsCount = DBGetContactSettingDword(NULL, MRA_AVT_SECT_NAME, "WorkThreadsCount", MRA_AVT_DEFAULT_WRK_THREAD_COUNTS);
- if (pmraaqAvatarsQueue->dwThreadsCount == 0)
- pmraaqAvatarsQueue->dwThreadsCount = 1;
- if (pmraaqAvatarsQueue->dwThreadsCount > MAXIMUM_WAIT_OBJECTS)
- pmraaqAvatarsQueue->dwThreadsCount = MAXIMUM_WAIT_OBJECTS;
- for (DWORD i = 0; i < pmraaqAvatarsQueue->dwThreadsCount; i++)
+ pmraaqAvatarsQueue->iThreadsCount = DBGetContactSettingDword(NULL, MRA_AVT_SECT_NAME, "WorkThreadsCount", MRA_AVT_DEFAULT_WRK_THREAD_COUNTS);
+ if (pmraaqAvatarsQueue->iThreadsCount == 0)
+ pmraaqAvatarsQueue->iThreadsCount = 1;
+ if (pmraaqAvatarsQueue->iThreadsCount > MAXIMUM_WAIT_OBJECTS)
+ pmraaqAvatarsQueue->iThreadsCount = MAXIMUM_WAIT_OBJECTS;
+ for (int i=0; i < pmraaqAvatarsQueue->iThreadsCount; i++)
pmraaqAvatarsQueue->hThread[i] = ForkThreadEx(&CMraProto::MraAvatarsThreadProc, pmraaqAvatarsQueue);
*phAvatarsQueueHandle = (HANDLE)pmraaqAvatarsQueue;
@@ -138,12 +138,14 @@ void CMraProto::MraAvatarsQueueDestroy(HANDLE hAvatarsQueueHandle)
InterlockedExchange((volatile LONG*)&pmraaqAvatarsQueue->bIsRunning, FALSE);
SetEvent(pmraaqAvatarsQueue->hThreadEvent);
- WaitForMultipleObjects(pmraaqAvatarsQueue->dwThreadsCount, (HANDLE*)&pmraaqAvatarsQueue->hThread[0], TRUE, (WAIT_FOR_THREAD_TIMEOUT*1000));
+ WaitForMultipleObjects(pmraaqAvatarsQueue->iThreadsCount, (HANDLE*)&pmraaqAvatarsQueue->hThread[0], TRUE, (WAIT_FOR_THREAD_TIMEOUT*1000));
if (InterlockedExchangeAdd((volatile LONG*)&pmraaqAvatarsQueue->lThreadsRunningCount, 0))
while (InterlockedExchangeAdd((volatile LONG*)&pmraaqAvatarsQueue->lThreadsRunningCount, 0))
SleepEx(100, TRUE);
+ for (int i=0; i < pmraaqAvatarsQueue->iThreadsCount; i++)
+ CloseHandle(pmraaqAvatarsQueue->hThread[i]);
CloseHandle(pmraaqAvatarsQueue->hThreadEvent);
MraAvatarsQueueClear(hAvatarsQueueHandle);