From 8b8283c62cc5b8fce419fd7e0fe38c33f4457e17 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 4 Jun 2015 13:32:26 +0000 Subject: fix for MSN avatars thread hangup git-svn-id: http://svn.miranda-ng.org/main/trunk@13998 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/MSN/src/msn.cpp | 1 + protocols/MSN/src/msn_auth.cpp | 2 +- protocols/MSN/src/msn_avatar.cpp | 2 +- protocols/MSN/src/msn_commands.cpp | 2 +- protocols/MSN/src/msn_misc.cpp | 6 +++--- protocols/MSN/src/msn_natdetect.cpp | 8 ++++---- protocols/MSN/src/msn_proto.cpp | 3 ++- protocols/MSN/src/stdafx.h | 1 + 8 files changed, 14 insertions(+), 11 deletions(-) (limited to 'protocols/MSN/src') diff --git a/protocols/MSN/src/msn.cpp b/protocols/MSN/src/msn.cpp index eec8390b96..8f4200e74a 100644 --- a/protocols/MSN/src/msn.cpp +++ b/protocols/MSN/src/msn.cpp @@ -38,6 +38,7 @@ void MsnLinks_Destroy(void); ///////////////////////////////////////////////////////////////////////////////////////// // Global variables +bool g_bTerminated = false; int avsPresent = -1; static const PLUGININFOEX pluginInfo = diff --git a/protocols/MSN/src/msn_auth.cpp b/protocols/MSN/src/msn_auth.cpp index 325c903a94..4dbd10237a 100644 --- a/protocols/MSN/src/msn_auth.cpp +++ b/protocols/MSN/src/msn_auth.cpp @@ -288,7 +288,7 @@ int CMsnProto::MSN_GetPassportAuth(void) } if (retVal != 0) { - if (!Miranda_Terminated()) { + if (!g_bTerminated) { switch (retVal) { case 3: MSN_ShowError("Your username or password is incorrect"); diff --git a/protocols/MSN/src/msn_avatar.cpp b/protocols/MSN/src/msn_avatar.cpp index 9df3cdee08..943cd6f0ae 100644 --- a/protocols/MSN/src/msn_avatar.cpp +++ b/protocols/MSN/src/msn_avatar.cpp @@ -100,7 +100,7 @@ void __cdecl CMsnProto::MSN_AvatarsThread(void*) if (WaitForSingleObject(hevAvatarQueue, INFINITE) != WAIT_OBJECT_0) break; - if (Miranda_Terminated()) + if (g_bTerminated) break; AvatarQueueEntry *p = NULL; diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp index 8ee67673a7..7d0eeac2a5 100644 --- a/protocols/MSN/src/msn_commands.cpp +++ b/protocols/MSN/src/msn_commands.cpp @@ -1876,7 +1876,7 @@ LBL_InvalidCommand: CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); } else { - if (!Miranda_Terminated() && MessageBox(NULL, + if (!g_bTerminated && MessageBox(NULL, TranslateT("There is only 1 person left in the chat, do you want to switch back to standard message window?"), TranslateT("MSN Chat"), MB_YESNO | MB_ICONQUESTION) == IDYES) { // kill chat dlg and open srmm dialog diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp index 6298102415..b788bee022 100644 --- a/protocols/MSN/src/msn_misc.cpp +++ b/protocols/MSN/src/msn_misc.cpp @@ -385,7 +385,7 @@ void CMsnProto::MSN_GoOffline(void) msnPreviousUUX = NULL; msnSearchId = NULL; - if (!Miranda_Terminated()) + if (!g_bTerminated) MSN_EnableMenuItems(false); MSN_FreeGroups(); @@ -394,7 +394,7 @@ void CMsnProto::MSN_GoOffline(void) #endif clearCachedMsg(); - if (!Miranda_Terminated()) { + if (!g_bTerminated) { int msnOldStatus = m_iStatus; m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)msnOldStatus, ID_STATUS_OFFLINE); isIdle = false; @@ -1084,7 +1084,7 @@ void CALLBACK sttMainThreadCallback(PVOID dwParam) void CMsnProto::MSN_ShowPopup(const TCHAR* nickname, const TCHAR* msg, int flags, const char* url) { - if (Miranda_Terminated()) return; + if (g_bTerminated) return; PopupData *pud = (PopupData*)mir_calloc(sizeof(PopupData)); pud->flags = flags; diff --git a/protocols/MSN/src/msn_natdetect.cpp b/protocols/MSN/src/msn_natdetect.cpp index 5458b2853b..18e3a5746e 100644 --- a/protocols/MSN/src/msn_natdetect.cpp +++ b/protocols/MSN/src/msn_natdetect.cpp @@ -76,7 +76,7 @@ static void DiscardExtraPackets(SOCKET s) unsigned buf; for (;;) { - if (Miranda_Terminated()) break; + if (g_bTerminated) break; fd_set fd; FD_ZERO(&fd); @@ -142,7 +142,7 @@ void CMsnProto::MSNatDetect(void) // NAT detection unsigned i; for (i = 0; i < 4; ++i) { - if (Miranda_Terminated()) break; + if (g_bTerminated) break; // Send echo request to server 1 debugLogA("P2PNAT Request 1 attempt %d sent", i); @@ -207,7 +207,7 @@ void CMsnProto::MSNatDetect(void) addr2.sin_addr.S_un.S_addr = rpkt.testIP; addr2.sin_port = rpkt.discardPort; for (i = 0; i < 4; ++i) { - if (Miranda_Terminated()) break; + if (g_bTerminated) break; debugLogA("P2PNAT Request 2 attempt %d sent", i); // Remove IP restriction for server 2 @@ -243,7 +243,7 @@ void CMsnProto::MSNatDetect(void) // Symmetric NAT detection addr2.sin_port = rpkt.testPort; for (i = 0; i < 4; ++i) { - if (Miranda_Terminated()) break; + if (g_bTerminated) break; debugLogA("P2PNAT Request 3 attempt %d sent", i); // Send echo request to server 1 diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index 7cd17188fd..195f7a4303 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -212,7 +212,8 @@ int CMsnProto::OnModulesLoaded(WPARAM, LPARAM) int CMsnProto::OnPreShutdown(WPARAM, LPARAM) { - SetEvent(hevAvatarQueue); + g_bTerminated = true; + ReleaseSemaphore(hevAvatarQueue, 1, NULL); Popup_UnregisterClass(hPopupError); Popup_UnregisterClass(hPopupHotmail); diff --git a/protocols/MSN/src/stdafx.h b/protocols/MSN/src/stdafx.h index 1ce626523e..fa4a6f165a 100644 --- a/protocols/MSN/src/stdafx.h +++ b/protocols/MSN/src/stdafx.h @@ -885,6 +885,7 @@ const char msnProductVer[] = "0/6.16.0.105/259/"; const char msnProtID[] = "MSNP24"; extern HINSTANCE hInst; +extern bool g_bTerminated; /////////////////////////////////////////////////////////////////////////////// // UTF8 encode helper -- cgit v1.2.3