Fix a small memory leak in etcd_state_client

Vitaliy Filippov 2021-02-04 02:02:24 +03:00
parent 314b20437b
commit bc742ccf8c
2 changed files with 12 additions and 1 deletions

View File

@ -7,6 +7,16 @@
#include "http_client.h"
#include "base64.h"
etcd_state_client_t::~etcd_state_client_t()
{
etcd_watches_initialised = -1;
if (etcd_watch_ws)
{
etcd_watch_ws->close();
etcd_watch_ws = NULL;
}
}
json_kv_t etcd_state_client_t::parse_etcd_kv(const json11::Json & kv_json)
{
json_kv_t kv;
@ -160,7 +170,7 @@ void etcd_state_client_t::start_etcd_watcher()
start_etcd_watcher();
});
}
else
else if (etcd_watches_initialised > 0)
{
// Connection was live, retry immediately
start_etcd_watcher();

View File

@ -81,4 +81,5 @@ struct etcd_state_client_t
void load_pgs();
void parse_state(const std::string & key, const json11::Json & value);
void parse_config(json11::Json & config);
~etcd_state_client_t();
};