Fix formatting, mem leak, stall

pull/6612/head
Craig Tiller 9 years ago
parent 20431a8618
commit e004958fd6
  1. 4
      src/core/lib/iomgr/tcp_server_windows.c
  2. 4
      src/cpp/server/server.cc
  3. 29
      test/cpp/end2end/hybrid_end2end_test.cc

@ -380,8 +380,8 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, bool from_iocp) {
/* The only time we should call our callback, is where we successfully
managed to accept a connection, and created an endpoint. */
if (ep) {
sp->server->on_accept_cb(exec_ctx, sp->server->on_accept_cb_arg, ep,
NULL, &acceptor);
sp->server->on_accept_cb(exec_ctx, sp->server->on_accept_cb_arg, ep, NULL,
&acceptor);
}
/* As we were notified from the IOCP of one and exactly one accept,
the former socked we created has now either been destroy or assigned

@ -412,7 +412,9 @@ bool Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) {
sync_methods_->push_back(SyncRequest(unknown_method_.get(), nullptr));
}
for (size_t i = 0; i < num_cqs; i++) {
new UnimplementedAsyncRequest(this, cqs[i]);
if (cqs[i]->IsFrequentlyPolled()) {
new UnimplementedAsyncRequest(this, cqs[i]);
}
}
}
// Start processing rpcs.

@ -199,7 +199,8 @@ class HybridEnd2endTest : public ::testing::Test {
HybridEnd2endTest() {}
void SetUpServer(::grpc::Service* service1, ::grpc::Service* service2,
AsyncGenericService* generic_service) {
AsyncGenericService* generic_service,
int num_cqs_frequently_polled) {
int port = grpc_pick_unused_port_or_die();
server_address_ << "localhost:" << port;
@ -216,7 +217,7 @@ class HybridEnd2endTest : public ::testing::Test {
}
// Create a separate cq for each potential handler.
for (int i = 0; i < 5; i++) {
cqs_.push_back(builder.AddCompletionQueue(false));
cqs_.push_back(builder.AddCompletionQueue(i < num_cqs_frequently_polled));
}
server_ = builder.BuildAndStart();
}
@ -346,7 +347,7 @@ class HybridEnd2endTest : public ::testing::Test {
TEST_F(HybridEnd2endTest, AsyncEcho) {
EchoTestService::WithAsyncMethod_Echo<TestServiceImpl> service;
SetUpServer(&service, nullptr, nullptr);
SetUpServer(&service, nullptr, nullptr, 1);
ResetStub();
std::thread echo_handler_thread(
[this, &service] { HandleEcho(&service, cqs_[0].get(), false); });
@ -358,7 +359,7 @@ TEST_F(HybridEnd2endTest, AsyncEchoRequestStream) {
EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_Echo<TestServiceImpl> >
service;
SetUpServer(&service, nullptr, nullptr);
SetUpServer(&service, nullptr, nullptr, 2);
ResetStub();
std::thread echo_handler_thread(
[this, &service] { HandleEcho(&service, cqs_[0].get(), false); });
@ -373,7 +374,7 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream) {
EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> >
service;
SetUpServer(&service, nullptr, nullptr);
SetUpServer(&service, nullptr, nullptr, 2);
ResetStub();
std::thread response_stream_handler_thread(
[this, &service] { HandleServerStreaming(&service, cqs_[0].get()); });
@ -390,7 +391,7 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncDupService) {
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> >
service;
TestServiceImplDupPkg dup_service;
SetUpServer(&service, &dup_service, nullptr);
SetUpServer(&service, &dup_service, nullptr, 2);
ResetStub();
std::thread response_stream_handler_thread(
[this, &service] { HandleServerStreaming(&service, cqs_[0].get()); });
@ -408,7 +409,7 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_AsyncDupService) {
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> >
service;
duplicate::EchoTestService::AsyncService dup_service;
SetUpServer(&service, &dup_service, nullptr);
SetUpServer(&service, &dup_service, nullptr, 3);
ResetStub();
std::thread response_stream_handler_thread(
[this, &service] { HandleServerStreaming(&service, cqs_[0].get()); });
@ -426,7 +427,7 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_AsyncDupService) {
TEST_F(HybridEnd2endTest, GenericEcho) {
EchoTestService::WithGenericMethod_Echo<TestServiceImpl> service;
AsyncGenericService generic_service;
SetUpServer(&service, nullptr, &generic_service);
SetUpServer(&service, nullptr, &generic_service, 1);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
@ -440,7 +441,7 @@ TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream) {
EchoTestService::WithGenericMethod_Echo<TestServiceImpl> >
service;
AsyncGenericService generic_service;
SetUpServer(&service, nullptr, &generic_service);
SetUpServer(&service, nullptr, &generic_service, 2);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
@ -459,7 +460,7 @@ TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_SyncDupService) {
service;
AsyncGenericService generic_service;
TestServiceImplDupPkg dup_service;
SetUpServer(&service, &dup_service, &generic_service);
SetUpServer(&service, &dup_service, &generic_service, 2);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
@ -479,7 +480,7 @@ TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_AsyncDupService) {
service;
AsyncGenericService generic_service;
duplicate::EchoTestService::AsyncService dup_service;
SetUpServer(&service, &dup_service, &generic_service);
SetUpServer(&service, &dup_service, &generic_service, 3);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
@ -501,7 +502,7 @@ TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStreamResponseStream) {
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> > >
service;
AsyncGenericService generic_service;
SetUpServer(&service, nullptr, &generic_service);
SetUpServer(&service, nullptr, &generic_service, 3);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
@ -522,7 +523,7 @@ TEST_F(HybridEnd2endTest, GenericEchoRequestStreamAsyncResponseStream) {
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> > >
service;
AsyncGenericService generic_service;
SetUpServer(&service, nullptr, &generic_service);
SetUpServer(&service, nullptr, &generic_service, 3);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
@ -545,7 +546,7 @@ TEST_F(HybridEnd2endTest, GenericMethodWithoutGenericService) {
EchoTestService::WithGenericMethod_Echo<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> > >
service;
SetUpServer(&service, nullptr, nullptr);
SetUpServer(&service, nullptr, nullptr, 0);
EXPECT_EQ(nullptr, server_.get());
}

Loading…
Cancel
Save