diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-10-01 07:08:42 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-10-01 07:08:42 +0000 |
commit | ad3488c78ba1d6c077c584849f6c6c71f91cc35b (patch) | |
tree | c69baf0e47bbcb0436be8cb16cad1756a133f4e6 /protocols/VKontakte | |
parent | 1f3f340be39ea193b1c210ddd986d74b468ea4ef (diff) |
VKontakte: fix freeze proto when internal error occurred.
git-svn-id: http://svn.miranda-ng.org/main/trunk@10661 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 14 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 2 |
2 files changed, 14 insertions, 2 deletions
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 <http://www.gnu.org/licenses/>. #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
|