summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2014-11-29 15:33:06 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2014-11-29 15:33:06 +0000
commit47ef7460d44bd169ada52ae8b1a2c7fa6f27d0d4 (patch)
treeb0a44385d3cd73b4627bafd4deb5f473c990b8d9
parentfe076d92eca402b27979bacf4062563e759e7279 (diff)
VKontakte:
fix(?) 5 sec freeze on Miranda shutdown git-svn-id: http://svn.miranda-ng.org/main/trunk@11152 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp2
-rw-r--r--protocols/VKontakte/src/vk_queue.cpp6
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp2
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);