From e1e2475b6938eca4378d2bc6632db31c7dfa2b02 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 13 Jan 2015 17:26:27 -0800 Subject: Unify signal handling in C --- test/core/iomgr/tcp_posix_test.c | 3 --- test/core/transport/chttp2_transport_end2end_test.c | 3 --- test/core/util/test_config.c | 3 +++ 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c index 7fd2567cec..6af3ded98b 100644 --- a/test/core/iomgr/tcp_posix_test.c +++ b/test/core/iomgr/tcp_posix_test.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -491,8 +490,6 @@ static grpc_endpoint_test_config configs[] = { int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_iomgr_init(); - /* disable SIGPIPE */ - signal(SIGPIPE, SIG_IGN); run_tests(); grpc_endpoint_tests(configs[0]); grpc_iomgr_shutdown(); diff --git a/test/core/transport/chttp2_transport_end2end_test.c b/test/core/transport/chttp2_transport_end2end_test.c index 30d2a17440..8b0f9aa25b 100644 --- a/test/core/transport/chttp2_transport_end2end_test.c +++ b/test/core/transport/chttp2_transport_end2end_test.c @@ -107,9 +107,6 @@ grpc_transport_test_config fixture_configs[] = { int main(int argc, char **argv) { size_t i; - /* disable SIGPIPE */ - signal(SIGPIPE, SIG_IGN); - grpc_test_init(argc, argv); grpc_iomgr_init(); diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c index ab2c0d80a9..94245d85bc 100644 --- a/test/core/util/test_config.c +++ b/test/core/util/test_config.c @@ -35,6 +35,7 @@ #include #include +#include #if GPR_GETPID_IN_UNISTD_H #include @@ -51,6 +52,8 @@ static int seed(void) { #endif void grpc_test_init(int argc, char **argv) { + /* disable SIGPIPE */ + signal(SIGPIPE, SIG_IGN); /* seed rng with pid, so we don't end up with the same random numbers as a concurrently running test binary */ srand(seed()); -- cgit v1.2.3 From 14e60e9f8b147d873b6320e24c100a8dbb087418 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 13 Jan 2015 17:26:46 -0800 Subject: Use C signal handling in C++ end2end --- test/cpp/end2end/end2end_test.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index e01a6efe82..3a1da68e47 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -34,6 +34,7 @@ #include #include +#include "test/core/util/test_config.h" #include "test/cpp/util/echo_duplicate.pb.h" #include "test/cpp/util/echo.pb.h" #include "src/cpp/util/time.h" @@ -435,6 +436,7 @@ TEST_F(End2endTest, BadCredentials) { } // namespace grpc int main(int argc, char** argv) { + grpc_test_init(argc, argv); grpc_init(); ::testing::InitGoogleTest(&argc, argv); int result = RUN_ALL_TESTS(); -- cgit v1.2.3 From 1ff11f6d044bdaf46f822ce3ad8fee2980496b70 Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Wed, 14 Jan 2015 11:45:32 -0800 Subject: Add a space in front of template argument list. Changing possible <:: to < :: --- src/compiler/cpp_generator.cc | 56 +++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 1116049806..41adb81c6b 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -143,16 +143,16 @@ void PrintHeaderClientMethod(google::protobuf::io::Printer* printer, } else if (ClientOnlyStreaming(method)) { printer->Print( *vars, - "::grpc::ClientWriter<$Request$>* $Method$(" + "::grpc::ClientWriter< $Request$>* $Method$(" "::grpc::ClientContext* context, $Response$* response);\n\n"); } else if (ServerOnlyStreaming(method)) { printer->Print( *vars, - "::grpc::ClientReader<$Response$>* $Method$(" + "::grpc::ClientReader< $Response$>* $Method$(" "::grpc::ClientContext* context, const $Request$* request);\n\n"); } else if (BidiStreaming(method)) { printer->Print(*vars, - "::grpc::ClientReaderWriter<$Request$, $Response$>* " + "::grpc::ClientReaderWriter< $Request$, $Response$>* " "$Method$(::grpc::ClientContext* context);\n\n"); } } @@ -174,18 +174,18 @@ void PrintHeaderServerMethod(google::protobuf::io::Printer* printer, printer->Print(*vars, "virtual ::grpc::Status $Method$(" "::grpc::ServerContext* context, " - "::grpc::ServerReader<$Request$>* reader, " + "::grpc::ServerReader< $Request$>* reader, " "$Response$* response);\n"); } else if (ServerOnlyStreaming(method)) { printer->Print(*vars, "virtual ::grpc::Status $Method$(" "::grpc::ServerContext* context, const $Request$* request, " - "::grpc::ServerWriter<$Response$>* writer);\n"); + "::grpc::ServerWriter< $Response$>* writer);\n"); } else if (BidiStreaming(method)) { printer->Print(*vars, "virtual ::grpc::Status $Method$(" "::grpc::ServerContext* context, " - "::grpc::ServerReaderWriter<$Response$, $Request$>* stream);" + "::grpc::ServerReaderWriter< $Response$, $Request$>* stream);" "\n"); } } @@ -211,7 +211,7 @@ void PrintHeaderService(google::protobuf::io::Printer* printer, printer->Outdent(); printer->Print("};\n"); printer->Print( - "static Stub* NewStub(const std::shared_ptr<::grpc::ChannelInterface>& " + "static Stub* NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& " "channel);\n"); printer->Print("\n"); @@ -270,10 +270,10 @@ void PrintSourceClientMethod(google::protobuf::io::Printer* printer, "}\n\n"); } else if (ClientOnlyStreaming(method)) { printer->Print(*vars, - "::grpc::ClientWriter<$Request$>* $Service$::Stub::$Method$(" + "::grpc::ClientWriter< $Request$>* $Service$::Stub::$Method$(" "::grpc::ClientContext* context, $Response$* response) {\n"); printer->Print(*vars, - " return new ::grpc::ClientWriter<$Request$>(" + " return new ::grpc::ClientWriter< $Request$>(" "channel()->CreateStream(" "::grpc::RpcMethod(\"/$Package$$Service$/$Method$\", " "::grpc::RpcMethod::RpcType::CLIENT_STREAMING), " @@ -282,10 +282,10 @@ void PrintSourceClientMethod(google::protobuf::io::Printer* printer, } else if (ServerOnlyStreaming(method)) { printer->Print( *vars, - "::grpc::ClientReader<$Response$>* $Service$::Stub::$Method$(" + "::grpc::ClientReader< $Response$>* $Service$::Stub::$Method$(" "::grpc::ClientContext* context, const $Request$* request) {\n"); printer->Print(*vars, - " return new ::grpc::ClientReader<$Response$>(" + " return new ::grpc::ClientReader< $Response$>(" "channel()->CreateStream(" "::grpc::RpcMethod(\"/$Package$$Service$/$Method$\", " "::grpc::RpcMethod::RpcType::SERVER_STREAMING), " @@ -294,11 +294,11 @@ void PrintSourceClientMethod(google::protobuf::io::Printer* printer, } else if (BidiStreaming(method)) { printer->Print( *vars, - "::grpc::ClientReaderWriter<$Request$, $Response$>* " + "::grpc::ClientReaderWriter< $Request$, $Response$>* " "$Service$::Stub::$Method$(::grpc::ClientContext* context) {\n"); printer->Print( *vars, - " return new ::grpc::ClientReaderWriter<$Request$, $Response$>(" + " return new ::grpc::ClientReaderWriter< $Request$, $Response$>(" "channel()->CreateStream(" "::grpc::RpcMethod(\"/$Package$$Service$/$Method$\", " "::grpc::RpcMethod::RpcType::BIDI_STREAMING), " @@ -328,7 +328,7 @@ void PrintSourceServerMethod(google::protobuf::io::Printer* printer, printer->Print(*vars, "::grpc::Status $Service$::Service::$Method$(" "::grpc::ServerContext* context, " - "::grpc::ServerReader<$Request$>* reader, " + "::grpc::ServerReader< $Request$>* reader, " "$Response$* response) {\n"); printer->Print( " return ::grpc::Status(" @@ -339,7 +339,7 @@ void PrintSourceServerMethod(google::protobuf::io::Printer* printer, "::grpc::Status $Service$::Service::$Method$(" "::grpc::ServerContext* context, " "const $Request$* request, " - "::grpc::ServerWriter<$Response$>* writer) {\n"); + "::grpc::ServerWriter< $Response$>* writer) {\n"); printer->Print( " return ::grpc::Status(" "::grpc::StatusCode::UNIMPLEMENTED);\n"); @@ -348,7 +348,7 @@ void PrintSourceServerMethod(google::protobuf::io::Printer* printer, printer->Print(*vars, "::grpc::Status $Service$::Service::$Method$(" "::grpc::ServerContext* context, " - "::grpc::ServerReaderWriter<$Response$, $Request$>* " + "::grpc::ServerReaderWriter< $Response$, $Request$>* " "stream) {\n"); printer->Print( " return ::grpc::Status(" @@ -363,7 +363,7 @@ void PrintSourceService(google::protobuf::io::Printer* printer, (*vars)["Service"] = service->name(); printer->Print(*vars, "$Service$::Stub* $Service$::NewStub(" - "const std::shared_ptr<::grpc::ChannelInterface>& channel) {\n" + "const std::shared_ptr< ::grpc::ChannelInterface>& channel) {\n" " $Service$::Stub* stub = new $Service$::Stub();\n" " stub->set_channel(channel);\n" " return stub;\n" @@ -400,9 +400,9 @@ void PrintSourceService(google::protobuf::io::Printer* printer, "service_->AddMethod(new ::grpc::RpcServiceMethod(\n" " \"/$Package$$Service$/$Method$\",\n" " ::grpc::RpcMethod::NORMAL_RPC,\n" - " new ::grpc::RpcMethodHandler<$Service$::Service, $Request$, " + " new ::grpc::RpcMethodHandler< $Service$::Service, $Request$, " "$Response$>(\n" - " std::function<::grpc::Status($Service$::Service*, " + " std::function< ::grpc::Status($Service$::Service*, " "::grpc::ServerContext*, const $Request$*, $Response$*)>(" "&$Service$::Service::$Method$), this),\n" " new $Request$, new $Response$));\n"); @@ -412,11 +412,11 @@ void PrintSourceService(google::protobuf::io::Printer* printer, "service_->AddMethod(new ::grpc::RpcServiceMethod(\n" " \"/$Package$$Service$/$Method$\",\n" " ::grpc::RpcMethod::CLIENT_STREAMING,\n" - " new ::grpc::ClientStreamingHandler<" + " new ::grpc::ClientStreamingHandler< " "$Service$::Service, $Request$, $Response$>(\n" - " std::function<::grpc::Status($Service$::Service*, " + " std::function< ::grpc::Status($Service$::Service*, " "::grpc::ServerContext*, " - "::grpc::ServerReader<$Request$>*, $Response$*)>(" + "::grpc::ServerReader< $Request$>*, $Response$*)>(" "&$Service$::Service::$Method$), this),\n" " new $Request$, new $Response$));\n"); } else if (ServerOnlyStreaming(method)) { @@ -425,11 +425,11 @@ void PrintSourceService(google::protobuf::io::Printer* printer, "service_->AddMethod(new ::grpc::RpcServiceMethod(\n" " \"/$Package$$Service$/$Method$\",\n" " ::grpc::RpcMethod::SERVER_STREAMING,\n" - " new ::grpc::ServerStreamingHandler<" + " new ::grpc::ServerStreamingHandler< " "$Service$::Service, $Request$, $Response$>(\n" - " std::function<::grpc::Status($Service$::Service*, " + " std::function< ::grpc::Status($Service$::Service*, " "::grpc::ServerContext*, " - "const $Request$*, ::grpc::ServerWriter<$Response$>*)>(" + "const $Request$*, ::grpc::ServerWriter< $Response$>*)>(" "&$Service$::Service::$Method$), this),\n" " new $Request$, new $Response$));\n"); } else if (BidiStreaming(method)) { @@ -438,11 +438,11 @@ void PrintSourceService(google::protobuf::io::Printer* printer, "service_->AddMethod(new ::grpc::RpcServiceMethod(\n" " \"/$Package$$Service$/$Method$\",\n" " ::grpc::RpcMethod::BIDI_STREAMING,\n" - " new ::grpc::BidiStreamingHandler<" + " new ::grpc::BidiStreamingHandler< " "$Service$::Service, $Request$, $Response$>(\n" - " std::function<::grpc::Status($Service$::Service*, " + " std::function< ::grpc::Status($Service$::Service*, " "::grpc::ServerContext*, " - "::grpc::ServerReaderWriter<$Response$, $Request$>*)>(" + "::grpc::ServerReaderWriter< $Response$, $Request$>*)>(" "&$Service$::Service::$Method$), this),\n" " new $Request$, new $Response$));\n"); } -- cgit v1.2.3 From 5680ff4687deaafc84a96d8f7c50f503c2581e71 Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Wed, 14 Jan 2015 12:14:21 -0800 Subject: Run clang-format-all.sh --- src/compiler/cpp_generator.cc | 33 ++++++++++++++++++--------------- src/core/support/log_posix.c | 1 - test/core/util/test_config.c | 8 ++------ 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 41adb81c6b..94e56d73a6 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -182,11 +182,12 @@ void PrintHeaderServerMethod(google::protobuf::io::Printer* printer, "::grpc::ServerContext* context, const $Request$* request, " "::grpc::ServerWriter< $Response$>* writer);\n"); } else if (BidiStreaming(method)) { - printer->Print(*vars, - "virtual ::grpc::Status $Method$(" - "::grpc::ServerContext* context, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* stream);" - "\n"); + printer->Print( + *vars, + "virtual ::grpc::Status $Method$(" + "::grpc::ServerContext* context, " + "::grpc::ServerReaderWriter< $Response$, $Request$>* stream);" + "\n"); } } @@ -269,9 +270,10 @@ void PrintSourceClientMethod(google::protobuf::io::Printer* printer, "context, request, response);\n" "}\n\n"); } else if (ClientOnlyStreaming(method)) { - printer->Print(*vars, - "::grpc::ClientWriter< $Request$>* $Service$::Stub::$Method$(" - "::grpc::ClientContext* context, $Response$* response) {\n"); + printer->Print( + *vars, + "::grpc::ClientWriter< $Request$>* $Service$::Stub::$Method$(" + "::grpc::ClientContext* context, $Response$* response) {\n"); printer->Print(*vars, " return new ::grpc::ClientWriter< $Request$>(" "channel()->CreateStream(" @@ -361,13 +363,14 @@ void PrintSourceService(google::protobuf::io::Printer* printer, const google::protobuf::ServiceDescriptor* service, map* vars) { (*vars)["Service"] = service->name(); - printer->Print(*vars, - "$Service$::Stub* $Service$::NewStub(" - "const std::shared_ptr< ::grpc::ChannelInterface>& channel) {\n" - " $Service$::Stub* stub = new $Service$::Stub();\n" - " stub->set_channel(channel);\n" - " return stub;\n" - "};\n\n"); + printer->Print( + *vars, + "$Service$::Stub* $Service$::NewStub(" + "const std::shared_ptr< ::grpc::ChannelInterface>& channel) {\n" + " $Service$::Stub* stub = new $Service$::Stub();\n" + " stub->set_channel(channel);\n" + " return stub;\n" + "};\n\n"); for (int i = 0; i < service->method_count(); ++i) { PrintSourceClientMethod(printer, service->method(i), vars); } diff --git a/src/core/support/log_posix.c b/src/core/support/log_posix.c index 55a38b136d..ee2705a2c2 100644 --- a/src/core/support/log_posix.c +++ b/src/core/support/log_posix.c @@ -31,7 +31,6 @@ * */ - #ifndef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200112L #endif diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c index 94245d85bc..44ab35fc5e 100644 --- a/test/core/util/test_config.c +++ b/test/core/util/test_config.c @@ -39,16 +39,12 @@ #if GPR_GETPID_IN_UNISTD_H #include -static int seed() { - return getpid(); -} +static int seed() { return getpid(); } #endif #if GPR_GETPID_IN_PROCESS_H #include -static int seed(void) { - return _getpid(); -} +static int seed(void) { return _getpid(); } #endif void grpc_test_init(int argc, char **argv) { -- cgit v1.2.3