diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-08-23 12:41:40 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-08-23 12:41:40 +0000 |
commit | b2c2e5c5b1eefa07a3aff95930cae6c9d1b6bc52 (patch) | |
tree | 9b3ac6ee7ad51abfb4f5e34328745c3295736e7f /protocols/SkypeWeb/src/skype_polling.cpp | |
parent | 2036ef157e7743223a4f52f791cc821d2d45695d (diff) |
SkypeWeb: more login fixes.
git-svn-id: http://svn.miranda-ng.org/main/trunk@15017 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_polling.cpp')
-rw-r--r-- | protocols/SkypeWeb/src/skype_polling.cpp | 88 |
1 files changed, 46 insertions, 42 deletions
diff --git a/protocols/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp index e4f503cd08..cec5055c66 100644 --- a/protocols/SkypeWeb/src/skype_polling.cpp +++ b/protocols/SkypeWeb/src/skype_polling.cpp @@ -21,64 +21,68 @@ void CSkypeProto::PollingThread(void*) {
debugLogA(__FUNCTION__ ": entering");
- int errors = 0;
- isTerminated = false;
- while (!isTerminated && errors < POLLING_ERRORS_LIMIT)
+ int nErrors = 0;
+ while (!m_bThreadsTerminated)
{
- PollRequest *request = new PollRequest(li);
- request->nlc = m_pollingConnection;
- NLHR_PTR response(request->Send(m_hNetlibUser));
- delete request;
+ WaitForSingleObject(m_hPollingEvent, INFINITE);
- if (response == NULL)
+ while ((nErrors < POLLING_ERRORS_LIMIT) && (m_iStatus > ID_STATUS_OFFLINE || IsStatusConnecting(m_iStatus)))
{
- errors++;
- continue;
- }
+ PollRequest *request = new PollRequest(li);
+ request->nlc = m_pollingConnection;
+ NLHR_PTR response(request->Send(m_hNetlibUser));
+ delete request;
- if (response->resultCode == 200)
- {
- if (response->pData)
+ if (response == NULL)
{
- char *pData = mir_strdup(response->pData);
- if (pData != NULL)
- {
- ForkThread(&CSkypeProto::ParsePollData, pData);
- }
- else
- {
- debugLogA(__FUNCTION__ ": memory overflow !!!");
- break;
- }
+ nErrors++;
+ continue;
}
- }
- else
- {
- errors++;
- if (response->pData)
+ if (response->resultCode == 200)
{
- JSONNode root = JSONNode::parse(response->pData);
- const JSONNode &error = root["errorCode"];
- if (error != NULL)
+ if (response->pData)
{
- int errorCode = error.as_int();
- if (errorCode == 729)
+ char *pData = mir_strdup(response->pData);
+ if (pData != NULL)
+ {
+ ForkThread(&CSkypeProto::ParsePollData, pData);
+ }
+ else
{
+ debugLogA(__FUNCTION__ ": memory overflow !!!");
break;
}
}
}
- }
+ else
+ {
+ nErrors++;
- m_pollingConnection = response->nlc;
-
- }
+ if (response->pData)
+ {
+ JSONNode root = JSONNode::parse(response->pData);
+ const JSONNode &error = root["errorCode"];
+ if (error != NULL)
+ {
+ int errorCode = error.as_int();
+ if (errorCode == 729)
+ {
+ break;
+ }
+ }
+ }
+ }
- if (!isTerminated)
- {
- debugLogA(__FUNCTION__ ": unexpected termination; switching protocol to offline");
- SetStatus(ID_STATUS_OFFLINE);
+ m_pollingConnection = response->nlc;
+
+ }
+
+ if (m_iStatus > ID_STATUS_OFFLINE)
+ {
+ debugLogA(__FUNCTION__ ": unexpected termination; switching protocol to offline");
+ SetStatus(ID_STATUS_OFFLINE);
+ }
}
m_hPollingThread = NULL;
m_pollingConnection = NULL;
|