summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_polling.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-10-31 13:13:13 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-10-31 13:13:13 +0300
commit9437834f8f4d3abf32a8629747385d666c652084 (patch)
tree3756bbc3e4648bf539ab78a891697f9a4e89690f /protocols/SkypeWeb/src/skype_polling.cpp
parentce8b02d7c3df822605392d3e8e6f817953af0864 (diff)
fixes #1011 (thread-unsafe code in SkypeWeb)
Diffstat (limited to 'protocols/SkypeWeb/src/skype_polling.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_polling.cpp33
1 files changed, 10 insertions, 23 deletions
diff --git a/protocols/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp
index 872c19d53d..00b6c4e57b 100644
--- a/protocols/SkypeWeb/src/skype_polling.cpp
+++ b/protocols/SkypeWeb/src/skype_polling.cpp
@@ -21,10 +21,12 @@ void CSkypeProto::PollingThread(void*)
{
debugLogA(__FUNCTION__ ": entering");
- int nErrors = 0;
- while (!m_bThreadsTerminated) {
+ while (true) {
m_hPollingEvent.Wait();
- nErrors = 0;
+ if (m_bThreadsTerminated)
+ break;
+
+ int nErrors = 0;
PollRequest *request = new PollRequest(li);
@@ -40,17 +42,8 @@ void CSkypeProto::PollingThread(void*)
if (response->resultCode == 200) {
nErrors = 0;
-
- if (response->pData) {
- char *pData = mir_strdup(response->pData);
- if (pData != NULL) {
- ForkThread(&CSkypeProto::ParsePollData, pData);
- }
- else {
- debugLogA(__FUNCTION__ ": memory overflow !!!");
- break;
- }
- }
+ if (response->pData)
+ ParsePollData(response->pData);
}
else {
nErrors++;
@@ -58,12 +51,8 @@ void CSkypeProto::PollingThread(void*)
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 (error && error.as_int() == 729)
+ break;
}
}
m_pollingConnection = response->nlc;
@@ -80,12 +69,10 @@ void CSkypeProto::PollingThread(void*)
debugLogA(__FUNCTION__ ": leaving");
}
-void CSkypeProto::ParsePollData(void *pData)
+void CSkypeProto::ParsePollData(const char *szData)
{
debugLogA(__FUNCTION__);
- ptrA szData((char*)pData); // memory must be freed in any case
-
JSONNode data = JSONNode::parse(szData);
if (!data) return;