Use clang-format-3.5

pull/104/head
Craig Tiller 10 years ago
parent cf1d6eb4ae
commit ecd49345b5
  1. 12
      .clang-format
  2. 58
      src/compiler/cpp_generator.cc
  3. 6
      src/compiler/cpp_generator.h
  4. 16
      src/compiler/cpp_generator_helpers.h
  5. 16
      src/compiler/cpp_plugin.cc
  6. 10
      src/compiler/ruby_generator.cc
  7. 2
      src/compiler/ruby_generator.h
  8. 6
      src/compiler/ruby_generator_helpers-inl.h
  9. 2
      src/compiler/ruby_generator_map-inl.h
  10. 22
      src/compiler/ruby_generator_string-inl.h
  11. 10
      src/compiler/ruby_plugin.cc
  12. 12
      src/core/channel/census_filter.c
  13. 11
      src/core/channel/channel_stack.c
  14. 4
      src/core/channel/child_channel.c
  15. 4
      src/core/channel/client_channel.c
  16. 6
      src/core/channel/connected_channel.c
  17. 4
      src/core/channel/http_client_filter.c
  18. 4
      src/core/channel/http_filter.c
  19. 4
      src/core/channel/http_server_filter.c
  20. 2
      src/core/channel/metadata_buffer.c
  21. 4
      src/core/channel/noop_filter.c
  22. 5
      src/core/security/auth.c
  23. 8
      src/core/security/security_context.c
  24. 5
      src/core/statistics/census_rpc_stats.c
  25. 3
      src/core/statistics/census_tracing.c
  26. 8
      src/core/support/murmur_hash.c
  27. 4
      src/core/surface/call.c
  28. 2
      src/core/surface/channel.c
  29. 4
      src/core/surface/client.c
  30. 4
      src/core/surface/lame_client.c
  31. 4
      src/core/surface/server.c
  32. 124
      src/core/transport/chttp2/hpack_table.c
  33. 20
      src/core/transport/chttp2/varint.h
  34. 14
      src/core/transport/chttp2_transport.c
  35. 17
      src/core/tsi/fake_transport_security.c
  36. 23
      src/core/tsi/ssl_transport_security.c
  37. 3
      src/core/tsi/ssl_transport_security.h
  38. 56
      src/cpp/client/channel.cc
  39. 22
      src/cpp/client/channel.h
  40. 18
      src/cpp/client/channel_arguments.cc
  41. 8
      src/cpp/client/client_context.cc
  42. 8
      src/cpp/client/create_channel.cc
  43. 40
      src/cpp/client/credentials.cc
  44. 12
      src/cpp/proto/proto_utils.cc
  45. 6
      src/cpp/proto/proto_utils.h
  46. 4
      src/cpp/server/async_server.cc
  47. 16
      src/cpp/server/async_server_context.cc
  48. 8
      src/cpp/server/completion_queue.cc
  49. 16
      src/cpp/server/server.cc
  50. 12
      src/cpp/server/server_builder.cc
  51. 20
      src/cpp/server/server_credentials.cc
  52. 14
      src/cpp/server/server_rpc_handler.cc
  53. 8
      src/cpp/server/server_rpc_handler.h
  54. 4
      src/cpp/server/thread_pool.cc
  55. 2
      src/cpp/server/thread_pool.h
  56. 34
      src/cpp/stream/stream_context.cc
  57. 50
      src/cpp/stream/stream_context.h
  58. 4
      src/cpp/util/status.cc
  59. 4
      src/cpp/util/time.cc
  60. 4
      src/cpp/util/time.h
  61. 19
      src/php/ext/grpc/call.c
  62. 2
      src/php/ext/grpc/channel.c
  63. 16
      src/php/ext/grpc/completion_queue.c
  64. 13
      src/php/ext/grpc/credentials.c
  65. 3
      src/php/ext/grpc/php_grpc.c
  66. 8
      src/php/ext/grpc/server.c
  67. 4
      src/php/ext/grpc/server_credentials.c
  68. 24
      src/php/ext/grpc/timeval.c
  69. 4
      test/core/channel/channel_stack_test.c
  70. 4
      test/core/channel/metadata_buffer_test.c
  71. 1
      test/core/end2end/cq_verifier.c
  72. 2
      test/core/end2end/tests/max_concurrent_streams.c
  73. 4
      test/core/end2end/tests/thread_stress.c
  74. 14
      test/core/iomgr/alarm_list_test.c
  75. 4
      test/core/iomgr/endpoint_tests.c
  76. 22
      test/core/statistics/hash_table_test.c
  77. 14
      test/core/surface/completion_queue_benchmark.c
  78. 20
      test/core/surface/completion_queue_test.c
  79. 6
      test/core/transport/chttp2/stream_map_test.c
  80. 5
      tools/clang-format/clang-format-all.sh
  81. 1
      tools/clang-format/config.sh

@ -2,27 +2,22 @@
Language: Cpp Language: Cpp
# BasedOnStyle: Google # BasedOnStyle: Google
AccessModifierOffset: -1 AccessModifierOffset: -1
AlignAfterOpenBracket: true ConstructorInitializerIndentWidth: 4
AlignEscapedNewlinesLeft: true AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: true AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: true AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true AllowShortLoopsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All AllowShortFunctionsOnASingleLine: All
AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakTemplateDeclarations: true AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: true AlwaysBreakBeforeMultilineStrings: true
BreakBeforeBinaryOperators: None BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: true BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false BreakConstructorInitializersBeforeComma: false
BinPackParameters: true BinPackParameters: true
BinPackArguments: true
ColumnLimit: 80 ColumnLimit: 80
ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
DerivePointerAlignment: true DerivePointerAlignment: true
ExperimentalAutoDetectBinPacking: false ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true IndentCaseLabels: true
@ -31,7 +26,6 @@ IndentFunctionDeclarationAfterType: false
MaxEmptyLinesToKeep: 1 MaxEmptyLinesToKeep: 1
KeepEmptyLinesAtTheStartOfBlocks: false KeepEmptyLinesAtTheStartOfBlocks: false
NamespaceIndentation: None NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 1 PenaltyBreakBeforeFirstCallParameter: 1
@ -49,11 +43,9 @@ TabWidth: 8
UseTab: Never UseTab: Never
BreakBeforeBraces: Attach BreakBeforeBraces: Attach
SpacesInParentheses: false SpacesInParentheses: false
SpacesInSquareBrackets: false
SpacesInAngles: false SpacesInAngles: false
SpaceInEmptyParentheses: false SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false SpacesInCStyleCastParentheses: false
SpaceAfterCStyleCast: false
SpacesInContainerLiterals: true SpacesInContainerLiterals: true
SpaceBeforeAssignmentOperators: true SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4 ContinuationIndentWidth: 4

@ -45,23 +45,23 @@
namespace grpc_cpp_generator { namespace grpc_cpp_generator {
namespace { namespace {
bool NoStreaming(const google::protobuf::MethodDescriptor* method) { bool NoStreaming(const google::protobuf::MethodDescriptor *method) {
return !method->client_streaming() && !method->server_streaming(); return !method->client_streaming() && !method->server_streaming();
} }
bool ClientOnlyStreaming(const google::protobuf::MethodDescriptor* method) { bool ClientOnlyStreaming(const google::protobuf::MethodDescriptor *method) {
return method->client_streaming() && !method->server_streaming(); return method->client_streaming() && !method->server_streaming();
} }
bool ServerOnlyStreaming(const google::protobuf::MethodDescriptor* method) { bool ServerOnlyStreaming(const google::protobuf::MethodDescriptor *method) {
return !method->client_streaming() && method->server_streaming(); return !method->client_streaming() && method->server_streaming();
} }
bool BidiStreaming(const google::protobuf::MethodDescriptor* method) { bool BidiStreaming(const google::protobuf::MethodDescriptor *method) {
return method->client_streaming() && method->server_streaming(); return method->client_streaming() && method->server_streaming();
} }
bool HasClientOnlyStreaming(const google::protobuf::FileDescriptor* file) { bool HasClientOnlyStreaming(const google::protobuf::FileDescriptor *file) {
for (int i = 0; i < file->service_count(); i++) { for (int i = 0; i < file->service_count(); i++) {
for (int j = 0; j < file->service(i)->method_count(); j++) { for (int j = 0; j < file->service(i)->method_count(); j++) {
if (ClientOnlyStreaming(file->service(i)->method(j))) { if (ClientOnlyStreaming(file->service(i)->method(j))) {
@ -72,7 +72,7 @@ bool HasClientOnlyStreaming(const google::protobuf::FileDescriptor* file) {
return false; return false;
} }
bool HasServerOnlyStreaming(const google::protobuf::FileDescriptor* file) { bool HasServerOnlyStreaming(const google::protobuf::FileDescriptor *file) {
for (int i = 0; i < file->service_count(); i++) { for (int i = 0; i < file->service_count(); i++) {
for (int j = 0; j < file->service(i)->method_count(); j++) { for (int j = 0; j < file->service(i)->method_count(); j++) {
if (ServerOnlyStreaming(file->service(i)->method(j))) { if (ServerOnlyStreaming(file->service(i)->method(j))) {
@ -83,7 +83,7 @@ bool HasServerOnlyStreaming(const google::protobuf::FileDescriptor* file) {
return false; return false;
} }
bool HasBidiStreaming(const google::protobuf::FileDescriptor* file) { bool HasBidiStreaming(const google::protobuf::FileDescriptor *file) {
for (int i = 0; i < file->service_count(); i++) { for (int i = 0; i < file->service_count(); i++) {
for (int j = 0; j < file->service(i)->method_count(); j++) { for (int j = 0; j < file->service(i)->method_count(); j++) {
if (BidiStreaming(file->service(i)->method(j))) { if (BidiStreaming(file->service(i)->method(j))) {
@ -95,7 +95,7 @@ bool HasBidiStreaming(const google::protobuf::FileDescriptor* file) {
} }
} // namespace } // namespace
std::string GetHeaderIncludes(const google::protobuf::FileDescriptor* file) { std::string GetHeaderIncludes(const google::protobuf::FileDescriptor *file) {
std::string temp = std::string temp =
"#include \"grpc++/impl/internal_stub.h\"\n" "#include \"grpc++/impl/internal_stub.h\"\n"
"#include \"grpc++/status.h\"\n" "#include \"grpc++/status.h\"\n"
@ -131,9 +131,9 @@ std::string GetSourceIncludes() {
"#include \"grpc++/stream.h\"\n"; "#include \"grpc++/stream.h\"\n";
} }
void PrintHeaderClientMethod(google::protobuf::io::Printer* printer, void PrintHeaderClientMethod(google::protobuf::io::Printer *printer,
const google::protobuf::MethodDescriptor* method, const google::protobuf::MethodDescriptor *method,
std::map<std::string, std::string>* vars) { std::map<std::string, std::string> *vars) {
(*vars)["Method"] = method->name(); (*vars)["Method"] = method->name();
(*vars)["Request"] = (*vars)["Request"] =
grpc_cpp_generator::ClassName(method->input_type(), true); grpc_cpp_generator::ClassName(method->input_type(), true);
@ -160,9 +160,9 @@ void PrintHeaderClientMethod(google::protobuf::io::Printer* printer,
} }
} }
void PrintHeaderServerMethod(google::protobuf::io::Printer* printer, void PrintHeaderServerMethod(google::protobuf::io::Printer *printer,
const google::protobuf::MethodDescriptor* method, const google::protobuf::MethodDescriptor *method,
std::map<std::string, std::string>* vars) { std::map<std::string, std::string> *vars) {
(*vars)["Method"] = method->name(); (*vars)["Method"] = method->name();
(*vars)["Request"] = (*vars)["Request"] =
grpc_cpp_generator::ClassName(method->input_type(), true); grpc_cpp_generator::ClassName(method->input_type(), true);
@ -194,9 +194,9 @@ void PrintHeaderServerMethod(google::protobuf::io::Printer* printer,
} }
} }
void PrintHeaderService(google::protobuf::io::Printer* printer, void PrintHeaderService(google::protobuf::io::Printer *printer,
const google::protobuf::ServiceDescriptor* service, const google::protobuf::ServiceDescriptor *service,
std::map<std::string, std::string>* vars) { std::map<std::string, std::string> *vars) {
(*vars)["Service"] = service->name(); (*vars)["Service"] = service->name();
printer->Print(*vars, printer->Print(*vars,
@ -241,7 +241,7 @@ void PrintHeaderService(google::protobuf::io::Printer* printer,
printer->Print("};\n"); printer->Print("};\n");
} }
std::string GetHeaderServices(const google::protobuf::FileDescriptor* file) { std::string GetHeaderServices(const google::protobuf::FileDescriptor *file) {
std::string output; std::string output;
google::protobuf::io::StringOutputStream output_stream(&output); google::protobuf::io::StringOutputStream output_stream(&output);
google::protobuf::io::Printer printer(&output_stream, '$'); google::protobuf::io::Printer printer(&output_stream, '$');
@ -254,9 +254,9 @@ std::string GetHeaderServices(const google::protobuf::FileDescriptor* file) {
return output; return output;
} }
void PrintSourceClientMethod(google::protobuf::io::Printer* printer, void PrintSourceClientMethod(google::protobuf::io::Printer *printer,
const google::protobuf::MethodDescriptor* method, const google::protobuf::MethodDescriptor *method,
std::map<std::string, std::string>* vars) { std::map<std::string, std::string> *vars) {
(*vars)["Method"] = method->name(); (*vars)["Method"] = method->name();
(*vars)["Request"] = (*vars)["Request"] =
grpc_cpp_generator::ClassName(method->input_type(), true); grpc_cpp_generator::ClassName(method->input_type(), true);
@ -312,9 +312,9 @@ void PrintSourceClientMethod(google::protobuf::io::Printer* printer,
} }
} }
void PrintSourceServerMethod(google::protobuf::io::Printer* printer, void PrintSourceServerMethod(google::protobuf::io::Printer *printer,
const google::protobuf::MethodDescriptor* method, const google::protobuf::MethodDescriptor *method,
std::map<std::string, std::string>* vars) { std::map<std::string, std::string> *vars) {
(*vars)["Method"] = method->name(); (*vars)["Method"] = method->name();
(*vars)["Request"] = (*vars)["Request"] =
grpc_cpp_generator::ClassName(method->input_type(), true); grpc_cpp_generator::ClassName(method->input_type(), true);
@ -362,9 +362,9 @@ void PrintSourceServerMethod(google::protobuf::io::Printer* printer,
} }
} }
void PrintSourceService(google::protobuf::io::Printer* printer, void PrintSourceService(google::protobuf::io::Printer *printer,
const google::protobuf::ServiceDescriptor* service, const google::protobuf::ServiceDescriptor *service,
std::map<std::string, std::string>* vars) { std::map<std::string, std::string> *vars) {
(*vars)["Service"] = service->name(); (*vars)["Service"] = service->name();
printer->Print( printer->Print(
*vars, *vars,
@ -394,7 +394,7 @@ void PrintSourceService(google::protobuf::io::Printer* printer,
"}\n"); "}\n");
printer->Print("service_ = new ::grpc::RpcService();\n"); printer->Print("service_ = new ::grpc::RpcService();\n");
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
const google::protobuf::MethodDescriptor* method = service->method(i); const google::protobuf::MethodDescriptor *method = service->method(i);
(*vars)["Method"] = method->name(); (*vars)["Method"] = method->name();
(*vars)["Request"] = (*vars)["Request"] =
grpc_cpp_generator::ClassName(method->input_type(), true); grpc_cpp_generator::ClassName(method->input_type(), true);
@ -458,7 +458,7 @@ void PrintSourceService(google::protobuf::io::Printer* printer,
printer->Print("}\n\n"); printer->Print("}\n\n");
} }
std::string GetSourceServices(const google::protobuf::FileDescriptor* file) { std::string GetSourceServices(const google::protobuf::FileDescriptor *file) {
std::string output; std::string output;
google::protobuf::io::StringOutputStream output_stream(&output); google::protobuf::io::StringOutputStream output_stream(&output);
google::protobuf::io::Printer printer(&output_stream, '$'); google::protobuf::io::Printer printer(&output_stream, '$');

@ -45,16 +45,16 @@ class FileDescriptor;
namespace grpc_cpp_generator { namespace grpc_cpp_generator {
// Return the includes needed for generated header file. // Return the includes needed for generated header file.
std::string GetHeaderIncludes(const google::protobuf::FileDescriptor* file); std::string GetHeaderIncludes(const google::protobuf::FileDescriptor *file);
// Return the includes needed for generated source file. // Return the includes needed for generated source file.
std::string GetSourceIncludes(); std::string GetSourceIncludes();
// Return the services for generated header file. // Return the services for generated header file.
std::string GetHeaderServices(const google::protobuf::FileDescriptor* file); std::string GetHeaderServices(const google::protobuf::FileDescriptor *file);
// Return the services for generated source file. // Return the services for generated source file.
std::string GetSourceServices(const google::protobuf::FileDescriptor* file); std::string GetSourceServices(const google::protobuf::FileDescriptor *file);
} // namespace grpc_cpp_generator } // namespace grpc_cpp_generator

@ -41,7 +41,7 @@
namespace grpc_cpp_generator { namespace grpc_cpp_generator {
inline bool StripSuffix(std::string* filename, const std::string& suffix) { inline bool StripSuffix(std::string *filename, const std::string &suffix) {
if (filename->length() >= suffix.length()) { if (filename->length() >= suffix.length()) {
size_t suffix_pos = filename->length() - suffix.length(); size_t suffix_pos = filename->length() - suffix.length();
if (filename->compare(suffix_pos, std::string::npos, suffix) == 0) { if (filename->compare(suffix_pos, std::string::npos, suffix) == 0) {
@ -60,8 +60,8 @@ inline std::string StripProto(std::string filename) {
return filename; return filename;
} }
inline std::string StringReplace(std::string str, const std::string& from, inline std::string StringReplace(std::string str, const std::string &from,
const std::string& to) { const std::string &to) {
size_t pos = 0; size_t pos = 0;
for (;;) { for (;;) {
@ -76,22 +76,22 @@ inline std::string StringReplace(std::string str, const std::string& from,
return str; return str;
} }
inline std::string DotsToColons(const std::string& name) { inline std::string DotsToColons(const std::string &name) {
return StringReplace(name, ".", "::"); return StringReplace(name, ".", "::");
} }
inline std::string DotsToUnderscores(const std::string& name) { inline std::string DotsToUnderscores(const std::string &name) {
return StringReplace(name, ".", "_"); return StringReplace(name, ".", "_");
} }
inline std::string ClassName(const google::protobuf::Descriptor* descriptor, inline std::string ClassName(const google::protobuf::Descriptor *descriptor,
bool qualified) { bool qualified) {
// Find "outer", the descriptor of the top-level message in which // Find "outer", the descriptor of the top-level message in which
// "descriptor" is embedded. // "descriptor" is embedded.
const google::protobuf::Descriptor* outer = descriptor; const google::protobuf::Descriptor *outer = descriptor;
while (outer->containing_type() != NULL) outer = outer->containing_type(); while (outer->containing_type() != NULL) outer = outer->containing_type();
const std::string& outer_name = outer->full_name(); const std::string &outer_name = outer->full_name();
std::string inner_name = descriptor->full_name().substr(outer_name.size()); std::string inner_name = descriptor->full_name().substr(outer_name.size());
if (qualified) { if (qualified) {

@ -51,10 +51,10 @@ class CppGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
CppGrpcGenerator() {} CppGrpcGenerator() {}
virtual ~CppGrpcGenerator() {} virtual ~CppGrpcGenerator() {}
virtual bool Generate(const google::protobuf::FileDescriptor* file, virtual bool Generate(const google::protobuf::FileDescriptor *file,
const std::string& parameter, const std::string &parameter,
google::protobuf::compiler::GeneratorContext* context, google::protobuf::compiler::GeneratorContext *context,
std::string* error) const { std::string *error) const {
if (file->options().cc_generic_services()) { if (file->options().cc_generic_services()) {
*error = *error =
"cpp grpc proto compiler plugin does not work with generic " "cpp grpc proto compiler plugin does not work with generic "
@ -81,9 +81,9 @@ class CppGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
private: private:
// Insert the given code into the given file at the given insertion point. // Insert the given code into the given file at the given insertion point.
void Insert(google::protobuf::compiler::GeneratorContext* context, void Insert(google::protobuf::compiler::GeneratorContext *context,
const std::string& filename, const std::string& insertion_point, const std::string &filename, const std::string &insertion_point,
const std::string& code) const { const std::string &code) const {
std::unique_ptr<google::protobuf::io::ZeroCopyOutputStream> output( std::unique_ptr<google::protobuf::io::ZeroCopyOutputStream> output(
context->OpenForInsert(filename, insertion_point)); context->OpenForInsert(filename, insertion_point));
google::protobuf::io::CodedOutputStream coded_out(output.get()); google::protobuf::io::CodedOutputStream coded_out(output.get());
@ -91,7 +91,7 @@ class CppGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
} }
}; };
int main(int argc, char* argv[]) { int main(int argc, char *argv[]) {
CppGrpcGenerator generator; CppGrpcGenerator generator;
return google::protobuf::compiler::PluginMain(argc, argv, &generator); return google::protobuf::compiler::PluginMain(argc, argv, &generator);
} }

@ -57,8 +57,8 @@ namespace grpc_ruby_generator {
namespace { namespace {
// Prints out the method using the ruby gRPC DSL. // Prints out the method using the ruby gRPC DSL.
void PrintMethod(const MethodDescriptor* method, const std::string& package, void PrintMethod(const MethodDescriptor *method, const std::string &package,
Printer* out) { Printer *out) {
std::string input_type = RubyTypeOf(method->input_type()->name(), package); std::string input_type = RubyTypeOf(method->input_type()->name(), package);
if (method->client_streaming()) { if (method->client_streaming()) {
input_type = "stream(" + input_type + ")"; input_type = "stream(" + input_type + ")";
@ -75,8 +75,8 @@ void PrintMethod(const MethodDescriptor* method, const std::string& package,
} }
// Prints out the service using the ruby gRPC DSL. // Prints out the service using the ruby gRPC DSL.
void PrintService(const ServiceDescriptor* service, const std::string& package, void PrintService(const ServiceDescriptor *service, const std::string &package,
Printer* out) { Printer *out) {
if (service->method_count() == 0) { if (service->method_count() == 0) {
return; return;
} }
@ -125,7 +125,7 @@ void PrintService(const ServiceDescriptor* service, const std::string& package,
} // namespace } // namespace
std::string GetServices(const FileDescriptor* file) { std::string GetServices(const FileDescriptor *file) {
std::string output; std::string output;
StringOutputStream output_stream(&output); StringOutputStream output_stream(&output);
Printer out(&output_stream, '$'); Printer out(&output_stream, '$');

@ -44,7 +44,7 @@ class FileDescriptor;
namespace grpc_ruby_generator { namespace grpc_ruby_generator {
std::string GetServices(const google::protobuf::FileDescriptor* file); std::string GetServices(const google::protobuf::FileDescriptor *file);
} // namespace grpc_ruby_generator } // namespace grpc_ruby_generator

@ -41,8 +41,8 @@
namespace grpc_ruby_generator { namespace grpc_ruby_generator {
inline bool ServicesFilename(const google::protobuf::FileDescriptor* file, inline bool ServicesFilename(const google::protobuf::FileDescriptor *file,
std::string* file_name_or_error) { std::string *file_name_or_error) {
// Get output file name. // Get output file name.
static const unsigned proto_suffix_length = 6; // length of ".proto" static const unsigned proto_suffix_length = 6; // length of ".proto"
if (file->name().size() > proto_suffix_length && if (file->name().size() > proto_suffix_length &&
@ -58,7 +58,7 @@ inline bool ServicesFilename(const google::protobuf::FileDescriptor* file,
} }
inline std::string MessagesRequireName( inline std::string MessagesRequireName(
const google::protobuf::FileDescriptor* file) { const google::protobuf::FileDescriptor *file) {
return Replace(file->name(), ".proto", ""); return Replace(file->name(), ".proto", "");
} }

@ -49,7 +49,7 @@ namespace grpc_ruby_generator {
// Converts an initializer list of the form { key0, value0, key1, value1, ... } // Converts an initializer list of the form { key0, value0, key1, value1, ... }
// into a map of key* to value*. Is merely a readability helper for later code. // into a map of key* to value*. Is merely a readability helper for later code.
inline std::map<std::string, std::string> ListToDict( inline std::map<std::string, std::string> ListToDict(
const initializer_list<std::string>& values) { const initializer_list<std::string> &values) {
if (values.size() % 2 != 0) { if (values.size() % 2 != 0) {
// MOE: insert std::cerr << "Not every 'key' has a value in `values`." // MOE: insert std::cerr << "Not every 'key' has a value in `values`."
// << std::endl; // << std::endl;

@ -45,8 +45,8 @@ using std::transform;
namespace grpc_ruby_generator { namespace grpc_ruby_generator {
// Split splits a string using char into elems. // Split splits a string using char into elems.
inline std::vector<std::string>& Split(const std::string& s, char delim, inline std::vector<std::string> &Split(const std::string &s, char delim,
std::vector<std::string>* elems) { std::vector<std::string> *elems) {
std::stringstream ss(s); std::stringstream ss(s);
std::string item; std::string item;
while (getline(ss, item, delim)) { while (getline(ss, item, delim)) {
@ -56,15 +56,15 @@ inline std::vector<std::string>& Split(const std::string& s, char delim,
} }
// Split splits a string using char, returning the result in a vector. // Split splits a string using char, returning the result in a vector.
inline std::vector<std::string> Split(const std::string& s, char delim) { inline std::vector<std::string> Split(const std::string &s, char delim) {
std::vector<std::string> elems; std::vector<std::string> elems;
Split(s, delim, &elems); Split(s, delim, &elems);
return elems; return elems;
} }
// Replace replaces from with to in s. // Replace replaces from with to in s.
inline std::string Replace(std::string s, const std::string& from, inline std::string Replace(std::string s, const std::string &from,
const std::string& to) { const std::string &to) {
size_t start_pos = s.find(from); size_t start_pos = s.find(from);
if (start_pos == std::string::npos) { if (start_pos == std::string::npos) {
return s; return s;
@ -74,8 +74,8 @@ inline std::string Replace(std::string s, const std::string& from,
} }
// ReplaceAll replaces all instances of search with replace in s. // ReplaceAll replaces all instances of search with replace in s.
inline std::string ReplaceAll(std::string s, const std::string& search, inline std::string ReplaceAll(std::string s, const std::string &search,
const std::string& replace) { const std::string &replace) {
size_t pos = 0; size_t pos = 0;
while ((pos = s.find(search, pos)) != std::string::npos) { while ((pos = s.find(search, pos)) != std::string::npos) {
s.replace(pos, search.length(), replace); s.replace(pos, search.length(), replace);
@ -85,8 +85,8 @@ inline std::string ReplaceAll(std::string s, const std::string& search,
} }
// ReplacePrefix replaces from with to in s if search is a prefix of s. // ReplacePrefix replaces from with to in s if search is a prefix of s.
inline bool ReplacePrefix(std::string* s, const std::string& from, inline bool ReplacePrefix(std::string *s, const std::string &from,
const std::string& to) { const std::string &to) {
size_t start_pos = s->find(from); size_t start_pos = s->find(from);
if (start_pos == std::string::npos || start_pos != 0) { if (start_pos == std::string::npos || start_pos != 0) {
return false; return false;
@ -105,8 +105,8 @@ inline std::string CapitalizeFirst(std::string s) {
} }
// RubyTypeOf updates a proto type to the required ruby equivalent. // RubyTypeOf updates a proto type to the required ruby equivalent.
inline std::string RubyTypeOf(const std::string& a_type, inline std::string RubyTypeOf(const std::string &a_type,
const std::string& package) { const std::string &package) {
std::string res(a_type); std::string res(a_type);
ReplacePrefix(&res, package, ""); // remove the leading package if present ReplacePrefix(&res, package, ""); // remove the leading package if present
ReplacePrefix(&res, ".", ""); // remove the leading . (no package) ReplacePrefix(&res, ".", ""); // remove the leading . (no package)

@ -52,10 +52,10 @@ class RubyGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
RubyGrpcGenerator() {} RubyGrpcGenerator() {}
~RubyGrpcGenerator() override {} ~RubyGrpcGenerator() override {}
bool Generate(const google::protobuf::FileDescriptor* file, bool Generate(const google::protobuf::FileDescriptor *file,
const std::string& parameter, const std::string &parameter,
google::protobuf::compiler::GeneratorContext* context, google::protobuf::compiler::GeneratorContext *context,
std::string* error) const override { std::string *error) const override {
std::string code = grpc_ruby_generator::GetServices(file); std::string code = grpc_ruby_generator::GetServices(file);
if (code.size() == 0) { if (code.size() == 0) {
return true; // don't generate a file if there are no services return true; // don't generate a file if there are no services
@ -74,7 +74,7 @@ class RubyGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
} }
}; };
int main(int argc, char* argv[]) { int main(int argc, char *argv[]) {
RubyGrpcGenerator generator; RubyGrpcGenerator generator;
return google::protobuf::compiler::PluginMain(argc, argv, &generator); return google::protobuf::compiler::PluginMain(argc, argv, &generator);
} }

@ -178,19 +178,19 @@ static void destroy_channel_elem(grpc_channel_element* elem) {
} }
const grpc_channel_filter grpc_client_census_filter = { const grpc_channel_filter grpc_client_census_filter = {
client_call_op, channel_op, client_call_op, channel_op,
sizeof(call_data), client_init_call_elem, client_destroy_call_elem, sizeof(call_data), client_init_call_elem, client_destroy_call_elem,
sizeof(channel_data), init_channel_elem, destroy_channel_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem,
"census-client"}; "census-client"};
const grpc_channel_filter grpc_server_census_filter = { const grpc_channel_filter grpc_server_census_filter = {
server_call_op, channel_op, server_call_op, channel_op,
sizeof(call_data), server_init_call_elem, server_destroy_call_elem, sizeof(call_data), server_init_call_elem, server_destroy_call_elem,
sizeof(channel_data), init_channel_elem, destroy_channel_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem,
"census-server"}; "census-server"};

@ -54,7 +54,7 @@
/* Given a size, round up to the next multiple of sizeof(void*) */ /* Given a size, round up to the next multiple of sizeof(void*) */
#define ROUND_UP_TO_ALIGNMENT_SIZE(x) \ #define ROUND_UP_TO_ALIGNMENT_SIZE(x) \
(((x) + GPR_MAX_ALIGNMENT - 1) & ~(GPR_MAX_ALIGNMENT - 1)) (((x)+GPR_MAX_ALIGNMENT - 1) & ~(GPR_MAX_ALIGNMENT - 1))
size_t grpc_channel_stack_size(const grpc_channel_filter **filters, size_t grpc_channel_stack_size(const grpc_channel_filter **filters,
size_t filter_count) { size_t filter_count) {
@ -190,13 +190,14 @@ void grpc_channel_next_op(grpc_channel_element *elem, grpc_channel_op *op) {
grpc_channel_stack *grpc_channel_stack_from_top_element( grpc_channel_stack *grpc_channel_stack_from_top_element(
grpc_channel_element *elem) { grpc_channel_element *elem) {
return (grpc_channel_stack *)((char *)(elem)-ROUND_UP_TO_ALIGNMENT_SIZE( return (grpc_channel_stack *)((char *)(elem) -
sizeof(grpc_channel_stack))); ROUND_UP_TO_ALIGNMENT_SIZE(
sizeof(grpc_channel_stack)));
} }
grpc_call_stack *grpc_call_stack_from_top_element(grpc_call_element *elem) { grpc_call_stack *grpc_call_stack_from_top_element(grpc_call_element *elem) {
return (grpc_call_stack *)((char *)(elem)-ROUND_UP_TO_ALIGNMENT_SIZE( return (grpc_call_stack *)((char *)(elem) - ROUND_UP_TO_ALIGNMENT_SIZE(
sizeof(grpc_call_stack))); sizeof(grpc_call_stack)));
} }
static void do_nothing(void *user_data, grpc_op_error error) {} static void do_nothing(void *user_data, grpc_op_error error) {}

@ -165,9 +165,9 @@ static void lb_destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_child_channel_top_filter = { const grpc_channel_filter grpc_child_channel_top_filter = {
lb_call_op, lb_channel_op, lb_call_op, lb_channel_op,
sizeof(lb_call_data), lb_init_call_elem, lb_destroy_call_elem, sizeof(lb_call_data), lb_init_call_elem, lb_destroy_call_elem,
sizeof(lb_channel_data), lb_init_channel_elem, lb_destroy_channel_elem, sizeof(lb_channel_data), lb_init_channel_elem, lb_destroy_channel_elem,

@ -450,9 +450,9 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_client_channel_filter = { const grpc_channel_filter grpc_client_channel_filter = {
call_op, channel_op, call_op, channel_op,
sizeof(call_data), init_call_elem, destroy_call_elem, sizeof(call_data), init_call_elem, destroy_call_elem,
sizeof(channel_data), init_channel_elem, destroy_channel_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem,

@ -69,7 +69,7 @@ typedef struct {
/* We perform a small hack to locate transport data alongside the connected /* We perform a small hack to locate transport data alongside the connected
channel data in call allocations, to allow everything to be pulled in minimal channel data in call allocations, to allow everything to be pulled in minimal
cache line requests */ cache line requests */
#define TRANSPORT_STREAM_FROM_CALL_DATA(calld) ((grpc_stream *)((calld) + 1)) #define TRANSPORT_STREAM_FROM_CALL_DATA(calld) ((grpc_stream *)((calld)+1))
#define CALL_DATA_FROM_TRANSPORT_STREAM(transport_stream) \ #define CALL_DATA_FROM_TRANSPORT_STREAM(transport_stream) \
(((call_data *)(transport_stream)) - 1) (((call_data *)(transport_stream)) - 1)
@ -257,9 +257,9 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_connected_channel_filter = { const grpc_channel_filter grpc_connected_channel_filter = {
call_op, channel_op, call_op, channel_op,
sizeof(call_data), init_call_elem, destroy_call_elem, sizeof(call_data), init_call_elem, destroy_call_elem,
sizeof(channel_data), init_channel_elem, destroy_channel_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem,

@ -178,9 +178,9 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_http_client_filter = { const grpc_channel_filter grpc_http_client_filter = {
call_op, channel_op, call_op, channel_op,
sizeof(call_data), init_call_elem, destroy_call_elem, sizeof(call_data), init_call_elem, destroy_call_elem,
sizeof(channel_data), init_channel_elem, destroy_channel_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem,

@ -132,9 +132,9 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_http_filter = { const grpc_channel_filter grpc_http_filter = {
call_op, channel_op, call_op, channel_op,
sizeof(call_data), init_call_elem, destroy_call_elem, sizeof(call_data), init_call_elem, destroy_call_elem,
sizeof(channel_data), init_channel_elem, destroy_channel_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem,

@ -244,9 +244,9 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_http_server_filter = { const grpc_channel_filter grpc_http_server_filter = {
call_op, channel_op, call_op, channel_op,
sizeof(call_data), init_call_elem, destroy_call_elem, sizeof(call_data), init_call_elem, destroy_call_elem,
sizeof(channel_data), init_channel_elem, destroy_channel_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem,

@ -61,7 +61,7 @@ struct grpc_metadata_buffer_impl {
size_t elem_cap; size_t elem_cap;
}; };
#define ELEMS(buffer) ((qelem *)((buffer) + 1)) #define ELEMS(buffer) ((qelem *)((buffer)+1))
void grpc_metadata_buffer_init(grpc_metadata_buffer *buffer) { void grpc_metadata_buffer_init(grpc_metadata_buffer *buffer) {
/* start buffer as NULL, indicating no elements */ /* start buffer as NULL, indicating no elements */

@ -131,9 +131,9 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_no_op_filter = { const grpc_channel_filter grpc_no_op_filter = {
call_op, channel_op, call_op, channel_op,
sizeof(call_data), init_call_elem, destroy_call_elem, sizeof(call_data), init_call_elem, destroy_call_elem,
sizeof(channel_data), init_channel_elem, destroy_channel_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem,

@ -157,5 +157,6 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
const grpc_channel_filter grpc_client_auth_filter = { const grpc_channel_filter grpc_client_auth_filter = {
call_op, channel_op, sizeof(call_data), init_call_elem, destroy_call_elem, call_op, channel_op, sizeof(call_data),
sizeof(channel_data), init_channel_elem, destroy_channel_elem, "auth"}; init_call_elem, destroy_call_elem, sizeof(channel_data),
init_channel_elem, destroy_channel_elem, "auth"};

@ -413,10 +413,10 @@ grpc_security_status grpc_ssl_server_security_context_create(
(const unsigned char **)&config->pem_private_key, (const unsigned char **)&config->pem_private_key,
&config->pem_private_key_size, &config->pem_private_key_size,
(const unsigned char **)&config->pem_cert_chain, (const unsigned char **)&config->pem_cert_chain,
&config->pem_cert_chain_size, 1, &config->pem_cert_chain_size, 1, config->pem_root_certs,
config->pem_root_certs, config->pem_root_certs_size, config->pem_root_certs_size, GRPC_SSL_CIPHER_SUITES,
GRPC_SSL_CIPHER_SUITES, alpn_protocol_strings, alpn_protocol_strings, alpn_protocol_string_lengths, num_alpn_protocols,
alpn_protocol_string_lengths, num_alpn_protocols, &c->handshaker_factory); &c->handshaker_factory);
if (result != TSI_OK) { if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.", gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
tsi_result_to_string(result)); tsi_result_to_string(result));

@ -85,8 +85,9 @@ static void delete_key(void* key) { gpr_free(key); }
static const census_ht_option ht_opt = { static const census_ht_option ht_opt = {
CENSUS_HT_POINTER /* key type */, 1999 /* n_of_buckets */, CENSUS_HT_POINTER /* key type */, 1999 /* n_of_buckets */,
simple_hash /* hash function */, cmp_str_keys /* key comparator */, simple_hash /* hash function */, cmp_str_keys /* key comparator */,
delete_stats /* data deleter */, delete_key /* key deleter */}; delete_stats /* data deleter */, delete_key /* key deleter */
};
static void init_rpc_stats(void* stats) { static void init_rpc_stats(void* stats) {
memset(stats, 0, sizeof(census_rpc_stats)); memset(stats, 0, sizeof(census_rpc_stats));

@ -76,7 +76,8 @@ static void delete_trace_obj(void* obj) { trace_obj_destroy((trace_obj*)obj); }
static const census_ht_option ht_opt = { static const census_ht_option ht_opt = {
CENSUS_HT_UINT64 /* key type*/, 571 /* n_of_buckets */, NULL /* hash */, CENSUS_HT_UINT64 /* key type*/, 571 /* n_of_buckets */, NULL /* hash */,
NULL /* compare_keys */, delete_trace_obj /* delete data */, NULL /* compare_keys */, delete_trace_obj /* delete data */,
NULL /* delete key */}; NULL /* delete key */
};
static gpr_once g_init_mutex_once = GPR_ONCE_INIT; static gpr_once g_init_mutex_once = GPR_ONCE_INIT;
static gpr_mu g_mu; /* Guards following two static variables. */ static gpr_mu g_mu; /* Guards following two static variables. */

@ -46,8 +46,8 @@
handle aligned reads, do the conversion here */ handle aligned reads, do the conversion here */
#define GETBLOCK32(p, i) (p)[(i)] #define GETBLOCK32(p, i) (p)[(i)]
gpr_uint32 gpr_murmur_hash3(const void* key, size_t len, gpr_uint32 seed) { gpr_uint32 gpr_murmur_hash3(const void *key, size_t len, gpr_uint32 seed) {
const gpr_uint8* data = (const gpr_uint8*)key; const gpr_uint8 *data = (const gpr_uint8 *)key;
const int nblocks = len / 4; const int nblocks = len / 4;
int i; int i;
@ -57,8 +57,8 @@ gpr_uint32 gpr_murmur_hash3(const void* key, size_t len, gpr_uint32 seed) {
const gpr_uint32 c1 = 0xcc9e2d51; const gpr_uint32 c1 = 0xcc9e2d51;
const gpr_uint32 c2 = 0x1b873593; const gpr_uint32 c2 = 0x1b873593;
const gpr_uint32* blocks = (const uint32_t*)(data + nblocks * 4); const gpr_uint32 *blocks = (const uint32_t *)(data + nblocks * 4);
const uint8_t* tail = (const uint8_t*)(data + nblocks * 4); const uint8_t *tail = (const uint8_t *)(data + nblocks * 4);
/* body */ /* body */
for (i = -nblocks; i; i++) { for (i = -nblocks; i; i++) {

@ -198,7 +198,7 @@ struct grpc_call {
gpr_refcount internal_refcount; gpr_refcount internal_refcount;
}; };
#define CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call) + 1)) #define CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call)+1))
#define CALL_FROM_CALL_STACK(call_stack) (((grpc_call *)(call_stack)) - 1) #define CALL_FROM_CALL_STACK(call_stack) (((grpc_call *)(call_stack)) - 1)
#define CALL_ELEM_FROM_CALL(call, idx) \ #define CALL_ELEM_FROM_CALL(call, idx) \
grpc_call_stack_element(CALL_STACK_FROM_CALL(call), idx) grpc_call_stack_element(CALL_STACK_FROM_CALL(call), idx)
@ -801,7 +801,7 @@ static gpr_uint32 decode_status(grpc_mdelem *md) {
gpr_uint32 status; gpr_uint32 status;
void *user_data = grpc_mdelem_get_user_data(md, destroy_status); void *user_data = grpc_mdelem_get_user_data(md, destroy_status);
if (user_data) { if (user_data) {
status = ((gpr_uint32)(gpr_intptr)user_data) - STATUS_OFFSET; status = ((gpr_uint32)(gpr_intptr) user_data) - STATUS_OFFSET;
} else { } else {
if (!gpr_parse_bytes_to_uint32(grpc_mdstr_as_c_string(md->value), if (!gpr_parse_bytes_to_uint32(grpc_mdstr_as_c_string(md->value),
GPR_SLICE_LENGTH(md->value->slice), GPR_SLICE_LENGTH(md->value->slice),

@ -51,7 +51,7 @@ struct grpc_channel {
grpc_mdstr *authority_string; grpc_mdstr *authority_string;
}; };
#define CHANNEL_STACK_FROM_CHANNEL(c) ((grpc_channel_stack *)((c) + 1)) #define CHANNEL_STACK_FROM_CHANNEL(c) ((grpc_channel_stack *)((c)+1))
grpc_channel *grpc_channel_create_from_filters( grpc_channel *grpc_channel_create_from_filters(
const grpc_channel_filter **filters, size_t num_filters, const grpc_channel_filter **filters, size_t num_filters,

@ -109,9 +109,9 @@ static void init_channel_elem(grpc_channel_element *elem,
static void destroy_channel_elem(grpc_channel_element *elem) {} static void destroy_channel_elem(grpc_channel_element *elem) {}
const grpc_channel_filter grpc_client_surface_filter = { const grpc_channel_filter grpc_client_surface_filter = {
call_op, channel_op, call_op, channel_op,
sizeof(call_data), init_call_elem, destroy_call_elem, sizeof(call_data), init_call_elem, destroy_call_elem,
sizeof(channel_data), init_channel_elem, destroy_channel_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem,

@ -111,9 +111,9 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
static const grpc_channel_filter lame_filter = { static const grpc_channel_filter lame_filter = {
call_op, channel_op, call_op, channel_op,
sizeof(call_data), init_call_elem, destroy_call_elem, sizeof(call_data), init_call_elem, destroy_call_elem,
sizeof(channel_data), init_channel_elem, destroy_channel_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem,

@ -411,9 +411,9 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
} }
static const grpc_channel_filter server_surface_filter = { static const grpc_channel_filter server_surface_filter = {
call_op, channel_op, call_op, channel_op,
sizeof(call_data), init_call_elem, destroy_call_elem, sizeof(call_data), init_call_elem, destroy_call_elem,
sizeof(channel_data), init_channel_elem, destroy_channel_elem, sizeof(channel_data), init_channel_elem, destroy_channel_elem,

@ -43,68 +43,68 @@ static struct {
const char *key; const char *key;
const char *value; const char *value;
} static_table[] = { } static_table[] = {
/* 0: */ {NULL, NULL}, /* 0: */ {NULL, NULL},
/* 1: */ {":authority", ""}, /* 1: */ {":authority", ""},
/* 2: */ {":method", "GET"}, /* 2: */ {":method", "GET"},
/* 3: */ {":method", "POST"}, /* 3: */ {":method", "POST"},
/* 4: */ {":path", "/"}, /* 4: */ {":path", "/"},
/* 5: */ {":path", "/index.html"}, /* 5: */ {":path", "/index.html"},
/* 6: */ {":scheme", "http"}, /* 6: */ {":scheme", "http"},
/* 7: */ {":scheme", "https"}, /* 7: */ {":scheme", "https"},
/* 8: */ {":status", "200"}, /* 8: */ {":status", "200"},
/* 9: */ {":status", "204"}, /* 9: */ {":status", "204"},
/* 10: */ {":status", "206"}, /* 10: */ {":status", "206"},
/* 11: */ {":status", "304"}, /* 11: */ {":status", "304"},
/* 12: */ {":status", "400"}, /* 12: */ {":status", "400"},
/* 13: */ {":status", "404"}, /* 13: */ {":status", "404"},
/* 14: */ {":status", "500"}, /* 14: */ {":status", "500"},
/* 15: */ {"accept-charset", ""}, /* 15: */ {"accept-charset", ""},
/* 16: */ {"accept-encoding", "gzip, deflate"}, /* 16: */ {"accept-encoding", "gzip, deflate"},
/* 17: */ {"accept-language", ""}, /* 17: */ {"accept-language", ""},
/* 18: */ {"accept-ranges", ""}, /* 18: */ {"accept-ranges", ""},
/* 19: */ {"accept", ""}, /* 19: */ {"accept", ""},
/* 20: */ {"access-control-allow-origin", ""}, /* 20: */ {"access-control-allow-origin", ""},
/* 21: */ {"age", ""}, /* 21: */ {"age", ""},
/* 22: */ {"allow", ""}, /* 22: */ {"allow", ""},
/* 23: */ {"authorization", ""}, /* 23: */ {"authorization", ""},
/* 24: */ {"cache-control", ""}, /* 24: */ {"cache-control", ""},
/* 25: */ {"content-disposition", ""}, /* 25: */ {"content-disposition", ""},
/* 26: */ {"content-encoding", ""}, /* 26: */ {"content-encoding", ""},
/* 27: */ {"content-language", ""}, /* 27: */ {"content-language", ""},
/* 28: */ {"content-length", ""}, /* 28: */ {"content-length", ""},
/* 29: */ {"content-location", ""}, /* 29: */ {"content-location", ""},
/* 30: */ {"content-range", ""}, /* 30: */ {"content-range", ""},
/* 31: */ {"content-type", ""}, /* 31: */ {"content-type", ""},
/* 32: */ {"cookie", ""}, /* 32: */ {"cookie", ""},
/* 33: */ {"date", ""}, /* 33: */ {"date", ""},
/* 34: */ {"etag", ""}, /* 34: */ {"etag", ""},
/* 35: */ {"expect", ""}, /* 35: */ {"expect", ""},
/* 36: */ {"expires", ""}, /* 36: */ {"expires", ""},
/* 37: */ {"from", ""}, /* 37: */ {"from", ""},
/* 38: */ {"host", ""}, /* 38: */ {"host", ""},
/* 39: */ {"if-match", ""}, /* 39: */ {"if-match", ""},
/* 40: */ {"if-modified-since", ""}, /* 40: */ {"if-modified-since", ""},
/* 41: */ {"if-none-match", ""}, /* 41: */ {"if-none-match", ""},
/* 42: */ {"if-range", ""}, /* 42: */ {"if-range", ""},
/* 43: */ {"if-unmodified-since", ""}, /* 43: */ {"if-unmodified-since", ""},
/* 44: */ {"last-modified", ""}, /* 44: */ {"last-modified", ""},
/* 45: */ {"link", ""}, /* 45: */ {"link", ""},
/* 46: */ {"location", ""}, /* 46: */ {"location", ""},
/* 47: */ {"max-forwards", ""}, /* 47: */ {"max-forwards", ""},
/* 48: */ {"proxy-authenticate", ""}, /* 48: */ {"proxy-authenticate", ""},
/* 49: */ {"proxy-authorization", ""}, /* 49: */ {"proxy-authorization", ""},
/* 50: */ {"range", ""}, /* 50: */ {"range", ""},
/* 51: */ {"referer", ""}, /* 51: */ {"referer", ""},
/* 52: */ {"refresh", ""}, /* 52: */ {"refresh", ""},
/* 53: */ {"retry-after", ""}, /* 53: */ {"retry-after", ""},
/* 54: */ {"server", ""}, /* 54: */ {"server", ""},
/* 55: */ {"set-cookie", ""}, /* 55: */ {"set-cookie", ""},
/* 56: */ {"strict-transport-security", ""}, /* 56: */ {"strict-transport-security", ""},
/* 57: */ {"transfer-encoding", ""}, /* 57: */ {"transfer-encoding", ""},
/* 58: */ {"user-agent", ""}, /* 58: */ {"user-agent", ""},
/* 59: */ {"vary", ""}, /* 59: */ {"vary", ""},
/* 60: */ {"via", ""}, /* 60: */ {"via", ""},
/* 61: */ {"www-authenticate", ""}, /* 61: */ {"www-authenticate", ""},
}; };
void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl *tbl, grpc_mdctx *mdctx) { void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl *tbl, grpc_mdctx *mdctx) {

@ -58,16 +58,16 @@ void grpc_chttp2_hpack_write_varint_tail(gpr_uint32 tail_value,
: grpc_chttp2_hpack_varint_length( \ : grpc_chttp2_hpack_varint_length( \
(n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits))) (n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits)))
#define GRPC_CHTTP2_WRITE_VARINT(n, prefix_bits, prefix_or, target, length) \ #define GRPC_CHTTP2_WRITE_VARINT(n, prefix_bits, prefix_or, target, length) \
do { \ do { \
gpr_uint8* tgt = target; \ gpr_uint8* tgt = target; \
if ((length) == 1) { \ if ((length) == 1) { \
(tgt)[0] = (prefix_or) | (n); \ (tgt)[0] = (prefix_or) | (n); \
} else { \ } else { \
(tgt)[0] = (prefix_or) | GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \ (tgt)[0] = (prefix_or) | GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \
grpc_chttp2_hpack_write_varint_tail( \ grpc_chttp2_hpack_write_varint_tail( \
(n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits), (tgt) + 1, (length)-1); \ (n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits), (tgt)+1, (length)-1); \
} \ } \
} while (0) } while (0)
#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_VARINT_H__ */ #endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_VARINT_H__ */

@ -525,7 +525,7 @@ static int init_stream(grpc_transport *gt, grpc_stream *gs,
lock(t); lock(t);
s->id = 0; s->id = 0;
} else { } else {
s->id = (gpr_uint32)(gpr_uintptr)server_data; s->id = (gpr_uint32)(gpr_uintptr) server_data;
t->incoming_stream = s; t->incoming_stream = s;
grpc_chttp2_stream_map_add(&t->stream_map, s->id, s); grpc_chttp2_stream_map_add(&t->stream_map, s->id, s);
} }
@ -1238,7 +1238,7 @@ static int init_header_frame_parser(transport *t, int is_continuation) {
t->incoming_stream = NULL; t->incoming_stream = NULL;
/* if stream is accepted, we set incoming_stream in init_stream */ /* if stream is accepted, we set incoming_stream in init_stream */
t->cb->accept_stream(t->cb_user_data, &t->base, t->cb->accept_stream(t->cb_user_data, &t->base,
(void *)(gpr_uintptr)t->incoming_stream_id); (void *)(gpr_uintptr) t->incoming_stream_id);
s = t->incoming_stream; s = t->incoming_stream;
if (!s) { if (!s) {
gpr_log(GPR_ERROR, "stream not accepted"); gpr_log(GPR_ERROR, "stream not accepted");
@ -1503,8 +1503,8 @@ static int process_read(transport *t, gpr_slice slice) {
"Connect string mismatch: expected '%c' (%d) got '%c' (%d) " "Connect string mismatch: expected '%c' (%d) got '%c' (%d) "
"at byte %d", "at byte %d",
CLIENT_CONNECT_STRING[t->deframe_state], CLIENT_CONNECT_STRING[t->deframe_state],
(int)(gpr_uint8)CLIENT_CONNECT_STRING[t->deframe_state], *cur, (int)(gpr_uint8) CLIENT_CONNECT_STRING[t->deframe_state],
(int)*cur, t->deframe_state); *cur, (int)*cur, t->deframe_state);
return 0; return 0;
} }
++cur; ++cur;
@ -1737,9 +1737,9 @@ static void add_to_pollset(grpc_transport *gt, grpc_pollset *pollset) {
*/ */
static const grpc_transport_vtable vtable = { static const grpc_transport_vtable vtable = {
sizeof(stream), init_stream, send_batch, set_allow_window_updates, sizeof(stream), init_stream, send_batch, set_allow_window_updates,
add_to_pollset, destroy_stream, abort_stream, goaway, close_transport, add_to_pollset, destroy_stream, abort_stream, goaway,
send_ping, destroy_transport}; close_transport, send_ping, destroy_transport};
void grpc_create_chttp2_transport(grpc_transport_setup_callback setup, void grpc_create_chttp2_transport(grpc_transport_setup_callback setup,
void *arg, void *arg,

@ -120,7 +120,7 @@ static void store32_little_endian(gpr_uint32 value, unsigned char* buf) {
buf[3] = (unsigned char)(value >> 24) & 0xFF; buf[3] = (unsigned char)(value >> 24) & 0xFF;
buf[2] = (unsigned char)(value >> 16) & 0xFF; buf[2] = (unsigned char)(value >> 16) & 0xFF;
buf[1] = (unsigned char)(value >> 8) & 0xFF; buf[1] = (unsigned char)(value >> 8) & 0xFF;
buf[0] = (unsigned char)(value)&0xFF; buf[0] = (unsigned char)(value) & 0xFF;
} }
static void tsi_fake_frame_reset(tsi_fake_frame* frame, int needs_draining) { static void tsi_fake_frame_reset(tsi_fake_frame* frame, int needs_draining) {
@ -230,10 +230,11 @@ static void tsi_fake_frame_destruct(tsi_fake_frame* frame) {
/* --- tsi_frame_protector methods implementation. ---*/ /* --- tsi_frame_protector methods implementation. ---*/
static tsi_result fake_protector_protect( static tsi_result fake_protector_protect(tsi_frame_protector* self,
tsi_frame_protector* self, const unsigned char* unprotected_bytes, const unsigned char* unprotected_bytes,
size_t* unprotected_bytes_size, unsigned char* protected_output_frames, size_t* unprotected_bytes_size,
size_t* protected_output_frames_size) { unsigned char* protected_output_frames,
size_t* protected_output_frames_size) {
tsi_result result = TSI_OK; tsi_result result = TSI_OK;
tsi_fake_frame_protector* impl = (tsi_fake_frame_protector*)self; tsi_fake_frame_protector* impl = (tsi_fake_frame_protector*)self;
unsigned char frame_header[TSI_FAKE_FRAME_HEADER_SIZE]; unsigned char frame_header[TSI_FAKE_FRAME_HEADER_SIZE];
@ -480,8 +481,10 @@ static void fake_handshaker_destroy(tsi_handshaker* self) {
static const tsi_handshaker_vtable handshaker_vtable = { static const tsi_handshaker_vtable handshaker_vtable = {
fake_handshaker_get_bytes_to_send_to_peer, fake_handshaker_get_bytes_to_send_to_peer,
fake_handshaker_process_bytes_from_peer, fake_handshaker_get_result, fake_handshaker_process_bytes_from_peer,
fake_handshaker_extract_peer, fake_handshaker_create_frame_protector, fake_handshaker_get_result,
fake_handshaker_extract_peer,
fake_handshaker_create_frame_protector,
fake_handshaker_destroy, fake_handshaker_destroy,
}; };

@ -573,10 +573,11 @@ static tsi_result build_alpn_protocol_name_list(
/* --- tsi_frame_protector methods implementation. ---*/ /* --- tsi_frame_protector methods implementation. ---*/
static tsi_result ssl_protector_protect( static tsi_result ssl_protector_protect(tsi_frame_protector* self,
tsi_frame_protector* self, const unsigned char* unprotected_bytes, const unsigned char* unprotected_bytes,
size_t* unprotected_bytes_size, unsigned char* protected_output_frames, size_t* unprotected_bytes_size,
size_t* protected_output_frames_size) { unsigned char* protected_output_frames,
size_t* protected_output_frames_size) {
tsi_ssl_frame_protector* impl = (tsi_ssl_frame_protector*)self; tsi_ssl_frame_protector* impl = (tsi_ssl_frame_protector*)self;
int read_from_ssl; int read_from_ssl;
size_t available; size_t available;
@ -707,8 +708,9 @@ static const tsi_frame_protector_vtable frame_protector_vtable = {
/* --- tsi_handshaker methods implementation. ---*/ /* --- tsi_handshaker methods implementation. ---*/
static tsi_result ssl_handshaker_get_bytes_to_send_to_peer( static tsi_result ssl_handshaker_get_bytes_to_send_to_peer(tsi_handshaker* self,
tsi_handshaker* self, unsigned char* bytes, size_t* bytes_size) { unsigned char* bytes,
size_t* bytes_size) {
tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self; tsi_ssl_handshaker* impl = (tsi_ssl_handshaker*)self;
int bytes_read_from_ssl = 0; int bytes_read_from_ssl = 0;
if (bytes == NULL || bytes_size == NULL || *bytes_size == 0 || if (bytes == NULL || bytes_size == NULL || *bytes_size == 0 ||
@ -871,8 +873,10 @@ static void ssl_handshaker_destroy(tsi_handshaker* self) {
static const tsi_handshaker_vtable handshaker_vtable = { static const tsi_handshaker_vtable handshaker_vtable = {
ssl_handshaker_get_bytes_to_send_to_peer, ssl_handshaker_get_bytes_to_send_to_peer,
ssl_handshaker_process_bytes_from_peer, ssl_handshaker_get_result, ssl_handshaker_process_bytes_from_peer,
ssl_handshaker_extract_peer, ssl_handshaker_create_frame_protector, ssl_handshaker_get_result,
ssl_handshaker_extract_peer,
ssl_handshaker_create_frame_protector,
ssl_handshaker_destroy, ssl_handshaker_destroy,
}; };
@ -1157,8 +1161,7 @@ tsi_result tsi_create_ssl_client_handshaker_factory(
tsi_result tsi_create_ssl_server_handshaker_factory( tsi_result tsi_create_ssl_server_handshaker_factory(
const unsigned char** pem_private_keys, const unsigned char** pem_private_keys,
const size_t* pem_private_keys_sizes, const size_t* pem_private_keys_sizes, const unsigned char** pem_cert_chains,
const unsigned char** pem_cert_chains,
const size_t* pem_cert_chains_sizes, size_t key_cert_pair_count, const size_t* pem_cert_chains_sizes, size_t key_cert_pair_count,
const unsigned char* pem_client_root_certs, const unsigned char* pem_client_root_certs,
size_t pem_client_root_certs_size, const char* cipher_list, size_t pem_client_root_certs_size, const char* cipher_list,

@ -132,8 +132,7 @@ tsi_result tsi_create_ssl_client_handshaker_factory(
where a parameter is invalid. */ where a parameter is invalid. */
tsi_result tsi_create_ssl_server_handshaker_factory( tsi_result tsi_create_ssl_server_handshaker_factory(
const unsigned char** pem_private_keys, const unsigned char** pem_private_keys,
const size_t* pem_private_keys_sizes, const size_t* pem_private_keys_sizes, const unsigned char** pem_cert_chains,
const unsigned char** pem_cert_chains,
const size_t* pem_cert_chains_sizes, size_t key_cert_pair_count, const size_t* pem_cert_chains_sizes, size_t key_cert_pair_count,
const unsigned char* pem_client_root_certs, const unsigned char* pem_client_root_certs,
size_t pem_client_root_certs_size, const char* cipher_suites, size_t pem_client_root_certs_size, const char* cipher_suites,

@ -53,7 +53,7 @@
namespace grpc { namespace grpc {
Channel::Channel(const grpc::string& target, const ChannelArguments& args) Channel::Channel(const grpc::string &target, const ChannelArguments &args)
: target_(target) { : target_(target) {
grpc_channel_args channel_args; grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args); args.SetChannelArgs(&channel_args);
@ -61,15 +61,15 @@ Channel::Channel(const grpc::string& target, const ChannelArguments& args)
target_.c_str(), channel_args.num_args > 0 ? &channel_args : nullptr); target_.c_str(), channel_args.num_args > 0 ? &channel_args : nullptr);
} }
Channel::Channel(const grpc::string& target, Channel::Channel(const grpc::string &target,
const std::unique_ptr<Credentials>& creds, const std::unique_ptr<Credentials> &creds,
const ChannelArguments& args) const ChannelArguments &args)
: target_(args.GetSslTargetNameOverride().empty() : target_(args.GetSslTargetNameOverride().empty()
? target ? target
: args.GetSslTargetNameOverride()) { : args.GetSslTargetNameOverride()) {
grpc_channel_args channel_args; grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args); args.SetChannelArgs(&channel_args);
grpc_credentials* c_creds = creds ? creds->GetRawCreds() : nullptr; grpc_credentials *c_creds = creds ? creds->GetRawCreds() : nullptr;
c_channel_ = grpc_secure_channel_create( c_channel_ = grpc_secure_channel_create(
c_creds, target.c_str(), c_creds, target.c_str(),
channel_args.num_args > 0 ? &channel_args : nullptr); channel_args.num_args > 0 ? &channel_args : nullptr);
@ -79,9 +79,9 @@ Channel::~Channel() { grpc_channel_destroy(c_channel_); }
namespace { namespace {
// Pluck the finished event and set to status when it is not nullptr. // Pluck the finished event and set to status when it is not nullptr.
void GetFinalStatus(grpc_completion_queue* cq, void* finished_tag, void GetFinalStatus(grpc_completion_queue *cq, void *finished_tag,
Status* status) { Status *status) {
grpc_event* ev = grpc_event *ev =
grpc_completion_queue_pluck(cq, finished_tag, gpr_inf_future); grpc_completion_queue_pluck(cq, finished_tag, gpr_inf_future);
if (status) { if (status) {
StatusCode error_code = static_cast<StatusCode>(ev->data.finished.status); StatusCode error_code = static_cast<StatusCode>(ev->data.finished.status);
@ -94,23 +94,23 @@ void GetFinalStatus(grpc_completion_queue* cq, void* finished_tag,
} // namespace } // namespace
// TODO(yangg) more error handling // TODO(yangg) more error handling
Status Channel::StartBlockingRpc(const RpcMethod& method, Status Channel::StartBlockingRpc(const RpcMethod &method,
ClientContext* context, ClientContext *context,
const google::protobuf::Message& request, const google::protobuf::Message &request,
google::protobuf::Message* result) { google::protobuf::Message *result) {
Status status; Status status;
grpc_call* call = grpc_channel_create_call( grpc_call *call = grpc_channel_create_call(
c_channel_, method.name(), target_.c_str(), context->RawDeadline()); c_channel_, method.name(), target_.c_str(), context->RawDeadline());
context->set_call(call); context->set_call(call);
grpc_event* ev; grpc_event *ev;
void* finished_tag = reinterpret_cast<char*>(call); void *finished_tag = reinterpret_cast<char *>(call);
void* invoke_tag = reinterpret_cast<char*>(call) + 1; void *invoke_tag = reinterpret_cast<char *>(call) + 1;
void* metadata_read_tag = reinterpret_cast<char*>(call) + 2; void *metadata_read_tag = reinterpret_cast<char *>(call) + 2;
void* write_tag = reinterpret_cast<char*>(call) + 3; void *write_tag = reinterpret_cast<char *>(call) + 3;
void* halfclose_tag = reinterpret_cast<char*>(call) + 4; void *halfclose_tag = reinterpret_cast<char *>(call) + 4;
void* read_tag = reinterpret_cast<char*>(call) + 5; void *read_tag = reinterpret_cast<char *>(call) + 5;
grpc_completion_queue* cq = grpc_completion_queue_create(); grpc_completion_queue *cq = grpc_completion_queue_create();
context->set_cq(cq); context->set_cq(cq);
// add_metadata from context // add_metadata from context
// //
@ -126,7 +126,7 @@ Status Channel::StartBlockingRpc(const RpcMethod& method,
return status; return status;
} }
// write request // write request
grpc_byte_buffer* write_buffer = nullptr; grpc_byte_buffer *write_buffer = nullptr;
success = SerializeProto(request, &write_buffer); success = SerializeProto(request, &write_buffer);
if (!success) { if (!success) {
grpc_call_cancel(call); grpc_call_cancel(call);
@ -172,14 +172,14 @@ Status Channel::StartBlockingRpc(const RpcMethod& method,
return status; return status;
} }
StreamContextInterface* Channel::CreateStream( StreamContextInterface *Channel::CreateStream(
const RpcMethod& method, ClientContext* context, const RpcMethod &method, ClientContext *context,
const google::protobuf::Message* request, const google::protobuf::Message *request,
google::protobuf::Message* result) { google::protobuf::Message *result) {
grpc_call* call = grpc_channel_create_call( grpc_call *call = grpc_channel_create_call(
c_channel_, method.name(), target_.c_str(), context->RawDeadline()); c_channel_, method.name(), target_.c_str(), context->RawDeadline());
context->set_call(call); context->set_call(call);
grpc_completion_queue* cq = grpc_completion_queue_create(); grpc_completion_queue *cq = grpc_completion_queue_create();
context->set_cq(cq); context->set_cq(cq);
return new StreamContext(method, context, request, result); return new StreamContext(method, context, request, result);
} }

@ -48,24 +48,24 @@ class StreamContextInterface;
class Channel : public ChannelInterface { class Channel : public ChannelInterface {
public: public:
Channel(const grpc::string& target, const ChannelArguments& args); Channel(const grpc::string &target, const ChannelArguments &args);
Channel(const grpc::string& target, const std::unique_ptr<Credentials>& creds, Channel(const grpc::string &target, const std::unique_ptr<Credentials> &creds,
const ChannelArguments& args); const ChannelArguments &args);
~Channel() override; ~Channel() override;
Status StartBlockingRpc(const RpcMethod& method, ClientContext* context, Status StartBlockingRpc(const RpcMethod &method, ClientContext *context,
const google::protobuf::Message& request, const google::protobuf::Message &request,
google::protobuf::Message* result) override; google::protobuf::Message *result) override;
StreamContextInterface* CreateStream( StreamContextInterface *CreateStream(
const RpcMethod& method, ClientContext* context, const RpcMethod &method, ClientContext *context,
const google::protobuf::Message* request, const google::protobuf::Message *request,
google::protobuf::Message* result) override; google::protobuf::Message *result) override;
private: private:
const grpc::string target_; const grpc::string target_;
grpc_channel* c_channel_; // owned grpc_channel *c_channel_; // owned
}; };
} // namespace grpc } // namespace grpc

@ -37,7 +37,7 @@
namespace grpc { namespace grpc {
void ChannelArguments::SetSslTargetNameOverride(const grpc::string& name) { void ChannelArguments::SetSslTargetNameOverride(const grpc::string &name) {
SetString(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, name); SetString(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, name);
} }
@ -50,32 +50,32 @@ grpc::string ChannelArguments::GetSslTargetNameOverride() const {
return ""; return "";
} }
void ChannelArguments::SetInt(const grpc::string& key, int value) { void ChannelArguments::SetInt(const grpc::string &key, int value) {
grpc_arg arg; grpc_arg arg;
arg.type = GRPC_ARG_INTEGER; arg.type = GRPC_ARG_INTEGER;
strings_.push_back(key); strings_.push_back(key);
arg.key = const_cast<char*>(strings_.back().c_str()); arg.key = const_cast<char *>(strings_.back().c_str());
arg.value.integer = value; arg.value.integer = value;
args_.push_back(arg); args_.push_back(arg);
} }
void ChannelArguments::SetString(const grpc::string& key, void ChannelArguments::SetString(const grpc::string &key,
const grpc::string& value) { const grpc::string &value) {
grpc_arg arg; grpc_arg arg;
arg.type = GRPC_ARG_STRING; arg.type = GRPC_ARG_STRING;
strings_.push_back(key); strings_.push_back(key);
arg.key = const_cast<char*>(strings_.back().c_str()); arg.key = const_cast<char *>(strings_.back().c_str());
strings_.push_back(value); strings_.push_back(value);
arg.value.string = const_cast<char*>(strings_.back().c_str()); arg.value.string = const_cast<char *>(strings_.back().c_str());
args_.push_back(arg); args_.push_back(arg);
} }
void ChannelArguments::SetChannelArgs(grpc_channel_args* channel_args) const { void ChannelArguments::SetChannelArgs(grpc_channel_args *channel_args) const {
channel_args->num_args = args_.size(); channel_args->num_args = args_.size();
if (channel_args->num_args > 0) { if (channel_args->num_args > 0) {
channel_args->args = const_cast<grpc_arg*>(&args_[0]); channel_args->args = const_cast<grpc_arg *>(&args_[0]);
} }
} }

@ -50,7 +50,7 @@ ClientContext::~ClientContext() {
if (cq_) { if (cq_) {
grpc_completion_queue_shutdown(cq_); grpc_completion_queue_shutdown(cq_);
// Drain cq_. // Drain cq_.
grpc_event* ev; grpc_event *ev;
grpc_completion_type t; grpc_completion_type t;
do { do {
ev = grpc_completion_queue_next(cq_, gpr_inf_future); ev = grpc_completion_queue_next(cq_, gpr_inf_future);
@ -62,7 +62,7 @@ ClientContext::~ClientContext() {
} }
void ClientContext::set_absolute_deadline( void ClientContext::set_absolute_deadline(
const system_clock::time_point& deadline) { const system_clock::time_point &deadline) {
Timepoint2Timespec(deadline, &absolute_deadline_); Timepoint2Timespec(deadline, &absolute_deadline_);
} }
@ -70,8 +70,8 @@ system_clock::time_point ClientContext::absolute_deadline() {
return Timespec2Timepoint(absolute_deadline_); return Timespec2Timepoint(absolute_deadline_);
} }
void ClientContext::AddMetadata(const grpc::string& meta_key, void ClientContext::AddMetadata(const grpc::string &meta_key,
const grpc::string& meta_value) { const grpc::string &meta_value) {
return; return;
} }

@ -40,14 +40,14 @@
namespace grpc { namespace grpc {
class ChannelArguments; class ChannelArguments;
std::shared_ptr<ChannelInterface> CreateChannel(const grpc::string& target, std::shared_ptr<ChannelInterface> CreateChannel(const grpc::string &target,
const ChannelArguments& args) { const ChannelArguments &args) {
return std::shared_ptr<ChannelInterface>(new Channel(target, args)); return std::shared_ptr<ChannelInterface>(new Channel(target, args));
} }
std::shared_ptr<ChannelInterface> CreateChannel( std::shared_ptr<ChannelInterface> CreateChannel(
const grpc::string& target, const std::unique_ptr<Credentials>& creds, const grpc::string &target, const std::unique_ptr<Credentials> &creds,
const ChannelArguments& args) { const ChannelArguments &args) {
return std::shared_ptr<ChannelInterface>(new Channel(target, creds, args)); return std::shared_ptr<ChannelInterface>(new Channel(target, creds, args));
} }
} // namespace grpc } // namespace grpc

@ -40,37 +40,37 @@
namespace grpc { namespace grpc {
Credentials::Credentials(grpc_credentials* c_creds) : creds_(c_creds) {} Credentials::Credentials(grpc_credentials *c_creds) : creds_(c_creds) {}
Credentials::~Credentials() { grpc_credentials_release(creds_); } Credentials::~Credentials() { grpc_credentials_release(creds_); }
grpc_credentials* Credentials::GetRawCreds() { return creds_; } grpc_credentials *Credentials::GetRawCreds() { return creds_; }
std::unique_ptr<Credentials> CredentialsFactory::DefaultCredentials() { std::unique_ptr<Credentials> CredentialsFactory::DefaultCredentials() {
grpc_credentials* c_creds = grpc_default_credentials_create(); grpc_credentials *c_creds = grpc_default_credentials_create();
std::unique_ptr<Credentials> cpp_creds(new Credentials(c_creds)); std::unique_ptr<Credentials> cpp_creds(new Credentials(c_creds));
return cpp_creds; return cpp_creds;
} }
// Builds SSL Credentials given SSL specific options // Builds SSL Credentials given SSL specific options
std::unique_ptr<Credentials> CredentialsFactory::SslCredentials( std::unique_ptr<Credentials> CredentialsFactory::SslCredentials(
const SslCredentialsOptions& options) { const SslCredentialsOptions &options) {
const unsigned char* pem_root_certs = const unsigned char *pem_root_certs =
options.pem_root_certs.empty() ? nullptr options.pem_root_certs.empty() ? nullptr
: reinterpret_cast<const unsigned char*>( : reinterpret_cast<const unsigned char *>(
options.pem_root_certs.c_str()); options.pem_root_certs.c_str());
if (pem_root_certs == nullptr) { if (pem_root_certs == nullptr) {
return std::unique_ptr<Credentials>(); return std::unique_ptr<Credentials>();
} }
const unsigned char* pem_private_key = const unsigned char *pem_private_key =
options.pem_private_key.empty() ? nullptr options.pem_private_key.empty() ? nullptr
: reinterpret_cast<const unsigned char*>( : reinterpret_cast<const unsigned char *>(
options.pem_private_key.c_str()); options.pem_private_key.c_str());
const unsigned char* pem_cert_chain = const unsigned char *pem_cert_chain =
options.pem_cert_chain.empty() ? nullptr options.pem_cert_chain.empty() ? nullptr
: reinterpret_cast<const unsigned char*>( : reinterpret_cast<const unsigned char *>(
options.pem_cert_chain.c_str()); options.pem_cert_chain.c_str());
grpc_credentials* c_creds = grpc_ssl_credentials_create( grpc_credentials *c_creds = grpc_ssl_credentials_create(
pem_root_certs, options.pem_root_certs.size(), pem_private_key, pem_root_certs, options.pem_root_certs.size(), pem_private_key,
options.pem_private_key.size(), pem_cert_chain, options.pem_private_key.size(), pem_cert_chain,
options.pem_cert_chain.size()); options.pem_cert_chain.size());
@ -81,7 +81,7 @@ std::unique_ptr<Credentials> CredentialsFactory::SslCredentials(
// Builds credentials for use when running in GCE // Builds credentials for use when running in GCE
std::unique_ptr<Credentials> CredentialsFactory::ComputeEngineCredentials() { std::unique_ptr<Credentials> CredentialsFactory::ComputeEngineCredentials() {
grpc_credentials* c_creds = grpc_compute_engine_credentials_create(); grpc_credentials *c_creds = grpc_compute_engine_credentials_create();
std::unique_ptr<Credentials> cpp_creds( std::unique_ptr<Credentials> cpp_creds(
c_creds == nullptr ? nullptr : new Credentials(c_creds)); c_creds == nullptr ? nullptr : new Credentials(c_creds));
return cpp_creds; return cpp_creds;
@ -89,11 +89,11 @@ std::unique_ptr<Credentials> CredentialsFactory::ComputeEngineCredentials() {
// Builds service account credentials. // Builds service account credentials.
std::unique_ptr<Credentials> CredentialsFactory::ServiceAccountCredentials( std::unique_ptr<Credentials> CredentialsFactory::ServiceAccountCredentials(
const grpc::string& json_key, const grpc::string& scope, const grpc::string &json_key, const grpc::string &scope,
std::chrono::seconds token_lifetime) { std::chrono::seconds token_lifetime) {
gpr_timespec lifetime = gpr_time_from_seconds( gpr_timespec lifetime = gpr_time_from_seconds(
token_lifetime.count() > 0 ? token_lifetime.count() : 0); token_lifetime.count() > 0 ? token_lifetime.count() : 0);
grpc_credentials* c_creds = grpc_service_account_credentials_create( grpc_credentials *c_creds = grpc_service_account_credentials_create(
json_key.c_str(), scope.c_str(), lifetime); json_key.c_str(), scope.c_str(), lifetime);
std::unique_ptr<Credentials> cpp_creds( std::unique_ptr<Credentials> cpp_creds(
c_creds == nullptr ? nullptr : new Credentials(c_creds)); c_creds == nullptr ? nullptr : new Credentials(c_creds));
@ -102,9 +102,9 @@ std::unique_ptr<Credentials> CredentialsFactory::ServiceAccountCredentials(
// Builds IAM credentials. // Builds IAM credentials.
std::unique_ptr<Credentials> CredentialsFactory::IAMCredentials( std::unique_ptr<Credentials> CredentialsFactory::IAMCredentials(
const grpc::string& authorization_token, const grpc::string &authorization_token,
const grpc::string& authority_selector) { const grpc::string &authority_selector) {
grpc_credentials* c_creds = grpc_iam_credentials_create( grpc_credentials *c_creds = grpc_iam_credentials_create(
authorization_token.c_str(), authority_selector.c_str()); authorization_token.c_str(), authority_selector.c_str());
std::unique_ptr<Credentials> cpp_creds( std::unique_ptr<Credentials> cpp_creds(
c_creds == nullptr ? nullptr : new Credentials(c_creds)); c_creds == nullptr ? nullptr : new Credentials(c_creds));
@ -113,13 +113,13 @@ std::unique_ptr<Credentials> CredentialsFactory::IAMCredentials(
// Combines two credentials objects into a composite credentials. // Combines two credentials objects into a composite credentials.
std::unique_ptr<Credentials> CredentialsFactory::ComposeCredentials( std::unique_ptr<Credentials> CredentialsFactory::ComposeCredentials(
const std::unique_ptr<Credentials>& creds1, const std::unique_ptr<Credentials> &creds1,
const std::unique_ptr<Credentials>& creds2) { const std::unique_ptr<Credentials> &creds2) {
// Note that we are not saving unique_ptrs to the two credentials // Note that we are not saving unique_ptrs to the two credentials
// passed in here. This is OK because the underlying C objects (i.e., // passed in here. This is OK because the underlying C objects (i.e.,
// creds1 and creds2) into grpc_composite_credentials_create will see their // creds1 and creds2) into grpc_composite_credentials_create will see their
// refcounts incremented. // refcounts incremented.
grpc_credentials* c_creds = grpc_composite_credentials_create( grpc_credentials *c_creds = grpc_composite_credentials_create(
creds1->GetRawCreds(), creds2->GetRawCreds()); creds1->GetRawCreds(), creds2->GetRawCreds());
std::unique_ptr<Credentials> cpp_creds( std::unique_ptr<Credentials> cpp_creds(
c_creds == nullptr ? nullptr : new Credentials(c_creds)); c_creds == nullptr ? nullptr : new Credentials(c_creds));

@ -40,8 +40,8 @@
namespace grpc { namespace grpc {
bool SerializeProto(const google::protobuf::Message& msg, bool SerializeProto(const google::protobuf::Message &msg,
grpc_byte_buffer** bp) { grpc_byte_buffer **bp) {
grpc::string msg_str; grpc::string msg_str;
bool success = msg.SerializeToString(&msg_str); bool success = msg.SerializeToString(&msg_str);
if (success) { if (success) {
@ -53,13 +53,13 @@ bool SerializeProto(const google::protobuf::Message& msg,
return success; return success;
} }
bool DeserializeProto(grpc_byte_buffer* buffer, bool DeserializeProto(grpc_byte_buffer *buffer,
google::protobuf::Message* msg) { google::protobuf::Message *msg) {
grpc::string msg_string; grpc::string msg_string;
grpc_byte_buffer_reader* reader = grpc_byte_buffer_reader_create(buffer); grpc_byte_buffer_reader *reader = grpc_byte_buffer_reader_create(buffer);
gpr_slice slice; gpr_slice slice;
while (grpc_byte_buffer_reader_next(reader, &slice)) { while (grpc_byte_buffer_reader_next(reader, &slice)) {
const char* data = reinterpret_cast<const char*>( const char *data = reinterpret_cast<const char *>(
slice.refcount ? slice.data.refcounted.bytes slice.refcount ? slice.data.refcounted.bytes
: slice.data.inlined.bytes); : slice.data.inlined.bytes);
msg_string.append(data, slice.refcount ? slice.data.refcounted.length msg_string.append(data, slice.refcount ? slice.data.refcounted.length

@ -46,11 +46,11 @@ namespace grpc {
// Serialize the msg into a buffer created inside the function. The caller // Serialize the msg into a buffer created inside the function. The caller
// should destroy the returned buffer when done with it. If serialization fails, // should destroy the returned buffer when done with it. If serialization fails,
// false is returned and buffer is left unchanged. // false is returned and buffer is left unchanged.
bool SerializeProto(const google::protobuf::Message& msg, bool SerializeProto(const google::protobuf::Message &msg,
grpc_byte_buffer** buffer); grpc_byte_buffer **buffer);
// The caller keeps ownership of buffer and msg. // The caller keeps ownership of buffer and msg.
bool DeserializeProto(grpc_byte_buffer* buffer, google::protobuf::Message* msg); bool DeserializeProto(grpc_byte_buffer *buffer, google::protobuf::Message *msg);
} // namespace grpc } // namespace grpc

@ -39,7 +39,7 @@
namespace grpc { namespace grpc {
AsyncServer::AsyncServer(CompletionQueue* cc) AsyncServer::AsyncServer(CompletionQueue *cc)
: started_(false), shutdown_(false) { : started_(false), shutdown_(false) {
server_ = grpc_server_create(cc->cq(), nullptr); server_ = grpc_server_create(cc->cq(), nullptr);
} }
@ -53,7 +53,7 @@ AsyncServer::~AsyncServer() {
grpc_server_destroy(server_); grpc_server_destroy(server_);
} }
void AsyncServer::AddPort(const grpc::string& addr) { void AsyncServer::AddPort(const grpc::string &addr) {
GPR_ASSERT(!started_); GPR_ASSERT(!started_);
int success = grpc_server_add_http2_port(server_, addr.c_str()); int success = grpc_server_add_http2_port(server_, addr.c_str());
GPR_ASSERT(success); GPR_ASSERT(success);

@ -42,7 +42,7 @@
namespace grpc { namespace grpc {
AsyncServerContext::AsyncServerContext( AsyncServerContext::AsyncServerContext(
grpc_call* call, const grpc::string& method, const grpc::string& host, grpc_call *call, const grpc::string &method, const grpc::string &host,
system_clock::time_point absolute_deadline) system_clock::time_point absolute_deadline)
: method_(method), : method_(method),
host_(host), host_(host),
@ -52,21 +52,21 @@ AsyncServerContext::AsyncServerContext(
AsyncServerContext::~AsyncServerContext() { grpc_call_destroy(call_); } AsyncServerContext::~AsyncServerContext() { grpc_call_destroy(call_); }
void AsyncServerContext::Accept(grpc_completion_queue* cq) { void AsyncServerContext::Accept(grpc_completion_queue *cq) {
GPR_ASSERT(grpc_call_server_accept(call_, cq, this) == GRPC_CALL_OK); GPR_ASSERT(grpc_call_server_accept(call_, cq, this) == GRPC_CALL_OK);
GPR_ASSERT(grpc_call_server_end_initial_metadata(call_, 0) == GRPC_CALL_OK); GPR_ASSERT(grpc_call_server_end_initial_metadata(call_, 0) == GRPC_CALL_OK);
} }
bool AsyncServerContext::StartRead(google::protobuf::Message* request) { bool AsyncServerContext::StartRead(google::protobuf::Message *request) {
GPR_ASSERT(request); GPR_ASSERT(request);
request_ = request; request_ = request;
grpc_call_error err = grpc_call_start_read(call_, this); grpc_call_error err = grpc_call_start_read(call_, this);
return err == GRPC_CALL_OK; return err == GRPC_CALL_OK;
} }
bool AsyncServerContext::StartWrite(const google::protobuf::Message& response, bool AsyncServerContext::StartWrite(const google::protobuf::Message &response,
int flags) { int flags) {
grpc_byte_buffer* buffer = nullptr; grpc_byte_buffer *buffer = nullptr;
if (!SerializeProto(response, &buffer)) { if (!SerializeProto(response, &buffer)) {
return false; return false;
} }
@ -75,16 +75,16 @@ bool AsyncServerContext::StartWrite(const google::protobuf::Message& response,
return err == GRPC_CALL_OK; return err == GRPC_CALL_OK;
} }
bool AsyncServerContext::StartWriteStatus(const Status& status) { bool AsyncServerContext::StartWriteStatus(const Status &status) {
grpc_call_error err = grpc_call_start_write_status( grpc_call_error err = grpc_call_start_write_status(
call_, static_cast<grpc_status_code>(status.code()), call_, static_cast<grpc_status_code>(status.code()),
status.details().empty() ? nullptr status.details().empty() ? nullptr
: const_cast<char*>(status.details().c_str()), : const_cast<char *>(status.details().c_str()),
this); this);
return err == GRPC_CALL_OK; return err == GRPC_CALL_OK;
} }
bool AsyncServerContext::ParseRead(grpc_byte_buffer* read_buffer) { bool AsyncServerContext::ParseRead(grpc_byte_buffer *read_buffer) {
GPR_ASSERT(request_); GPR_ASSERT(request_);
bool success = DeserializeProto(read_buffer, request_); bool success = DeserializeProto(read_buffer, request_);
request_ = nullptr; request_ = nullptr;

@ -48,8 +48,8 @@ CompletionQueue::~CompletionQueue() { grpc_completion_queue_destroy(cq_); }
void CompletionQueue::Shutdown() { grpc_completion_queue_shutdown(cq_); } void CompletionQueue::Shutdown() { grpc_completion_queue_shutdown(cq_); }
CompletionQueue::CompletionType CompletionQueue::Next(void** tag) { CompletionQueue::CompletionType CompletionQueue::Next(void **tag) {
grpc_event* ev; grpc_event *ev;
CompletionType return_type; CompletionType return_type;
bool success; bool success;
@ -65,8 +65,8 @@ CompletionQueue::CompletionType CompletionQueue::Next(void** tag) {
case GRPC_READ: case GRPC_READ:
*tag = ev->tag; *tag = ev->tag;
if (ev->data.read) { if (ev->data.read) {
success = success = static_cast<AsyncServerContext *>(ev->tag)
static_cast<AsyncServerContext*>(ev->tag)->ParseRead(ev->data.read); ->ParseRead(ev->data.read);
return_type = success ? SERVER_READ_OK : SERVER_READ_ERROR; return_type = success ? SERVER_READ_OK : SERVER_READ_ERROR;
} else { } else {
return_type = SERVER_READ_ERROR; return_type = SERVER_READ_ERROR;

@ -49,7 +49,7 @@ namespace grpc {
// TODO(rocking): consider a better default value like num of cores. // TODO(rocking): consider a better default value like num of cores.
static const int kNumThreads = 4; static const int kNumThreads = 4;
Server::Server(ThreadPoolInterface* thread_pool, ServerCredentials* creds) Server::Server(ThreadPoolInterface *thread_pool, ServerCredentials *creds)
: started_(false), : started_(false),
shutdown_(false), shutdown_(false),
num_running_cb_(0), num_running_cb_(0),
@ -82,14 +82,14 @@ Server::~Server() {
} }
} }
void Server::RegisterService(RpcService* service) { void Server::RegisterService(RpcService *service) {
for (int i = 0; i < service->GetMethodCount(); ++i) { for (int i = 0; i < service->GetMethodCount(); ++i) {
RpcServiceMethod* method = service->GetMethod(i); RpcServiceMethod *method = service->GetMethod(i);
method_map_.insert(std::make_pair(method->name(), method)); method_map_.insert(std::make_pair(method->name(), method));
} }
} }
void Server::AddPort(const grpc::string& addr) { void Server::AddPort(const grpc::string &addr) {
GPR_ASSERT(!started_); GPR_ASSERT(!started_);
int success; int success;
if (secure_) { if (secure_) {
@ -131,7 +131,7 @@ void Server::Shutdown() {
// Shutdown the completion queue. // Shutdown the completion queue.
cq_.Shutdown(); cq_.Shutdown();
void* tag = nullptr; void *tag = nullptr;
CompletionQueue::CompletionType t = cq_.Next(&tag); CompletionQueue::CompletionType t = cq_.Next(&tag);
GPR_ASSERT(t == CompletionQueue::QUEUE_CLOSED); GPR_ASSERT(t == CompletionQueue::QUEUE_CLOSED);
} }
@ -147,18 +147,18 @@ void Server::ScheduleCallback() {
void Server::RunRpc() { void Server::RunRpc() {
// Wait for one more incoming rpc. // Wait for one more incoming rpc.
void* tag = nullptr; void *tag = nullptr;
AllowOneRpc(); AllowOneRpc();
CompletionQueue::CompletionType t = cq_.Next(&tag); CompletionQueue::CompletionType t = cq_.Next(&tag);
GPR_ASSERT(t == CompletionQueue::SERVER_RPC_NEW); GPR_ASSERT(t == CompletionQueue::SERVER_RPC_NEW);
AsyncServerContext* server_context = static_cast<AsyncServerContext*>(tag); AsyncServerContext *server_context = static_cast<AsyncServerContext *>(tag);
// server_context could be nullptr during server shutdown. // server_context could be nullptr during server shutdown.
if (server_context != nullptr) { if (server_context != nullptr) {
// Schedule a new callback to handle more rpcs. // Schedule a new callback to handle more rpcs.
ScheduleCallback(); ScheduleCallback();
RpcServiceMethod* method = nullptr; RpcServiceMethod *method = nullptr;
auto iter = method_map_.find(server_context->method()); auto iter = method_map_.find(server_context->method());
if (iter != method_map_.end()) { if (iter != method_map_.end()) {
method = iter->second; method = iter->second;

@ -40,30 +40,30 @@ namespace grpc {
ServerBuilder::ServerBuilder() : thread_pool_(nullptr) {} ServerBuilder::ServerBuilder() : thread_pool_(nullptr) {}
void ServerBuilder::RegisterService(RpcService* service) { void ServerBuilder::RegisterService(RpcService *service) {
services_.push_back(service); services_.push_back(service);
} }
void ServerBuilder::AddPort(const grpc::string& addr) { void ServerBuilder::AddPort(const grpc::string &addr) {
ports_.push_back(addr); ports_.push_back(addr);
} }
void ServerBuilder::SetCredentials( void ServerBuilder::SetCredentials(
const std::shared_ptr<ServerCredentials>& creds) { const std::shared_ptr<ServerCredentials> &creds) {
GPR_ASSERT(!creds_); GPR_ASSERT(!creds_);
creds_ = creds; creds_ = creds;
} }
void ServerBuilder::SetThreadPool(ThreadPoolInterface* thread_pool) { void ServerBuilder::SetThreadPool(ThreadPoolInterface *thread_pool) {
thread_pool_ = thread_pool; thread_pool_ = thread_pool;
} }
std::unique_ptr<Server> ServerBuilder::BuildAndStart() { std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
std::unique_ptr<Server> server(new Server(thread_pool_, creds_.get())); std::unique_ptr<Server> server(new Server(thread_pool_, creds_.get()));
for (auto* service : services_) { for (auto *service : services_) {
server->RegisterService(service); server->RegisterService(service);
} }
for (auto& port : ports_) { for (auto &port : ports_) {
server->AddPort(port); server->AddPort(port);
} }
server->Start(); server->Start();

@ -37,31 +37,31 @@
namespace grpc { namespace grpc {
ServerCredentials::ServerCredentials(grpc_server_credentials* c_creds) ServerCredentials::ServerCredentials(grpc_server_credentials *c_creds)
: creds_(c_creds) {} : creds_(c_creds) {}
ServerCredentials::~ServerCredentials() { ServerCredentials::~ServerCredentials() {
grpc_server_credentials_release(creds_); grpc_server_credentials_release(creds_);
} }
grpc_server_credentials* ServerCredentials::GetRawCreds() { return creds_; } grpc_server_credentials *ServerCredentials::GetRawCreds() { return creds_; }
std::shared_ptr<ServerCredentials> ServerCredentialsFactory::SslCredentials( std::shared_ptr<ServerCredentials> ServerCredentialsFactory::SslCredentials(
const SslServerCredentialsOptions& options) { const SslServerCredentialsOptions &options) {
const unsigned char* pem_root_certs = const unsigned char *pem_root_certs =
options.pem_root_certs.empty() ? nullptr options.pem_root_certs.empty() ? nullptr
: reinterpret_cast<const unsigned char*>( : reinterpret_cast<const unsigned char *>(
options.pem_root_certs.c_str()); options.pem_root_certs.c_str());
const unsigned char* pem_private_key = const unsigned char *pem_private_key =
options.pem_private_key.empty() ? nullptr options.pem_private_key.empty() ? nullptr
: reinterpret_cast<const unsigned char*>( : reinterpret_cast<const unsigned char *>(
options.pem_private_key.c_str()); options.pem_private_key.c_str());
const unsigned char* pem_cert_chain = const unsigned char *pem_cert_chain =
options.pem_cert_chain.empty() ? nullptr options.pem_cert_chain.empty() ? nullptr
: reinterpret_cast<const unsigned char*>( : reinterpret_cast<const unsigned char *>(
options.pem_cert_chain.c_str()); options.pem_cert_chain.c_str());
grpc_server_credentials* c_creds = grpc_ssl_server_credentials_create( grpc_server_credentials *c_creds = grpc_ssl_server_credentials_create(
pem_root_certs, options.pem_root_certs.size(), pem_private_key, pem_root_certs, options.pem_root_certs.size(), pem_private_key,
options.pem_private_key.size(), pem_cert_chain, options.pem_private_key.size(), pem_cert_chain,
options.pem_cert_chain.size()); options.pem_cert_chain.size());

@ -41,8 +41,8 @@
namespace grpc { namespace grpc {
ServerRpcHandler::ServerRpcHandler(AsyncServerContext* async_server_context, ServerRpcHandler::ServerRpcHandler(AsyncServerContext *async_server_context,
RpcServiceMethod* method) RpcServiceMethod *method)
: async_server_context_(async_server_context), method_(method) {} : async_server_context_(async_server_context), method_(method) {}
void ServerRpcHandler::StartRpc() { void ServerRpcHandler::StartRpc() {
@ -71,7 +71,7 @@ void ServerRpcHandler::StartRpc() {
GPR_ASSERT(type == CompletionQueue::SERVER_READ_OK); GPR_ASSERT(type == CompletionQueue::SERVER_READ_OK);
// Run the application's rpc handler // Run the application's rpc handler
MethodHandler* handler = method_->handler(); MethodHandler *handler = method_->handler();
Status status = handler->RunHandler(MethodHandler::HandlerParameter( Status status = handler->RunHandler(MethodHandler::HandlerParameter(
&user_context, request.get(), response.get())); &user_context, request.get(), response.get()));
@ -97,7 +97,7 @@ void ServerRpcHandler::StartRpc() {
cq_.cq(), request.get(), response.get()); cq_.cq(), request.get(), response.get());
// Run the application's rpc handler // Run the application's rpc handler
MethodHandler* handler = method_->handler(); MethodHandler *handler = method_->handler();
Status status = handler->RunHandler(MethodHandler::HandlerParameter( Status status = handler->RunHandler(MethodHandler::HandlerParameter(
&user_context, request.get(), response.get(), &stream_context)); &user_context, request.get(), response.get(), &stream_context));
if (status.IsOk() && if (status.IsOk() &&
@ -110,17 +110,17 @@ void ServerRpcHandler::StartRpc() {
} }
CompletionQueue::CompletionType ServerRpcHandler::WaitForNextEvent() { CompletionQueue::CompletionType ServerRpcHandler::WaitForNextEvent() {
void* tag = nullptr; void *tag = nullptr;
CompletionQueue::CompletionType type = cq_.Next(&tag); CompletionQueue::CompletionType type = cq_.Next(&tag);
if (type != CompletionQueue::QUEUE_CLOSED && if (type != CompletionQueue::QUEUE_CLOSED &&
type != CompletionQueue::RPC_END) { type != CompletionQueue::RPC_END) {
GPR_ASSERT(static_cast<AsyncServerContext*>(tag) == GPR_ASSERT(static_cast<AsyncServerContext *>(tag) ==
async_server_context_.get()); async_server_context_.get());
} }
return type; return type;
} }
void ServerRpcHandler::FinishRpc(const Status& status) { void ServerRpcHandler::FinishRpc(const Status &status) {
async_server_context_->StartWriteStatus(status); async_server_context_->StartWriteStatus(status);
CompletionQueue::CompletionType type; CompletionQueue::CompletionType type;

@ -47,17 +47,17 @@ class RpcServiceMethod;
class ServerRpcHandler { class ServerRpcHandler {
public: public:
// Takes ownership of async_server_context. // Takes ownership of async_server_context.
ServerRpcHandler(AsyncServerContext* async_server_context, ServerRpcHandler(AsyncServerContext *async_server_context,
RpcServiceMethod* method); RpcServiceMethod *method);
void StartRpc(); void StartRpc();
private: private:
CompletionQueue::CompletionType WaitForNextEvent(); CompletionQueue::CompletionType WaitForNextEvent();
void FinishRpc(const Status& status); void FinishRpc(const Status &status);
std::unique_ptr<AsyncServerContext> async_server_context_; std::unique_ptr<AsyncServerContext> async_server_context_;
RpcServiceMethod* method_; RpcServiceMethod *method_;
CompletionQueue cq_; CompletionQueue cq_;
}; };

@ -63,12 +63,12 @@ ThreadPool::~ThreadPool() {
shutdown_ = true; shutdown_ = true;
cv_.notify_all(); cv_.notify_all();
} }
for (auto& t : threads_) { for (auto &t : threads_) {
t.join(); t.join();
} }
} }
void ThreadPool::ScheduleCallback(const std::function<void()>& callback) { void ThreadPool::ScheduleCallback(const std::function<void()> &callback) {
std::lock_guard<std::mutex> lock(mu_); std::lock_guard<std::mutex> lock(mu_);
callbacks_.push(callback); callbacks_.push(callback);
cv_.notify_all(); cv_.notify_all();

@ -49,7 +49,7 @@ class ThreadPool : public ThreadPoolInterface {
explicit ThreadPool(int num_threads); explicit ThreadPool(int num_threads);
~ThreadPool(); ~ThreadPool();
void ScheduleCallback(const std::function<void()>& callback) final; void ScheduleCallback(const std::function<void()> &callback) final;
private: private:
std::mutex mu_; std::mutex mu_;

@ -44,14 +44,14 @@
namespace grpc { namespace grpc {
// Client only ctor // Client only ctor
StreamContext::StreamContext(const RpcMethod& method, ClientContext* context, StreamContext::StreamContext(const RpcMethod &method, ClientContext *context,
const google::protobuf::Message* request, const google::protobuf::Message *request,
google::protobuf::Message* result) google::protobuf::Message *result)
: is_client_(true), : is_client_(true),
method_(&method), method_(&method),
call_(context->call()), call_(context->call()),
cq_(context->cq()), cq_(context->cq()),
request_(const_cast<google::protobuf::Message*>(request)), request_(const_cast<google::protobuf::Message *>(request)),
result_(result), result_(result),
peer_halfclosed_(false), peer_halfclosed_(false),
self_halfclosed_(false) { self_halfclosed_(false) {
@ -59,10 +59,10 @@ StreamContext::StreamContext(const RpcMethod& method, ClientContext* context,
} }
// Server only ctor // Server only ctor
StreamContext::StreamContext(const RpcMethod& method, grpc_call* call, StreamContext::StreamContext(const RpcMethod &method, grpc_call *call,
grpc_completion_queue* cq, grpc_completion_queue *cq,
google::protobuf::Message* request, google::protobuf::Message *request,
google::protobuf::Message* result) google::protobuf::Message *result)
: is_client_(false), : is_client_(false),
method_(&method), method_(&method),
call_(call), call_(call),
@ -84,7 +84,7 @@ void StreamContext::Start(bool buffered) {
client_metadata_read_tag(), client_metadata_read_tag(),
finished_tag(), flag); finished_tag(), flag);
GPR_ASSERT(GRPC_CALL_OK == error); GPR_ASSERT(GRPC_CALL_OK == error);
grpc_event* invoke_ev = grpc_event *invoke_ev =
grpc_completion_queue_pluck(cq(), invoke_tag(), gpr_inf_future); grpc_completion_queue_pluck(cq(), invoke_tag(), gpr_inf_future);
if (invoke_ev->data.invoke_accepted != GRPC_OP_OK) { if (invoke_ev->data.invoke_accepted != GRPC_OP_OK) {
peer_halfclosed_ = true; peer_halfclosed_ = true;
@ -101,11 +101,11 @@ void StreamContext::Start(bool buffered) {
} }
} }
bool StreamContext::Read(google::protobuf::Message* msg) { bool StreamContext::Read(google::protobuf::Message *msg) {
// TODO(yangg) check peer_halfclosed_ here for possible early return. // TODO(yangg) check peer_halfclosed_ here for possible early return.
grpc_call_error err = grpc_call_start_read(call(), read_tag()); grpc_call_error err = grpc_call_start_read(call(), read_tag());
GPR_ASSERT(err == GRPC_CALL_OK); GPR_ASSERT(err == GRPC_CALL_OK);
grpc_event* read_ev = grpc_event *read_ev =
grpc_completion_queue_pluck(cq(), read_tag(), gpr_inf_future); grpc_completion_queue_pluck(cq(), read_tag(), gpr_inf_future);
GPR_ASSERT(read_ev->type == GRPC_READ); GPR_ASSERT(read_ev->type == GRPC_READ);
bool ret = true; bool ret = true;
@ -123,13 +123,13 @@ bool StreamContext::Read(google::protobuf::Message* msg) {
return ret; return ret;
} }
bool StreamContext::Write(const google::protobuf::Message* msg, bool is_last) { bool StreamContext::Write(const google::protobuf::Message *msg, bool is_last) {
// TODO(yangg) check self_halfclosed_ for possible early return. // TODO(yangg) check self_halfclosed_ for possible early return.
bool ret = true; bool ret = true;
grpc_event* ev = nullptr; grpc_event *ev = nullptr;
if (msg) { if (msg) {
grpc_byte_buffer* out_buf = nullptr; grpc_byte_buffer *out_buf = nullptr;
if (!SerializeProto(*msg, &out_buf)) { if (!SerializeProto(*msg, &out_buf)) {
grpc_call_cancel_with_status(call(), GRPC_STATUS_INVALID_ARGUMENT, grpc_call_cancel_with_status(call(), GRPC_STATUS_INVALID_ARGUMENT,
"Failed to serialize outgoing proto"); "Failed to serialize outgoing proto");
@ -163,16 +163,16 @@ bool StreamContext::Write(const google::protobuf::Message* msg, bool is_last) {
return ret; return ret;
} }
const Status& StreamContext::Wait() { const Status &StreamContext::Wait() {
// TODO(yangg) properly support metadata // TODO(yangg) properly support metadata
grpc_event* metadata_ev = grpc_completion_queue_pluck( grpc_event *metadata_ev = grpc_completion_queue_pluck(
cq(), client_metadata_read_tag(), gpr_inf_future); cq(), client_metadata_read_tag(), gpr_inf_future);
grpc_event_finish(metadata_ev); grpc_event_finish(metadata_ev);
// TODO(yangg) protect states by a mutex, including other places. // TODO(yangg) protect states by a mutex, including other places.
if (!self_halfclosed_ || !peer_halfclosed_) { if (!self_halfclosed_ || !peer_halfclosed_) {
Cancel(); Cancel();
} }
grpc_event* finish_ev = grpc_event *finish_ev =
grpc_completion_queue_pluck(cq(), finished_tag(), gpr_inf_future); grpc_completion_queue_pluck(cq(), finished_tag(), gpr_inf_future);
GPR_ASSERT(finish_ev->type == GRPC_FINISHED); GPR_ASSERT(finish_ev->type == GRPC_FINISHED);
final_status_ = Status( final_status_ = Status(

@ -50,43 +50,45 @@ class RpcMethod;
class StreamContext final : public StreamContextInterface { class StreamContext final : public StreamContextInterface {
public: public:
StreamContext(const RpcMethod& method, ClientContext* context, StreamContext(const RpcMethod &method, ClientContext *context,
const google::protobuf::Message* request, const google::protobuf::Message *request,
google::protobuf::Message* result); google::protobuf::Message *result);
StreamContext(const RpcMethod& method, grpc_call* call, StreamContext(const RpcMethod &method, grpc_call *call,
grpc_completion_queue* cq, google::protobuf::Message* request, grpc_completion_queue *cq, google::protobuf::Message *request,
google::protobuf::Message* result); google::protobuf::Message *result);
~StreamContext(); ~StreamContext();
// Start the stream, if there is a final write following immediately, set // Start the stream, if there is a final write following immediately, set
// buffered so that the messages can be sent in batch. // buffered so that the messages can be sent in batch.
void Start(bool buffered) override; void Start(bool buffered) override;
bool Read(google::protobuf::Message* msg) override; bool Read(google::protobuf::Message *msg) override;
bool Write(const google::protobuf::Message* msg, bool is_last) override; bool Write(const google::protobuf::Message *msg, bool is_last) override;
const Status& Wait() override; const Status &Wait() override;
void Cancel() override; void Cancel() override;
google::protobuf::Message* request() override { return request_; } google::protobuf::Message *request() override { return request_; }
google::protobuf::Message* response() override { return result_; } google::protobuf::Message *response() override { return result_; }
private: private:
// Unique tags for plucking events from the c layer. this pointer is casted // Unique tags for plucking events from the c layer. this pointer is casted
// to char* to create single byte step between tags. It implicitly relies on // to char* to create single byte step between tags. It implicitly relies on
// that StreamContext is large enough to contain all the pointers. // that StreamContext is large enough to contain all the pointers.
void* finished_tag() { return reinterpret_cast<char*>(this); } void *finished_tag() { return reinterpret_cast<char *>(this); }
void* read_tag() { return reinterpret_cast<char*>(this) + 1; } void *read_tag() { return reinterpret_cast<char *>(this) + 1; }
void* write_tag() { return reinterpret_cast<char*>(this) + 2; } void *write_tag() { return reinterpret_cast<char *>(this) + 2; }
void* halfclose_tag() { return reinterpret_cast<char*>(this) + 3; } void *halfclose_tag() { return reinterpret_cast<char *>(this) + 3; }
void* invoke_tag() { return reinterpret_cast<char*>(this) + 4; } void *invoke_tag() { return reinterpret_cast<char *>(this) + 4; }
void* client_metadata_read_tag() { return reinterpret_cast<char*>(this) + 5; } void *client_metadata_read_tag() {
grpc_call* call() { return call_; } return reinterpret_cast<char *>(this) + 5;
grpc_completion_queue* cq() { return cq_; } }
grpc_call *call() { return call_; }
grpc_completion_queue *cq() { return cq_; }
bool is_client_; bool is_client_;
const RpcMethod* method_; // not owned const RpcMethod *method_; // not owned
grpc_call* call_; // not owned grpc_call *call_; // not owned
grpc_completion_queue* cq_; // not owned grpc_completion_queue *cq_; // not owned
google::protobuf::Message* request_; // first request, not owned google::protobuf::Message *request_; // first request, not owned
google::protobuf::Message* result_; // last response, not owned google::protobuf::Message *result_; // last response, not owned
bool peer_halfclosed_; bool peer_halfclosed_;
bool self_halfclosed_; bool self_halfclosed_;

@ -35,7 +35,7 @@
namespace grpc { namespace grpc {
const Status& Status::OK = Status(); const Status &Status::OK = Status();
const Status& Status::Cancelled = Status(StatusCode::CANCELLED); const Status &Status::Cancelled = Status(StatusCode::CANCELLED);
} // namespace grpc } // namespace grpc

@ -43,8 +43,8 @@ using std::chrono::system_clock;
namespace grpc { namespace grpc {
// TODO(yangg) prevent potential overflow. // TODO(yangg) prevent potential overflow.
void Timepoint2Timespec(const system_clock::time_point& from, void Timepoint2Timespec(const system_clock::time_point &from,
gpr_timespec* to) { gpr_timespec *to) {
system_clock::duration deadline = from.time_since_epoch(); system_clock::duration deadline = from.time_since_epoch();
seconds secs = duration_cast<seconds>(deadline); seconds secs = duration_cast<seconds>(deadline);
nanoseconds nsecs = duration_cast<nanoseconds>(deadline - secs); nanoseconds nsecs = duration_cast<nanoseconds>(deadline - secs);

@ -41,8 +41,8 @@
namespace grpc { namespace grpc {
// from and to should be absolute time. // from and to should be absolute time.
void Timepoint2Timespec(const std::chrono::system_clock::time_point& from, void Timepoint2Timespec(const std::chrono::system_clock::time_point &from,
gpr_timespec* to); gpr_timespec *to);
std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t); std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t);

@ -423,16 +423,15 @@ PHP_METHOD(Call, start_read) {
static zend_function_entry call_methods[] = { static zend_function_entry call_methods[] = {
PHP_ME(Call, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) PHP_ME(Call, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(Call, server_accept, NULL, ZEND_ACC_PUBLIC) PHP_ME(Call, server_accept, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Call, server_end_initial_metadata, NULL, ZEND_ACC_PUBLIC) PHP_ME(Call, server_end_initial_metadata, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Call, add_metadata, NULL, ZEND_ACC_PUBLIC) PHP_ME( PHP_ME(Call, add_metadata, NULL, ZEND_ACC_PUBLIC)
Call, cancel, NULL, ZEND_ACC_PUBLIC) PHP_ME(Call, cancel, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Call, start_invoke, NULL, ZEND_ACC_PUBLIC) PHP_ME( PHP_ME(Call, start_invoke, NULL, ZEND_ACC_PUBLIC)
Call, start_read, NULL, ZEND_ACC_PUBLIC) PHP_ME(Call, start_read, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Call, start_write, NULL, ZEND_ACC_PUBLIC) PHP_ME( PHP_ME(Call, start_write, NULL, ZEND_ACC_PUBLIC)
Call, start_write_status, NULL, ZEND_ACC_PUBLIC) PHP_ME(Call, start_write_status, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Call, writes_done, NULL, ZEND_ACC_PUBLIC) PHP_ME(Call, writes_done, NULL, ZEND_ACC_PUBLIC) PHP_FE_END};
PHP_FE_END};
void grpc_init_call(TSRMLS_D) { void grpc_init_call(TSRMLS_D) {
zend_class_entry ce; zend_class_entry ce;

@ -155,7 +155,7 @@ PHP_METHOD(Channel, close) {
static zend_function_entry channel_methods[] = { static zend_function_entry channel_methods[] = {
PHP_ME(Channel, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) PHP_ME(Channel, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(Channel, close, NULL, ZEND_ACC_PUBLIC) PHP_FE_END}; PHP_ME(Channel, close, NULL, ZEND_ACC_PUBLIC) PHP_FE_END};
void grpc_init_channel(TSRMLS_D) { void grpc_init_channel(TSRMLS_D) {
zend_class_entry ce; zend_class_entry ce;

@ -63,8 +63,8 @@ zend_object_value create_wrapped_grpc_completion_queue(
*/ */
PHP_METHOD(CompletionQueue, __construct) { PHP_METHOD(CompletionQueue, __construct) {
wrapped_grpc_completion_queue *queue = wrapped_grpc_completion_queue *queue =
(wrapped_grpc_completion_queue *)zend_object_store_get_object( (wrapped_grpc_completion_queue *)zend_object_store_get_object(getThis()
getThis() TSRMLS_CC); TSRMLS_CC);
queue->wrapped = grpc_completion_queue_create(); queue->wrapped = grpc_completion_queue_create();
} }
@ -86,8 +86,8 @@ PHP_METHOD(CompletionQueue, next) {
return; return;
} }
wrapped_grpc_completion_queue *completion_queue = wrapped_grpc_completion_queue *completion_queue =
(wrapped_grpc_completion_queue *)zend_object_store_get_object( (wrapped_grpc_completion_queue *)zend_object_store_get_object(getThis()
getThis() TSRMLS_CC); TSRMLS_CC);
wrapped_grpc_timeval *wrapped_timeout = wrapped_grpc_timeval *wrapped_timeout =
(wrapped_grpc_timeval *)zend_object_store_get_object(timeout TSRMLS_CC); (wrapped_grpc_timeval *)zend_object_store_get_object(timeout TSRMLS_CC);
grpc_event *event = grpc_completion_queue_next(completion_queue->wrapped, grpc_event *event = grpc_completion_queue_next(completion_queue->wrapped,
@ -109,8 +109,8 @@ PHP_METHOD(CompletionQueue, pluck) {
"pluck needs a long and a Timeval", 1 TSRMLS_CC); "pluck needs a long and a Timeval", 1 TSRMLS_CC);
} }
wrapped_grpc_completion_queue *completion_queue = wrapped_grpc_completion_queue *completion_queue =
(wrapped_grpc_completion_queue *)zend_object_store_get_object( (wrapped_grpc_completion_queue *)zend_object_store_get_object(getThis()
getThis() TSRMLS_CC); TSRMLS_CC);
wrapped_grpc_timeval *wrapped_timeout = wrapped_grpc_timeval *wrapped_timeout =
(wrapped_grpc_timeval *)zend_object_store_get_object(timeout TSRMLS_CC); (wrapped_grpc_timeval *)zend_object_store_get_object(timeout TSRMLS_CC);
grpc_event *event = grpc_completion_queue_pluck( grpc_event *event = grpc_completion_queue_pluck(
@ -124,8 +124,8 @@ PHP_METHOD(CompletionQueue, pluck) {
static zend_function_entry completion_queue_methods[] = { static zend_function_entry completion_queue_methods[] = {
PHP_ME(CompletionQueue, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) PHP_ME(CompletionQueue, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(CompletionQueue, next, NULL, ZEND_ACC_PUBLIC) PHP_ME(CompletionQueue, next, NULL, ZEND_ACC_PUBLIC)
PHP_ME(CompletionQueue, pluck, NULL, ZEND_ACC_PUBLIC) PHP_FE_END}; PHP_ME(CompletionQueue, pluck, NULL, ZEND_ACC_PUBLIC) PHP_FE_END};
void grpc_init_completion_queue(TSRMLS_D) { void grpc_init_completion_queue(TSRMLS_D) {
zend_class_entry ce; zend_class_entry ce;

@ -151,13 +151,12 @@ PHP_METHOD(Credentials, createFake) {
static zend_function_entry credentials_methods[] = { static zend_function_entry credentials_methods[] = {
PHP_ME(Credentials, createDefault, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(Credentials, createDefault, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Credentials, createSsl, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(Credentials, createSsl, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Credentials, createComposite, NULL, PHP_ME(Credentials, createComposite, NULL,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Credentials, createGce, NULL, PHP_ME(Credentials, createGce, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(Credentials, createFake, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Credentials, createFake, NULL, PHP_FE_END};
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_FE_END};
void grpc_init_credentials(TSRMLS_D) { void grpc_init_credentials(TSRMLS_D) {
zend_class_entry ce; zend_class_entry ce;

@ -33,7 +33,8 @@ zend_module_entry grpc_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901 #if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER, STANDARD_MODULE_HEADER,
#endif #endif
"grpc", grpc_functions, PHP_MINIT(grpc), PHP_MSHUTDOWN(grpc), NULL, NULL, "grpc", grpc_functions, PHP_MINIT(grpc),
PHP_MSHUTDOWN(grpc), NULL, NULL,
PHP_MINFO(grpc), PHP_MINFO(grpc),
#if ZEND_MODULE_API_NO >= 20010901 #if ZEND_MODULE_API_NO >= 20010901
PHP_GRPC_VERSION, PHP_GRPC_VERSION,

@ -176,10 +176,10 @@ PHP_METHOD(Server, start) {
static zend_function_entry server_methods[] = { static zend_function_entry server_methods[] = {
PHP_ME(Server, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) PHP_ME(Server, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(Server, request_call, NULL, ZEND_ACC_PUBLIC) PHP_ME(Server, request_call, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Server, add_http2_port, NULL, ZEND_ACC_PUBLIC) PHP_ME(Server, add_http2_port, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Server, add_secure_http2_port, NULL, ZEND_ACC_PUBLIC) PHP_ME(Server, add_secure_http2_port, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Server, start, NULL, ZEND_ACC_PUBLIC) PHP_FE_END}; PHP_ME(Server, start, NULL, ZEND_ACC_PUBLIC) PHP_FE_END};
void grpc_init_server(TSRMLS_D) { void grpc_init_server(TSRMLS_D) {
zend_class_entry ce; zend_class_entry ce;

@ -102,8 +102,8 @@ PHP_METHOD(ServerCredentials, createFake) {
static zend_function_entry server_credentials_methods[] = { static zend_function_entry server_credentials_methods[] = {
PHP_ME(ServerCredentials, createSsl, NULL, PHP_ME(ServerCredentials, createSsl, NULL,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(ServerCredentials, createFake, NULL, PHP_ME(ServerCredentials, createFake, NULL,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_FE_END}; ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_FE_END};
void grpc_init_server_credentials(TSRMLS_D) { void grpc_init_server_credentials(TSRMLS_D) {
zend_class_entry ce; zend_class_entry ce;

@ -217,20 +217,16 @@ PHP_METHOD(Timeval, sleep_until) {
} }
static zend_function_entry timeval_methods[] = { static zend_function_entry timeval_methods[] = {
PHP_ME(Timeval, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) PHP_ME( PHP_ME(Timeval, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
Timeval, add, NULL, PHP_ME(Timeval, add, NULL, ZEND_ACC_PUBLIC)
ZEND_ACC_PUBLIC) PHP_ME(Timeval, compare, NULL, PHP_ME(Timeval, compare, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(Timeval, inf_future, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Timeval, inf_future, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(Timeval, inf_past, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Timeval, inf_past, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(Timeval, now, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Timeval, now, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(Timeval, similar, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Timeval, similar, NULL, PHP_ME(Timeval, sleep_until, NULL, ZEND_ACC_PUBLIC)
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(Timeval, subtract, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Timeval, sleep_until, NULL, ZEND_ACC_PUBLIC) PHP_ME(Timeval, zero, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_FE_END};
PHP_ME(Timeval, subtract, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Timeval, zero, NULL,
ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_FE_END};
void grpc_init_timeval(TSRMLS_D) { void grpc_init_timeval(TSRMLS_D) {
zend_class_entry ce; zend_class_entry ce;

@ -78,9 +78,9 @@ static void channel_func(grpc_channel_element *elem,
static void test_create_channel_stack(void) { static void test_create_channel_stack(void) {
const grpc_channel_filter filter = { const grpc_channel_filter filter = {
call_func, channel_func, call_func, channel_func,
sizeof(int), call_init_func, call_destroy_func, sizeof(int), call_init_func, call_destroy_func,
sizeof(int), channel_init_func, channel_destroy_func, sizeof(int), channel_init_func, channel_destroy_func,
}; };

@ -78,7 +78,7 @@ static void expect_call_op(grpc_call_element *elem,
GPR_ASSERT(op->dir == GRPC_CALL_DOWN); GPR_ASSERT(op->dir == GRPC_CALL_DOWN);
GPR_ASSERT(op->flags == *n); GPR_ASSERT(op->flags == *n);
GPR_ASSERT(op->done_cb == do_nothing); GPR_ASSERT(op->done_cb == do_nothing);
GPR_ASSERT(op->user_data == (void *)(gpr_uintptr)*n); GPR_ASSERT(op->user_data == (void *)(gpr_uintptr) * n);
GPR_ASSERT(0 == gpr_slice_cmp(op->data.metadata->key->slice, key)); GPR_ASSERT(0 == gpr_slice_cmp(op->data.metadata->key->slice, key));
GPR_ASSERT(0 == gpr_slice_cmp(op->data.metadata->value->slice, value)); GPR_ASSERT(0 == gpr_slice_cmp(op->data.metadata->value->slice, value));
@ -148,7 +148,7 @@ static void test_case(size_t key_prefix_len, size_t value_prefix_len,
op.flags = i; op.flags = i;
op.data.metadata = grpc_mdelem_from_slices(mdctx, key, value); op.data.metadata = grpc_mdelem_from_slices(mdctx, key, value);
op.done_cb = do_nothing; op.done_cb = do_nothing;
op.user_data = (void *)(gpr_uintptr)i; op.user_data = (void *)(gpr_uintptr) i;
grpc_metadata_buffer_queue(&buffer, &op); grpc_metadata_buffer_queue(&buffer, &op);
} }

@ -495,4 +495,3 @@ void cq_expect_finished(cq_verifier *v, void *tag, ...) {
void cq_expect_server_shutdown(cq_verifier *v, void *tag) { void cq_expect_server_shutdown(cq_verifier *v, void *tag) {
add(v, GRPC_SERVER_SHUTDOWN, tag); add(v, GRPC_SERVER_SHUTDOWN, tag);
} }

@ -203,7 +203,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
GPR_ASSERT(ev->data.invoke_accepted == GRPC_OP_OK); GPR_ASSERT(ev->data.invoke_accepted == GRPC_OP_OK);
/* The /alpha or /beta calls started above could be invoked (but NOT both); /* The /alpha or /beta calls started above could be invoked (but NOT both);
* check this here */ * check this here */
live_call = (int)(gpr_intptr)ev->tag; live_call = (int)(gpr_intptr) ev->tag;
live_call_obj = live_call == 300 ? c1 : c2; live_call_obj = live_call == 300 ? c1 : c2;
grpc_event_finish(ev); grpc_event_finish(ev);

@ -282,11 +282,11 @@ static void run_test(grpc_end2end_test_config config, int requests_in_flight) {
/* kick off threads */ /* kick off threads */
for (i = 0; i < CLIENT_THREADS; i++) { for (i = 0; i < CLIENT_THREADS; i++) {
gpr_event_init(&g_client_done[i]); gpr_event_init(&g_client_done[i]);
gpr_thd_new(&thd_id, client_thread, (void *)(gpr_intptr)i, NULL); gpr_thd_new(&thd_id, client_thread, (void *)(gpr_intptr) i, NULL);
} }
for (i = 0; i < SERVER_THREADS; i++) { for (i = 0; i < SERVER_THREADS; i++) {
gpr_event_init(&g_server_done[i]); gpr_event_init(&g_server_done[i]);
gpr_thd_new(&thd_id, server_thread, (void *)(gpr_intptr)i, NULL); gpr_thd_new(&thd_id, server_thread, (void *)(gpr_intptr) i, NULL);
} }
/* start requests */ /* start requests */

@ -61,13 +61,13 @@ static void add_test(void) {
/* 10 ms alarms. will expire in the current epoch */ /* 10 ms alarms. will expire in the current epoch */
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
grpc_alarm_init(&alarms[i], gpr_time_add(start, gpr_time_from_millis(10)), grpc_alarm_init(&alarms[i], gpr_time_add(start, gpr_time_from_millis(10)),
cb, (void *)(gpr_intptr)i, start); cb, (void *)(gpr_intptr) i, start);
} }
/* 1010 ms alarms. will expire in the next epoch */ /* 1010 ms alarms. will expire in the next epoch */
for (i = 10; i < 20; i++) { for (i = 10; i < 20; i++) {
grpc_alarm_init(&alarms[i], gpr_time_add(start, gpr_time_from_millis(1010)), grpc_alarm_init(&alarms[i], gpr_time_add(start, gpr_time_from_millis(1010)),
cb, (void *)(gpr_intptr)i, start); cb, (void *)(gpr_intptr) i, start);
} }
/* collect alarms. Only the first batch should be ready. */ /* collect alarms. Only the first batch should be ready. */
@ -115,15 +115,15 @@ void destruction_test(void) {
memset(cb_called, 0, sizeof(cb_called)); memset(cb_called, 0, sizeof(cb_called));
grpc_alarm_init(&alarms[0], gpr_time_from_millis(100), cb, grpc_alarm_init(&alarms[0], gpr_time_from_millis(100), cb,
(void *)(gpr_intptr)0, gpr_time_0); (void *)(gpr_intptr) 0, gpr_time_0);
grpc_alarm_init(&alarms[1], gpr_time_from_millis(3), cb, grpc_alarm_init(&alarms[1], gpr_time_from_millis(3), cb,
(void *)(gpr_intptr)1, gpr_time_0); (void *)(gpr_intptr) 1, gpr_time_0);
grpc_alarm_init(&alarms[2], gpr_time_from_millis(100), cb, grpc_alarm_init(&alarms[2], gpr_time_from_millis(100), cb,
(void *)(gpr_intptr)2, gpr_time_0); (void *)(gpr_intptr) 2, gpr_time_0);
grpc_alarm_init(&alarms[3], gpr_time_from_millis(3), cb, grpc_alarm_init(&alarms[3], gpr_time_from_millis(3), cb,
(void *)(gpr_intptr)3, gpr_time_0); (void *)(gpr_intptr) 3, gpr_time_0);
grpc_alarm_init(&alarms[4], gpr_time_from_millis(1), cb, grpc_alarm_init(&alarms[4], gpr_time_from_millis(1), cb,
(void *)(gpr_intptr)4, gpr_time_0); (void *)(gpr_intptr) 4, gpr_time_0);
GPR_ASSERT(1 == grpc_alarm_check(NULL, gpr_time_from_millis(2), NULL)); GPR_ASSERT(1 == grpc_alarm_check(NULL, gpr_time_from_millis(2), NULL));
GPR_ASSERT(1 == cb_called[4][1]); GPR_ASSERT(1 == cb_called[4][1]);
grpc_alarm_cancel(&alarms[0]); grpc_alarm_cancel(&alarms[0]);

@ -290,7 +290,7 @@ static void shutdown_during_write_test_read_handler(
if (error != GRPC_ENDPOINT_CB_OK) { if (error != GRPC_ENDPOINT_CB_OK) {
grpc_endpoint_destroy(st->ep); grpc_endpoint_destroy(st->ep);
gpr_event_set(&st->ev, (void *)(gpr_intptr)error); gpr_event_set(&st->ev, (void *)(gpr_intptr) error);
} else { } else {
grpc_endpoint_notify_on_read( grpc_endpoint_notify_on_read(
st->ep, shutdown_during_write_test_read_handler, user_data); st->ep, shutdown_during_write_test_read_handler, user_data);
@ -309,7 +309,7 @@ static void shutdown_during_write_test_write_handler(
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"shutdown_during_write_test_write_handler completed unexpectedly"); "shutdown_during_write_test_write_handler completed unexpectedly");
} }
gpr_event_set(&st->ev, (void *)(gpr_intptr)1); gpr_event_set(&st->ev, (void *)(gpr_intptr) 1);
} }
static void shutdown_during_write_test(grpc_endpoint_test_config config, static void shutdown_during_write_test(grpc_endpoint_test_config config,

@ -64,8 +64,8 @@ static void free_data(void* data) { gpr_free(data); }
static void test_create_table(void) { static void test_create_table(void) {
/* Create table with uint64 key type */ /* Create table with uint64 key type */
census_ht* ht = NULL; census_ht* ht = NULL;
census_ht_option ht_options = {CENSUS_HT_UINT64, 1999, NULL, NULL, NULL, census_ht_option ht_options = {CENSUS_HT_UINT64, 1999, NULL,
NULL}; NULL, NULL, NULL};
ht = census_ht_create(&ht_options); ht = census_ht_create(&ht_options);
GPR_ASSERT(ht != NULL); GPR_ASSERT(ht != NULL);
GPR_ASSERT(census_ht_get_size(ht) == 0); GPR_ASSERT(census_ht_get_size(ht) == 0);
@ -119,8 +119,8 @@ static void test_table_with_int_key(void) {
/* Test that there is no memory leak when keys and values are owned by table. */ /* Test that there is no memory leak when keys and values are owned by table. */
static void test_value_and_key_deleter(void) { static void test_value_and_key_deleter(void) {
census_ht_option opt = {CENSUS_HT_POINTER, 7, &hash64, &cmp_str_keys, census_ht_option opt = {CENSUS_HT_POINTER, 7, &hash64,
&free_data, &free_data}; &cmp_str_keys, &free_data, &free_data};
census_ht* ht = census_ht_create(&opt); census_ht* ht = census_ht_create(&opt);
census_ht_key key; census_ht_key key;
char* val = NULL; char* val = NULL;
@ -184,8 +184,8 @@ static void test_simple_add_and_erase(void) {
} }
static void test_insertion_and_deletion_with_high_collision_rate(void) { static void test_insertion_and_deletion_with_high_collision_rate(void) {
census_ht_option opt = {CENSUS_HT_POINTER, 13, &force_collision, census_ht_option opt = {CENSUS_HT_POINTER, 13, &force_collision,
&cmp_str_keys, NULL, NULL}; &cmp_str_keys, NULL, NULL};
census_ht* ht = census_ht_create(&opt); census_ht* ht = census_ht_create(&opt);
char key_str[1000][10]; char key_str[1000][10];
gpr_uint64 val = 0; gpr_uint64 val = 0;
@ -208,12 +208,12 @@ static void test_insertion_and_deletion_with_high_collision_rate(void) {
} }
static void test_table_with_string_key(void) { static void test_table_with_string_key(void) {
census_ht_option opt = {CENSUS_HT_POINTER, 7, &hash64, &cmp_str_keys, NULL, census_ht_option opt = {CENSUS_HT_POINTER, 7, &hash64,
NULL}; &cmp_str_keys, NULL, NULL};
census_ht* ht = census_ht_create(&opt); census_ht* ht = census_ht_create(&opt);
const char* keys[] = {"k1", "a", "000", "apple", const char* keys[] = {"k1", "a", "000",
"banana_a_long_long_long_banana", "%$", "111", "foo", "apple", "banana_a_long_long_long_banana", "%$",
"b"}; "111", "foo", "b"};
const int vals[] = {0, 1, 2, 3, 4, 5, 6, 7, 8}; const int vals[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
int i = 0; int i = 0;
GPR_ASSERT(ht != NULL); GPR_ASSERT(ht != NULL);

@ -53,23 +53,23 @@ static void producer_thread(void *arg) {
test_thread_options *opt = arg; test_thread_options *opt = arg;
int i; int i;
gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1); gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->start, gpr_inf_future)); GPR_ASSERT(gpr_event_wait(opt->start, gpr_inf_future));
for (i = 0; i < opt->iterations; i++) { for (i = 0; i < opt->iterations; i++) {
grpc_cq_begin_op(opt->cc, NULL, GRPC_WRITE_ACCEPTED); grpc_cq_begin_op(opt->cc, NULL, GRPC_WRITE_ACCEPTED);
grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr)1, NULL, NULL, NULL, grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr) 1, NULL, NULL,
GRPC_OP_OK); NULL, GRPC_OP_OK);
} }
gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1); gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
} }
static void consumer_thread(void *arg) { static void consumer_thread(void *arg) {
test_thread_options *opt = arg; test_thread_options *opt = arg;
grpc_event *ev; grpc_event *ev;
gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1); gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->start, gpr_inf_future)); GPR_ASSERT(gpr_event_wait(opt->start, gpr_inf_future));
for (;;) { for (;;) {
@ -78,7 +78,7 @@ static void consumer_thread(void *arg) {
case GRPC_WRITE_ACCEPTED: case GRPC_WRITE_ACCEPTED:
break; break;
case GRPC_QUEUE_SHUTDOWN: case GRPC_QUEUE_SHUTDOWN:
gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1); gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
return; return;
default: default:
gpr_log(GPR_ERROR, "Invalid event received: %d", ev->type); gpr_log(GPR_ERROR, "Invalid event received: %d", ev->type);
@ -112,7 +112,7 @@ double ops_per_second(int consumers, int producers, int iterations) {
/* start the benchmark */ /* start the benchmark */
t_start = gpr_now(); t_start = gpr_now();
gpr_event_set(&start, (void *)(gpr_intptr)1); gpr_event_set(&start, (void *)(gpr_intptr) 1);
/* wait for producers to finish */ /* wait for producers to finish */
for (i = 0; i < producers; i++) { for (i = 0; i < producers; i++) {

@ -282,7 +282,7 @@ static void producer_thread(void *arg) {
int i; int i;
gpr_log(GPR_INFO, "producer %d started", opt->id); gpr_log(GPR_INFO, "producer %d started", opt->id);
gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1); gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time())); GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 1", opt->id); gpr_log(GPR_INFO, "producer %d phase 1", opt->id);
@ -291,18 +291,18 @@ static void producer_thread(void *arg) {
} }
gpr_log(GPR_INFO, "producer %d phase 1 done", opt->id); gpr_log(GPR_INFO, "producer %d phase 1 done", opt->id);
gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr)1); gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time())); GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 2", opt->id); gpr_log(GPR_INFO, "producer %d phase 2", opt->id);
for (i = 0; i < TEST_THREAD_EVENTS; i++) { for (i = 0; i < TEST_THREAD_EVENTS; i++) {
grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr)1, NULL, NULL, NULL, grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr) 1, NULL, NULL,
GRPC_OP_OK); NULL, GRPC_OP_OK);
opt->events_triggered++; opt->events_triggered++;
} }
gpr_log(GPR_INFO, "producer %d phase 2 done", opt->id); gpr_log(GPR_INFO, "producer %d phase 2 done", opt->id);
gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1); gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
} }
static void consumer_thread(void *arg) { static void consumer_thread(void *arg) {
@ -310,13 +310,13 @@ static void consumer_thread(void *arg) {
grpc_event *ev; grpc_event *ev;
gpr_log(GPR_INFO, "consumer %d started", opt->id); gpr_log(GPR_INFO, "consumer %d started", opt->id);
gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1); gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time())); GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 1", opt->id); gpr_log(GPR_INFO, "consumer %d phase 1", opt->id);
gpr_log(GPR_INFO, "consumer %d phase 1 done", opt->id); gpr_log(GPR_INFO, "consumer %d phase 1 done", opt->id);
gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr)1); gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr) 1);
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time())); GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 2", opt->id); gpr_log(GPR_INFO, "consumer %d phase 2", opt->id);
@ -331,7 +331,7 @@ static void consumer_thread(void *arg) {
break; break;
case GRPC_QUEUE_SHUTDOWN: case GRPC_QUEUE_SHUTDOWN:
gpr_log(GPR_INFO, "consumer %d phase 2 done", opt->id); gpr_log(GPR_INFO, "consumer %d phase 2 done", opt->id);
gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1); gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
grpc_event_finish(ev); grpc_event_finish(ev);
return; return;
default: default:
@ -376,7 +376,7 @@ static void test_threading(int producers, int consumers) {
/* start phase1: producers will pre-declare all operations they will /* start phase1: producers will pre-declare all operations they will
complete */ complete */
gpr_log(GPR_INFO, "start phase 1"); gpr_log(GPR_INFO, "start phase 1");
gpr_event_set(&phase1, (void *)(gpr_intptr)1); gpr_event_set(&phase1, (void *)(gpr_intptr) 1);
gpr_log(GPR_INFO, "wait phase 1"); gpr_log(GPR_INFO, "wait phase 1");
for (i = 0; i < producers + consumers; i++) { for (i = 0; i < producers + consumers; i++) {
@ -386,7 +386,7 @@ static void test_threading(int producers, int consumers) {
/* start phase2: operations will complete, and consumers will consume them */ /* start phase2: operations will complete, and consumers will consume them */
gpr_log(GPR_INFO, "start phase 2"); gpr_log(GPR_INFO, "start phase 2");
gpr_event_set(&phase2, (void *)(gpr_intptr)1); gpr_event_set(&phase2, (void *)(gpr_intptr) 1);
/* in parallel, we shutdown the completion channel - all events should still /* in parallel, we shutdown the completion channel - all events should still
be consumed */ be consumed */

@ -93,7 +93,7 @@ static void test_basic_add_find(size_t n) {
grpc_chttp2_stream_map_init(&map, 8); grpc_chttp2_stream_map_init(&map, 8);
GPR_ASSERT(0 == grpc_chttp2_stream_map_size(&map)); GPR_ASSERT(0 == grpc_chttp2_stream_map_size(&map));
for (i = 1; i <= n; i++) { for (i = 1; i <= n; i++) {
grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i); grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr) i);
} }
GPR_ASSERT(n == grpc_chttp2_stream_map_size(&map)); GPR_ASSERT(n == grpc_chttp2_stream_map_size(&map));
GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 0)); GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 0));
@ -148,7 +148,7 @@ static void test_delete_evens_sweep(size_t n) {
grpc_chttp2_stream_map_init(&map, 8); grpc_chttp2_stream_map_init(&map, 8);
for (i = 1; i <= n; i++) { for (i = 1; i <= n; i++) {
grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i); grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr) i);
} }
for (i = 1; i <= n; i++) { for (i = 1; i <= n; i++) {
if ((i & 1) == 0) { if ((i & 1) == 0) {
@ -170,7 +170,7 @@ static void test_delete_evens_incremental(size_t n) {
grpc_chttp2_stream_map_init(&map, 8); grpc_chttp2_stream_map_init(&map, 8);
for (i = 1; i <= n; i++) { for (i = 1; i <= n; i++) {
grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i); grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr) i);
if ((i & 1) == 0) { if ((i & 1) == 0) {
grpc_chttp2_stream_map_delete(&map, i); grpc_chttp2_stream_map_delete(&map, i);
} }

@ -1,8 +1,9 @@
#!/bin/bash #!/bin/bash
set -ex set -e
source $(dirname $0)/config.sh
cd $(dirname $0)/../.. cd $(dirname $0)/../..
for dir in src test include for dir in src test include
do do
find $dir -name '*.c' -or -name '*.cc' -or -name '*.h' | xargs clang-format -i find $dir -name '*.c' -or -name '*.cc' -or -name '*.h' | xargs $CLANG_FORMAT -i
done done

@ -0,0 +1 @@
CLANG_FORMAT=clang-format-3.5
Loading…
Cancel
Save