diff options
| -rw-r--r-- | protocols/VKontakte/src/vk_history.cpp | 17 | ||||
| -rw-r--r-- | protocols/VKontakte/src/vk_pollserver.cpp | 6 | ||||
| -rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 1 | ||||
| -rw-r--r-- | protocols/VKontakte/src/vk_queue.cpp | 6 | ||||
| -rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 11 | 
5 files changed, 35 insertions, 6 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) {
 diff --git a/protocols/VKontakte/src/vk_pollserver.cpp b/protocols/VKontakte/src/vk_pollserver.cpp index cc1a75b1fc..adaaaaaf83 100644 --- a/protocols/VKontakte/src/vk_pollserver.cpp +++ b/protocols/VKontakte/src/vk_pollserver.cpp @@ -265,7 +265,11 @@ void CVkProto::PollingThread(void*)  		if (PollServer() == -1 || !m_hPollingThread)
  			break;
 -	m_hPollingThread = NULL;
  	m_pollingConn = NULL;
  	debugLogA("CVkProto::PollingThread: leaving");
 +	
 +	if (m_hPollingThread) {
 +		CloseHandle(m_hPollingThread);
 +		m_hPollingThread = NULL;
 +	}
  }
\ No newline at end of file diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 45b68efee4..f7438c450f 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -76,6 +76,7 @@ CVkProto::CVkProto(const char *szModuleName, const wchar_t *pwszUserName) :  	db_set_b(NULL, "ListeningTo", szListeningTo, m_vkOptions.iMusicSendMetod == 0 ? 0 : 1);
  	delSetting("InviteGroupIds");
 +	db_set_resident(m_szModuleName, "ActiveHistoryTask");
  	// Set all contacts offline -- in case we crashed
  	SetAllContactStatuses(ID_STATUS_OFFLINE);
 diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp index b190d080c7..1113a0850f 100644 --- a/protocols/VKontakte/src/vk_queue.cpp +++ b/protocols/VKontakte/src/vk_queue.cpp @@ -189,7 +189,6 @@ void CVkProto::WorkerThread(void*)  		}
  	}
 -	m_hWorkerThread = NULL;
  	if (m_hAPIConnection) {
  		debugLogA("CVkProto::WorkerThread: Netlib_CloseHandle(m_hAPIConnection) beg");
  		Netlib_CloseHandle(m_hAPIConnection);
 @@ -198,6 +197,11 @@ void CVkProto::WorkerThread(void*)  	}
  	debugLogA("CVkProto::WorkerThread: leaving m_bTerminated = %d", m_bTerminated ? 1 : 0);
 +
 +	if (m_hWorkerThread) {
 +		CloseHandle(m_hWorkerThread);
 +		m_hWorkerThread = NULL;
 +	}
  }
  /////////////////////////////////////////////////////////////////////////////////////////
 diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 9594480776..a0bf8e7dc7 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -102,8 +102,15 @@ void CVkProto::OnLoggedOut()  	debugLogA("CVkProto::OnLoggedOut");
  	m_bOnline = false;
 -	m_hPollingThread = NULL;
 -	m_hWorkerThread = NULL;
 +	if (m_hPollingThread) {
 +		CloseHandle(m_hPollingThread);
 +		m_hPollingThread = NULL;
 +	}
 +
 +	if (m_hWorkerThread) {
 +		CloseHandle(m_hWorkerThread);
 +		m_hWorkerThread = NULL;
 +	}
  	if (m_hAPIConnection)
  		Netlib_CloseHandle(m_hAPIConnection);
  | 
