From 47ef7460d44bd169ada52ae8b1a2c7fa6f27d0d4 Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Sat, 29 Nov 2014 15:33:06 +0000 Subject: VKontakte: fix(?) 5 sec freeze on Miranda shutdown git-svn-id: http://svn.miranda-ng.org/main/trunk@11152 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/vk_proto.cpp | 2 ++ protocols/VKontakte/src/vk_queue.cpp | 6 ++++-- protocols/VKontakte/src/vk_thread.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 3f38487f2c..1475bf0782 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -355,6 +355,8 @@ void CVkProto::MsgPopup(MCONTACT hContact, const TCHAR *szMsg, const TCHAR *szTi int CVkProto::OnPreShutdown(WPARAM wParam, LPARAM lParam) { + debugLogA("CVkProto::OnPreShutdown"); + m_bTerminated = true; SetEvent(m_evRequestsQueue); return 0; diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp index 5fbbff50df..0740c14ce6 100644 --- a/protocols/VKontakte/src/vk_queue.cpp +++ b/protocols/VKontakte/src/vk_queue.cpp @@ -58,7 +58,7 @@ void CVkProto::ExecuteRequest(AsyncHttpRequest *pReq) else if (pReq->bIsMainConn) { if (m_iStatus >= ID_STATUS_CONNECTING && m_iStatus < ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES) ConnectionFailed(LOGINERR_NONETWORK); - else if (pReq->m_iRetry){ + else if (pReq->m_iRetry && !m_bTerminated){ pReq->bNeedsRestart = true; Sleep(1000); //Pause for fix err pReq->m_iRetry--; @@ -70,7 +70,7 @@ void CVkProto::ExecuteRequest(AsyncHttpRequest *pReq) } } debugLogA("CVkProto::ExecuteRequest pReq->bNeedsRestart = %d", (int)pReq->bNeedsRestart); - } while (pReq->bNeedsRestart); + } while (pReq->bNeedsRestart && !m_bTerminated); delete pReq; } @@ -127,6 +127,8 @@ void CVkProto::WorkerThread(void*) m_arRequestsQueue.remove(0); need_sleep = (m_arRequestsQueue.getCount() > 1) && (pReq->m_bApiReq); // more than two to not gather } + if (m_bTerminated) + break; ExecuteRequest(pReq); if (need_sleep) // There can be maximum 3 requests to API methods per second from a client Sleep(330); // (c) https://vk.com/dev/api_requests diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 159b703365..78843d5ea5 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -895,7 +895,7 @@ int CVkProto::PollServer() break; debugLogA("CVkProto::PollServer is dead"); m_pollingConn = NULL; - if (iPollConnRetry){ + if (iPollConnRetry && !m_bTerminated){ iPollConnRetry--; debugLogA("CVkProto::PollServer restarting %d", MAX_RETRIES - iPollConnRetry); Sleep(1000); -- cgit v1.2.3