Fix exit STK requests leak

This commit is contained in:
Benau 2018-09-30 12:42:17 +08:00
parent 6809984928
commit 05e1d629ee
3 changed files with 21 additions and 4 deletions

View File

@ -326,7 +326,11 @@ namespace Online
setProgress(-1.0f);
Request::afterOperation();
if (m_curl_session)
{
curl_easy_cleanup(m_curl_session);
m_curl_session = NULL;
}
} // afterOperation
// ------------------------------------------------------------------------

View File

@ -63,7 +63,7 @@ namespace Online
std::string m_filename;
/** Pointer to the curl data structure for this request. */
CURL *m_curl_session;
CURL *m_curl_session = NULL;
/** curl return code. */
CURLcode m_curl_code;
@ -93,7 +93,14 @@ namespace Online
int priority = 1);
HTTPRequest(const char * const filename, bool manage_memory = false,
int priority = 1);
virtual ~HTTPRequest() {}
virtual ~HTTPRequest()
{
if (m_curl_session)
{
curl_easy_cleanup(m_curl_session);
m_curl_session = NULL;
}
}
virtual bool isAllowedToAdd() const OVERRIDE;
void setApiURL(const std::string& url, const std::string &action);
void setAddonsURL(const std::string& path);

View File

@ -213,7 +213,13 @@ namespace Online
me->m_current_request->execute();
// This test is necessary in case that execute() was aborted
// (otherwise the assert in addResult will be triggered).
if (!me->getAbort()) me->addResult(me->m_current_request);
if (!me->getAbort())
me->addResult(me->m_current_request);
else if (me->m_current_request->manageMemory())
{
delete me->m_current_request;
me->m_current_request = NULL;
}
me->m_request_queue.lock();
} // while handle all requests