diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-12-05 03:33:32 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-12-05 03:33:32 +0000 |
commit | e6a811520437964dcdc2a447afb05664839f4f50 (patch) | |
tree | 5d03cddc6efbd5904380e29be97c6b9dd1ffdee7 /protocols/VKontakte | |
parent | e63926f79d51119b829d683983e562527f7dd10a (diff) |
VKontakre: rework PollServer
git-svn-id: http://svn.miranda-ng.org/main/trunk@11246 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 78c9f34cb9..de191a61e3 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -879,37 +879,33 @@ int CVkProto::PollServer() debugLogA("CVkProto::PollServer (online)");
int iPollConnRetry = MAX_RETRIES;
NETLIBHTTPREQUEST *reply;
- char *szUrl = NULL;
- do {
- NETLIBHTTPREQUEST req = { sizeof(req) };
- req.requestType = REQUEST_GET;
- mir_free(szUrl);
- CMStringA szReqUrl;
- szReqUrl.AppendFormat("http://%s?act=a_check&key=%s&ts=%s&wait=25&access_token=%s&mode=%d", m_pollingServer, m_pollingKey, m_pollingTs, m_szAccessToken, 106);
- // see mode parametr description on https://vk.com/dev/using_longpoll (Russian version)
- szUrl = mir_strdup(szReqUrl.GetBuffer());
- req.szUrl = szUrl;
- req.flags = VK_NODUMPHEADERS | NLHRF_PERSISTENT;
- req.timeout = 30000;
- req.nlc = m_pollingConn;
-
- reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
- if (reply != NULL)
- break;
+ CMStringA szReqUrl;
+ szReqUrl.AppendFormat("http://%s?act=a_check&key=%s&ts=%s&wait=25&access_token=%s&mode=%d", m_pollingServer, m_pollingKey, m_pollingTs, m_szAccessToken, 106);
+ // see mode parametr description on https://vk.com/dev/using_longpoll (Russian version)
+ NETLIBHTTPREQUEST req = { sizeof(req) };
+ req.requestType = REQUEST_GET;
+ req.szUrl = mir_strdup(szReqUrl.GetBuffer());
+ req.flags = VK_NODUMPHEADERS | NLHRF_PERSISTENT;
+ req.timeout = 30000;
+ req.nlc = m_pollingConn;
+
+ while ((reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req)) == NULL) {
debugLogA("CVkProto::PollServer is dead");
m_pollingConn = NULL;
- if (iPollConnRetry && !m_bTerminated){
- debugLogA("CVkProto::PollServer restarting %d", MAX_RETRIES - iPollConnRetry + 1);
- Sleep(1000);
+ if (iPollConnRetry && !m_bTerminated){
+ iPollConnRetry--;
+ debugLogA("CVkProto::PollServer restarting %d", MAX_RETRIES - iPollConnRetry);
+ Sleep(1000);
}
else {
debugLogA("CVkProto::PollServer => ShutdownSession");
+ mir_free(req.szUrl);
ShutdownSession();
return 0;
- }
- } while(!m_bTerminated && iPollConnRetry--);
-
- mir_free(szUrl);
+ }
+ }
+
+ mir_free(req.szUrl);
int retVal = 0;
if (reply->resultCode == 200) {
|