summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/steam_pooling.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-11-28 21:13:59 +0000
committerRobert Pösel <robyer@seznam.cz>2014-11-28 21:13:59 +0000
commit8ef06acf351fdb6034b6e13670d84bfd79161956 (patch)
tree88b2768a06fc078890363520eb38a15f81504dba /protocols/Steam/src/steam_pooling.cpp
parent92beff959051eec8d60e4e146aa3d8a13bee9fea (diff)
Steam: Fix polling thread memleak, handle (max 3) errors and eventually disconnect (finally); version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@11135 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam/src/steam_pooling.cpp')
-rw-r--r--protocols/Steam/src/steam_pooling.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/protocols/Steam/src/steam_pooling.cpp b/protocols/Steam/src/steam_pooling.cpp
index 3a375d4ab3..64d72acb09 100644
--- a/protocols/Steam/src/steam_pooling.cpp
+++ b/protocols/Steam/src/steam_pooling.cpp
@@ -1,5 +1,7 @@
#include "common.h"
+#define POLLING_ERRORS_LIMIT 3
+
void CSteamProto::ParsePollData(JSONNODE *data)
{
JSONNODE *node, *item = NULL;
@@ -175,8 +177,9 @@ void CSteamProto::PollingThread(void*)
UINT32 messageId = getDword("MessageID", 0);
//SteamWebApi::PollApi::PollResult pollResult;
+ int errors = 0;
bool breaked = false;
- while (!isTerminated && !breaked)
+ while (!isTerminated && !breaked && errors < POLLING_ERRORS_LIMIT)
{
SteamWebApi::PollRequest *request = new SteamWebApi::PollRequest(token, umqId, messageId);
debugLogA("CSteamProto::PollingThread: %s", request->szUrl);
@@ -186,7 +189,15 @@ void CSteamProto::PollingThread(void*)
delete request;
if (response == NULL || response->resultCode != HTTP_STATUS_OK)
- return;
+ {
+ if (response != NULL)
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response);
+
+ errors++;
+ continue;
+ }
+ else
+ errors = 0;
JSONROOT root(response->pData);
JSONNODE *node = json_get(root, "error");
@@ -241,7 +252,9 @@ void CSteamProto::PollingThread(void*)
m_hPollingThread = NULL;
debugLogA("CSteamProto::PollingThread: leaving");
- // if something wrong, switch proto to offline
- if (breaked)
+ if (!isTerminated)
+ {
+ debugLogA("CSteamProto::PollingThread: unexpected termination; switching protocol to offline");
SetStatus(ID_STATUS_OFFLINE);
+ }
} \ No newline at end of file