Code review changes and fix threading bug in test.

reviewable/pr16342/r8
Mark D. Roth 7 years ago
parent 4c4e51d568
commit 4d6f002780
  1. 11
      src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
  2. 2
      src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
  3. 7
      test/cpp/end2end/client_lb_end2end_test.cc

@ -248,14 +248,9 @@ void PickFirst::CancelMatchingPicksLocked(uint32_t initial_metadata_flags_mask,
void PickFirst::StartPickingLocked() {
started_picking_ = true;
if (subchannel_list_ != nullptr) {
for (size_t i = 0; i < subchannel_list_->num_subchannels(); ++i) {
if (subchannel_list_->subchannel(i)->subchannel() != nullptr) {
subchannel_list_->subchannel(i)
->CheckConnectivityStateAndStartWatchingLocked();
break;
}
}
if (subchannel_list_ != nullptr && subchannel_list_->num_subchannels() > 0) {
subchannel_list_->subchannel(0)
->CheckConnectivityStateAndStartWatchingLocked();
}
}

@ -103,8 +103,8 @@ void FakeResolver::NextLocked(grpc_channel_args** target_result,
}
void FakeResolver::RequestReresolutionLocked() {
grpc_channel_args_destroy(next_results_);
if (reresolution_results_ != nullptr) {
grpc_channel_args_destroy(next_results_);
next_results_ = grpc_channel_args_copy(reresolution_results_);
MaybeFinishNextLocked();
}

@ -131,6 +131,7 @@ class ClientLbEnd2endTest : public ::testing::Test {
void CreateServers(size_t num_servers,
std::vector<int> ports = std::vector<int>()) {
servers_.clear();
for (size_t i = 0; i < num_servers; ++i) {
int port = 0;
if (ports.size() == num_servers) port = ports[i];
@ -144,7 +145,7 @@ class ClientLbEnd2endTest : public ::testing::Test {
void StartServers(size_t num_servers,
std::vector<int> ports = std::vector<int>()) {
if (servers_.empty()) CreateServers(num_servers, ports);
CreateServers(num_servers, ports);
for (size_t i = 0; i < num_servers; ++i) {
StartServer(i);
}
@ -630,7 +631,7 @@ TEST_F(ClientLbEnd2endTest,
gpr_log(GPR_INFO, "****** STOPPING SERVER ******");
servers_[1]->Shutdown();
EXPECT_TRUE(WaitForChannelNotReady(channel.get()));
gpr_log(GPR_INFO, "****** STARTING SERVER 0 ******");
gpr_log(GPR_INFO, "****** STARTING BOTH SERVERS ******");
servers_.clear();
StartServers(2, ports);
WaitForServer(stub, 0, DEBUG_LOCATION);
@ -895,7 +896,7 @@ TEST_F(ClientLbEnd2endTest, RoundRobinReresolve) {
// Kill all servers
gpr_log(GPR_INFO, "****** ABOUT TO KILL SERVERS *******");
for (size_t i = 0; i < servers_.size(); ++i) {
servers_[i]->Shutdown(false);
servers_[i]->Shutdown(true);
}
gpr_log(GPR_INFO, "****** SERVERS KILLED *******");
gpr_log(GPR_INFO, "****** SENDING DOOMED REQUESTS *******");

Loading…
Cancel
Save