Unverified Commit dde83f0c authored by Ge Jun's avatar Ge Jun Committed by GitHub

Merge pull request #586 from cdjingit/consul_ns_fix_caidaojin

bug fix: consul ns thread can not quit
parents aceaebb4 af7f77e1
...@@ -214,6 +214,10 @@ int ConsulNamingService::RunNamingService(const char* service_name, ...@@ -214,6 +214,10 @@ int ConsulNamingService::RunNamingService(const char* service_name,
for (;;) { for (;;) {
servers.clear(); servers.clear();
const int rc = GetServers(service_name, &servers); const int rc = GetServers(service_name, &servers);
if (bthread_stopped(bthread_self())) {
RPC_VLOG << "Quit NamingServiceThread=" << bthread_self();
return 0;
}
if (rc == 0) { if (rc == 0) {
ever_reset = true; ever_reset = true;
actions->ResetServers(servers); actions->ResetServers(servers);
...@@ -225,7 +229,7 @@ int ConsulNamingService::RunNamingService(const char* service_name, ...@@ -225,7 +229,7 @@ int ConsulNamingService::RunNamingService(const char* service_name,
servers.clear(); servers.clear();
actions->ResetServers(servers); actions->ResetServers(servers);
} }
if (bthread_usleep(std::max(FLAGS_consul_retry_interval_ms, 1) * butil::Time::kMillisecondsPerSecond) < 0) { if (bthread_usleep(std::max(FLAGS_consul_retry_interval_ms, 1) * butil::Time::kMicrosecondsPerMillisecond) < 0) {
if (errno == ESTOP) { if (errno == ESTOP) {
RPC_VLOG << "Quit NamingServiceThread=" << bthread_self(); RPC_VLOG << "Quit NamingServiceThread=" << bthread_self();
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment