Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneo committed Jan 8, 2025
1 parent dc65036 commit 75d0858
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/lib/iomgr/tcp_server_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@ static void tcp_server_start(grpc_tcp_server* s,
size_t i;
grpc_tcp_listener* sp;
gpr_mu_lock(&s->mu);
LOG(INFO) << s->head;
CHECK(s->on_accept_cb);
CHECK_EQ(s->active_ports, 0u);
s->pollsets = pollsets;
Expand Down
22 changes: 22 additions & 0 deletions test/cpp/server/server_builder_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,28 @@ TEST_F(ServerBuilderTest, PassiveListenerAcceptConnectedEndpoint) {
server->Shutdown();
}

TEST_F(ServerBuilderTest, PortZeroIsBoundOnce) {
int selected_port = -1;
ServerBuilder builder;
builder.RegisterService(&g_service)
.AddListeningPort("localhost:0", InsecureServerCredentials(),
&selected_port);
std::vector<std::unique_ptr<::grpc::ServerCompletionQueue>> cqs;
cqs.reserve(10);
for (int i = 0; i < 10; ++i) {
cqs.emplace_back(builder.AddCompletionQueue());
}
auto server = builder.BuildAndStart();
ASSERT_NE(server, nullptr);
EXPECT_GE(selected_port, 0);
LOG(INFO) << "Port selected: " << selected_port << " CQs: " << cqs.size();
absl::SleepFor(absl::Minutes(3));
server->Shutdown();
for (auto& cq : cqs) {
cq->Shutdown();
}
}

} // namespace
} // namespace grpc

Expand Down

0 comments on commit 75d0858

Please sign in to comment.