diff options
author | ElzorFox <elzorfox@ya.ru> | 2017-04-02 00:11:41 +0500 |
---|---|---|
committer | ElzorFox <elzorfox@ya.ru> | 2017-04-02 00:11:41 +0500 |
commit | a8007991b6f8f5381dd290b44fdcf346f68f48b3 (patch) | |
tree | afa9de4cb46c10a972df04b97d34345e2e5ddd53 /protocols/VKontakte/src/vk_history.cpp | |
parent | 177bd7053cb265b1634e1a1a2a635ca4a8b72395 (diff) |
VKontakte:
fix treads handle leaks
fix multiply loading history on quick online-offline-online
Diffstat (limited to 'protocols/VKontakte/src/vk_history.cpp')
-rw-r--r-- | protocols/VKontakte/src/vk_history.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index ec1e9e53a7..503a370593 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -60,6 +60,9 @@ INT_PTR __cdecl CVkProto::SvcGetAllServerHistory(WPARAM, LPARAM) if (userID == VK_INVALID_USER || userID == VK_FEED_USER)
continue;
+ if (getBool(hContact, "ActiveHistoryTask"))
+ break;
+ setByte(hContact, "ActiveHistoryTask", 1);
MEVENT hDBEvent = db_event_first(hContact);
while (hDBEvent) {
@@ -89,6 +92,10 @@ void CVkProto::GetServerHistoryLastNDay(MCONTACT hContact, int NDay) {
debugLogA("CVkProto::SvcGetServerHistoryLastNDay %d", NDay);
+ if (getBool(hContact, "ActiveHistoryTask"))
+ return;
+ setByte(hContact, "ActiveHistoryTask", 1);
+
time_t tTime = time(NULL) - 60 * 60 * 24 * NDay;
MEVENT hDBEvent = db_event_first(hContact);
@@ -147,6 +154,9 @@ void CVkProto::GetHistoryDlg(MCONTACT hContact, int iLastMsg) return;
}
m_bNotifyForEndLoadingHistory = false;
+ if (getBool(hContact, "ActiveHistoryTask"))
+ return;
+ setByte(hContact, "ActiveHistoryTask", 1);
GetServerHistory(hContact, 0, MAXHISTORYMIDSPERONE, 0, lastmsgid);
break;
case sync1Days:
@@ -172,7 +182,8 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque MsgPopup(NULL, TranslateT("Loading messages for all contacts is completed."), TranslateT("Loading history"));
m_bNotifyForEndLoadingHistoryAllContact = m_bNotifyForEndLoadingHistory = false;
}
-
+ if (pReq->pUserInfo)
+ setByte(((CVkSendMsgParam*)pReq->pUserInfo)->hContact, "ActiveHistoryTask", 0);
return;
}
@@ -180,6 +191,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque CVkSendMsgParam *param = (CVkSendMsgParam*)pReq->pUserInfo;
const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot);
if (!jnResponse) {
+ setByte(param->hContact, "ActiveHistoryTask", 0);
if (!pReq->bNeedsRestart || m_bTerminated) {
mir_cslock lck(m_csLoadHistoryTask);
if (m_iLoadHistoryTask > 0)
@@ -195,7 +207,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque MsgPopup(NULL, TranslateT("Loading messages for all contacts is completed."), TranslateT("Loading history"));
m_bNotifyForEndLoadingHistoryAllContact = m_bNotifyForEndLoadingHistory = false;
}
-
+
delete param;
pReq->pUserInfo = NULL;
}
@@ -296,6 +308,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque MsgPopup(NULL, TranslateT("Loading messages for all contacts is completed."), TranslateT("Loading history"));
m_bNotifyForEndLoadingHistoryAllContact = m_bNotifyForEndLoadingHistory = false;
}
+ setByte(param->hContact, "ActiveHistoryTask", 0);
}
if (!pReq->bNeedsRestart || m_bTerminated) {
|