From c650e1e172dd9131dfcb17948113935d805c0dfb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 22 Dec 2014 14:57:50 +0000 Subject: trying to catch hung thread in clist_modern git-svn-id: http://svn.miranda-ng.org/main/trunk@11582 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/src/hdr/modern_commonprototypes.h | 10 ---------- plugins/Clist_modern/src/modern_aniavatars.cpp | 16 ++++++++-------- plugins/Clist_modern/src/modern_awaymsg.cpp | 10 +++++++--- plugins/Clist_modern/src/modern_clui.cpp | 12 ++++++++---- plugins/Clist_modern/src/modern_gettextasync.cpp | 2 +- 5 files changed, 24 insertions(+), 26 deletions(-) (limited to 'plugins/Clist_modern/src') diff --git a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h index 4aefa96a4d..339cc83eb1 100644 --- a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h +++ b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h @@ -67,16 +67,6 @@ extern BYTE gl_TrimText; /* TYPE DEFS */ /************************************************************************/ -class thread_catcher -{ - HANDLE &m_ptr; - __forceinline thread_catcher& operator = (const thread_catcher &) {} - -public: - __forceinline thread_catcher(HANDLE ¶m) : m_ptr(param) {} - __forceinline ~thread_catcher() { m_ptr = 0; } -}; - typedef INT_PTR(*PSYNCCALLBACKPROC)(WPARAM, LPARAM); /************************************************************************/ diff --git a/plugins/Clist_modern/src/modern_aniavatars.cpp b/plugins/Clist_modern/src/modern_aniavatars.cpp index 2fcc3731bd..a60083a7e7 100644 --- a/plugins/Clist_modern/src/modern_aniavatars.cpp +++ b/plugins/Clist_modern/src/modern_aniavatars.cpp @@ -178,7 +178,9 @@ int _AniAva_OnModulesUnload(WPARAM, LPARAM) static void _AniAva_AnimationTreadProc(void*) { - //wait forever till hExitEvent signalled + Netlib_Logf(NULL, "AnimationTreadProc thread start"); + + // wait forever till hExitEvent signalled HANDLE hThread = 0; s_AnimationThreadID = GetCurrentThreadId(); DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hThread, 0, FALSE, DUPLICATE_SAME_ACCESS); @@ -198,6 +200,8 @@ static void _AniAva_AnimationTreadProc(void*) else if (rc == WAIT_OBJECT_0) break; } + + Netlib_Logf(NULL, "AnimationTreadProc thread end"); CloseHandle(s_AnimationThreadHandle); s_AnimationThreadHandle = NULL; } @@ -375,18 +379,13 @@ int AniAva_SetAvatarPos(MCONTACT hContact, RECT *rc, int overlayIdx, BYTE bAlpha if (pai) { ANIAVA_POSINFO * api = (ANIAVA_POSINFO *)malloc(sizeof(ANIAVA_POSINFO)); if (!pai->hWindow) { - HWND hwnd; - HWND parent; ANIAVATARIMAGEINFO avii = { 0 }; //not found -> create window char szName[150] = "AniAvaWnd_"; - TCHAR * tszName; _itoa((int)hContact, szName + 10, 16); - tszName = mir_a2t(szName); - hwnd = _AniAva_CreateAvatarWindowSync(tszName); - mir_free(tszName); - parent = GetAncestor(pcli->hwndContactList, GA_PARENT); + HWND hwnd = _AniAva_CreateAvatarWindowSync(_A2T(szName)); + HWND parent = GetAncestor(pcli->hwndContactList, GA_PARENT); pai->hWindow = hwnd; SendMessage(hwnd, AAM_SETPARENT, (WPARAM)parent, 0); if (_AniAva_GetAvatarImageInfo(pai->dwAvatarUniqId, &avii)) @@ -485,6 +484,7 @@ static void CALLBACK _AniAva_SyncCallerUserAPCProc(DWORD_PTR dwParam) item->nResult = item->pfnProc(item->wParam, item->lParam); SetEvent(item->hDoneEvent); } + static INT_PTR _AniAva_CreateAvatarWindowSync_Worker(WPARAM tszName, LPARAM) { HWND hwnd = CreateWindowEx(WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_NOPARENTNOTIFY, ANIAVAWINDOWCLASS, (TCHAR*)tszName, WS_POPUP, diff --git a/plugins/Clist_modern/src/modern_awaymsg.cpp b/plugins/Clist_modern/src/modern_awaymsg.cpp index adba1130a3..d98489d9cc 100644 --- a/plugins/Clist_modern/src/modern_awaymsg.cpp +++ b/plugins/Clist_modern/src/modern_awaymsg.cpp @@ -76,7 +76,7 @@ static MCONTACT amGetCurrentChain() */ static void amThreadProc(void *) { - thread_catcher lck(g_hAwayMsgThread); + Netlib_Logf(NULL, "amThreadProc thread start"); ClcCacheEntry dnce; memset(&dnce, 0, sizeof(dnce)); @@ -88,7 +88,7 @@ static void amThreadProc(void *) if ((time - amRequestTick) < AMASKPERIOD) { SleepEx(AMASKPERIOD - (time - amRequestTick) + 10, TRUE); if (MirandaExiting()) - return; + goto LBL_Exit; } CListSettings_FreeCacheItemData(&dnce); dnce.hContact = hContact; @@ -120,13 +120,17 @@ static void amThreadProc(void *) } else break; if (MirandaExiting()) - return; + goto LBL_Exit; } WaitForSingleObjectEx(hamProcessEvent, INFINITE, TRUE); ResetEvent(hamProcessEvent); if (MirandaExiting()) break; } + +LBL_Exit: + g_hAwayMsgThread = NULL; + Netlib_Logf(NULL, "amThreadProc thread end"); } BOOL amWakeThread() diff --git a/plugins/Clist_modern/src/modern_clui.cpp b/plugins/Clist_modern/src/modern_clui.cpp index 65b79e2627..a87d3c4cad 100644 --- a/plugins/Clist_modern/src/modern_clui.cpp +++ b/plugins/Clist_modern/src/modern_clui.cpp @@ -1425,22 +1425,26 @@ static int CLUI_SyncSmoothAnimation(WPARAM, LPARAM) static void CLUI_SmoothAnimationThreadProc(void *param) { - thread_catcher lck(g_hSmoothAnimationThread); + Netlib_Logf(NULL, "SmoothAnimationThreadProc thread end"); if (mutex_bAnimationInProgress) { do { if (!g_mutex_bLockUpdating) { if (MirandaExiting()) - return; + break; Sync(CLUI_SyncSmoothAnimation, 0, (LPARAM)param); SleepEx(20, TRUE); if (MirandaExiting()) - return; + break; } else SleepEx(0, TRUE); - } while (mutex_bAnimationInProgress); + } + while (mutex_bAnimationInProgress); } + + Netlib_Logf(NULL, "SmoothAnimationThreadProc thread end"); + g_hSmoothAnimationThread = NULL; } static int CLUI_SmoothAlphaThreadTransition() diff --git a/plugins/Clist_modern/src/modern_gettextasync.cpp b/plugins/Clist_modern/src/modern_gettextasync.cpp index 82f90e95fa..9e0d957baa 100644 --- a/plugins/Clist_modern/src/modern_gettextasync.cpp +++ b/plugins/Clist_modern/src/modern_gettextasync.cpp @@ -71,7 +71,6 @@ static void gtaThreadProc(void*) { Netlib_Logf(NULL, "GTA thread start"); - thread_catcher lck(g_hGetTextAsyncThread); SHORTDATA data = { 0 }; while (!MirandaExiting()) { @@ -118,6 +117,7 @@ static void gtaThreadProc(void*) LBL_Exit: CloseHandle(hgtaWakeupEvent); hgtaWakeupEvent = NULL; + g_hGetTextAsyncThread = NULL; Netlib_Logf(NULL, "GTA thread end"); } -- cgit v1.2.3