diff options
author | George Hazan <george.hazan@gmail.com> | 2013-10-21 18:31:43 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-10-21 18:31:43 +0000 |
commit | df4400de118f490139543d4121fec6a85dd74cb4 (patch) | |
tree | 71d9f2c938b55a08df60c54393b2b9aa2900fc24 /protocols | |
parent | a54038ee2896f6c09ba03e1ef4174a3258b4cb2c (diff) |
preventing VK polling thread from crashes
git-svn-id: http://svn.miranda-ng.org/main/trunk@6580 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 5f7e51b977..5dfabf3b08 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -488,19 +488,27 @@ int CVkProto::PollServer() {
debugLogA("CVkProto::PollServer");
- NETLIBHTTPREQUEST req = { sizeof(req) };
+ NETLIBHTTPREQUEST req = { sizeof(req) }, *reply;
req.requestType = REQUEST_GET;
req.szUrl = NEWSTR_ALLOCA(CMStringA().Format("%s?act=a_check&key=%s&ts=%s&wait=25&access_token=%s", m_pollingServer, m_pollingKey, m_pollingTs, m_szAccessToken));
req.flags = NLHRF_NODUMPHEADERS | NLHRF_HTTP11 | NLHRF_PERSISTENT;
- req.nlc = m_pollingConn;
req.timeout = 30000;
- NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
- if (reply == NULL)
- return 0;
+ while (true) {
+ req.nlc = m_pollingConn;
+ __try {
+ reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
+ if (reply == NULL)
+ return 0;
+ break;
+ }
+ __except(EXCEPTION_EXECUTE_HANDLER) {
+ m_pollingConn = NULL;
+ }
+ }
int retVal = 0;
- if (reply->resultCode = 200) {
+ if (reply->resultCode == 200) {
JSONROOT pRoot(reply->pData);
if ( CheckJsonResult(NULL, reply, pRoot)) {
m_pollingTs = mir_t2a( ptrT( json_as_string( json_get(pRoot, "ts"))));
@@ -509,7 +517,6 @@ int CVkProto::PollServer() PollUpdates(pUpdates);
retVal = 1;
}
- else retVal = 0;
}
m_pollingConn = reply->nlc;
|