From ad3488c78ba1d6c077c584849f6c6c71f91cc35b Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Wed, 1 Oct 2014 07:08:42 +0000 Subject: VKontakte: fix freeze proto when internal error occurred. git-svn-id: http://svn.miranda-ng.org/main/trunk@10661 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/misc.cpp | 14 ++++++++++++-- protocols/VKontakte/src/vk_proto.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'protocols') diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 0f3396b72f..7eb1a6dde2 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -111,8 +111,16 @@ bool CVkProto::CheckJsonResult(AsyncHttpRequest *pReq, NETLIBHTTPREQUEST *reply, case VKERR_TOO_MANY_REQ_PER_SEC: case VKERR_FLOOD_CONTROL: case VKERR_INTERNAL_SERVER_ERR: - pReq->bNeedsRestart = true; - Sleep(500); //Pause for fix err + if (pReq->m_iRetry > 0){ + pReq->bNeedsRestart = true; + Sleep(500); //Pause for fix err + pReq->m_iRetry--; + } + else{ + CMString msg, msgformat = TranslateT("Error %d. Data will not be send or received."); + msg.AppendFormat(msgformat, iErrorCode); + MsgPopup(NULL, msg.GetBuffer(), TranslateT("Error"), true); + } break; case VKERR_HIMSELF_AS_FRIEND: case VKERR_YOU_ON_BLACKLIST: @@ -239,6 +247,7 @@ AsyncHttpRequest::AsyncHttpRequest() AddHeader("Connection", "keep-alive"); AddHeader("Accept-Encoding", "booo"); pUserInfo = NULL; + m_iRetry = MAX_RETRIES; } AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url, bool bSecure, VK_REQUEST_HANDLER pFunc) @@ -265,6 +274,7 @@ AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url requestType = iRequestType; m_pFunc = pFunc; pUserInfo = NULL; + m_iRetry = MAX_RETRIES; } AsyncHttpRequest::~AsyncHttpRequest() diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 2768b61ebe..03e18048e3 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -23,6 +23,7 @@ along with this program. If not, see . #define PS_BANUSER "/BanUser" #define PS_REPORTABUSE "/ReportAbuse" #define MAXHISTORYMIDSPERONE 200 +#define MAX_RETRIES 10 struct CVkProto; typedef void (CVkProto::*VK_REQUEST_HANDLER)(NETLIBHTTPREQUEST*, struct AsyncHttpRequest*); @@ -42,6 +43,7 @@ struct AsyncHttpRequest : public NETLIBHTTPREQUEST, public MZeroedObject VK_REQUEST_HANDLER m_pFunc; void *pUserInfo; bool m_bApiReq; + int m_iRetry; }; struct PARAM -- cgit v1.2.3