fix wait for service memory leak bug (#656)

* when call wait for service in an while loop, the event will be make forever and never release
* fix it by: creating it when we need

Signed-off-by: reed-lau <geoliuwei@gmail.com>
This commit is contained in:
Wei Liu 2019-03-16 00:55:53 +08:00 committed by Dirk Thomas
parent ec64b40a9d
commit 284d0c1c70

View file

@ -118,7 +118,6 @@ ClientBase::wait_for_service_nanoseconds(std::chrono::nanoseconds timeout)
if (!node_ptr) { if (!node_ptr) {
throw InvalidNodeError(); throw InvalidNodeError();
} }
auto event = node_ptr->get_graph_event();
// check to see if the server is ready immediately // check to see if the server is ready immediately
if (this->service_is_ready()) { if (this->service_is_ready()) {
return true; return true;
@ -127,6 +126,7 @@ ClientBase::wait_for_service_nanoseconds(std::chrono::nanoseconds timeout)
// check was non-blocking, return immediately // check was non-blocking, return immediately
return false; return false;
} }
auto event = node_ptr->get_graph_event();
// update the time even on the first loop to account for time spent in the first call // update the time even on the first loop to account for time spent in the first call
// to this->server_is_ready() // to this->server_is_ready()
std::chrono::nanoseconds time_to_wait = std::chrono::nanoseconds time_to_wait =