summaryrefslogtreecommitdiff
path: root/plugins/Ping/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-05-04 20:42:25 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-05-04 20:42:25 +0300
commit68c7bf3b55ca132143686ab433659c3b828760aa (patch)
tree5e2b5f5bc674f05a4c351a8f4f0ea6b6e596ca16 /plugins/Ping/src
parentef6ef30fac86de58bfd7d52b1d8a213b8d955d5d (diff)
attempt to fix some problems on exit
Diffstat (limited to 'plugins/Ping/src')
-rw-r--r--plugins/Ping/src/pingthread.cpp33
1 files changed, 12 insertions, 21 deletions
diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp
index 0dad666e44..03847a4f3d 100644
--- a/plugins/Ping/src/pingthread.cpp
+++ b/plugins/Ping/src/pingthread.cpp
@@ -74,6 +74,8 @@ void SetProtoStatus(wchar_t *pszLabel, char *pszProto, int if_status, int new_st
void __cdecl sttCheckStatusThreadProc(void*)
{
+ MThreadHandle threadLock(status_update_thread);
+
clock_t start_t = clock(), end_t;
while (!get_thread_finished()) {
end_t = clock();
@@ -222,24 +224,6 @@ void __cdecl sttCheckStatusThreadProc(void*)
}
}
-void start_ping_thread()
-{
- if (status_update_thread)
- CloseHandle(status_update_thread);
- status_update_thread = mir_forkthread(sttCheckStatusThreadProc);
-}
-
-void stop_ping_thread()
-{
- set_thread_finished(true);
- SetEvent(hWakeEvent);
- //ICMP::get_instance()->stop();
- WaitForSingleObject(status_update_thread, 2000);
- TerminateThread(status_update_thread, 0);
- CloseHandle(status_update_thread);
- status_update_thread = nullptr;
-}
-
bool FrameIsFloating()
{
if (frame_id == -1)
@@ -921,12 +905,19 @@ void InitList()
ReloadFont(0, 0);
- start_ping_thread();
+ mir_forkthread(sttCheckStatusThreadProc);
}
void DeinitList()
{
DestroyWindow(hpwnd);
- stop_ping_thread();
- if (hFont) DeleteObject(hFont);
+
+ SetEvent(hWakeEvent);
+ if (status_update_thread) {
+ WaitForSingleObject(status_update_thread, INFINITE);
+ status_update_thread = nullptr;
+ }
+
+ if (hFont)
+ DeleteObject(hFont);
}