Skip to content

Commit

Permalink
Manage httpclient instance
Browse files Browse the repository at this point in the history
If the httpClient is external, never try to delete it (must be done by instance maker)
  • Loading branch information
jano42 committed Dec 3, 2019
1 parent 769cafd commit 1c81d05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions cpp/src/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ Driver::Driver(string const& _controllerPath, ControllerInterface const& _interf
Options::Get()->GetOptionAsBool("IntervalBetweenPolls", &m_bIntervalBetweenPolls);

m_httpClient = new Internal::HttpClient(this);
m_httpClientIsExternal = false;

m_mfs = Internal::ManufacturerSpecificDB::Create();

Expand Down Expand Up @@ -295,7 +296,8 @@ Driver::~Driver()
m_eventMutex->Release();
delete this->AuthKey;
delete this->EncryptKey;
delete this->m_httpClient;
if(!m_httpClientIsExternal)
delete this->m_httpClient;
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -6925,9 +6927,10 @@ void Driver::processConfigRevision(Internal::DNSLookup *result)

bool Driver::setHttpClient(Internal::i_HttpClient *client)
{
if (m_httpClient)
if (m_httpClient && !m_httpClientIsExternal)
delete m_httpClient;
m_httpClient = client;
m_httpClientIsExternal = true;
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ namespace OpenZWave
bool refreshNodeConfig(uint8 node);
void processDownload(Internal::HttpDownload *);
Internal::i_HttpClient *m_httpClient;

bool m_httpClientIsExternal;
//-----------------------------------------------------------------------------
// Metadata Related
//-----------------------------------------------------------------------------
Expand Down

0 comments on commit 1c81d05

Please sign in to comment.