summaryrefslogtreecommitdiff
path: root/src/mir_core
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-03-15 15:33:54 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-03-15 15:34:09 +0300
commit44b60862c97e5ec855d2bacd4d15f81f7ae7f410 (patch)
treecfe6fd232fac8c80c2f7673804352b94187d698b /src/mir_core
parent0a03c7c9ccd36ce03bdb9feb4827314e4dd553c6 (diff)
MUCH more effective way of removing records from iterators
Diffstat (limited to 'src/mir_core')
-rw-r--r--src/mir_core/src/threads.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/mir_core/src/threads.cpp b/src/mir_core/src/threads.cpp
index 87a03fc62f..5be6150a91 100644
--- a/src/mir_core/src/threads.cpp
+++ b/src/mir_core/src/threads.cpp
@@ -228,14 +228,15 @@ MIR_CORE_DLL(void) KillObjectThreads(void* owner)
if (WaitForMultipleObjects(threadCount, threadPool, TRUE, 5000) == WAIT_TIMEOUT) {
// forcibly kill all remaining threads after 5 secs
mir_cslock lck(csThreads);
- for (auto &it : threads.rev_iter()) {
+ auto T = threads.rev_iter();
+ for (auto &it : T) {
if (it->pObject == owner) {
char szModuleName[MAX_PATH];
GetModuleFileNameA(it->hOwner, szModuleName, sizeof(szModuleName));
Netlib_Logf(nullptr, "Killing object thread %s:%p", szModuleName, it->dwThreadId);
TerminateThread(it->hThread, 9999);
CloseHandle(it->hThread);
- threads.remove(it);
+ threads.remove(T.indexOf(&it));
mir_free(it);
}
}