diff --git a/src/etcd_state_client.cpp b/src/etcd_state_client.cpp index 2ad9c98f..cdae49e0 100644 --- a/src/etcd_state_client.cpp +++ b/src/etcd_state_client.cpp @@ -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(); diff --git a/src/etcd_state_client.h b/src/etcd_state_client.h index d7ae52cc..89fd5200 100644 --- a/src/etcd_state_client.h +++ b/src/etcd_state_client.h @@ -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(); };