diff options
| author | George Hazan <ghazan@miranda.im> | 2021-05-04 20:42:25 +0300 |
|---|---|---|
| committer | George Hazan <ghazan@miranda.im> | 2021-05-04 20:42:25 +0300 |
| commit | 68c7bf3b55ca132143686ab433659c3b828760aa (patch) | |
| tree | 5e2b5f5bc674f05a4c351a8f4f0ea6b6e596ca16 /plugins/NotifyAnything/src | |
| parent | ef6ef30fac86de58bfd7d52b1d8a213b8d955d5d (diff) | |
attempt to fix some problems on exit
Diffstat (limited to 'plugins/NotifyAnything/src')
| -rw-r--r-- | plugins/NotifyAnything/src/main.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/plugins/NotifyAnything/src/main.cpp b/plugins/NotifyAnything/src/main.cpp index c47d8fb24d..6c0c7fb9ae 100644 --- a/plugins/NotifyAnything/src/main.cpp +++ b/plugins/NotifyAnything/src/main.cpp @@ -837,6 +837,8 @@ void initWinsock() void __cdecl udptcpThreadFunc(void *useUdp)
{
+ MThreadHandle threadLock(useUdp ? g_udp_thread : g_tcp_thread);
+
try
{
initWinsock();
@@ -946,8 +948,8 @@ void __cdecl udptcpThreadFunc(void *useUdp) void start_threads()
{
g_exit_threads = false;
- g_udp_thread = mir_forkthread(udptcpThreadFunc, (void *)1);
- g_tcp_thread = mir_forkthread(udptcpThreadFunc);
+ mir_forkthread(udptcpThreadFunc, (void *)1);
+ mir_forkthread(udptcpThreadFunc);
}
void stop_threads()
@@ -957,8 +959,10 @@ void stop_threads() shutdown(g_tcp_socket, 2);
closesocket(g_udp_socket);
closesocket(g_tcp_socket);
- WaitForSingleObject(g_udp_thread, INFINITE);
- WaitForSingleObject(g_tcp_thread, INFINITE);
+ if (g_udp_thread)
+ WaitForSingleObject(g_udp_thread, INFINITE);
+ if (g_tcp_thread)
+ WaitForSingleObject(g_tcp_thread, INFINITE);
}
/////////////////////////////////////////////////////////////////////////////////////////
|
