diff options
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r-- | protocols/VKontakte/src/version.h | 4 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_pollserver.cpp | 5 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 9 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_queue.cpp | 4 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 34 |
6 files changed, 54 insertions, 4 deletions
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 53c1a8f399..00bdeae82c 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
-#define __RELEASE_NUM 8
-#define __BUILD_NUM 1
+#define __RELEASE_NUM 9
+#define __BUILD_NUM 0
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_pollserver.cpp b/protocols/VKontakte/src/vk_pollserver.cpp index 5be1d266a8..c257bdf08c 100644 --- a/protocols/VKontakte/src/vk_pollserver.cpp +++ b/protocols/VKontakte/src/vk_pollserver.cpp @@ -260,6 +260,11 @@ int CVkProto::PollServer() req.timeout = 30000;
req.nlc = m_pollingConn;
+ {
+ mir_cslock lck(m_csPoolThreadTimer);
+ m_tPoolThreadTimer = time(0);
+ }
+
while ((reply = Netlib_HttpTransaction(m_hNetlibUser, &req)) == nullptr) {
debugLogA("CVkProto::PollServer is dead");
ClosePollingConnection();
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index b4ed130c73..15cd3d4451 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -42,6 +42,8 @@ CVkProto::CVkProto(const char *szModuleName, const wchar_t *pwszUserName) : m_bNeedSendOnline(false),
m_vkOptions(this)
{
+ m_tWorkThreadTimer = m_tPoolThreadTimer = time(0);
+
InitQueue();
CreateProtoService(PS_CREATEACCMGRUI, &CVkProto::SvcCreateAccMgrUI);
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 64bfc9c29d..876d365853 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -117,6 +117,7 @@ struct CVkProto : public PROTO<CVkProto> void CreateNewChat(LPCSTR uids, LPCWSTR pwszTitle);
__forceinline bool IsOnline() const { return m_bOnline; }
+ bool CheckHealthThreads();
void OnTimerTic();
void ClearAccessToken();
wchar_t* GetUserStoredPassword(void);
@@ -206,7 +207,13 @@ private: m_csChatTyping,
m_csLoadHistoryTask,
m_csRequestsQueue,
- m_csSetStatus;
+ m_csSetStatus,
+ m_csWorkThreadTimer,
+ m_csPoolThreadTimer;
+
+ time_t
+ m_tWorkThreadTimer,
+ m_tPoolThreadTimer;
int m_iLoadHistoryTask;
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp index f0c0bce359..bea360df75 100644 --- a/protocols/VKontakte/src/vk_queue.cpp +++ b/protocols/VKontakte/src/vk_queue.cpp @@ -191,6 +191,10 @@ void CVkProto::WorkerThread(void*) // There can be maximum 3 requests to API methods per second from a client
// see https://vk.com/dev/api_requests
}
+ {
+ mir_cslock lck(m_csWorkThreadTimer);
+ m_tWorkThreadTimer = time(0);
+ }
ExecuteRequest(pReq);
}
}
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index bea0d174b4..0014b5ae3b 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -30,6 +30,37 @@ static char fieldsName[] = "id, first_name, last_name, photo_100, bdate, sex, ti /////////////////////////////////////////////////////////////////////////////////////////
+bool CVkProto::CheckHealthThreads()
+{
+ if (!IsOnline()) {
+ debugLogA("CVkProto::CheckHealthThreads Offline");
+ return false;
+ }
+
+ time_t tNow = time(0);
+
+ {
+ mir_cslock lck(m_csWorkThreadTimer);
+ if ((m_tWorkThreadTimer + 3 * 60) < tNow) {
+ debugLogA("CVkProto::CheckHealthThreads Work Thread is freeze => ShutdownSession()");
+ ShutdownSession();
+ return false;
+ }
+ }
+
+ {
+ mir_cslock lck(m_csPoolThreadTimer);
+ if ((m_tPoolThreadTimer + 3 * 60) < tNow) {
+ debugLogA("CVkProto::CheckHealthThreads Pool Thread is freeze => ShutdownSession()");
+ ShutdownSession();
+ return false;
+ }
+ }
+
+ debugLogA("CVkProto::CheckHealthThreads OK");
+ return true;
+}
+
void CVkProto::ShutdownSession()
{
debugLogA("CVkProto::ShutdownSession");
@@ -56,7 +87,8 @@ static VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) for (auto &it : g_plugin.g_arInstances)
if (it->IsOnline()) {
it->debugLogA("Tic timer for %s", it->m_szModuleName);
- it->OnTimerTic();
+ if (it->CheckHealthThreads())
+ it->OnTimerTic();
}
}
|