Merge branch 'master' into fix-time

pull/14894/head
Sree Kuchibhotla 7 years ago
commit 7b011b296e
  1. 9
      BUILD
  2. 17
      CMakeLists.txt
  3. 19
      Makefile
  4. 3
      PYTHON-MANIFEST.in
  5. 8
      bazel/grpc_deps.bzl
  6. 9
      build.yaml
  7. 4
      config.w32
  8. 1
      doc/g_stands_for.md
  9. 44
      examples/android/helloworld/app/CMakeLists.txt
  10. 7
      gRPC-C++.podspec
  11. 2
      gRPC-Core.podspec
  12. 2
      gRPC-ProtoRPC.podspec
  13. 2
      gRPC-RxLibrary.podspec
  14. 2
      gRPC.podspec
  15. 2
      grpc.gyp
  16. 2
      include/grpcpp/client_context.h
  17. 43
      include/grpcpp/impl/codegen/byte_buffer.h
  18. 3
      include/grpcpp/impl/codegen/core_codegen.h
  19. 5
      include/grpcpp/impl/codegen/core_codegen_interface.h
  20. 151
      include/grpcpp/impl/codegen/proto_buffer_reader.h
  21. 168
      include/grpcpp/impl/codegen/proto_buffer_writer.h
  22. 220
      include/grpcpp/impl/codegen/proto_utils.h
  23. 4
      include/grpcpp/impl/codegen/server_context.h
  24. 39
      include/grpcpp/impl/codegen/slice.h
  25. 24
      include/grpcpp/support/proto_buffer_reader.h
  26. 24
      include/grpcpp/support/proto_buffer_writer.h
  27. 4
      package.xml
  28. 2
      src/compiler/objective_c_generator.cc
  29. 10
      src/compiler/objective_c_plugin.cc
  30. 27
      src/core/ext/filters/client_channel/client_channel.cc
  31. 3
      src/core/lib/debug/trace.cc
  32. 62
      src/core/lib/gprpp/inlined_vector.h
  33. 23
      src/core/lib/iomgr/ev_epollex_linux.cc
  34. 6
      src/core/lib/iomgr/ev_poll_posix.cc
  35. 1
      src/core/lib/iomgr/socket_utils_linux.cc
  36. 5
      src/core/lib/iomgr/socket_utils_posix.cc
  37. 4
      src/core/lib/iomgr/socket_utils_uv.cc
  38. 2
      src/core/lib/iomgr/tcp_custom.h
  39. 7
      src/core/lib/iomgr/tcp_server_custom.cc
  40. 1
      src/core/lib/iomgr/tcp_server_windows.cc
  41. 35
      src/core/lib/iomgr/tcp_uv.cc
  42. 10
      src/core/lib/iomgr/timer_generic.cc
  43. 4
      src/core/lib/slice/slice.cc
  44. 8
      src/core/lib/slice/slice_buffer.cc
  45. 4
      src/core/lib/surface/call.cc
  46. 2
      src/core/lib/surface/version.cc
  47. 10
      src/cpp/common/core_codegen.cc
  48. 2
      src/cpp/common/version_cc.cc
  49. 40
      src/cpp/util/byte_buffer_cc.cc
  50. 55
      src/cpp/util/slice_cc.cc
  51. 2
      src/csharp/Grpc.Core/Version.csproj.include
  52. 4
      src/csharp/Grpc.Core/VersionInfo.cs
  53. 2
      src/csharp/build_packages_dotnetcli.bat
  54. 4
      src/csharp/build_packages_dotnetcli.sh
  55. 2
      src/objective-c/!ProtoCompiler-gRPCPlugin.podspec
  56. 24
      src/objective-c/GRPCClient/GRPCCall.m
  57. 2
      src/objective-c/GRPCClient/private/version.h
  58. 38
      src/objective-c/tests/GRPCClientTests.m
  59. 2
      src/objective-c/tests/version.h
  60. 2
      src/php/composer.json
  61. 2
      src/php/ext/grpc/version.h
  62. 2
      src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pxd
  63. 6
      src/python/grpcio/grpc/_cython/_cygrpc/grpc_gevent.pyx
  64. 2
      src/python/grpcio/grpc/_grpcio_metadata.py
  65. 2
      src/python/grpcio/grpc_version.py
  66. 2
      src/python/grpcio_health_checking/grpc_version.py
  67. 2
      src/python/grpcio_reflection/grpc_version.py
  68. 2
      src/python/grpcio_testing/grpc_version.py
  69. 2
      src/python/grpcio_tests/grpc_version.py
  70. 6
      src/ruby/end2end/multiple_killed_watching_threads_driver.rb
  71. 2
      src/ruby/ext/grpc/extconf.rb
  72. 12
      src/ruby/ext/grpc/rb_channel.c
  73. 13
      src/ruby/lib/grpc/generic/bidi_call.rb
  74. 2
      src/ruby/lib/grpc/version.rb
  75. 133
      src/ruby/spec/generic/client_stub_spec.rb
  76. 7
      src/ruby/spec/pb/package_with_underscore/checker_spec.rb
  77. 2
      src/ruby/tools/version.rb
  78. 4
      templates/config.w32.template
  79. 8
      templates/test/cpp/naming/resolver_component_tests_defs.include
  80. 80
      templates/tools/dockerfile/interoptest/grpc_interop_android_java/Dockerfile.template
  81. 2
      templates/tools/dockerfile/python_deps.include
  82. 3
      templates/tools/dockerfile/test/cxx_alpine_x64/Dockerfile.template
  83. 1
      test/core/gprpp/inlined_vector_test.cc
  84. 5
      test/core/surface/server_chttp2_test.cc
  85. 5
      test/core/surface/server_test.cc
  86. 2
      test/core/util/fuzzer_corpus_test.cc
  87. 42
      test/cpp/codegen/proto_utils_test.cc
  88. 8
      test/cpp/naming/resolver_component_tests_runner.sh
  89. 5
      test/cpp/naming/resolver_component_tests_runner_invoker.cc
  90. 15
      test/cpp/server/server_builder_test.cc
  91. 2
      test/cpp/util/BUILD
  92. 6
      test/cpp/util/byte_buffer_test.cc
  93. 3
      test/cpp/util/grpc_tool_test.cc
  94. 6
      test/cpp/util/slice_test.cc
  95. 10
      tools/distrib/build_ruby_environment_macos.sh
  96. 2
      tools/distrib/pylint_code.sh
  97. 2
      tools/distrib/python/grpcio_tools/grpc_version.py
  98. 2
      tools/distrib/yapf_code.sh
  99. 2
      tools/dockerfile/grpc_clang_tidy/Dockerfile
  100. 78
      tools/dockerfile/interoptest/grpc_interop_android_java/Dockerfile
  101. Some files were not shown because too many files have changed in this diff Show More

@ -64,11 +64,11 @@ config_setting(
) )
# This should be updated along with build.yaml # This should be updated along with build.yaml
g_stands_for = "gorgeous" g_stands_for = "glorious"
core_version = "6.0.0-dev" core_version = "6.0.0-dev"
version = "1.11.0-dev" version = "1.12.0-dev"
GPR_PUBLIC_HDRS = [ GPR_PUBLIC_HDRS = [
"include/grpc/support/alloc.h", "include/grpc/support/alloc.h",
@ -141,7 +141,6 @@ GRPCXX_SRCS = [
"src/cpp/server/server_posix.cc", "src/cpp/server/server_posix.cc",
"src/cpp/thread_manager/thread_manager.cc", "src/cpp/thread_manager/thread_manager.cc",
"src/cpp/util/byte_buffer_cc.cc", "src/cpp/util/byte_buffer_cc.cc",
"src/cpp/util/slice_cc.cc",
"src/cpp/util/status.cc", "src/cpp/util/status.cc",
"src/cpp/util/string_ref.cc", "src/cpp/util/string_ref.cc",
"src/cpp/util/time_cc.cc", "src/cpp/util/time_cc.cc",
@ -245,6 +244,8 @@ GRPCXX_PUBLIC_HDRS = [
"include/grpcpp/support/byte_buffer.h", "include/grpcpp/support/byte_buffer.h",
"include/grpcpp/support/channel_arguments.h", "include/grpcpp/support/channel_arguments.h",
"include/grpcpp/support/config.h", "include/grpcpp/support/config.h",
"include/grpcpp/support/proto_buffer_reader.h",
"include/grpcpp/support/proto_buffer_writer.h",
"include/grpcpp/support/slice.h", "include/grpcpp/support/slice.h",
"include/grpcpp/support/status.h", "include/grpcpp/support/status.h",
"include/grpcpp/support/status_code_enum.h", "include/grpcpp/support/status_code_enum.h",
@ -1871,6 +1872,8 @@ grpc_cc_library(
language = "c++", language = "c++",
public_hdrs = [ public_hdrs = [
"include/grpc++/impl/codegen/proto_utils.h", "include/grpc++/impl/codegen/proto_utils.h",
"include/grpcpp/impl/codegen/proto_buffer_reader.h",
"include/grpcpp/impl/codegen/proto_buffer_writer.h",
"include/grpcpp/impl/codegen/proto_utils.h", "include/grpcpp/impl/codegen/proto_utils.h",
], ],
deps = [ deps = [

@ -24,7 +24,7 @@
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
set(PACKAGE_NAME "grpc") set(PACKAGE_NAME "grpc")
set(PACKAGE_VERSION "1.11.0-dev") set(PACKAGE_VERSION "1.12.0-dev")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/")
@ -2716,7 +2716,6 @@ add_library(grpc++
src/cpp/server/server_posix.cc src/cpp/server/server_posix.cc
src/cpp/thread_manager/thread_manager.cc src/cpp/thread_manager/thread_manager.cc
src/cpp/util/byte_buffer_cc.cc src/cpp/util/byte_buffer_cc.cc
src/cpp/util/slice_cc.cc
src/cpp/util/status.cc src/cpp/util/status.cc
src/cpp/util/string_ref.cc src/cpp/util/string_ref.cc
src/cpp/util/time_cc.cc src/cpp/util/time_cc.cc
@ -2841,6 +2840,8 @@ foreach(_hdr
include/grpcpp/support/byte_buffer.h include/grpcpp/support/byte_buffer.h
include/grpcpp/support/channel_arguments.h include/grpcpp/support/channel_arguments.h
include/grpcpp/support/config.h include/grpcpp/support/config.h
include/grpcpp/support/proto_buffer_reader.h
include/grpcpp/support/proto_buffer_writer.h
include/grpcpp/support/slice.h include/grpcpp/support/slice.h
include/grpcpp/support/status.h include/grpcpp/support/status.h
include/grpcpp/support/status_code_enum.h include/grpcpp/support/status_code_enum.h
@ -2959,6 +2960,8 @@ foreach(_hdr
include/grpcpp/impl/codegen/sync_stream.h include/grpcpp/impl/codegen/sync_stream.h
include/grpcpp/impl/codegen/time.h include/grpcpp/impl/codegen/time.h
include/grpc++/impl/codegen/proto_utils.h include/grpc++/impl/codegen/proto_utils.h
include/grpcpp/impl/codegen/proto_buffer_reader.h
include/grpcpp/impl/codegen/proto_buffer_writer.h
include/grpcpp/impl/codegen/proto_utils.h include/grpcpp/impl/codegen/proto_utils.h
include/grpc++/impl/codegen/config_protobuf.h include/grpc++/impl/codegen/config_protobuf.h
include/grpcpp/impl/codegen/config_protobuf.h include/grpcpp/impl/codegen/config_protobuf.h
@ -3067,7 +3070,6 @@ add_library(grpc++_cronet
src/cpp/server/server_posix.cc src/cpp/server/server_posix.cc
src/cpp/thread_manager/thread_manager.cc src/cpp/thread_manager/thread_manager.cc
src/cpp/util/byte_buffer_cc.cc src/cpp/util/byte_buffer_cc.cc
src/cpp/util/slice_cc.cc
src/cpp/util/status.cc src/cpp/util/status.cc
src/cpp/util/string_ref.cc src/cpp/util/string_ref.cc
src/cpp/util/time_cc.cc src/cpp/util/time_cc.cc
@ -3402,6 +3404,8 @@ foreach(_hdr
include/grpcpp/support/byte_buffer.h include/grpcpp/support/byte_buffer.h
include/grpcpp/support/channel_arguments.h include/grpcpp/support/channel_arguments.h
include/grpcpp/support/config.h include/grpcpp/support/config.h
include/grpcpp/support/proto_buffer_reader.h
include/grpcpp/support/proto_buffer_writer.h
include/grpcpp/support/slice.h include/grpcpp/support/slice.h
include/grpcpp/support/status.h include/grpcpp/support/status.h
include/grpcpp/support/status_code_enum.h include/grpcpp/support/status_code_enum.h
@ -3945,6 +3949,8 @@ foreach(_hdr
include/grpc/impl/codegen/sync_posix.h include/grpc/impl/codegen/sync_posix.h
include/grpc/impl/codegen/sync_windows.h include/grpc/impl/codegen/sync_windows.h
include/grpc++/impl/codegen/proto_utils.h include/grpc++/impl/codegen/proto_utils.h
include/grpcpp/impl/codegen/proto_buffer_reader.h
include/grpcpp/impl/codegen/proto_buffer_writer.h
include/grpcpp/impl/codegen/proto_utils.h include/grpcpp/impl/codegen/proto_utils.h
include/grpc++/impl/codegen/config_protobuf.h include/grpc++/impl/codegen/config_protobuf.h
include/grpcpp/impl/codegen/config_protobuf.h include/grpcpp/impl/codegen/config_protobuf.h
@ -4118,6 +4124,8 @@ foreach(_hdr
include/grpc/impl/codegen/sync_posix.h include/grpc/impl/codegen/sync_posix.h
include/grpc/impl/codegen/sync_windows.h include/grpc/impl/codegen/sync_windows.h
include/grpc++/impl/codegen/proto_utils.h include/grpc++/impl/codegen/proto_utils.h
include/grpcpp/impl/codegen/proto_buffer_reader.h
include/grpcpp/impl/codegen/proto_buffer_writer.h
include/grpcpp/impl/codegen/proto_utils.h include/grpcpp/impl/codegen/proto_utils.h
include/grpc++/impl/codegen/config_protobuf.h include/grpc++/impl/codegen/config_protobuf.h
include/grpcpp/impl/codegen/config_protobuf.h include/grpcpp/impl/codegen/config_protobuf.h
@ -4166,7 +4174,6 @@ add_library(grpc++_unsecure
src/cpp/server/server_posix.cc src/cpp/server/server_posix.cc
src/cpp/thread_manager/thread_manager.cc src/cpp/thread_manager/thread_manager.cc
src/cpp/util/byte_buffer_cc.cc src/cpp/util/byte_buffer_cc.cc
src/cpp/util/slice_cc.cc
src/cpp/util/status.cc src/cpp/util/status.cc
src/cpp/util/string_ref.cc src/cpp/util/string_ref.cc
src/cpp/util/time_cc.cc src/cpp/util/time_cc.cc
@ -4290,6 +4297,8 @@ foreach(_hdr
include/grpcpp/support/byte_buffer.h include/grpcpp/support/byte_buffer.h
include/grpcpp/support/channel_arguments.h include/grpcpp/support/channel_arguments.h
include/grpcpp/support/config.h include/grpcpp/support/config.h
include/grpcpp/support/proto_buffer_reader.h
include/grpcpp/support/proto_buffer_writer.h
include/grpcpp/support/slice.h include/grpcpp/support/slice.h
include/grpcpp/support/status.h include/grpcpp/support/status.h
include/grpcpp/support/status_code_enum.h include/grpcpp/support/status_code_enum.h

@ -421,8 +421,8 @@ Q = @
endif endif
CORE_VERSION = 6.0.0-dev CORE_VERSION = 6.0.0-dev
CPP_VERSION = 1.11.0-dev CPP_VERSION = 1.12.0-dev
CSHARP_VERSION = 1.11.0-dev CSHARP_VERSION = 1.12.0-dev
CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
@ -5019,7 +5019,6 @@ LIBGRPC++_SRC = \
src/cpp/server/server_posix.cc \ src/cpp/server/server_posix.cc \
src/cpp/thread_manager/thread_manager.cc \ src/cpp/thread_manager/thread_manager.cc \
src/cpp/util/byte_buffer_cc.cc \ src/cpp/util/byte_buffer_cc.cc \
src/cpp/util/slice_cc.cc \
src/cpp/util/status.cc \ src/cpp/util/status.cc \
src/cpp/util/string_ref.cc \ src/cpp/util/string_ref.cc \
src/cpp/util/time_cc.cc \ src/cpp/util/time_cc.cc \
@ -5109,6 +5108,8 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/support/byte_buffer.h \ include/grpcpp/support/byte_buffer.h \
include/grpcpp/support/channel_arguments.h \ include/grpcpp/support/channel_arguments.h \
include/grpcpp/support/config.h \ include/grpcpp/support/config.h \
include/grpcpp/support/proto_buffer_reader.h \
include/grpcpp/support/proto_buffer_writer.h \
include/grpcpp/support/slice.h \ include/grpcpp/support/slice.h \
include/grpcpp/support/status.h \ include/grpcpp/support/status.h \
include/grpcpp/support/status_code_enum.h \ include/grpcpp/support/status_code_enum.h \
@ -5227,6 +5228,8 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/codegen/sync_stream.h \ include/grpcpp/impl/codegen/sync_stream.h \
include/grpcpp/impl/codegen/time.h \ include/grpcpp/impl/codegen/time.h \
include/grpc++/impl/codegen/proto_utils.h \ include/grpc++/impl/codegen/proto_utils.h \
include/grpcpp/impl/codegen/proto_buffer_reader.h \
include/grpcpp/impl/codegen/proto_buffer_writer.h \
include/grpcpp/impl/codegen/proto_utils.h \ include/grpcpp/impl/codegen/proto_utils.h \
include/grpc++/impl/codegen/config_protobuf.h \ include/grpc++/impl/codegen/config_protobuf.h \
include/grpcpp/impl/codegen/config_protobuf.h \ include/grpcpp/impl/codegen/config_protobuf.h \
@ -5380,7 +5383,6 @@ LIBGRPC++_CRONET_SRC = \
src/cpp/server/server_posix.cc \ src/cpp/server/server_posix.cc \
src/cpp/thread_manager/thread_manager.cc \ src/cpp/thread_manager/thread_manager.cc \
src/cpp/util/byte_buffer_cc.cc \ src/cpp/util/byte_buffer_cc.cc \
src/cpp/util/slice_cc.cc \
src/cpp/util/status.cc \ src/cpp/util/status.cc \
src/cpp/util/string_ref.cc \ src/cpp/util/string_ref.cc \
src/cpp/util/time_cc.cc \ src/cpp/util/time_cc.cc \
@ -5679,6 +5681,8 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/support/byte_buffer.h \ include/grpcpp/support/byte_buffer.h \
include/grpcpp/support/channel_arguments.h \ include/grpcpp/support/channel_arguments.h \
include/grpcpp/support/config.h \ include/grpcpp/support/config.h \
include/grpcpp/support/proto_buffer_reader.h \
include/grpcpp/support/proto_buffer_writer.h \
include/grpcpp/support/slice.h \ include/grpcpp/support/slice.h \
include/grpcpp/support/status.h \ include/grpcpp/support/status.h \
include/grpcpp/support/status_code_enum.h \ include/grpcpp/support/status_code_enum.h \
@ -6207,6 +6211,8 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/sync_posix.h \ include/grpc/impl/codegen/sync_posix.h \
include/grpc/impl/codegen/sync_windows.h \ include/grpc/impl/codegen/sync_windows.h \
include/grpc++/impl/codegen/proto_utils.h \ include/grpc++/impl/codegen/proto_utils.h \
include/grpcpp/impl/codegen/proto_buffer_reader.h \
include/grpcpp/impl/codegen/proto_buffer_writer.h \
include/grpcpp/impl/codegen/proto_utils.h \ include/grpcpp/impl/codegen/proto_utils.h \
include/grpc++/impl/codegen/config_protobuf.h \ include/grpc++/impl/codegen/config_protobuf.h \
include/grpcpp/impl/codegen/config_protobuf.h \ include/grpcpp/impl/codegen/config_protobuf.h \
@ -6357,6 +6363,8 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/sync_posix.h \ include/grpc/impl/codegen/sync_posix.h \
include/grpc/impl/codegen/sync_windows.h \ include/grpc/impl/codegen/sync_windows.h \
include/grpc++/impl/codegen/proto_utils.h \ include/grpc++/impl/codegen/proto_utils.h \
include/grpcpp/impl/codegen/proto_buffer_reader.h \
include/grpcpp/impl/codegen/proto_buffer_writer.h \
include/grpcpp/impl/codegen/proto_utils.h \ include/grpcpp/impl/codegen/proto_utils.h \
include/grpc++/impl/codegen/config_protobuf.h \ include/grpc++/impl/codegen/config_protobuf.h \
include/grpcpp/impl/codegen/config_protobuf.h \ include/grpcpp/impl/codegen/config_protobuf.h \
@ -6444,7 +6452,6 @@ LIBGRPC++_UNSECURE_SRC = \
src/cpp/server/server_posix.cc \ src/cpp/server/server_posix.cc \
src/cpp/thread_manager/thread_manager.cc \ src/cpp/thread_manager/thread_manager.cc \
src/cpp/util/byte_buffer_cc.cc \ src/cpp/util/byte_buffer_cc.cc \
src/cpp/util/slice_cc.cc \
src/cpp/util/status.cc \ src/cpp/util/status.cc \
src/cpp/util/string_ref.cc \ src/cpp/util/string_ref.cc \
src/cpp/util/time_cc.cc \ src/cpp/util/time_cc.cc \
@ -6534,6 +6541,8 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/support/byte_buffer.h \ include/grpcpp/support/byte_buffer.h \
include/grpcpp/support/channel_arguments.h \ include/grpcpp/support/channel_arguments.h \
include/grpcpp/support/config.h \ include/grpcpp/support/config.h \
include/grpcpp/support/proto_buffer_reader.h \
include/grpcpp/support/proto_buffer_writer.h \
include/grpcpp/support/slice.h \ include/grpcpp/support/slice.h \
include/grpcpp/support/status.h \ include/grpcpp/support/status.h \
include/grpcpp/support/status_code_enum.h \ include/grpcpp/support/status_code_enum.h \

@ -4,10 +4,11 @@ graft src/python/grpcio/grpcio.egg-info
graft src/core graft src/core
graft src/boringssl graft src/boringssl
graft include/grpc graft include/grpc
graft third_party/address_sorting
graft third_party/boringssl graft third_party/boringssl
graft third_party/cares
graft third_party/nanopb graft third_party/nanopb
graft third_party/zlib graft third_party/zlib
graft third_party/cares
include src/python/grpcio/_spawn_patch.py include src/python/grpcio/_spawn_patch.py
include src/python/grpcio/commands.py include src/python/grpcio/commands.py
include src/python/grpcio/grpc_version.py include src/python/grpcio/grpc_version.py

@ -130,12 +130,12 @@ def grpc_deps():
if "com_github_bazelbuild_bazeltoolchains" not in native.existing_rules(): if "com_github_bazelbuild_bazeltoolchains" not in native.existing_rules():
native.http_archive( native.http_archive(
name = "com_github_bazelbuild_bazeltoolchains", name = "com_github_bazelbuild_bazeltoolchains",
strip_prefix = "bazel-toolchains-b850ccdf53fed1ccab7670f52d6b297d74348d1b", strip_prefix = "bazel-toolchains-44200e0c026d86c53470d107b3697a3e46469c43",
urls = [ urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/b850ccdf53fed1ccab7670f52d6b297d74348d1b.tar.gz", "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/44200e0c026d86c53470d107b3697a3e46469c43.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/b850ccdf53fed1ccab7670f52d6b297d74348d1b.tar.gz", "https://github.com/bazelbuild/bazel-toolchains/archive/44200e0c026d86c53470d107b3697a3e46469c43.tar.gz",
], ],
sha256 = "d84d6b2fe88ef99963febf91ddce33503eed14c155ace922e2122271b483be64", sha256 = "699b55a6916c687f4b7dc092dbbf5f64672cde0dc965f79717735ec4e5416556",
) )
# TODO: move some dependencies from "grpc_deps" here? # TODO: move some dependencies from "grpc_deps" here?

@ -13,8 +13,8 @@ settings:
'#09': Per-language overrides are possible with (eg) ruby_version tag here '#09': Per-language overrides are possible with (eg) ruby_version tag here
'#10': See the expand_version.py for all the quirks here '#10': See the expand_version.py for all the quirks here
core_version: 6.0.0-dev core_version: 6.0.0-dev
g_stands_for: gorgeous g_stands_for: glorious
version: 1.11.0-dev version: 1.12.0-dev
filegroups: filegroups:
- name: alts_proto - name: alts_proto
headers: headers:
@ -1164,6 +1164,8 @@ filegroups:
language: c++ language: c++
public_headers: public_headers:
- include/grpc++/impl/codegen/proto_utils.h - include/grpc++/impl/codegen/proto_utils.h
- include/grpcpp/impl/codegen/proto_buffer_reader.h
- include/grpcpp/impl/codegen/proto_buffer_writer.h
- include/grpcpp/impl/codegen/proto_utils.h - include/grpcpp/impl/codegen/proto_utils.h
uses: uses:
- grpc++_codegen_base - grpc++_codegen_base
@ -1254,6 +1256,8 @@ filegroups:
- include/grpcpp/support/byte_buffer.h - include/grpcpp/support/byte_buffer.h
- include/grpcpp/support/channel_arguments.h - include/grpcpp/support/channel_arguments.h
- include/grpcpp/support/config.h - include/grpcpp/support/config.h
- include/grpcpp/support/proto_buffer_reader.h
- include/grpcpp/support/proto_buffer_writer.h
- include/grpcpp/support/slice.h - include/grpcpp/support/slice.h
- include/grpcpp/support/status.h - include/grpcpp/support/status.h
- include/grpcpp/support/status_code_enum.h - include/grpcpp/support/status_code_enum.h
@ -1300,7 +1304,6 @@ filegroups:
- src/cpp/server/server_posix.cc - src/cpp/server/server_posix.cc
- src/cpp/thread_manager/thread_manager.cc - src/cpp/thread_manager/thread_manager.cc
- src/cpp/util/byte_buffer_cc.cc - src/cpp/util/byte_buffer_cc.cc
- src/cpp/util/slice_cc.cc
- src/cpp/util/status.cc - src/cpp/util/status.cc
- src/cpp/util/string_ref.cc - src/cpp/util/string_ref.cc
- src/cpp/util/time_cc.cc - src/cpp/util/time_cc.cc

@ -637,11 +637,13 @@ if (PHP_GRPC != "no") {
EXTENSION("grpc", grpc_source, null, EXTENSION("grpc", grpc_source, null,
"/DOPENSSL_NO_ASM /D_GNU_SOURCE /DWIN32_LEAN_AND_MEAN "+ "/DOPENSSL_NO_ASM /D_GNU_SOURCE /DWIN32_LEAN_AND_MEAN "+
"/D_HAS_EXCEPTIONS=0 /DNOMINMAX /DGRPC_ARES=0 /D_WIN32_WINNT=0x600 "+ "/D_HAS_EXCEPTIONS=0 /DNOMINMAX /DGRPC_ARES=0 /D_WIN32_WINNT=0x600 "+
"/DPB_FIELD_16BIT "+
"/I"+configure_module_dirname+" "+ "/I"+configure_module_dirname+" "+
"/I"+configure_module_dirname+"\\include "+ "/I"+configure_module_dirname+"\\include "+
"/I"+configure_module_dirname+"\\src\\php\\ext\\grpc "+ "/I"+configure_module_dirname+"\\src\\php\\ext\\grpc "+
"/I"+configure_module_dirname+"\\third_party\\boringssl\\include "+ "/I"+configure_module_dirname+"\\third_party\\boringssl\\include "+
"/I"+configure_module_dirname+"\\third_party\\zlib"); "/I"+configure_module_dirname+"\\third_party\\zlib "+
"/I"+configure_module_dirname+"\\third_party\\address_sorting\\include");
base_dir = get_define('BUILD_DIR'); base_dir = get_define('BUILD_DIR');
FSO.CreateFolder(base_dir+"\\ext"); FSO.CreateFolder(base_dir+"\\ext");

@ -15,3 +15,4 @@ future), and the corresponding version numbers that used them:
- 1.9 'g' stands for 'glossy' - 1.9 'g' stands for 'glossy'
- 1.10 'g' stands for 'glamorous' - 1.10 'g' stands for 'glamorous'
- 1.11 'g' stands for 'gorgeous' - 1.11 'g' stands for 'gorgeous'
- 1.12 'g' stands for 'glorious'

@ -12,40 +12,6 @@ file(MAKE_DIRECTORY ${GRPC_BUILD_DIR})
add_subdirectory(${GRPC_SRC_DIR} ${GRPC_BUILD_DIR}) add_subdirectory(${GRPC_SRC_DIR} ${GRPC_BUILD_DIR})
include_directories(${GRPC_SRC_DIR}/include)
add_library(libgrpc STATIC IMPORTED)
set_target_properties(libgrpc PROPERTIES IMPORTED_LOCATION
${GRPC_BUILD_DIR}/libgrpc.a)
add_library(libgrpc++ STATIC IMPORTED)
set_target_properties(libgrpc++ PROPERTIES IMPORTED_LOCATION
${GRPC_BUILD_DIR}/libgrpc++.a)
add_library(libgpr STATIC IMPORTED)
set_target_properties(libgpr PROPERTIES IMPORTED_LOCATION
${GRPC_BUILD_DIR}/libgpr.a)
add_library(libaddress_sorting STATIC IMPORTED)
set_target_properties(libaddress_sorting PROPERTIES IMPORTED_LOCATION
${GRPC_BUILD_DIR}/libaddress_sorting.a)
add_library(libcares STATIC IMPORTED)
set_target_properties(libcares PROPERTIES IMPORTED_LOCATION
${GRPC_BUILD_DIR}/third_party/cares/cares/lib/libcares.a)
add_library(libzlib STATIC IMPORTED)
set_target_properties(libzlib PROPERTIES IMPORTED_LOCATION
${GRPC_BUILD_DIR}/third_party/zlib/libz.a)
add_library(libcrypto STATIC IMPORTED)
set_target_properties(libcrypto PROPERTIES IMPORTED_LOCATION
${GRPC_BUILD_DIR}/third_party/boringssl/crypto/libcrypto.a)
add_library(libssl STATIC IMPORTED)
set_target_properties(libssl PROPERTIES IMPORTED_LOCATION
${GRPC_BUILD_DIR}/third_party/boringssl/ssl/libssl.a)
set(GRPC_PROTO_GENS_DIR ${CMAKE_BINARY_DIR}/gens) set(GRPC_PROTO_GENS_DIR ${CMAKE_BINARY_DIR}/gens)
file(MAKE_DIRECTORY ${GRPC_PROTO_GENS_DIR}) file(MAKE_DIRECTORY ${GRPC_PROTO_GENS_DIR})
include_directories(${GRPC_PROTO_GENS_DIR}) include_directories(${GRPC_PROTO_GENS_DIR})
@ -100,8 +66,8 @@ add_library(helloworld_proto_lib
SHARED ${HELLOWORLD_PROTO_HDRS} ${HELLOWORLD_PROTO_SRCS}) SHARED ${HELLOWORLD_PROTO_HDRS} ${HELLOWORLD_PROTO_SRCS})
target_link_libraries(helloworld_proto_lib target_link_libraries(helloworld_proto_lib
grpc++
libprotobuf libprotobuf
libgrpc++
android android
log) log)
@ -115,14 +81,6 @@ target_include_directories(grpc-helloworld
PRIVATE ${HELLOWORLD_PROTO_HEADERS}) PRIVATE ${HELLOWORLD_PROTO_HEADERS})
target_link_libraries(grpc-helloworld target_link_libraries(grpc-helloworld
libgrpc++
libgrpc
libaddress_sorting
libzlib
libcares
libssl
libcrypto
helloworld_proto_lib helloworld_proto_lib
libgpr
android android
${log-lib}) ${log-lib})

@ -23,7 +23,7 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'gRPC-C++' s.name = 'gRPC-C++'
# TODO (mxyan): use version that match gRPC version when pod is stabilized # TODO (mxyan): use version that match gRPC version when pod is stabilized
# version = '1.11.0-dev' # version = '1.12.0-dev'
version = '0.0.2' version = '0.0.2'
s.version = version s.version = version
s.summary = 'gRPC C++ library' s.summary = 'gRPC C++ library'
@ -31,7 +31,7 @@ Pod::Spec.new do |s|
s.license = 'Apache License, Version 2.0' s.license = 'Apache License, Version 2.0'
s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
grpc_version = '1.11.0-dev' grpc_version = '1.12.0-dev'
s.source = { s.source = {
:git => 'https://github.com/grpc/grpc.git', :git => 'https://github.com/grpc/grpc.git',
@ -112,6 +112,8 @@ Pod::Spec.new do |s|
'include/grpcpp/support/byte_buffer.h', 'include/grpcpp/support/byte_buffer.h',
'include/grpcpp/support/channel_arguments.h', 'include/grpcpp/support/channel_arguments.h',
'include/grpcpp/support/config.h', 'include/grpcpp/support/config.h',
'include/grpcpp/support/proto_buffer_reader.h',
'include/grpcpp/support/proto_buffer_writer.h',
'include/grpcpp/support/slice.h', 'include/grpcpp/support/slice.h',
'include/grpcpp/support/status.h', 'include/grpcpp/support/status.h',
'include/grpcpp/support/status_code_enum.h', 'include/grpcpp/support/status_code_enum.h',
@ -206,7 +208,6 @@ Pod::Spec.new do |s|
'src/cpp/server/server_posix.cc', 'src/cpp/server/server_posix.cc',
'src/cpp/thread_manager/thread_manager.cc', 'src/cpp/thread_manager/thread_manager.cc',
'src/cpp/util/byte_buffer_cc.cc', 'src/cpp/util/byte_buffer_cc.cc',
'src/cpp/util/slice_cc.cc',
'src/cpp/util/status.cc', 'src/cpp/util/status.cc',
'src/cpp/util/string_ref.cc', 'src/cpp/util/string_ref.cc',
'src/cpp/util/time_cc.cc', 'src/cpp/util/time_cc.cc',

@ -22,7 +22,7 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'gRPC-Core' s.name = 'gRPC-Core'
version = '1.11.0-dev' version = '1.12.0-dev'
s.version = version s.version = version
s.summary = 'Core cross-platform gRPC library, written in C' s.summary = 'Core cross-platform gRPC library, written in C'
s.homepage = 'https://grpc.io' s.homepage = 'https://grpc.io'

@ -21,7 +21,7 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'gRPC-ProtoRPC' s.name = 'gRPC-ProtoRPC'
version = '1.11.0-dev' version = '1.12.0-dev'
s.version = version s.version = version
s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.summary = 'RPC library for Protocol Buffers, based on gRPC'
s.homepage = 'https://grpc.io' s.homepage = 'https://grpc.io'

@ -21,7 +21,7 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'gRPC-RxLibrary' s.name = 'gRPC-RxLibrary'
version = '1.11.0-dev' version = '1.12.0-dev'
s.version = version s.version = version
s.summary = 'Reactive Extensions library for iOS/OSX.' s.summary = 'Reactive Extensions library for iOS/OSX.'
s.homepage = 'https://grpc.io' s.homepage = 'https://grpc.io'

@ -20,7 +20,7 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'gRPC' s.name = 'gRPC'
version = '1.11.0-dev' version = '1.12.0-dev'
s.version = version s.version = version
s.summary = 'gRPC client library for iOS/OSX' s.summary = 'gRPC client library for iOS/OSX'
s.homepage = 'https://grpc.io' s.homepage = 'https://grpc.io'

@ -1342,7 +1342,6 @@
'src/cpp/server/server_posix.cc', 'src/cpp/server/server_posix.cc',
'src/cpp/thread_manager/thread_manager.cc', 'src/cpp/thread_manager/thread_manager.cc',
'src/cpp/util/byte_buffer_cc.cc', 'src/cpp/util/byte_buffer_cc.cc',
'src/cpp/util/slice_cc.cc',
'src/cpp/util/status.cc', 'src/cpp/util/status.cc',
'src/cpp/util/string_ref.cc', 'src/cpp/util/string_ref.cc',
'src/cpp/util/time_cc.cc', 'src/cpp/util/time_cc.cc',
@ -1490,7 +1489,6 @@
'src/cpp/server/server_posix.cc', 'src/cpp/server/server_posix.cc',
'src/cpp/thread_manager/thread_manager.cc', 'src/cpp/thread_manager/thread_manager.cc',
'src/cpp/util/byte_buffer_cc.cc', 'src/cpp/util/byte_buffer_cc.cc',
'src/cpp/util/slice_cc.cc',
'src/cpp/util/status.cc', 'src/cpp/util/status.cc',
'src/cpp/util/string_ref.cc', 'src/cpp/util/string_ref.cc',
'src/cpp/util/time_cc.cc', 'src/cpp/util/time_cc.cc',

@ -26,7 +26,7 @@
/// ///
/// Context settings are only relevant to the call they are invoked with, that /// Context settings are only relevant to the call they are invoked with, that
/// is to say, they aren't sticky. Some of these settings, such as the /// is to say, they aren't sticky. Some of these settings, such as the
/// compression options, can be made persistant at channel construction time /// compression options, can be made persistent at channel construction time
/// (see \a grpc::CreateCustomChannel). /// (see \a grpc::CreateCustomChannel).
/// ///
/// \warning ClientContext instances should \em not be reused across rpcs. /// \warning ClientContext instances should \em not be reused across rpcs.

@ -31,6 +31,8 @@
namespace grpc { namespace grpc {
class ServerInterface;
class ByteBuffer;
class ServerInterface; class ServerInterface;
namespace internal { namespace internal {
@ -45,6 +47,7 @@ template <class ServiceType, class RequestType, class ResponseType>
class ServerStreamingHandler; class ServerStreamingHandler;
template <class R> template <class R>
class DeserializeFuncType; class DeserializeFuncType;
class GrpcByteBufferPeer;
} // namespace internal } // namespace internal
/// A sequence of bytes. /// A sequence of bytes.
class ByteBuffer final { class ByteBuffer final {
@ -53,7 +56,30 @@ class ByteBuffer final {
ByteBuffer() : buffer_(nullptr) {} ByteBuffer() : buffer_(nullptr) {}
/// Construct buffer from \a slices, of which there are \a nslices. /// Construct buffer from \a slices, of which there are \a nslices.
ByteBuffer(const Slice* slices, size_t nslices); ByteBuffer(const Slice* slices, size_t nslices) {
// The following assertions check that the representation of a grpc::Slice
// is identical to that of a grpc_slice: it has a grpc_slice field, and
// nothing else.
static_assert(std::is_same<decltype(slices[0].slice_), grpc_slice>::value,
"Slice must have same representation as grpc_slice");
static_assert(sizeof(Slice) == sizeof(grpc_slice),
"Slice must have same representation as grpc_slice");
// The following assertions check that the representation of a ByteBuffer is
// identical to grpc_byte_buffer*: it has a grpc_byte_buffer* field,
// and nothing else.
static_assert(std::is_same<decltype(buffer_), grpc_byte_buffer*>::value,
"ByteBuffer must have same representation as "
"grpc_byte_buffer*");
static_assert(sizeof(ByteBuffer) == sizeof(grpc_byte_buffer*),
"ByteBuffer must have same representation as "
"grpc_byte_buffer*");
// The const_cast is legal if grpc_raw_byte_buffer_create() does no more
// than its advertised side effect of increasing the reference count of the
// slices it processes, and such an increase does not affect the semantics
// seen by the caller of this constructor.
buffer_ = g_core_codegen_interface->grpc_raw_byte_buffer_create(
reinterpret_cast<grpc_slice*>(const_cast<Slice*>(slices)), nslices);
}
/// Constuct a byte buffer by referencing elements of existing buffer /// Constuct a byte buffer by referencing elements of existing buffer
/// \a buf. Wrapper of core function grpc_byte_buffer_copy /// \a buf. Wrapper of core function grpc_byte_buffer_copy
@ -90,10 +116,18 @@ class ByteBuffer final {
void Release() { buffer_ = nullptr; } void Release() { buffer_ = nullptr; }
/// Buffer size in bytes. /// Buffer size in bytes.
size_t Length() const; size_t Length() const {
return buffer_ == nullptr
? 0
: g_core_codegen_interface->grpc_byte_buffer_length(buffer_);
}
/// Swap the state of *this and *other. /// Swap the state of *this and *other.
void Swap(ByteBuffer* other); void Swap(ByteBuffer* other) {
grpc_byte_buffer* tmp = other->buffer_;
other->buffer_ = buffer_;
buffer_ = tmp;
}
/// Is this ByteBuffer valid? /// Is this ByteBuffer valid?
bool Valid() const { return (buffer_ != nullptr); } bool Valid() const { return (buffer_ != nullptr); }
@ -112,6 +146,9 @@ class ByteBuffer final {
friend class internal::ServerStreamingHandler; friend class internal::ServerStreamingHandler;
template <class R> template <class R>
friend class internal::DeserializeFuncType; friend class internal::DeserializeFuncType;
friend class GrpcProtoBufferReader;
friend class GrpcProtoBufferWriter;
friend class internal::GrpcByteBufferPeer;
grpc_byte_buffer* buffer_; grpc_byte_buffer* buffer_;

@ -73,6 +73,7 @@ class CoreCodegen final : public CoreCodegenInterface {
grpc_byte_buffer* grpc_byte_buffer_copy(grpc_byte_buffer* bb) override; grpc_byte_buffer* grpc_byte_buffer_copy(grpc_byte_buffer* bb) override;
void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) override; void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) override;
size_t grpc_byte_buffer_length(grpc_byte_buffer* bb) override;
int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader, int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
grpc_byte_buffer* buffer) override; grpc_byte_buffer* buffer) override;
@ -86,6 +87,8 @@ class CoreCodegen final : public CoreCodegenInterface {
grpc_slice grpc_slice_new_with_user_data(void* p, size_t len, grpc_slice grpc_slice_new_with_user_data(void* p, size_t len,
void (*destroy)(void*), void (*destroy)(void*),
void* user_data) override; void* user_data) override;
grpc_slice grpc_slice_new_with_len(void* p, size_t len,
void (*destroy)(void*, size_t)) override;
grpc_slice grpc_empty_slice() override; grpc_slice grpc_empty_slice() override;
grpc_slice grpc_slice_malloc(size_t length) override; grpc_slice grpc_slice_malloc(size_t length) override;
void grpc_slice_unref(grpc_slice slice) override; void grpc_slice_unref(grpc_slice slice) override;

@ -81,6 +81,8 @@ class CoreCodegenInterface {
virtual grpc_byte_buffer* grpc_byte_buffer_copy(grpc_byte_buffer* bb) = 0; virtual grpc_byte_buffer* grpc_byte_buffer_copy(grpc_byte_buffer* bb) = 0;
virtual void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) = 0; virtual void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) = 0;
virtual size_t grpc_byte_buffer_length(grpc_byte_buffer* bb)
GRPC_MUST_USE_RESULT = 0;
virtual int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader, virtual int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
grpc_byte_buffer* buffer) grpc_byte_buffer* buffer)
@ -95,6 +97,9 @@ class CoreCodegenInterface {
virtual grpc_slice grpc_slice_new_with_user_data(void* p, size_t len, virtual grpc_slice grpc_slice_new_with_user_data(void* p, size_t len,
void (*destroy)(void*), void (*destroy)(void*),
void* user_data) = 0; void* user_data) = 0;
virtual grpc_slice grpc_slice_new_with_len(void* p, size_t len,
void (*destroy)(void*,
size_t)) = 0;
virtual grpc_call_error grpc_call_cancel_with_status(grpc_call* call, virtual grpc_call_error grpc_call_cancel_with_status(grpc_call* call,
grpc_status_code status, grpc_status_code status,
const char* description, const char* description,

@ -0,0 +1,151 @@
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPCPP_IMPL_CODEGEN_PROTO_BUFFER_READER_H
#define GRPCPP_IMPL_CODEGEN_PROTO_BUFFER_READER_H
#include <type_traits>
#include <grpc/impl/codegen/byte_buffer_reader.h>
#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/impl/codegen/slice.h>
#include <grpcpp/impl/codegen/byte_buffer.h>
#include <grpcpp/impl/codegen/config_protobuf.h>
#include <grpcpp/impl/codegen/core_codegen_interface.h>
#include <grpcpp/impl/codegen/serialization_traits.h>
#include <grpcpp/impl/codegen/status.h>
/// This header provides an object that reads bytes directly from a
/// grpc::ByteBuffer, via the ZeroCopyInputStream interface
namespace grpc {
extern CoreCodegenInterface* g_core_codegen_interface;
/// This is a specialization of the protobuf class ZeroCopyInputStream
/// The principle is to get one chunk of data at a time from the proto layer,
/// with options to backup (re-see some bytes) or skip (forward past some bytes)
///
/// Read more about ZeroCopyInputStream interface here:
/// https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.io.zero_copy_stream#ZeroCopyInputStream
class GrpcProtoBufferReader : public ::grpc::protobuf::io::ZeroCopyInputStream {
public:
/// Constructs buffer reader from \a buffer. Will set \a status() to non ok
/// if \a buffer is invalid (the internal buffer has not been initialized).
explicit GrpcProtoBufferReader(ByteBuffer* buffer)
: byte_count_(0), backup_count_(0), status_() {
/// Implemented through a grpc_byte_buffer_reader which iterates
/// over the slices that make up a byte buffer
if (!buffer->Valid() ||
!g_core_codegen_interface->grpc_byte_buffer_reader_init(
&reader_, buffer->c_buffer())) {
status_ = Status(StatusCode::INTERNAL,
"Couldn't initialize byte buffer reader");
}
}
~GrpcProtoBufferReader() {
if (status_.ok()) {
g_core_codegen_interface->grpc_byte_buffer_reader_destroy(&reader_);
}
}
/// Give the proto library a chunk of data from the stream. The caller
/// may safely read from data[0, size - 1].
bool Next(const void** data, int* size) override {
if (!status_.ok()) {
return false;
}
/// If we have backed up previously, we need to return the backed-up slice
if (backup_count_ > 0) {
*data = GRPC_SLICE_START_PTR(slice_) + GRPC_SLICE_LENGTH(slice_) -
backup_count_;
GPR_CODEGEN_ASSERT(backup_count_ <= INT_MAX);
*size = (int)backup_count_;
backup_count_ = 0;
return true;
}
/// Otherwise get the next slice from the byte buffer reader
if (!g_core_codegen_interface->grpc_byte_buffer_reader_next(&reader_,
&slice_)) {
return false;
}
g_core_codegen_interface->grpc_slice_unref(slice_);
*data = GRPC_SLICE_START_PTR(slice_);
// On win x64, int is only 32bit
GPR_CODEGEN_ASSERT(GRPC_SLICE_LENGTH(slice_) <= INT_MAX);
byte_count_ += * size = (int)GRPC_SLICE_LENGTH(slice_);
return true;
}
/// Returns the status of the buffer reader.
Status status() const { return status_; }
/// The proto library calls this to indicate that we should back up \a count
/// bytes that have already been returned by the last call of Next.
/// So do the backup and have that ready for a later Next.
void BackUp(int count) override {
GPR_CODEGEN_ASSERT(count <= static_cast<int>(GRPC_SLICE_LENGTH(slice_)));
backup_count_ = count;
}
/// The proto library calls this to skip over \a count bytes. Implement this
/// using Next and BackUp combined.
bool Skip(int count) override {
const void* data;
int size;
while (Next(&data, &size)) {
if (size >= count) {
BackUp(size - count);
return true;
}
// size < count;
count -= size;
}
// error or we have too large count;
return false;
}
/// Returns the total number of bytes read since this object was created.
grpc::protobuf::int64 ByteCount() const override {
return byte_count_ - backup_count_;
}
// These protected members are needed to support internal optimizations.
// they expose internal bits of grpc core that are NOT stable. If you have
// a use case needs to use one of these functions, please send an email to
// https://groups.google.com/forum/#!forum/grpc-io.
protected:
void set_byte_count(int64_t byte_count) { byte_count_ = byte_count; }
int64_t backup_count() { return backup_count_; }
void set_backup_count(int64_t backup_count) { backup_count_ = backup_count; }
grpc_byte_buffer_reader* reader() { return &reader_; }
grpc_slice* slice() { return &slice_; }
private:
int64_t byte_count_; ///< total bytes read since object creation
int64_t backup_count_; ///< how far backed up in the stream we are
grpc_byte_buffer_reader reader_; ///< internal object to read \a grpc_slice
///< from the \a grpc_byte_buffer
grpc_slice slice_; ///< current slice passed back to the caller
Status status_; ///< status of the entire object
};
} // namespace grpc
#endif // GRPCPP_IMPL_CODEGEN_PROTO_BUFFER_READER_H

@ -0,0 +1,168 @@
/*
*
* Copyright 2018 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPCPP_IMPL_CODEGEN_PROTO_BUFFER_WRITER_H
#define GRPCPP_IMPL_CODEGEN_PROTO_BUFFER_WRITER_H
#include <type_traits>
#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/impl/codegen/slice.h>
#include <grpcpp/impl/codegen/byte_buffer.h>
#include <grpcpp/impl/codegen/config_protobuf.h>
#include <grpcpp/impl/codegen/core_codegen_interface.h>
#include <grpcpp/impl/codegen/serialization_traits.h>
#include <grpcpp/impl/codegen/status.h>
/// This header provides an object that writes bytes directly into a
/// grpc::ByteBuffer, via the ZeroCopyOutputStream interface
namespace grpc {
extern CoreCodegenInterface* g_core_codegen_interface;
// Forward declaration for testing use only
namespace internal {
class GrpcProtoBufferWriterPeer;
} // namespace internal
const int kGrpcProtoBufferWriterMaxBufferLength = 1024 * 1024;
/// This is a specialization of the protobuf class ZeroCopyOutputStream.
/// The principle is to give the proto layer one buffer of bytes at a time
/// that it can use to serialize the next portion of the message, with the
/// option to "backup" if more buffer is given than required at the last buffer.
///
/// Read more about ZeroCopyOutputStream interface here:
/// https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.io.zero_copy_stream#ZeroCopyOutputStream
class GrpcProtoBufferWriter
: public ::grpc::protobuf::io::ZeroCopyOutputStream {
public:
/// Constructor for this derived class
///
/// \param[out] byte_buffer A pointer to the grpc::ByteBuffer created
/// \param block_size How big are the chunks to allocate at a time
/// \param total_size How many total bytes are required for this proto
GrpcProtoBufferWriter(ByteBuffer* byte_buffer, int block_size, int total_size)
: block_size_(block_size),
total_size_(total_size),
byte_count_(0),
have_backup_(false) {
GPR_CODEGEN_ASSERT(!byte_buffer->Valid());
/// Create an empty raw byte buffer and look at its underlying slice buffer
grpc_byte_buffer* bp =
g_core_codegen_interface->grpc_raw_byte_buffer_create(NULL, 0);
byte_buffer->set_buffer(bp);
slice_buffer_ = &bp->data.raw.slice_buffer;
}
~GrpcProtoBufferWriter() {
if (have_backup_) {
g_core_codegen_interface->grpc_slice_unref(backup_slice_);
}
}
/// Give the proto library the next buffer of bytes and its size. It is
/// safe for the caller to write from data[0, size - 1].
bool Next(void** data, int* size) override {
// Protobuf should not ask for more memory than total_size_.
GPR_CODEGEN_ASSERT(byte_count_ < total_size_);
// 1. Use the remaining backup slice if we have one
// 2. Otherwise allocate a slice, up to the remaining length needed
// or our maximum allocation size
// 3. Provide the slice start and size available
// 4. Add the slice being returned to the slice buffer
size_t remain = total_size_ - byte_count_;
if (have_backup_) {
/// If we have a backup slice, we should use it first
slice_ = backup_slice_;
have_backup_ = false;
if (GRPC_SLICE_LENGTH(slice_) > remain) {
GRPC_SLICE_SET_LENGTH(slice_, remain);
}
} else {
// When less than a whole block is needed, only allocate that much.
// But make sure the allocated slice is not inlined.
size_t allocate_length =
remain > static_cast<size_t>(block_size_) ? block_size_ : remain;
slice_ = g_core_codegen_interface->grpc_slice_malloc(
allocate_length > GRPC_SLICE_INLINED_SIZE
? allocate_length
: GRPC_SLICE_INLINED_SIZE + 1);
}
*data = GRPC_SLICE_START_PTR(slice_);
// On win x64, int is only 32bit
GPR_CODEGEN_ASSERT(GRPC_SLICE_LENGTH(slice_) <= INT_MAX);
byte_count_ += * size = (int)GRPC_SLICE_LENGTH(slice_);
g_core_codegen_interface->grpc_slice_buffer_add(slice_buffer_, slice_);
return true;
}
/// Backup by \a count bytes because Next returned more bytes than needed
/// (only used in the last buffer). \a count must be less than or equal too
/// the last buffer returned from next.
void BackUp(int count) override {
/// 1. Remove the partially-used last slice from the slice buffer
/// 2. Split it into the needed (if any) and unneeded part
/// 3. Add the needed part back to the slice buffer
/// 4. Mark that we still have the remaining part (for later use/unref)
GPR_CODEGEN_ASSERT(count <= static_cast<int>(GRPC_SLICE_LENGTH(slice_)));
g_core_codegen_interface->grpc_slice_buffer_pop(slice_buffer_);
if ((size_t)count == GRPC_SLICE_LENGTH(slice_)) {
backup_slice_ = slice_;
} else {
backup_slice_ = g_core_codegen_interface->grpc_slice_split_tail(
&slice_, GRPC_SLICE_LENGTH(slice_) - count);
g_core_codegen_interface->grpc_slice_buffer_add(slice_buffer_, slice_);
}
// It's dangerous to keep an inlined grpc_slice as the backup slice, since
// on a following Next() call, a reference will be returned to this slice
// via GRPC_SLICE_START_PTR, which will not be an address held by
// slice_buffer_.
have_backup_ = backup_slice_.refcount != NULL;
byte_count_ -= count;
}
/// Returns the total number of bytes written since this object was created.
grpc::protobuf::int64 ByteCount() const override { return byte_count_; }
// These protected members are needed to support internal optimizations.
// they expose internal bits of grpc core that are NOT stable. If you have
// a use case needs to use one of these functions, please send an email to
// https://groups.google.com/forum/#!forum/grpc-io.
protected:
grpc_slice_buffer* slice_buffer() { return slice_buffer_; }
void set_byte_count(int64_t byte_count) { byte_count_ = byte_count; }
private:
// friend for testing purposes only
friend class internal::GrpcProtoBufferWriterPeer;
const int block_size_; ///< size to alloc for each new \a grpc_slice needed
const int total_size_; ///< byte size of proto being serialized
int64_t byte_count_; ///< bytes written since this object was created
grpc_slice_buffer*
slice_buffer_; ///< internal buffer of slices holding the serialized data
bool have_backup_; ///< if we are holding a backup slice or not
grpc_slice backup_slice_; ///< holds space we can still write to, if the
///< caller has called BackUp
grpc_slice slice_; ///< current slice passed back to the caller
};
} // namespace grpc
#endif // GRPCPP_IMPL_CODEGEN_PROTO_BUFFER_WRITER_H

@ -24,203 +24,62 @@
#include <grpc/impl/codegen/byte_buffer_reader.h> #include <grpc/impl/codegen/byte_buffer_reader.h>
#include <grpc/impl/codegen/grpc_types.h> #include <grpc/impl/codegen/grpc_types.h>
#include <grpc/impl/codegen/slice.h> #include <grpc/impl/codegen/slice.h>
#include <grpcpp/impl/codegen/byte_buffer.h>
#include <grpcpp/impl/codegen/config_protobuf.h> #include <grpcpp/impl/codegen/config_protobuf.h>
#include <grpcpp/impl/codegen/core_codegen_interface.h> #include <grpcpp/impl/codegen/core_codegen_interface.h>
#include <grpcpp/impl/codegen/proto_buffer_reader.h>
#include <grpcpp/impl/codegen/proto_buffer_writer.h>
#include <grpcpp/impl/codegen/serialization_traits.h> #include <grpcpp/impl/codegen/serialization_traits.h>
#include <grpcpp/impl/codegen/slice.h>
#include <grpcpp/impl/codegen/status.h> #include <grpcpp/impl/codegen/status.h>
/// This header provides serialization and deserialization between gRPC
/// messages serialized using protobuf and the C++ objects they represent.
namespace grpc { namespace grpc {
extern CoreCodegenInterface* g_core_codegen_interface; extern CoreCodegenInterface* g_core_codegen_interface;
namespace internal { // ProtoBufferWriter must be a subclass of ::protobuf::io::ZeroCopyOutputStream.
template <class ProtoBufferWriter, class T>
class GrpcBufferWriterPeer; Status GenericSerialize(const grpc::protobuf::Message& msg, ByteBuffer* bb,
bool* own_buffer) {
const int kGrpcBufferWriterMaxBufferLength = 1024 * 1024; static_assert(std::is_base_of<protobuf::io::ZeroCopyOutputStream,
ProtoBufferWriter>::value,
class GrpcBufferWriter : public ::grpc::protobuf::io::ZeroCopyOutputStream { "ProtoBufferWriter must be a subclass of "
public: "::protobuf::io::ZeroCopyOutputStream");
GrpcBufferWriter(grpc_byte_buffer** bp, int block_size, int total_size)
: block_size_(block_size),
total_size_(total_size),
byte_count_(0),
have_backup_(false) {
*bp = g_core_codegen_interface->grpc_raw_byte_buffer_create(NULL, 0);
slice_buffer_ = &(*bp)->data.raw.slice_buffer;
}
~GrpcBufferWriter() override {
if (have_backup_) {
g_core_codegen_interface->grpc_slice_unref(backup_slice_);
}
}
bool Next(void** data, int* size) override {
// Protobuf should not ask for more memory than total_size_.
GPR_CODEGEN_ASSERT(byte_count_ < total_size_);
size_t remain = total_size_ - byte_count_;
if (have_backup_) {
slice_ = backup_slice_;
have_backup_ = false;
if (GRPC_SLICE_LENGTH(slice_) > remain) {
GRPC_SLICE_SET_LENGTH(slice_, remain);
}
} else {
// When less than a whole block is needed, only allocate that much.
// But make sure the allocated slice is not inlined.
size_t allocate_length =
remain > static_cast<size_t>(block_size_) ? block_size_ : remain;
slice_ = g_core_codegen_interface->grpc_slice_malloc(
allocate_length > GRPC_SLICE_INLINED_SIZE
? allocate_length
: GRPC_SLICE_INLINED_SIZE + 1);
}
*data = GRPC_SLICE_START_PTR(slice_);
// On win x64, int is only 32bit
GPR_CODEGEN_ASSERT(GRPC_SLICE_LENGTH(slice_) <= INT_MAX);
byte_count_ += * size = (int)GRPC_SLICE_LENGTH(slice_);
g_core_codegen_interface->grpc_slice_buffer_add(slice_buffer_, slice_);
return true;
}
void BackUp(int count) override {
g_core_codegen_interface->grpc_slice_buffer_pop(slice_buffer_);
if ((size_t)count == GRPC_SLICE_LENGTH(slice_)) {
backup_slice_ = slice_;
} else {
backup_slice_ = g_core_codegen_interface->grpc_slice_split_tail(
&slice_, GRPC_SLICE_LENGTH(slice_) - count);
g_core_codegen_interface->grpc_slice_buffer_add(slice_buffer_, slice_);
}
// It's dangerous to keep an inlined grpc_slice as the backup slice, since
// on a following Next() call, a reference will be returned to this slice
// via GRPC_SLICE_START_PTR, which will not be an adddress held by
// slice_buffer_.
have_backup_ = backup_slice_.refcount != NULL;
byte_count_ -= count;
}
grpc::protobuf::int64 ByteCount() const override { return byte_count_; }
protected:
friend class GrpcBufferWriterPeer;
const int block_size_;
const int total_size_;
int64_t byte_count_;
grpc_slice_buffer* slice_buffer_;
bool have_backup_;
grpc_slice backup_slice_;
grpc_slice slice_;
};
class GrpcBufferReader : public ::grpc::protobuf::io::ZeroCopyInputStream {
public:
explicit GrpcBufferReader(grpc_byte_buffer* buffer)
: byte_count_(0), backup_count_(0), status_() {
if (!g_core_codegen_interface->grpc_byte_buffer_reader_init(&reader_,
buffer)) {
status_ = Status(StatusCode::INTERNAL,
"Couldn't initialize byte buffer reader");
}
}
~GrpcBufferReader() override {
g_core_codegen_interface->grpc_byte_buffer_reader_destroy(&reader_);
}
bool Next(const void** data, int* size) override {
if (!status_.ok()) {
return false;
}
if (backup_count_ > 0) {
*data = GRPC_SLICE_START_PTR(slice_) + GRPC_SLICE_LENGTH(slice_) -
backup_count_;
GPR_CODEGEN_ASSERT(backup_count_ <= INT_MAX);
*size = (int)backup_count_;
backup_count_ = 0;
return true;
}
if (!g_core_codegen_interface->grpc_byte_buffer_reader_next(&reader_,
&slice_)) {
return false;
}
g_core_codegen_interface->grpc_slice_unref(slice_);
*data = GRPC_SLICE_START_PTR(slice_);
// On win x64, int is only 32bit
GPR_CODEGEN_ASSERT(GRPC_SLICE_LENGTH(slice_) <= INT_MAX);
byte_count_ += * size = (int)GRPC_SLICE_LENGTH(slice_);
return true;
}
Status status() const { return status_; }
void BackUp(int count) override { backup_count_ = count; }
bool Skip(int count) override {
const void* data;
int size;
while (Next(&data, &size)) {
if (size >= count) {
BackUp(size - count);
return true;
}
// size < count;
count -= size;
}
// error or we have too large count;
return false;
}
grpc::protobuf::int64 ByteCount() const override {
return byte_count_ - backup_count_;
}
protected:
int64_t byte_count_;
int64_t backup_count_;
grpc_byte_buffer_reader reader_;
grpc_slice slice_;
Status status_;
};
// BufferWriter must be a subclass of io::ZeroCopyOutputStream.
template <class BufferWriter, class T>
Status GenericSerialize(const grpc::protobuf::Message& msg,
grpc_byte_buffer** bp, bool* own_buffer) {
static_assert(
std::is_base_of<protobuf::io::ZeroCopyOutputStream, BufferWriter>::value,
"BufferWriter must be a subclass of io::ZeroCopyOutputStream");
*own_buffer = true; *own_buffer = true;
int byte_size = msg.ByteSize(); int byte_size = msg.ByteSize();
if ((size_t)byte_size <= GRPC_SLICE_INLINED_SIZE) { if ((size_t)byte_size <= GRPC_SLICE_INLINED_SIZE) {
grpc_slice slice = g_core_codegen_interface->grpc_slice_malloc(byte_size); Slice slice(byte_size);
GPR_CODEGEN_ASSERT( // We serialize directly into the allocated slices memory
GRPC_SLICE_END_PTR(slice) == GPR_CODEGEN_ASSERT(slice.end() == msg.SerializeWithCachedSizesToArray(
msg.SerializeWithCachedSizesToArray(GRPC_SLICE_START_PTR(slice))); const_cast<uint8_t*>(slice.begin())));
*bp = g_core_codegen_interface->grpc_raw_byte_buffer_create(&slice, 1); ByteBuffer tmp(&slice, 1);
g_core_codegen_interface->grpc_slice_unref(slice); bb->Swap(&tmp);
return g_core_codegen_interface->ok(); return g_core_codegen_interface->ok();
} }
BufferWriter writer(bp, kGrpcBufferWriterMaxBufferLength, byte_size); ProtoBufferWriter writer(bb, kGrpcProtoBufferWriterMaxBufferLength,
byte_size);
return msg.SerializeToZeroCopyStream(&writer) return msg.SerializeToZeroCopyStream(&writer)
? g_core_codegen_interface->ok() ? g_core_codegen_interface->ok()
: Status(StatusCode::INTERNAL, "Failed to serialize message"); : Status(StatusCode::INTERNAL, "Failed to serialize message");
} }
// BufferReader must be a subclass of io::ZeroCopyInputStream. // BufferReader must be a subclass of ::protobuf::io::ZeroCopyInputStream.
template <class BufferReader, class T> template <class ProtoBufferReader, class T>
Status GenericDeserialize(grpc_byte_buffer* buffer, Status GenericDeserialize(ByteBuffer* buffer, grpc::protobuf::Message* msg) {
grpc::protobuf::Message* msg) { static_assert(std::is_base_of<protobuf::io::ZeroCopyInputStream,
static_assert( ProtoBufferReader>::value,
std::is_base_of<protobuf::io::ZeroCopyInputStream, BufferReader>::value, "ProtoBufferReader must be a subclass of "
"BufferReader must be a subclass of io::ZeroCopyInputStream"); "::protobuf::io::ZeroCopyInputStream");
if (buffer == nullptr) { if (buffer == nullptr) {
return Status(StatusCode::INTERNAL, "No payload"); return Status(StatusCode::INTERNAL, "No payload");
} }
Status result = g_core_codegen_interface->ok(); Status result = g_core_codegen_interface->ok();
{ {
BufferReader reader(buffer); ProtoBufferReader reader(buffer);
if (!reader.status().ok()) { if (!reader.status().ok()) {
return reader.status(); return reader.status();
} }
@ -233,12 +92,10 @@ Status GenericDeserialize(grpc_byte_buffer* buffer,
result = Status(StatusCode::INTERNAL, "Did not read entire message"); result = Status(StatusCode::INTERNAL, "Did not read entire message");
} }
} }
g_core_codegen_interface->grpc_byte_buffer_destroy(buffer); buffer->Clear();
return result; return result;
} }
} // namespace internal
// this is needed so the following class does not conflict with protobuf // this is needed so the following class does not conflict with protobuf
// serializers that utilize internal-only tools. // serializers that utilize internal-only tools.
#ifdef GRPC_OPEN_SOURCE_PROTO #ifdef GRPC_OPEN_SOURCE_PROTO
@ -249,16 +106,13 @@ template <class T>
class SerializationTraits<T, typename std::enable_if<std::is_base_of< class SerializationTraits<T, typename std::enable_if<std::is_base_of<
grpc::protobuf::Message, T>::value>::type> { grpc::protobuf::Message, T>::value>::type> {
public: public:
static Status Serialize(const grpc::protobuf::Message& msg, static Status Serialize(const grpc::protobuf::Message& msg, ByteBuffer* bb,
grpc_byte_buffer** bp, bool* own_buffer) { bool* own_buffer) {
return internal::GenericSerialize<internal::GrpcBufferWriter, T>( return GenericSerialize<GrpcProtoBufferWriter, T>(msg, bb, own_buffer);
msg, bp, own_buffer);
} }
static Status Deserialize(grpc_byte_buffer* buffer, static Status Deserialize(ByteBuffer* buffer, grpc::protobuf::Message* msg) {
grpc::protobuf::Message* msg) { return GenericDeserialize<GrpcProtoBufferReader, T>(buffer, msg);
return internal::GenericDeserialize<internal::GrpcBufferReader, T>(buffer,
msg);
} }
}; };
#endif #endif

@ -88,8 +88,8 @@ class ServerContextTestSpouse;
/// ///
/// Context settings are only relevant to the call handler they are supplied to, /// Context settings are only relevant to the call handler they are supplied to,
/// that is to say, they aren't sticky across multiple calls. Some of these /// that is to say, they aren't sticky across multiple calls. Some of these
/// settings, such as the compression options, can be made persistant at server /// settings, such as the compression options, can be made persistent at server
/// construction time by specifying the approriate \a ChannelArguments /// construction time by specifying the appropriate \a ChannelArguments
/// to a \a grpc::ServerBuilder, via \a ServerBuilder::AddChannelArgument. /// to a \a grpc::ServerBuilder, via \a ServerBuilder::AddChannelArgument.
/// ///
/// \warning ServerContext instances should \em not be reused across rpcs. /// \warning ServerContext instances should \em not be reused across rpcs.

@ -35,34 +35,43 @@ namespace grpc {
class Slice final { class Slice final {
public: public:
/// Construct an empty slice. /// Construct an empty slice.
Slice(); Slice() : slice_(g_core_codegen_interface->grpc_empty_slice()) {}
/// Destructor - drops one reference. /// Destructor - drops one reference.
~Slice(); ~Slice() { g_core_codegen_interface->grpc_slice_unref(slice_); }
enum AddRef { ADD_REF }; enum AddRef { ADD_REF };
/// Construct a slice from \a slice, adding a reference. /// Construct a slice from \a slice, adding a reference.
Slice(grpc_slice slice, AddRef); Slice(grpc_slice slice, AddRef)
: slice_(g_core_codegen_interface->grpc_slice_ref(slice)) {}
enum StealRef { STEAL_REF }; enum StealRef { STEAL_REF };
/// Construct a slice from \a slice, stealing a reference. /// Construct a slice from \a slice, stealing a reference.
Slice(grpc_slice slice, StealRef); Slice(grpc_slice slice, StealRef) : slice_(slice) {}
/// Allocate a slice of specified size /// Allocate a slice of specified size
Slice(size_t len); Slice(size_t len)
: slice_(g_core_codegen_interface->grpc_slice_malloc(len)) {}
/// Construct a slice from a copied buffer /// Construct a slice from a copied buffer
Slice(const void* buf, size_t len); Slice(const void* buf, size_t len)
: slice_(g_core_codegen_interface->grpc_slice_from_copied_buffer(
reinterpret_cast<const char*>(buf), len)) {}
/// Construct a slice from a copied string /// Construct a slice from a copied string
Slice(const grpc::string& str); Slice(const grpc::string& str)
: slice_(g_core_codegen_interface->grpc_slice_from_copied_buffer(
str.c_str(), str.length())) {}
enum StaticSlice { STATIC_SLICE }; enum StaticSlice { STATIC_SLICE };
/// Construct a slice from a static buffer /// Construct a slice from a static buffer
Slice(const void* buf, size_t len, StaticSlice); Slice(const void* buf, size_t len, StaticSlice)
: slice_(g_core_codegen_interface->grpc_slice_from_static_buffer(
reinterpret_cast<const char*>(buf), len)) {}
/// Copy constructor, adds a reference. /// Copy constructor, adds a reference.
Slice(const Slice& other); Slice(const Slice& other)
: slice_(g_core_codegen_interface->grpc_slice_ref(other.slice_)) {}
/// Assignment, reference count is unchanged. /// Assignment, reference count is unchanged.
Slice& operator=(Slice other) { Slice& operator=(Slice other) {
@ -75,14 +84,18 @@ class Slice final {
/// user data pointer passed in at destruction. Can be the same as buf or /// user data pointer passed in at destruction. Can be the same as buf or
/// different (e.g., if data is part of a larger structure that must be /// different (e.g., if data is part of a larger structure that must be
/// destroyed when the data is no longer needed) /// destroyed when the data is no longer needed)
Slice(void* buf, size_t len, void (*destroy)(void*), void* user_data); Slice(void* buf, size_t len, void (*destroy)(void*), void* user_data)
: slice_(g_core_codegen_interface->grpc_slice_new_with_user_data(
buf, len, destroy, user_data)) {}
/// Specialization of above for common case where buf == user_data /// Specialization of above for common case where buf == user_data
Slice(void* buf, size_t len, void (*destroy)(void*)) Slice(void* buf, size_t len, void (*destroy)(void*))
: Slice(buf, len, destroy, buf) {} : Slice(buf, len, destroy, buf) {}
/// Similar to the above but has a destroy that also takes slice length /// Similar to the above but has a destroy that also takes slice length
Slice(void* buf, size_t len, void (*destroy)(void*, size_t)); Slice(void* buf, size_t len, void (*destroy)(void*, size_t))
: slice_(g_core_codegen_interface->grpc_slice_new_with_len(buf, len,
destroy)) {}
/// Byte size. /// Byte size.
size_t size() const { return GRPC_SLICE_LENGTH(slice_); } size_t size() const { return GRPC_SLICE_LENGTH(slice_); }
@ -94,7 +107,9 @@ class Slice final {
const uint8_t* end() const { return GRPC_SLICE_END_PTR(slice_); } const uint8_t* end() const { return GRPC_SLICE_END_PTR(slice_); }
/// Raw C slice. Caller needs to call grpc_slice_unref when done. /// Raw C slice. Caller needs to call grpc_slice_unref when done.
grpc_slice c_slice() const; grpc_slice c_slice() const {
return g_core_codegen_interface->grpc_slice_ref(slice_);
}
private: private:
friend class ByteBuffer; friend class ByteBuffer;

@ -0,0 +1,24 @@
/*
*
* Copyright 2018 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPCPP_SUPPORT_PROTO_BUFFER_READER_H
#define GRPCPP_SUPPORT_PROTO_BUFFER_READER_H
#include <grpcpp/impl/codegen/proto_buffer_reader.h>
#endif // GRPCPP_SUPPORT_PROTO_BUFFER_READER_H

@ -0,0 +1,24 @@
/*
*
* Copyright 2018 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPCPP_SUPPORT_PROTO_BUFFER_WRITER_H
#define GRPCPP_SUPPORT_PROTO_BUFFER_WRITER_H
#include <grpcpp/impl/codegen/proto_buffer_writer.h>
#endif // GRPCPP_SUPPORT_PROTO_BUFFER_WRITER_H

@ -13,8 +13,8 @@
<date>2018-01-19</date> <date>2018-01-19</date>
<time>16:06:07</time> <time>16:06:07</time>
<version> <version>
<release>1.11.0dev</release> <release>1.12.0dev</release>
<api>1.11.0dev</api> <api>1.12.0dev</api>
</version> </version>
<stability> <stability>
<release>beta</release> <release>beta</release>

@ -206,7 +206,7 @@ void PrintMethodImplementations(Printer* printer,
} }
} }
for (auto one_class : classes) { for (auto one_class : classes) {
output += " @class " + one_class + ";\n"; output += "@class " + one_class + ";\n";
} }
return output; return output;

@ -118,11 +118,11 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
Write(context, file_name + ".pbrpc.h", Write(context, file_name + ".pbrpc.h",
PreprocIfNot(kForwardDeclare, imports) + "\n" + PreprocIfNot(kForwardDeclare, imports) + "\n" +
PreprocIfNot(kProtocolOnly, system_imports) + "\n" + PreprocIfNot(kProtocolOnly, system_imports) + "\n" +
PreprocIfElse(kForwardDeclare, class_declarations, class_declarations + "\n" +
class_imports) + PreprocIfNot(kForwardDeclare, class_imports) + "\n" +
"\n" + forward_declarations + "\n" + kNonNullBegin + "\n" + forward_declarations + "\n" + kNonNullBegin + "\n" + protocols +
protocols + "\n" + PreprocIfNot(kProtocolOnly, interfaces) + "\n" + PreprocIfNot(kProtocolOnly, interfaces) + "\n" +
"\n" + kNonNullEnd + "\n"); kNonNullEnd + "\n");
} }
{ {

@ -924,7 +924,9 @@ typedef struct client_channel_call_data {
// Note: We inline the cache for the first 3 send_message ops and use // Note: We inline the cache for the first 3 send_message ops and use
// dynamic allocation after that. This number was essentially picked // dynamic allocation after that. This number was essentially picked
// at random; it could be changed in the future to tune performance. // at random; it could be changed in the future to tune performance.
grpc_core::InlinedVector<grpc_core::ByteStreamCache*, 3> send_messages; grpc_core::ManualConstructor<
grpc_core::InlinedVector<grpc_core::ByteStreamCache*, 3>>
send_messages;
// send_trailing_metadata // send_trailing_metadata
bool seen_send_trailing_metadata; bool seen_send_trailing_metadata;
grpc_linked_mdelem* send_trailing_metadata_storage; grpc_linked_mdelem* send_trailing_metadata_storage;
@ -974,7 +976,7 @@ static void maybe_cache_send_ops_for_batch(call_data* calld,
gpr_arena_alloc(calld->arena, sizeof(grpc_core::ByteStreamCache))); gpr_arena_alloc(calld->arena, sizeof(grpc_core::ByteStreamCache)));
new (cache) grpc_core::ByteStreamCache( new (cache) grpc_core::ByteStreamCache(
std::move(batch->payload->send_message.send_message)); std::move(batch->payload->send_message.send_message));
calld->send_messages.push_back(cache); calld->send_messages->push_back(cache);
} }
// Save metadata batch for send_trailing_metadata ops. // Save metadata batch for send_trailing_metadata ops.
if (batch->send_trailing_metadata) { if (batch->send_trailing_metadata) {
@ -1008,7 +1010,7 @@ static void free_cached_send_op_data_after_commit(
"]", "]",
chand, calld, i); chand, calld, i);
} }
calld->send_messages[i]->Destroy(); (*calld->send_messages)[i]->Destroy();
} }
if (retry_state->completed_send_trailing_metadata) { if (retry_state->completed_send_trailing_metadata) {
grpc_metadata_batch_destroy(&calld->send_trailing_metadata); grpc_metadata_batch_destroy(&calld->send_trailing_metadata);
@ -1032,7 +1034,7 @@ static void free_cached_send_op_data_for_completed_batch(
"]", "]",
chand, calld, retry_state->completed_send_message_count - 1); chand, calld, retry_state->completed_send_message_count - 1);
} }
calld->send_messages[retry_state->completed_send_message_count - 1] (*calld->send_messages)[retry_state->completed_send_message_count - 1]
->Destroy(); ->Destroy();
} }
if (batch_data->batch.send_trailing_metadata) { if (batch_data->batch.send_trailing_metadata) {
@ -1280,7 +1282,8 @@ static bool pending_batch_is_completed(
return false; return false;
} }
if (pending->batch->send_message && if (pending->batch->send_message &&
retry_state->completed_send_message_count < calld->send_messages.size()) { retry_state->completed_send_message_count <
calld->send_messages->size()) {
return false; return false;
} }
if (pending->batch->send_trailing_metadata && if (pending->batch->send_trailing_metadata &&
@ -1315,7 +1318,7 @@ static bool pending_batch_is_unstarted(
return true; return true;
} }
if (pending->batch->send_message && if (pending->batch->send_message &&
retry_state->started_send_message_count < calld->send_messages.size()) { retry_state->started_send_message_count < calld->send_messages->size()) {
return true; return true;
} }
if (pending->batch->send_trailing_metadata && if (pending->batch->send_trailing_metadata &&
@ -1817,7 +1820,7 @@ static void add_closures_for_replay_or_pending_send_ops(
channel_data* chand = static_cast<channel_data*>(elem->channel_data); channel_data* chand = static_cast<channel_data*>(elem->channel_data);
call_data* calld = static_cast<call_data*>(elem->call_data); call_data* calld = static_cast<call_data*>(elem->call_data);
bool have_pending_send_message_ops = bool have_pending_send_message_ops =
retry_state->started_send_message_count < calld->send_messages.size(); retry_state->started_send_message_count < calld->send_messages->size();
bool have_pending_send_trailing_metadata_op = bool have_pending_send_trailing_metadata_op =
calld->seen_send_trailing_metadata && calld->seen_send_trailing_metadata &&
!retry_state->started_send_trailing_metadata; !retry_state->started_send_trailing_metadata;
@ -2133,7 +2136,7 @@ static void add_retriable_send_message_op(
chand, calld, retry_state->started_send_message_count); chand, calld, retry_state->started_send_message_count);
} }
grpc_core::ByteStreamCache* cache = grpc_core::ByteStreamCache* cache =
calld->send_messages[retry_state->started_send_message_count]; (*calld->send_messages)[retry_state->started_send_message_count];
++retry_state->started_send_message_count; ++retry_state->started_send_message_count;
batch_data->send_message.Init(cache); batch_data->send_message.Init(cache);
batch_data->batch.send_message = true; batch_data->batch.send_message = true;
@ -2254,7 +2257,7 @@ static subchannel_batch_data* maybe_create_subchannel_batch_for_replay(
} }
// send_message. // send_message.
// Note that we can only have one send_message op in flight at a time. // Note that we can only have one send_message op in flight at a time.
if (retry_state->started_send_message_count < calld->send_messages.size() && if (retry_state->started_send_message_count < calld->send_messages->size() &&
retry_state->started_send_message_count == retry_state->started_send_message_count ==
retry_state->completed_send_message_count && retry_state->completed_send_message_count &&
!calld->pending_send_message) { !calld->pending_send_message) {
@ -2274,7 +2277,7 @@ static subchannel_batch_data* maybe_create_subchannel_batch_for_replay(
// to start, since we can't send down any more send_message ops after // to start, since we can't send down any more send_message ops after
// send_trailing_metadata. // send_trailing_metadata.
if (calld->seen_send_trailing_metadata && if (calld->seen_send_trailing_metadata &&
retry_state->started_send_message_count == calld->send_messages.size() && retry_state->started_send_message_count == calld->send_messages->size() &&
!retry_state->started_send_trailing_metadata && !retry_state->started_send_trailing_metadata &&
!calld->pending_send_trailing_metadata) { !calld->pending_send_trailing_metadata) {
if (grpc_client_channel_trace.enabled()) { if (grpc_client_channel_trace.enabled()) {
@ -2325,7 +2328,7 @@ static void add_subchannel_batches_for_pending_batches(
// send_message ops after send_trailing_metadata. // send_message ops after send_trailing_metadata.
if (batch->send_trailing_metadata && if (batch->send_trailing_metadata &&
(retry_state->started_send_message_count + batch->send_message < (retry_state->started_send_message_count + batch->send_message <
calld->send_messages.size() || calld->send_messages->size() ||
retry_state->started_send_trailing_metadata)) { retry_state->started_send_trailing_metadata)) {
continue; continue;
} }
@ -2976,6 +2979,7 @@ static grpc_error* cc_init_call_elem(grpc_call_element* elem,
calld->deadline); calld->deadline);
} }
calld->enable_retries = chand->enable_retries; calld->enable_retries = chand->enable_retries;
calld->send_messages.Init();
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
} }
@ -3011,6 +3015,7 @@ static void cc_destroy_call_elem(grpc_call_element* elem,
calld->pick.subchannel_call_context[i].value); calld->pick.subchannel_call_context[i].value);
} }
} }
calld->send_messages.Destroy();
GRPC_CLOSURE_SCHED(then_schedule_closure, GRPC_ERROR_NONE); GRPC_CLOSURE_SCHED(then_schedule_closure, GRPC_ERROR_NONE);
} }

@ -55,7 +55,8 @@ bool TraceFlagList::Set(const char* name, bool enabled) {
found = true; found = true;
} }
} }
if (!found) { // check for unknowns, but ignore "", to allow to GRPC_TRACE=
if (!found && 0 != strcmp(name, "")) {
gpr_log(GPR_ERROR, "Unknown trace var: '%s'", name); gpr_log(GPR_ERROR, "Unknown trace var: '%s'", name);
return false; /* early return */ return false; /* early return */
} }

@ -54,43 +54,43 @@ class InlinedVector {
InlinedVector(const InlinedVector&) = delete; InlinedVector(const InlinedVector&) = delete;
InlinedVector& operator=(const InlinedVector&) = delete; InlinedVector& operator=(const InlinedVector&) = delete;
T* data() {
return dynamic_ != nullptr ? dynamic_ : reinterpret_cast<T*>(inline_);
}
const T* data() const {
return dynamic_ != nullptr ? dynamic_ : reinterpret_cast<const T*>(inline_);
}
T& operator[](size_t offset) { T& operator[](size_t offset) {
assert(offset < size_); assert(offset < size_);
if (offset < N) { return data()[offset];
return *reinterpret_cast<T*>(inline_ + offset);
} else {
return dynamic_[offset - N];
}
} }
const T& operator[](size_t offset) const { const T& operator[](size_t offset) const {
assert(offset < size_); assert(offset < size_);
if (offset < N) { return data()[offset];
return *reinterpret_cast<const T*>(inline_ + offset);
} else {
return dynamic_[offset - N];
}
} }
template <typename... Args> void reserve(size_t capacity) {
void emplace_back(Args&&... args) { if (capacity > capacity_) {
if (size_ < N) { T* new_dynamic = static_cast<T*>(gpr_malloc(sizeof(T) * capacity));
new (&inline_[size_]) T(std::forward<Args>(args)...); for (size_t i = 0; i < size_; ++i) {
} else { new (&new_dynamic[i]) T(std::move(data()[i]));
if (size_ - N == dynamic_capacity_) { data()[i].~T();
size_t new_capacity =
dynamic_capacity_ == 0 ? 2 : dynamic_capacity_ * 2;
T* new_dynamic = static_cast<T*>(gpr_malloc(sizeof(T) * new_capacity));
for (size_t i = 0; i < dynamic_capacity_; ++i) {
new (&new_dynamic[i]) T(std::move(dynamic_[i]));
dynamic_[i].~T();
} }
gpr_free(dynamic_); gpr_free(dynamic_);
dynamic_ = new_dynamic; dynamic_ = new_dynamic;
dynamic_capacity_ = new_capacity; capacity_ = capacity;
} }
new (&dynamic_[size_ - N]) T(std::forward<Args>(args)...);
} }
template <typename... Args>
void emplace_back(Args&&... args) {
if (size_ == capacity_) {
reserve(capacity_ * 2);
}
new (&(data()[size_])) T(std::forward<Args>(args)...);
++size_; ++size_;
} }
@ -99,6 +99,7 @@ class InlinedVector {
void push_back(T&& value) { emplace_back(std::move(value)); } void push_back(T&& value) { emplace_back(std::move(value)); }
size_t size() const { return size_; } size_t size() const { return size_; }
size_t capacity() const { return capacity_; }
void clear() { void clear() {
destroy_elements(); destroy_elements();
@ -109,26 +110,21 @@ class InlinedVector {
void init_data() { void init_data() {
dynamic_ = nullptr; dynamic_ = nullptr;
size_ = 0; size_ = 0;
dynamic_capacity_ = 0; capacity_ = N;
} }
void destroy_elements() { void destroy_elements() {
for (size_t i = 0; i < size_ && i < N; ++i) { for (size_t i = 0; i < size_; ++i) {
T& value = *reinterpret_cast<T*>(inline_ + i); T& value = data()[i];
value.~T(); value.~T();
} }
if (size_ > N) { // Avoid subtracting two signed values.
for (size_t i = 0; i < size_ - N; ++i) {
dynamic_[i].~T();
}
}
gpr_free(dynamic_); gpr_free(dynamic_);
} }
typename std::aligned_storage<sizeof(T)>::type inline_[N]; typename std::aligned_storage<sizeof(T)>::type inline_[N];
T* dynamic_; T* dynamic_;
size_t size_; size_t size_;
size_t dynamic_capacity_; size_t capacity_;
}; };
} // namespace grpc_core } // namespace grpc_core

@ -59,7 +59,10 @@
//#define GRPC_EPOLLEX_CREATE_WORKERS_ON_HEAP 1 //#define GRPC_EPOLLEX_CREATE_WORKERS_ON_HEAP 1
#define MAX_EPOLL_EVENTS 100 #define MAX_EPOLL_EVENTS 100
#define MAX_EPOLL_EVENTS_HANDLED_EACH_POLL_CALL 1 // TODO(juanlishen): We use a greater-than-one value here as a workaround fix to
// a keepalive ping timeout issue. We may want to revert https://github
// .com/grpc/grpc/pull/14943 once we figure out the root cause.
#define MAX_EPOLL_EVENTS_HANDLED_EACH_POLL_CALL 16
grpc_core::DebugOnlyTraceFlag grpc_trace_pollable_refcount(false, grpc_core::DebugOnlyTraceFlag grpc_trace_pollable_refcount(false,
"pollable_refcount"); "pollable_refcount");
@ -198,6 +201,7 @@ struct grpc_pollset_worker {
struct grpc_pollset { struct grpc_pollset {
gpr_mu mu; gpr_mu mu;
gpr_atm worker_count;
pollable* active_pollable; pollable* active_pollable;
bool kicked_without_poller; bool kicked_without_poller;
grpc_closure* shutdown_closure; grpc_closure* shutdown_closure;
@ -685,6 +689,7 @@ static grpc_error* pollset_kick_all(grpc_pollset* pollset) {
static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) { static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
gpr_mu_init(&pollset->mu); gpr_mu_init(&pollset->mu);
gpr_atm_no_barrier_store(&pollset->worker_count, 0);
pollset->active_pollable = POLLABLE_REF(g_empty_pollable, "pollset"); pollset->active_pollable = POLLABLE_REF(g_empty_pollable, "pollset");
pollset->kicked_without_poller = false; pollset->kicked_without_poller = false;
pollset->shutdown_closure = nullptr; pollset->shutdown_closure = nullptr;
@ -758,8 +763,20 @@ static grpc_error* pollable_process_events(grpc_pollset* pollset,
pollable* pollable_obj, bool drain) { pollable* pollable_obj, bool drain) {
GPR_TIMER_SCOPE("pollable_process_events", 0); GPR_TIMER_SCOPE("pollable_process_events", 0);
static const char* err_desc = "pollset_process_events"; static const char* err_desc = "pollset_process_events";
// Use a simple heuristic to determine how many fd events to process
// per loop iteration. (events/workers)
int handle_count = 1;
int worker_count = gpr_atm_no_barrier_load(&pollset->worker_count);
GPR_ASSERT(worker_count > 0);
handle_count =
(pollable_obj->event_count - pollable_obj->event_cursor) / worker_count;
if (handle_count == 0) {
handle_count = 1;
} else if (handle_count > MAX_EPOLL_EVENTS_HANDLED_EACH_POLL_CALL) {
handle_count = MAX_EPOLL_EVENTS_HANDLED_EACH_POLL_CALL;
}
grpc_error* error = GRPC_ERROR_NONE; grpc_error* error = GRPC_ERROR_NONE;
for (int i = 0; (drain || i < MAX_EPOLL_EVENTS_HANDLED_EACH_POLL_CALL) && for (int i = 0; (drain || i < handle_count) &&
pollable_obj->event_cursor != pollable_obj->event_count; pollable_obj->event_cursor != pollable_obj->event_count;
i++) { i++) {
int n = pollable_obj->event_cursor++; int n = pollable_obj->event_cursor++;
@ -884,6 +901,7 @@ static bool begin_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
GPR_TIMER_SCOPE("begin_worker", 0); GPR_TIMER_SCOPE("begin_worker", 0);
bool do_poll = bool do_poll =
(pollset->shutdown_closure == nullptr && !pollset->already_shutdown); (pollset->shutdown_closure == nullptr && !pollset->already_shutdown);
gpr_atm_no_barrier_fetch_add(&pollset->worker_count, 1);
if (worker_hdl != nullptr) *worker_hdl = worker; if (worker_hdl != nullptr) *worker_hdl = worker;
worker->initialized_cv = false; worker->initialized_cv = false;
worker->kicked = false; worker->kicked = false;
@ -964,6 +982,7 @@ static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
if (worker->initialized_cv) { if (worker->initialized_cv) {
gpr_cv_destroy(&worker->cv); gpr_cv_destroy(&worker->cv);
} }
gpr_atm_no_barrier_fetch_add(&pollset->worker_count, -1);
} }
#ifndef NDEBUG #ifndef NDEBUG

@ -1530,6 +1530,12 @@ static void run_poll(void* args) {
// This function overrides poll() to handle condition variable wakeup fds // This function overrides poll() to handle condition variable wakeup fds
static int cvfd_poll(struct pollfd* fds, nfds_t nfds, int timeout) { static int cvfd_poll(struct pollfd* fds, nfds_t nfds, int timeout) {
if (timeout == 0) {
// Don't bother using background threads for polling if timeout is 0,
// poll-cv might not wait for a poll to return otherwise.
// https://github.com/grpc/grpc/issues/13298
return poll(fds, nfds, 0);
}
unsigned int i; unsigned int i;
int res, idx; int res, idx;
grpc_cv_node* pollcv; grpc_cv_node* pollcv;

@ -33,7 +33,6 @@
int grpc_accept4(int sockfd, grpc_resolved_address* resolved_addr, int nonblock, int grpc_accept4(int sockfd, grpc_resolved_address* resolved_addr, int nonblock,
int cloexec) { int cloexec) {
int flags = 0; int flags = 0;
GPR_ASSERT(sizeof(socklen_t) <= sizeof(size_t));
flags |= nonblock ? SOCK_NONBLOCK : 0; flags |= nonblock ? SOCK_NONBLOCK : 0;
flags |= cloexec ? SOCK_CLOEXEC : 0; flags |= cloexec ? SOCK_CLOEXEC : 0;
return accept4(sockfd, reinterpret_cast<grpc_sockaddr*>(resolved_addr->addr), return accept4(sockfd, reinterpret_cast<grpc_sockaddr*>(resolved_addr->addr),

@ -34,9 +34,8 @@
int grpc_accept4(int sockfd, grpc_resolved_address* resolved_addr, int nonblock, int grpc_accept4(int sockfd, grpc_resolved_address* resolved_addr, int nonblock,
int cloexec) { int cloexec) {
int fd, flags; int fd, flags;
GPR_ASSERT(sizeof(socklen_t) <= sizeof(size_t)); fd = accept(sockfd, reinterpret_cast<grpc_sockaddr*>(resolved_addr->addr),
fd = accept(sockfd, (grpc_sockaddr*)resolved_addr->addr, &resolved_addr->len);
(socklen_t*)&resolved_addr->len);
if (fd >= 0) { if (fd >= 0) {
if (nonblock) { if (nonblock) {
flags = fcntl(fd, F_GETFL, 0); flags = fcntl(fd, F_GETFL, 0);

@ -38,8 +38,8 @@ int grpc_inet_pton(int af, const char* src, void* dst) {
} }
const char* grpc_inet_ntop(int af, const void* src, char* dst, size_t size) { const char* grpc_inet_ntop(int af, const void* src, char* dst, size_t size) {
/* Windows InetNtopA wants a mutable ip pointer */ uv_inet_ntop(af, src, dst, size);
return inet_ntop(af, src, dst, (socklen_t)size); return dst;
} }
#endif /* GRPC_UV */ #endif /* GRPC_UV */

@ -62,8 +62,6 @@ typedef struct grpc_socket_vtable {
const grpc_sockaddr* addr, int* len); const grpc_sockaddr* addr, int* len);
grpc_error* (*getsockname)(grpc_custom_socket* socket, grpc_error* (*getsockname)(grpc_custom_socket* socket,
const grpc_sockaddr* addr, int* len); const grpc_sockaddr* addr, int* len);
grpc_error* (*setsockopt)(grpc_custom_socket* socket, int level, int optname,
const void* optval, uint32_t optlen);
grpc_error* (*bind)(grpc_custom_socket* socket, const grpc_sockaddr* addr, grpc_error* (*bind)(grpc_custom_socket* socket, const grpc_sockaddr* addr,
size_t len, int flags); size_t len, int flags);
grpc_error* (*listen)(grpc_custom_socket* socket); grpc_error* (*listen)(grpc_custom_socket* socket);

@ -393,13 +393,6 @@ static grpc_error* tcp_server_add_port(grpc_tcp_server* s,
grpc_custom_socket_vtable->init(socket, family); grpc_custom_socket_vtable->init(socket, family);
if (error == GRPC_ERROR_NONE) { if (error == GRPC_ERROR_NONE) {
#if defined(GPR_LINUX) && defined(SO_REUSEPORT)
if (family == AF_INET || family == AF_INET6) {
int enable = 1;
grpc_custom_socket_vtable->setsockopt(socket, SOL_SOCKET, SO_REUSEPORT,
&enable, sizeof(enable));
}
#endif /* GPR_LINUX && SO_REUSEPORT */
error = add_socket_to_server(s, socket, addr, port_index, &sp); error = add_socket_to_server(s, socket, addr, port_index, &sp);
} }
gpr_free(allocated_addr); gpr_free(allocated_addr);

@ -129,6 +129,7 @@ static void destroy_server(void* arg, grpc_error* error) {
gpr_free(sp); gpr_free(sp);
} }
grpc_channel_args_destroy(s->channel_args); grpc_channel_args_destroy(s->channel_args);
gpr_mu_destroy(&s->mu);
gpr_free(s); gpr_free(s);
} }

@ -192,6 +192,15 @@ static grpc_error* uv_socket_init_helper(uv_socket_t* uv_socket, int domain) {
if (status != 0) { if (status != 0) {
return tcp_error_create("Failed to initialize UV tcp handle", status); return tcp_error_create("Failed to initialize UV tcp handle", status);
} }
#if defined(GPR_LINUX) && defined(SO_REUSEPORT)
if (domain == AF_INET || domain == AF_INET6) {
int enable = 1;
int fd;
uv_fileno((uv_handle_t*)tcp, &fd);
// TODO Handle error here.
setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &enable, sizeof(enable));
}
#endif
uv_socket->write_buffers = nullptr; uv_socket->write_buffers = nullptr;
uv_socket->read_len = 0; uv_socket->read_len = 0;
uv_tcp_nodelay(uv_socket->handle, 1); uv_tcp_nodelay(uv_socket->handle, 1);
@ -299,17 +308,6 @@ static grpc_error* uv_socket_listen(grpc_custom_socket* socket) {
return tcp_error_create("Failed to listen to port", status); return tcp_error_create("Failed to listen to port", status);
} }
static grpc_error* uv_socket_setsockopt(grpc_custom_socket* socket, int level,
int option_name, const void* optval,
socklen_t option_len) {
int fd;
uv_socket_t* uv_socket = (uv_socket_t*)socket->impl;
uv_fileno((uv_handle_t*)uv_socket->handle, &fd);
// TODO Handle error here. Also, does this work on windows??
setsockopt(fd, level, option_name, &optval, (socklen_t)option_len);
return GRPC_ERROR_NONE;
}
static void uv_tc_on_connect(uv_connect_t* req, int status) { static void uv_tc_on_connect(uv_connect_t* req, int status) {
grpc_custom_socket* socket = (grpc_custom_socket*)req->data; grpc_custom_socket* socket = (grpc_custom_socket*)req->data;
uv_socket_t* uv_socket = (uv_socket_t*)socket->impl; uv_socket_t* uv_socket = (uv_socket_t*)socket->impl;
@ -340,7 +338,6 @@ static void uv_socket_connect(grpc_custom_socket* socket,
static grpc_resolved_addresses* handle_addrinfo_result( static grpc_resolved_addresses* handle_addrinfo_result(
struct addrinfo* result) { struct addrinfo* result) {
struct addrinfo* resp; struct addrinfo* resp;
struct addrinfo* prev;
size_t i; size_t i;
grpc_resolved_addresses* addresses = grpc_resolved_addresses* addresses =
(grpc_resolved_addresses*)gpr_malloc(sizeof(grpc_resolved_addresses)); (grpc_resolved_addresses*)gpr_malloc(sizeof(grpc_resolved_addresses));
@ -350,16 +347,13 @@ static grpc_resolved_addresses* handle_addrinfo_result(
} }
addresses->addrs = (grpc_resolved_address*)gpr_malloc( addresses->addrs = (grpc_resolved_address*)gpr_malloc(
sizeof(grpc_resolved_address) * addresses->naddrs); sizeof(grpc_resolved_address) * addresses->naddrs);
i = 0; for (resp = result, i = 0; resp != nullptr; resp = resp->ai_next, i++) {
resp = result;
while (resp != nullptr) {
memcpy(&addresses->addrs[i].addr, resp->ai_addr, resp->ai_addrlen); memcpy(&addresses->addrs[i].addr, resp->ai_addr, resp->ai_addrlen);
addresses->addrs[i].len = resp->ai_addrlen; addresses->addrs[i].len = resp->ai_addrlen;
i++;
prev = resp;
resp = resp->ai_next;
gpr_free(prev);
} }
// addrinfo objects are allocated by libuv (e.g. in uv_getaddrinfo)
// and not by gpr_malloc
uv_freeaddrinfo(result);
return addresses; return addresses;
} }
@ -418,7 +412,6 @@ grpc_socket_vtable grpc_uv_socket_vtable = {
uv_socket_init, uv_socket_connect, uv_socket_destroy, uv_socket_init, uv_socket_connect, uv_socket_destroy,
uv_socket_shutdown, uv_socket_close, uv_socket_write, uv_socket_shutdown, uv_socket_close, uv_socket_write,
uv_socket_read, uv_socket_getpeername, uv_socket_getsockname, uv_socket_read, uv_socket_getpeername, uv_socket_getsockname,
uv_socket_setsockopt, uv_socket_bind, uv_socket_listen, uv_socket_bind, uv_socket_listen, uv_socket_accept};
uv_socket_accept};
#endif #endif

@ -98,6 +98,12 @@ static void init_timer_ht() {
} }
} }
static void destroy_timer_ht() {
for (int i = 0; i < NUM_HASH_BUCKETS; i++) {
gpr_mu_destroy(&g_hash_mu[i]);
}
}
static bool is_in_ht(grpc_timer* t) { static bool is_in_ht(grpc_timer* t) {
size_t i = GPR_HASH_POINTER(t, NUM_HASH_BUCKETS); size_t i = GPR_HASH_POINTER(t, NUM_HASH_BUCKETS);
@ -189,6 +195,7 @@ static void validate_non_pending_timer(grpc_timer* t) {
} }
#define INIT_TIMER_HASH_TABLE() init_timer_ht() #define INIT_TIMER_HASH_TABLE() init_timer_ht()
#define DESTROY_TIMER_HASH_TABLE() destroy_timer_ht()
#define ADD_TO_HASH_TABLE(t) add_to_ht((t)) #define ADD_TO_HASH_TABLE(t) add_to_ht((t))
#define REMOVE_FROM_HASH_TABLE(t) remove_from_ht((t)) #define REMOVE_FROM_HASH_TABLE(t) remove_from_ht((t))
#define VALIDATE_NON_PENDING_TIMER(t) validate_non_pending_timer((t)) #define VALIDATE_NON_PENDING_TIMER(t) validate_non_pending_timer((t))
@ -196,6 +203,7 @@ static void validate_non_pending_timer(grpc_timer* t) {
#else #else
#define INIT_TIMER_HASH_TABLE() #define INIT_TIMER_HASH_TABLE()
#define DESTROY_TIMER_HASH_TABLE()
#define ADD_TO_HASH_TABLE(t) #define ADD_TO_HASH_TABLE(t)
#define REMOVE_FROM_HASH_TABLE(t) #define REMOVE_FROM_HASH_TABLE(t)
#define VALIDATE_NON_PENDING_TIMER(t) #define VALIDATE_NON_PENDING_TIMER(t)
@ -299,6 +307,8 @@ static void timer_list_shutdown() {
gpr_free(g_shards); gpr_free(g_shards);
gpr_free(g_shard_queue); gpr_free(g_shard_queue);
g_shared_mutables.initialized = false; g_shared_mutables.initialized = false;
DESTROY_TIMER_HASH_TABLE();
} }
/* returns true if the first element in the list */ /* returns true if the first element in the list */

@ -69,8 +69,12 @@ grpc_slice grpc_slice_ref(grpc_slice slice) {
/* Public API */ /* Public API */
void grpc_slice_unref(grpc_slice slice) { void grpc_slice_unref(grpc_slice slice) {
if (grpc_core::ExecCtx::Get() == nullptr) {
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
grpc_slice_unref_internal(slice); grpc_slice_unref_internal(slice);
} else {
grpc_slice_unref_internal(slice);
}
} }
/* grpc_slice_from_static_string support structure - a refcount that does /* grpc_slice_from_static_string support structure - a refcount that does

@ -75,8 +75,12 @@ void grpc_slice_buffer_destroy_internal(grpc_slice_buffer* sb) {
} }
void grpc_slice_buffer_destroy(grpc_slice_buffer* sb) { void grpc_slice_buffer_destroy(grpc_slice_buffer* sb) {
if (grpc_core::ExecCtx::Get() == nullptr) {
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
grpc_slice_buffer_destroy_internal(sb); grpc_slice_buffer_destroy_internal(sb);
} else {
grpc_slice_buffer_destroy_internal(sb);
}
} }
uint8_t* grpc_slice_buffer_tiny_add(grpc_slice_buffer* sb, size_t n) { uint8_t* grpc_slice_buffer_tiny_add(grpc_slice_buffer* sb, size_t n) {
@ -176,8 +180,12 @@ void grpc_slice_buffer_reset_and_unref_internal(grpc_slice_buffer* sb) {
} }
void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer* sb) { void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer* sb) {
if (grpc_core::ExecCtx::Get() == nullptr) {
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
grpc_slice_buffer_reset_and_unref_internal(sb); grpc_slice_buffer_reset_and_unref_internal(sb);
} else {
grpc_slice_buffer_reset_and_unref_internal(sb);
}
} }
void grpc_slice_buffer_swap(grpc_slice_buffer* a, grpc_slice_buffer* b) { void grpc_slice_buffer_swap(grpc_slice_buffer* a, grpc_slice_buffer* b) {

@ -878,8 +878,8 @@ static void set_encodings_accepted_by_peer(grpc_call* call, grpc_mdelem mdel,
} else { } else {
char* accept_encoding_entry_str = char* accept_encoding_entry_str =
grpc_slice_to_c_string(accept_encoding_entry_slice); grpc_slice_to_c_string(accept_encoding_entry_slice);
gpr_log(GPR_ERROR, gpr_log(GPR_DEBUG,
"Invalid entry in accept encoding metadata: '%s'. Ignoring.", "Unknown entry in accept encoding metadata: '%s'. Ignoring.",
accept_encoding_entry_str); accept_encoding_entry_str);
gpr_free(accept_encoding_entry_str); gpr_free(accept_encoding_entry_str);
} }

@ -25,4 +25,4 @@
const char* grpc_version_string(void) { return "6.0.0-dev"; } const char* grpc_version_string(void) { return "6.0.0-dev"; }
const char* grpc_g_stands_for(void) { return "gorgeous"; } const char* grpc_g_stands_for(void) { return "glorious"; }

@ -98,6 +98,10 @@ void CoreCodegen::grpc_byte_buffer_destroy(grpc_byte_buffer* bb) {
::grpc_byte_buffer_destroy(bb); ::grpc_byte_buffer_destroy(bb);
} }
size_t CoreCodegen::grpc_byte_buffer_length(grpc_byte_buffer* bb) {
return ::grpc_byte_buffer_length(bb);
}
grpc_call_error CoreCodegen::grpc_call_cancel_with_status( grpc_call_error CoreCodegen::grpc_call_cancel_with_status(
grpc_call* call, grpc_status_code status, const char* description, grpc_call* call, grpc_status_code status, const char* description,
void* reserved) { void* reserved) {
@ -135,6 +139,12 @@ grpc_slice CoreCodegen::grpc_slice_new_with_user_data(void* p, size_t len,
return ::grpc_slice_new_with_user_data(p, len, destroy, user_data); return ::grpc_slice_new_with_user_data(p, len, destroy, user_data);
} }
grpc_slice CoreCodegen::grpc_slice_new_with_len(void* p, size_t len,
void (*destroy)(void*,
size_t)) {
return ::grpc_slice_new_with_len(p, len, destroy);
}
grpc_slice CoreCodegen::grpc_empty_slice() { return ::grpc_empty_slice(); } grpc_slice CoreCodegen::grpc_empty_slice() { return ::grpc_empty_slice(); }
grpc_slice CoreCodegen::grpc_slice_malloc(size_t length) { grpc_slice CoreCodegen::grpc_slice_malloc(size_t length) {

@ -22,5 +22,5 @@
#include <grpcpp/grpcpp.h> #include <grpcpp/grpcpp.h>
namespace grpc { namespace grpc {
grpc::string Version() { return "1.11.0-dev"; } grpc::string Version() { return "1.12.0-dev"; }
} // namespace grpc } // namespace grpc

@ -25,32 +25,6 @@ namespace grpc {
static internal::GrpcLibraryInitializer g_gli_initializer; static internal::GrpcLibraryInitializer g_gli_initializer;
ByteBuffer::ByteBuffer(const Slice* slices, size_t nslices) {
// The following assertions check that the representation of a grpc::Slice is
// identical to that of a grpc_slice: it has a grpc_slice field, and nothing
// else.
static_assert(std::is_same<decltype(slices[0].slice_), grpc_slice>::value,
"Slice must have same representation as grpc_slice");
static_assert(sizeof(Slice) == sizeof(grpc_slice),
"Slice must have same representation as grpc_slice");
// The following assertions check that the representation of a ByteBuffer is
// identical to grpc_byte_buffer*: it has a grpc_byte_buffer* field,
// and nothing else.
static_assert(std::is_same<decltype(buffer_), grpc_byte_buffer*>::value,
"ByteBuffer must have same representation as "
"grpc_byte_buffer*");
static_assert(sizeof(ByteBuffer) == sizeof(grpc_byte_buffer*),
"ByteBuffer must have same representation as "
"grpc_byte_buffer*");
g_gli_initializer.summon(); // Make sure that initializer linked in
// The const_cast is legal if grpc_raw_byte_buffer_create() does no more
// than its advertised side effect of increasing the reference count of the
// slices it processes, and such an increase does not affect the semantics
// seen by the caller of this constructor.
buffer_ = grpc_raw_byte_buffer_create(
reinterpret_cast<grpc_slice*>(const_cast<Slice*>(slices)), nslices);
}
Status ByteBuffer::Dump(std::vector<Slice>* slices) const { Status ByteBuffer::Dump(std::vector<Slice>* slices) const {
slices->clear(); slices->clear();
if (!buffer_) { if (!buffer_) {
@ -69,14 +43,6 @@ Status ByteBuffer::Dump(std::vector<Slice>* slices) const {
return Status::OK; return Status::OK;
} }
size_t ByteBuffer::Length() const {
if (buffer_) {
return grpc_byte_buffer_length(buffer_);
} else {
return 0;
}
}
ByteBuffer::ByteBuffer(const ByteBuffer& buf) ByteBuffer::ByteBuffer(const ByteBuffer& buf)
: buffer_(grpc_byte_buffer_copy(buf.buffer_)) {} : buffer_(grpc_byte_buffer_copy(buf.buffer_)) {}
@ -90,10 +56,4 @@ ByteBuffer& ByteBuffer::operator=(const ByteBuffer& buf) {
return *this; return *this;
} }
void ByteBuffer::Swap(ByteBuffer* other) {
grpc_byte_buffer* tmp = other->buffer_;
other->buffer_ = buffer_;
buffer_ = tmp;
}
} // namespace grpc } // namespace grpc

@ -1,55 +0,0 @@
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <grpc/slice.h>
#include <grpcpp/support/slice.h>
namespace grpc {
Slice::Slice() : slice_(grpc_empty_slice()) {}
Slice::~Slice() { grpc_slice_unref(slice_); }
Slice::Slice(grpc_slice slice, AddRef) : slice_(grpc_slice_ref(slice)) {}
Slice::Slice(grpc_slice slice, StealRef) : slice_(slice) {}
Slice::Slice(size_t len) : slice_(grpc_slice_malloc(len)) {}
Slice::Slice(const void* buf, size_t len)
: slice_(
grpc_slice_from_copied_buffer(static_cast<const char*>(buf), len)) {}
Slice::Slice(const grpc::string& str)
: slice_(grpc_slice_from_copied_buffer(str.c_str(), str.length())) {}
Slice::Slice(const void* buf, size_t len, StaticSlice)
: slice_(
grpc_slice_from_static_buffer(static_cast<const char*>(buf), len)) {}
Slice::Slice(const Slice& other) : slice_(grpc_slice_ref(other.slice_)) {}
Slice::Slice(void* buf, size_t len, void (*destroy)(void*), void* user_data)
: slice_(grpc_slice_new_with_user_data(buf, len, destroy, user_data)) {}
Slice::Slice(void* buf, size_t len, void (*destroy)(void*, size_t))
: slice_(grpc_slice_new_with_len(buf, len, destroy)) {}
grpc_slice Slice::c_slice() const { return grpc_slice_ref(slice_); }
} // namespace grpc

@ -1,7 +1,7 @@
<!-- This file is generated --> <!-- This file is generated -->
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<GrpcCsharpVersion>1.11.0-dev</GrpcCsharpVersion> <GrpcCsharpVersion>1.12.0-dev</GrpcCsharpVersion>
<GoogleProtobufVersion>3.3.0</GoogleProtobufVersion> <GoogleProtobufVersion>3.3.0</GoogleProtobufVersion>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

@ -33,11 +33,11 @@ namespace Grpc.Core
/// <summary> /// <summary>
/// Current <c>AssemblyFileVersion</c> of gRPC C# assemblies /// Current <c>AssemblyFileVersion</c> of gRPC C# assemblies
/// </summary> /// </summary>
public const string CurrentAssemblyFileVersion = "1.11.0.0"; public const string CurrentAssemblyFileVersion = "1.12.0.0";
/// <summary> /// <summary>
/// Current version of gRPC C# /// Current version of gRPC C#
/// </summary> /// </summary>
public const string CurrentVersion = "1.11.0-dev"; public const string CurrentVersion = "1.12.0-dev";
} }
} }

@ -13,7 +13,7 @@
@rem limitations under the License. @rem limitations under the License.
@rem Current package versions @rem Current package versions
set VERSION=1.11.0-dev set VERSION=1.12.0-dev
@rem Adjust the location of nuget.exe @rem Adjust the location of nuget.exe
set NUGET=C:\nuget\nuget.exe set NUGET=C:\nuget\nuget.exe

@ -45,7 +45,7 @@ dotnet pack --configuration Release Grpc.Auth --output ../../../artifacts
dotnet pack --configuration Release Grpc.HealthCheck --output ../../../artifacts dotnet pack --configuration Release Grpc.HealthCheck --output ../../../artifacts
dotnet pack --configuration Release Grpc.Reflection --output ../../../artifacts dotnet pack --configuration Release Grpc.Reflection --output ../../../artifacts
nuget pack Grpc.nuspec -Version "1.11.0-dev" -OutputDirectory ../../artifacts nuget pack Grpc.nuspec -Version "1.12.0-dev" -OutputDirectory ../../artifacts
nuget pack Grpc.Tools.nuspec -Version "1.11.0-dev" -OutputDirectory ../../artifacts nuget pack Grpc.Tools.nuspec -Version "1.12.0-dev" -OutputDirectory ../../artifacts
(cd ../../artifacts && zip csharp_nugets_dotnetcli.zip *.nupkg) (cd ../../artifacts && zip csharp_nugets_dotnetcli.zip *.nupkg)

@ -42,7 +42,7 @@ Pod::Spec.new do |s|
# exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed
# before them. # before them.
s.name = '!ProtoCompiler-gRPCPlugin' s.name = '!ProtoCompiler-gRPCPlugin'
v = '1.11.0-dev' v = '1.12.0-dev'
s.version = v s.version = v
s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.'
s.description = <<-DESC s.description = <<-DESC

@ -355,17 +355,8 @@ static NSString * const kBearerPrefix = @"Bearer ";
} }
dispatch_async(_callQueue, ^{ dispatch_async(_callQueue, ^{
__weak GRPCCall *weakSelf = self; // Write error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT
[self writeMessage:value withErrorHandler:^{ [self writeMessage:value withErrorHandler:nil];
__strong GRPCCall *strongSelf = weakSelf;
if (strongSelf != nil) {
[strongSelf maybeFinishWithError:[NSError errorWithDomain:kGRPCErrorDomain
code:GRPCErrorCodeInternal
userInfo:nil]];
// Wrapped call must be canceled when error is reported to upper layers
[strongSelf cancelCall];
}
}];
}); });
} }
@ -387,15 +378,8 @@ static NSString * const kBearerPrefix = @"Bearer ";
[self cancel]; [self cancel];
} else { } else {
dispatch_async(_callQueue, ^{ dispatch_async(_callQueue, ^{
__weak GRPCCall *weakSelf = self; // EOS error is not processed here. It is handled by op batch of GRPC_OP_RECV_STATUS_ON_CLIENT
[self finishRequestWithErrorHandler:^{ [self finishRequestWithErrorHandler:nil];
__strong GRPCCall *strongSelf = weakSelf;
[strongSelf maybeFinishWithError:[NSError errorWithDomain:kGRPCErrorDomain
code:GRPCErrorCodeInternal
userInfo:nil]];
// Wrapped call must be canceled when error is reported to upper layers
[strongSelf cancelCall];
}];
}); });
} }
} }

@ -23,4 +23,4 @@
// `tools/buildgen/generate_projects.sh`. // `tools/buildgen/generate_projects.sh`.
#define GRPC_OBJC_VERSION_STRING @"1.11.0-dev" #define GRPC_OBJC_VERSION_STRING @"1.12.0-dev"

@ -31,6 +31,8 @@
#import <RxLibrary/GRXWriter+Immediate.h> #import <RxLibrary/GRXWriter+Immediate.h>
#import <RxLibrary/GRXBufferedPipe.h> #import <RxLibrary/GRXBufferedPipe.h>
#include <netinet/in.h>
#import "version.h" #import "version.h"
#define TEST_TIMEOUT 16 #define TEST_TIMEOUT 16
@ -482,4 +484,40 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
} }
- (int)findFreePort {
struct sockaddr_in addr;
unsigned int addr_len = sizeof(addr);
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
int fd = socket(AF_INET, SOCK_STREAM, 0);
XCTAssertEqual(bind(fd, (struct sockaddr*)&addr, sizeof(addr)), 0);
XCTAssertEqual(getsockname(fd, (struct sockaddr*)&addr, &addr_len), 0);
XCTAssertEqual(addr_len, sizeof(addr));
close(fd);
return addr.sin_port;
}
- (void)testErrorCode {
int port = [self findFreePort];
NSString * const kDummyAddress = [NSString stringWithFormat:@"localhost:%d", port];
__weak XCTestExpectation *completion = [self expectationWithDescription:@"Empty RPC completed."];
GRPCCall *call = [[GRPCCall alloc] initWithHost:kDummyAddress
path:kEmptyCallMethod.HTTPPath
requestsWriter:[GRXWriter writerWithValue:[NSData data]]];
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
// Should not reach here
XCTAssert(NO);
} completionHandler:^(NSError *errorOrNil) {
XCTAssertNotNil(errorOrNil, @"Finished with no error");
XCTAssertEqual(errorOrNil.code, GRPC_STATUS_UNAVAILABLE);
[completion fulfill];
}];
[call startWithWriteable:responsesWriteable];
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
}
@end @end

@ -23,5 +23,5 @@
// `tools/buildgen/generate_projects.sh`. // `tools/buildgen/generate_projects.sh`.
#define GRPC_OBJC_VERSION_STRING @"1.11.0-dev" #define GRPC_OBJC_VERSION_STRING @"1.12.0-dev"
#define GRPC_C_VERSION_STRING @"6.0.0-dev" #define GRPC_C_VERSION_STRING @"6.0.0-dev"

@ -2,7 +2,7 @@
"name": "grpc/grpc-dev", "name": "grpc/grpc-dev",
"description": "gRPC library for PHP - for Developement use only", "description": "gRPC library for PHP - for Developement use only",
"license": "Apache-2.0", "license": "Apache-2.0",
"version": "1.11.0", "version": "1.12.0",
"require": { "require": {
"php": ">=5.5.0", "php": ">=5.5.0",
"google/protobuf": "^v3.3.0" "google/protobuf": "^v3.3.0"

@ -20,6 +20,6 @@
#ifndef VERSION_H #ifndef VERSION_H
#define VERSION_H #define VERSION_H
#define PHP_GRPC_VERSION "1.11.0dev" #define PHP_GRPC_VERSION "1.12.0dev"
#endif /* VERSION_H */ #endif /* VERSION_H */

@ -83,8 +83,6 @@ cdef extern from "src/core/lib/iomgr/tcp_custom.h":
const grpc_sockaddr* addr, int* len); const grpc_sockaddr* addr, int* len);
grpc_error* (*getsockname)(grpc_custom_socket* socket, grpc_error* (*getsockname)(grpc_custom_socket* socket,
const grpc_sockaddr* addr, int* len); const grpc_sockaddr* addr, int* len);
grpc_error* (*setsockopt)(grpc_custom_socket* socket, int level, int optname,
const void* optval, uint32_t len);
grpc_error* (*bind)(grpc_custom_socket* socket, const grpc_sockaddr* addr, grpc_error* (*bind)(grpc_custom_socket* socket, const grpc_sockaddr* addr,
size_t len, int flags); size_t len, int flags);
grpc_error* (*listen)(grpc_custom_socket* socket); grpc_error* (*listen)(grpc_custom_socket* socket);

@ -239,11 +239,6 @@ cdef grpc_error* socket_getsockname(grpc_custom_socket* socket,
length[0] = c_addr.len length[0] = c_addr.len
return grpc_error_none() return grpc_error_none()
cdef grpc_error* socket_setsockopt(grpc_custom_socket* socket, int level, int optname,
const void *optval, uint32_t optlen) with gil:
# No-op; we provide a default set of options
return grpc_error_none()
def applysockopts(s): def applysockopts(s):
s.setsockopt(gevent_socket.SOL_SOCKET, gevent_socket.SO_REUSEADDR, 1) s.setsockopt(gevent_socket.SOL_SOCKET, gevent_socket.SO_REUSEADDR, 1)
s.setsockopt(gevent_socket.IPPROTO_TCP, gevent_socket.TCP_NODELAY, True) s.setsockopt(gevent_socket.IPPROTO_TCP, gevent_socket.TCP_NODELAY, True)
@ -435,7 +430,6 @@ def init_grpc_gevent():
gevent_socket_vtable.read = socket_read gevent_socket_vtable.read = socket_read
gevent_socket_vtable.getpeername = socket_getpeername gevent_socket_vtable.getpeername = socket_getpeername
gevent_socket_vtable.getsockname = socket_getsockname gevent_socket_vtable.getsockname = socket_getsockname
gevent_socket_vtable.setsockopt = socket_setsockopt
gevent_socket_vtable.bind = socket_bind gevent_socket_vtable.bind = socket_bind
gevent_socket_vtable.listen = socket_listen gevent_socket_vtable.listen = socket_listen
gevent_socket_vtable.accept = socket_accept gevent_socket_vtable.accept = socket_accept

@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!!
__version__ = """1.11.0.dev0""" __version__ = """1.12.0.dev0"""

@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!!
VERSION = '1.11.0.dev0' VERSION = '1.12.0.dev0'

@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!!
VERSION = '1.11.0.dev0' VERSION = '1.12.0.dev0'

@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!!
VERSION = '1.11.0.dev0' VERSION = '1.12.0.dev0'

@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!! # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!!
VERSION = '1.11.0.dev0' VERSION = '1.12.0.dev0'

@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!!
VERSION = '1.11.0.dev0' VERSION = '1.12.0.dev0'

@ -54,8 +54,14 @@ def run_multiple_killed_watches(num_threads, sleep_time)
end end
def main def main
STDERR.puts '10 iterations, sleep 0.1 before killing thread'
run_multiple_killed_watches(10, 0.1) run_multiple_killed_watches(10, 0.1)
STDERR.puts '1000 iterations, sleep 0.001 before killing thread'
run_multiple_killed_watches(1000, 0.001) run_multiple_killed_watches(1000, 0.001)
STDERR.puts '10000 iterations, sleep 0.00001 before killing thread'
run_multiple_killed_watches(10_000, 0.00001)
STDERR.puts '20000 iterations, sleep 0.00001 before killing thread'
run_multiple_killed_watches(20_000, 0.00001)
end end
main main

@ -84,7 +84,7 @@ if grpc_config == 'gcov'
end end
if grpc_config == 'dbg' if grpc_config == 'dbg'
$CFLAGS << ' -O0' $CFLAGS << ' -O0 -ggdb3'
end end
$LDFLAGS << ' -Wl,-wrap,memcpy' if RUBY_PLATFORM =~ /linux/ $LDFLAGS << ' -Wl,-wrap,memcpy' if RUBY_PLATFORM =~ /linux/

@ -315,7 +315,7 @@ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE* argv,
} }
typedef struct watch_state_stack { typedef struct watch_state_stack {
grpc_channel* channel; bg_watched_channel* bg_wrapped;
gpr_timespec deadline; gpr_timespec deadline;
int last_state; int last_state;
} watch_state_stack; } watch_state_stack;
@ -328,15 +328,15 @@ static void* wait_for_watch_state_op_complete_without_gvl(void* arg) {
gpr_mu_lock(&global_connection_polling_mu); gpr_mu_lock(&global_connection_polling_mu);
// its unsafe to do a "watch" after "channel polling abort" because the cq has // its unsafe to do a "watch" after "channel polling abort" because the cq has
// been shut down. // been shut down.
if (abort_channel_polling) { if (abort_channel_polling || stack->bg_wrapped->channel_destroyed) {
gpr_mu_unlock(&global_connection_polling_mu); gpr_mu_unlock(&global_connection_polling_mu);
return (void*)0; return (void*)0;
} }
op = gpr_zalloc(sizeof(watch_state_op)); op = gpr_zalloc(sizeof(watch_state_op));
op->op_type = WATCH_STATE_API; op->op_type = WATCH_STATE_API;
grpc_channel_watch_connectivity_state(stack->channel, stack->last_state, grpc_channel_watch_connectivity_state(stack->bg_wrapped->channel,
stack->deadline, channel_polling_cq, stack->last_state, stack->deadline,
op); channel_polling_cq, op);
while (!op->op.api_callback_args.called_back) { while (!op->op.api_callback_args.called_back) {
gpr_cv_wait(&global_connection_polling_cv, &global_connection_polling_mu, gpr_cv_wait(&global_connection_polling_cv, &global_connection_polling_mu,
@ -388,7 +388,7 @@ static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self,
return Qnil; return Qnil;
} }
stack.channel = wrapper->bg_wrapped->channel; stack.bg_wrapped = wrapper->bg_wrapped;
stack.deadline = grpc_rb_time_timeval(deadline, 0), stack.deadline = grpc_rb_time_timeval(deadline, 0),
stack.last_state = NUM2LONG(last_state); stack.last_state = NUM2LONG(last_state);

@ -124,12 +124,18 @@ module GRPC
def read_using_run_batch def read_using_run_batch
ops = { RECV_MESSAGE => nil } ops = { RECV_MESSAGE => nil }
ops[RECV_INITIAL_METADATA] = nil unless @metadata_received ops[RECV_INITIAL_METADATA] = nil unless @metadata_received
begin
batch_result = @call.run_batch(ops) batch_result = @call.run_batch(ops)
unless @metadata_received unless @metadata_received
@call.metadata = batch_result.metadata @call.metadata = batch_result.metadata
@metadata_received = true @metadata_received = true
end end
batch_result batch_result
rescue GRPC::Core::CallError => e
GRPC.logger.warn('bidi call: read_using_run_batch failed')
GRPC.logger.warn(e)
nil
end
end end
# set_output_stream_done is relevant on client-side # set_output_stream_done is relevant on client-side
@ -155,7 +161,12 @@ module GRPC
GRPC.logger.debug("bidi-write-loop: #{count} writes done") GRPC.logger.debug("bidi-write-loop: #{count} writes done")
if is_client if is_client
GRPC.logger.debug("bidi-write-loop: client sent #{count}, waiting") GRPC.logger.debug("bidi-write-loop: client sent #{count}, waiting")
begin
@call.run_batch(SEND_CLOSE_FROM_CLIENT => nil) @call.run_batch(SEND_CLOSE_FROM_CLIENT => nil)
rescue GRPC::Core::CallError => e
GRPC.logger.warn('bidi-write-loop: send close failed')
GRPC.logger.warn(e)
end
GRPC.logger.debug('bidi-write-loop: done') GRPC.logger.debug('bidi-write-loop: done')
end end
GRPC.logger.debug('bidi-write-loop: finished') GRPC.logger.debug('bidi-write-loop: finished')
@ -187,7 +198,7 @@ module GRPC
batch_result = read_using_run_batch batch_result = read_using_run_batch
# handle the next message # handle the next message
if batch_result.message.nil? if batch_result.nil? || batch_result.message.nil?
GRPC.logger.debug("bidi-read-loop: null batch #{batch_result}") GRPC.logger.debug("bidi-read-loop: null batch #{batch_result}")
if is_client if is_client

@ -14,5 +14,5 @@
# GRPC contains the General RPC module. # GRPC contains the General RPC module.
module GRPC module GRPC
VERSION = '1.11.0.dev' VERSION = '1.12.0.dev'
end end

@ -750,6 +750,90 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
expected_error_message) expected_error_message)
end end
end end
# Prompted by grpc/github #14853
describe 'client-side error handling on bidi streams' do
class EnumeratorQueue
def initialize(queue)
@queue = queue
end
def each
loop do
msg = @queue.pop
break if msg.nil?
yield msg
end
end
end
def run_server_bidi_shutdown_after_one_read
@server.start
recvd_rpc = @server.request_call
recvd_call = recvd_rpc.call
server_call = GRPC::ActiveCall.new(
recvd_call, noop, noop, INFINITE_FUTURE,
metadata_received: true, started: false)
expect(server_call.remote_read).to eq('first message')
@server.shutdown_and_notify(from_relative_time(0))
@server.close
end
it 'receives a grpc status code when writes to a bidi stream fail' do
# This test tries to trigger the case when a 'SEND_MESSAGE' op
# and subseqeunt 'SEND_CLOSE_FROM_CLIENT' op of a bidi stream fails.
# In this case, iteration through the response stream should result
# in a grpc status code, and the writer thread should not raise an
# exception.
server_thread = Thread.new do
run_server_bidi_shutdown_after_one_read
end
stub = GRPC::ClientStub.new(@host, :this_channel_is_insecure)
request_queue = Queue.new
@sent_msgs = EnumeratorQueue.new(request_queue)
responses = get_responses(stub)
request_queue.push('first message')
# Now wait for the server to shut down.
server_thread.join
# Sanity check. This test is not interesting if
# Thread.abort_on_exception is not set.
expect(Thread.abort_on_exception).to be(true)
# An attempt to send a second message should fail now that the
# server is down.
request_queue.push('second message')
request_queue.push(nil)
expect { responses.next }.to raise_error(GRPC::BadStatus)
end
def run_server_bidi_shutdown_after_one_write
@server.start
recvd_rpc = @server.request_call
recvd_call = recvd_rpc.call
server_call = GRPC::ActiveCall.new(
recvd_call, noop, noop, INFINITE_FUTURE,
metadata_received: true, started: false)
server_call.send_initial_metadata
server_call.remote_send('message')
@server.shutdown_and_notify(from_relative_time(0))
@server.close
end
it 'receives a grpc status code when reading from a failed bidi call' do
server_thread = Thread.new do
run_server_bidi_shutdown_after_one_write
end
stub = GRPC::ClientStub.new(@host, :this_channel_is_insecure)
request_queue = Queue.new
@sent_msgs = EnumeratorQueue.new(request_queue)
responses = get_responses(stub)
expect(responses.next).to eq('message')
# Wait for the server to shut down
server_thread.join
expect { responses.next }.to raise_error(GRPC::BadStatus)
# Push a sentinel to allow the writer thread to finish
request_queue.push(nil)
end
end
end end
describe 'without a call operation' do describe 'without a call operation' do
@ -810,6 +894,55 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
responses.each { |r| p r } responses.each { |r| p r }
end end
end end
def run_server_bidi_expect_client_to_cancel(wait_for_shutdown_ok_callback)
@server.start
recvd_rpc = @server.request_call
recvd_call = recvd_rpc.call
server_call = GRPC::ActiveCall.new(
recvd_call, noop, noop, INFINITE_FUTURE,
metadata_received: true, started: false)
server_call.send_initial_metadata
server_call.remote_send('server call received')
wait_for_shutdown_ok_callback.call
# since the client is cancelling the call,
# we should be able to shut down cleanly
@server.shutdown_and_notify(nil)
@server.close
end
it 'receives a grpc status code when reading from a cancelled bidi call' do
# This test tries to trigger a 'RECV_INITIAL_METADATA' and/or
# 'RECV_MESSAGE' op failure.
# An attempt to read a message might fail; in that case, iteration
# through the response stream should still result in a grpc status.
server_can_shutdown = false
server_can_shutdown_mu = Mutex.new
server_can_shutdown_cv = ConditionVariable.new
wait_for_shutdown_ok_callback = proc do
server_can_shutdown_mu.synchronize do
server_can_shutdown_cv.wait(server_can_shutdown_mu) until server_can_shutdown
end
end
server_thread = Thread.new do
run_server_bidi_expect_client_to_cancel(wait_for_shutdown_ok_callback)
end
stub = GRPC::ClientStub.new(@host, :this_channel_is_insecure)
request_queue = Queue.new
@sent_msgs = EnumeratorQueue.new(request_queue)
responses = get_responses(stub)
expect(responses.next).to eq('server call received')
@op.cancel
expect { responses.next }.to raise_error(GRPC::Cancelled)
# Now let the server proceed to shut down.
server_can_shutdown_mu.synchronize do
server_can_shutdown = true
server_can_shutdown_cv.broadcast
end
server_thread.join
# Push a sentinel to allow the writer thread to finish
request_queue.push(nil)
end
end end
end end

@ -15,16 +15,13 @@
require 'open3' require 'open3'
require 'tmpdir' require 'tmpdir'
def debug_mode?
!ENV['CONFIG'].nil? && ENV['CONFIG'] == 'dbg'
end
describe 'Package with underscore protobuf code generation' do describe 'Package with underscore protobuf code generation' do
it 'should have the same content as created by code generation' do it 'should have the same content as created by code generation' do
root_dir = File.join(File.dirname(__FILE__), '..', '..', '..', '..', '..') root_dir = File.join(File.dirname(__FILE__), '..', '..', '..', '..', '..')
pb_dir = File.join(root_dir, 'src', 'ruby', 'spec', 'pb') pb_dir = File.join(root_dir, 'src', 'ruby', 'spec', 'pb')
bins_sub_dir = debug_mode? ? 'dbg' : 'opt' fail 'CONFIG env variable unexpectedly unset' unless ENV['CONFIG']
bins_sub_dir = ENV['CONFIG']
bins_dir = File.join(root_dir, 'bins', bins_sub_dir) bins_dir = File.join(root_dir, 'bins', bins_sub_dir)
plugin = File.join(bins_dir, 'grpc_ruby_plugin') plugin = File.join(bins_dir, 'grpc_ruby_plugin')

@ -14,6 +14,6 @@
module GRPC module GRPC
module Tools module Tools
VERSION = '1.11.0.dev' VERSION = '1.12.0.dev'
end end
end end

@ -23,11 +23,13 @@
EXTENSION("grpc", grpc_source, null, EXTENSION("grpc", grpc_source, null,
"/DOPENSSL_NO_ASM /D_GNU_SOURCE /DWIN32_LEAN_AND_MEAN "+ "/DOPENSSL_NO_ASM /D_GNU_SOURCE /DWIN32_LEAN_AND_MEAN "+
"/D_HAS_EXCEPTIONS=0 /DNOMINMAX /DGRPC_ARES=0 /D_WIN32_WINNT=0x600 "+ "/D_HAS_EXCEPTIONS=0 /DNOMINMAX /DGRPC_ARES=0 /D_WIN32_WINNT=0x600 "+
"/DPB_FIELD_16BIT "+
"/I"+configure_module_dirname+" "+ "/I"+configure_module_dirname+" "+
"/I"+configure_module_dirname+"\\include "+ "/I"+configure_module_dirname+"\\include "+
"/I"+configure_module_dirname+"\\src\\php\\ext\\grpc "+ "/I"+configure_module_dirname+"\\src\\php\\ext\\grpc "+
"/I"+configure_module_dirname+"\\third_party\\boringssl\\include "+ "/I"+configure_module_dirname+"\\third_party\\boringssl\\include "+
"/I"+configure_module_dirname+"\\third_party\\zlib"); "/I"+configure_module_dirname+"\\third_party\\zlib "+
"/I"+configure_module_dirname+"\\third_party\\address_sorting\\include");
<% <%
dirs = {} dirs = {}
for lib in libs: for lib in libs:

@ -36,7 +36,8 @@ if [[ "$GRPC_DNS_RESOLVER" != "" && "$GRPC_DNS_RESOLVER" != ares ]]; then
fi fi
export GRPC_DNS_RESOLVER=ares export GRPC_DNS_RESOLVER=ares
"$FLAGS_dns_server_bin_path" --records_config_path="$FLAGS_records_config_path" --port="$FLAGS_dns_server_port" > /dev/null 2>&1 & DNS_SERVER_LOG="$(mktemp)"
"$FLAGS_dns_server_bin_path" --records_config_path="$FLAGS_records_config_path" --port="$FLAGS_dns_server_port" > "$DNS_SERVER_LOG" 2>&1 &
DNS_SERVER_PID=$! DNS_SERVER_PID=$!
echo "Local DNS server started. PID: $DNS_SERVER_PID" echo "Local DNS server started. PID: $DNS_SERVER_PID"
@ -55,8 +56,11 @@ done
if [[ $RETRY == 1 ]]; then if [[ $RETRY == 1 ]]; then
echo "FAILED TO START LOCAL DNS SERVER" echo "FAILED TO START LOCAL DNS SERVER"
kill -SIGTERM "$DNS_SERVER_PID" kill -SIGTERM "$DNS_SERVER_PID" || true
wait wait
echo "========== DNS server log (merged stdout and stderr) ========="
cat "$DNS_SERVER_LOG"
echo "========== end DNS server log ================================"
exit 1 exit 1
fi fi

@ -1,80 +0,0 @@
%YAML 1.2
--- |
# Copyright 2017 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM debian:jessie
# Install JDK 8 and Git
RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && ${'\\'}
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list && ${'\\'}
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && ${'\\'}
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
RUN apt-get update && apt-get -y install ${'\\'}
git ${'\\'}
libapr1 ${'\\'}
oracle-java8-installer ${'\\'}
&& ${'\\'}
apt-get clean && rm -r /var/cache/oracle-jdk8-installer/
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
ENV PATH $PATH:$JAVA_HOME/bin
# Install protobuf
RUN apt-get update && apt-get install -y ${'\\'}
autoconf ${'\\'}
build-essential ${'\\'}
curl ${'\\'}
gcc ${'\\'}
libtool ${'\\'}
unzip ${'\\'}
&& ${'\\'}
apt-get clean
WORKDIR /
RUN git clone https://github.com/google/protobuf.git
WORKDIR /protobuf
RUN git checkout v3.3.1 && ${'\\'}
./autogen.sh && ${'\\'}
./configure && ${'\\'}
make && ${'\\'}
make check && ${'\\'}
make install
# Install gcloud command line tools
ENV CLOUD_SDK_REPO "cloud-sdk-jessie"
RUN echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && ${'\\'}
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && ${'\\'}
apt-get update && apt-get install -y google-cloud-sdk && apt-get clean && ${'\\'}
gcloud config set component_manager/disable_update_check true
# Install Android SDK
WORKDIR /
RUN mkdir android-sdk
WORKDIR android-sdk
RUN wget -q https://dl.google.com/android/repository/tools_r25.2.5-linux.zip && ${'\\'}
unzip -qq tools_r25.2.5-linux.zip && ${'\\'}
rm tools_r25.2.5-linux.zip && ${'\\'}
echo y | tools/bin/sdkmanager "platforms;android-22" && ${'\\'}
echo y | tools/bin/sdkmanager "build-tools;25.0.2" && ${'\\'}
echo y | tools/bin/sdkmanager "extras;android;m2repository" && ${'\\'}
echo y | tools/bin/sdkmanager "extras;google;google_play_services" && ${'\\'}
echo y | tools/bin/sdkmanager "extras;google;m2repository" && ${'\\'}
echo y | tools/bin/sdkmanager "patcher;v4" && ${'\\'}
echo y | tools/bin/sdkmanager "platform-tools"
ENV ANDROID_HOME "/android-sdk"
# Reset the working directory
WORKDIR /
# Define the default command.
CMD ["bash"]

@ -9,6 +9,6 @@ RUN apt-get update && apt-get install -y ${'\\'}
python-pip python-pip
# Install Python packages from PyPI # Install Python packages from PyPI
RUN pip install --upgrade pip==9.0.1 RUN pip install --upgrade pip==9.0.2
RUN pip install virtualenv RUN pip install virtualenv
RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0 RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0

@ -34,12 +34,13 @@
strace ${'\\'} strace ${'\\'}
python-dev ${'\\'} python-dev ${'\\'}
py-pip ${'\\'} py-pip ${'\\'}
py-yaml ${'\\'}
unzip ${'\\'} unzip ${'\\'}
wget ${'\\'} wget ${'\\'}
zip zip
# Install Python packages from PyPI # Install Python packages from PyPI
RUN pip install --upgrade pip==9.0.1 RUN pip install --upgrade pip==9.0.2
RUN pip install virtualenv RUN pip install virtualenv
RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0 RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0

@ -33,6 +33,7 @@ TEST(InlinedVectorTest, CreateAndIterate) {
EXPECT_EQ(static_cast<size_t>(kNumElements), v.size()); EXPECT_EQ(static_cast<size_t>(kNumElements), v.size());
for (int i = 0; i < kNumElements; ++i) { for (int i = 0; i < kNumElements; ++i) {
EXPECT_EQ(i, v[i]); EXPECT_EQ(i, v[i]);
EXPECT_EQ(i, &v[i] - &v[0]); // Ensure contiguous allocation.
} }
} }

@ -37,6 +37,8 @@ void test_unparsable_target(void) {
grpc_server_destroy(server); grpc_server_destroy(server);
} }
// GRPC_ARG_ALLOW_REUSEPORT isn't supported for custom servers
#ifndef GRPC_UV
void test_add_same_port_twice() { void test_add_same_port_twice() {
grpc_arg a; grpc_arg a;
a.type = GRPC_ARG_INTEGER; a.type = GRPC_ARG_INTEGER;
@ -62,12 +64,15 @@ void test_add_same_port_twice() {
grpc_server_destroy(server); grpc_server_destroy(server);
grpc_completion_queue_destroy(cq); grpc_completion_queue_destroy(cq);
} }
#endif
int main(int argc, char** argv) { int main(int argc, char** argv) {
grpc_test_init(argc, argv); grpc_test_init(argc, argv);
grpc_init(); grpc_init();
test_unparsable_target(); test_unparsable_target();
#ifndef GRPC_UV
test_add_same_port_twice(); test_add_same_port_twice();
#endif
grpc_shutdown(); grpc_shutdown();
return 0; return 0;
} }

@ -69,6 +69,8 @@ void test_request_call_on_no_server_cq(void) {
grpc_server_destroy(server); grpc_server_destroy(server);
} }
// GRPC_ARG_ALLOW_REUSEPORT isn't supported for custom servers
#ifndef GRPC_UV
void test_bind_server_twice(void) { void test_bind_server_twice(void) {
grpc_arg a; grpc_arg a;
a.type = GRPC_ARG_INTEGER; a.type = GRPC_ARG_INTEGER;
@ -100,6 +102,7 @@ void test_bind_server_twice(void) {
grpc_completion_queue_destroy(cq); grpc_completion_queue_destroy(cq);
gpr_free(addr); gpr_free(addr);
} }
#endif
void test_bind_server_to_addr(const char* host, bool secure) { void test_bind_server_to_addr(const char* host, bool secure) {
int port = grpc_pick_unused_port_or_die(); int port = grpc_pick_unused_port_or_die();
@ -149,7 +152,9 @@ int main(int argc, char** argv) {
grpc_init(); grpc_init();
test_register_method_fail(); test_register_method_fail();
test_request_call_on_no_server_cq(); test_request_call_on_no_server_cq();
#ifndef GRPC_UV
test_bind_server_twice(); test_bind_server_twice();
#endif
static const char* addrs[] = { static const char* addrs[] = {
"::1", "127.0.0.1", "::ffff:127.0.0.1", "localhost", "0.0.0.0", "::", "::1", "127.0.0.1", "::ffff:127.0.0.1", "localhost", "0.0.0.0", "::",

@ -20,6 +20,7 @@
#include <dirent.h> #include <dirent.h>
#include <gflags/gflags.h> #include <gflags/gflags.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <stdio.h> #include <stdio.h>
@ -91,6 +92,7 @@ class ExampleGenerator
perror("Couldn't open the directory"); perror("Couldn't open the directory");
abort(); abort();
} }
gpr_free(test_srcdir);
} }
} }
} }

@ -24,32 +24,43 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
namespace grpc { namespace grpc {
namespace internal { namespace internal {
// Provide access to GrpcBufferWriter internals. // Provide access to GrpcProtoBufferWriter internals.
class GrpcBufferWriterPeer { class GrpcProtoBufferWriterPeer {
public: public:
explicit GrpcBufferWriterPeer(internal::GrpcBufferWriter* writer) explicit GrpcProtoBufferWriterPeer(GrpcProtoBufferWriter* writer)
: writer_(writer) {} : writer_(writer) {}
bool have_backup() const { return writer_->have_backup_; } bool have_backup() const { return writer_->have_backup_; }
const grpc_slice& backup_slice() const { return writer_->backup_slice_; } const grpc_slice& backup_slice() const { return writer_->backup_slice_; }
const grpc_slice& slice() const { return writer_->slice_; } const grpc_slice& slice() const { return writer_->slice_; }
private: private:
GrpcBufferWriter* writer_; GrpcProtoBufferWriter* writer_;
};
// Provide access to ByteBuffer internals.
class GrpcByteBufferPeer {
public:
explicit GrpcByteBufferPeer(ByteBuffer* bb) : bb_(bb) {}
grpc_byte_buffer* c_buffer() { return bb_->c_buffer(); }
private:
ByteBuffer* bb_;
}; };
class ProtoUtilsTest : public ::testing::Test {}; class ProtoUtilsTest : public ::testing::Test {};
// Regression test for a memory corruption bug where a series of // Regression test for a memory corruption bug where a series of
// GrpcBufferWriter Next()/Backup() invocations could result in a dangling // GrpcProtoBufferWriter Next()/Backup() invocations could result in a dangling
// pointer returned by Next() due to the interaction between grpc_slice inlining // pointer returned by Next() due to the interaction between grpc_slice inlining
// and GRPC_SLICE_START_PTR. // and GRPC_SLICE_START_PTR.
TEST_F(ProtoUtilsTest, TinyBackupThenNext) { TEST_F(ProtoUtilsTest, TinyBackupThenNext) {
grpc_byte_buffer* bp; ByteBuffer bp;
const int block_size = 1024; const int block_size = 1024;
GrpcBufferWriter writer(&bp, block_size, 8192); GrpcProtoBufferWriter writer(&bp, block_size, 8192);
GrpcBufferWriterPeer peer(&writer); GrpcProtoBufferWriterPeer peer(&writer);
void* data; void* data;
int size; int size;
@ -63,17 +74,14 @@ TEST_F(ProtoUtilsTest, TinyBackupThenNext) {
ASSERT_TRUE(writer.Next(&data, &size)); ASSERT_TRUE(writer.Next(&data, &size));
EXPECT_TRUE(peer.slice().refcount != nullptr); EXPECT_TRUE(peer.slice().refcount != nullptr);
EXPECT_EQ(block_size, size); EXPECT_EQ(block_size, size);
// Cleanup.
g_core_codegen_interface->grpc_byte_buffer_destroy(bp);
} }
namespace { namespace {
// Set backup_size to 0 to indicate no backup is needed. // Set backup_size to 0 to indicate no backup is needed.
void BufferWriterTest(int block_size, int total_size, int backup_size) { void BufferWriterTest(int block_size, int total_size, int backup_size) {
grpc_byte_buffer* bp; ByteBuffer bb;
GrpcBufferWriter writer(&bp, block_size, total_size); GrpcProtoBufferWriter writer(&bb, block_size, total_size);
int written_size = 0; int written_size = 0;
void* data; void* data;
@ -110,10 +118,11 @@ void BufferWriterTest(int block_size, int total_size, int backup_size) {
writer.BackUp(backup_size); writer.BackUp(backup_size);
} }
} }
EXPECT_EQ(grpc_byte_buffer_length(bp), (size_t)total_size); EXPECT_EQ(bb.Length(), (size_t)total_size);
grpc_byte_buffer_reader reader; grpc_byte_buffer_reader reader;
grpc_byte_buffer_reader_init(&reader, bp); GrpcByteBufferPeer peer(&bb);
grpc_byte_buffer_reader_init(&reader, peer.c_buffer());
int read_bytes = 0; int read_bytes = 0;
while (read_bytes < total_size) { while (read_bytes < total_size) {
grpc_slice s; grpc_slice s;
@ -126,7 +135,6 @@ void BufferWriterTest(int block_size, int total_size, int backup_size) {
} }
EXPECT_EQ(read_bytes, total_size); EXPECT_EQ(read_bytes, total_size);
grpc_byte_buffer_reader_destroy(&reader); grpc_byte_buffer_reader_destroy(&reader);
grpc_byte_buffer_destroy(bp);
} }
TEST(WriterTest, TinyBlockTinyBackup) { TEST(WriterTest, TinyBlockTinyBackup) {
@ -154,7 +162,7 @@ TEST(WriterTest, LargeBlockLargeBackup) { BufferWriterTest(4096, 8192, 4095); }
} // namespace grpc } // namespace grpc
int main(int argc, char** argv) { int main(int argc, char** argv) {
// Ensure the GrpcBufferWriter internals are initialized. // Ensure the GrpcProtoBufferWriter internals are initialized.
grpc::internal::GrpcLibraryInitializer init; grpc::internal::GrpcLibraryInitializer init;
init.summon(); init.summon();
grpc::GrpcLibraryCodegen lib; grpc::GrpcLibraryCodegen lib;

@ -36,7 +36,8 @@ if [[ "$GRPC_DNS_RESOLVER" != "" && "$GRPC_DNS_RESOLVER" != ares ]]; then
fi fi
export GRPC_DNS_RESOLVER=ares export GRPC_DNS_RESOLVER=ares
"$FLAGS_dns_server_bin_path" --records_config_path="$FLAGS_records_config_path" --port="$FLAGS_dns_server_port" > /dev/null 2>&1 & DNS_SERVER_LOG="$(mktemp)"
"$FLAGS_dns_server_bin_path" --records_config_path="$FLAGS_records_config_path" --port="$FLAGS_dns_server_port" > "$DNS_SERVER_LOG" 2>&1 &
DNS_SERVER_PID=$! DNS_SERVER_PID=$!
echo "Local DNS server started. PID: $DNS_SERVER_PID" echo "Local DNS server started. PID: $DNS_SERVER_PID"
@ -55,8 +56,11 @@ done
if [[ $RETRY == 1 ]]; then if [[ $RETRY == 1 ]]; then
echo "FAILED TO START LOCAL DNS SERVER" echo "FAILED TO START LOCAL DNS SERVER"
kill -SIGTERM "$DNS_SERVER_PID" kill -SIGTERM "$DNS_SERVER_PID" || true
wait wait
echo "========== DNS server log (merged stdout and stderr) ========="
cat "$DNS_SERVER_LOG"
echo "========== end DNS server log ================================"
exit 1 exit 1
fi fi

@ -165,9 +165,9 @@ int main(int argc, char** argv) {
GPR_ASSERT(FLAGS_grpc_test_directory_relative_to_test_srcdir != ""); GPR_ASSERT(FLAGS_grpc_test_directory_relative_to_test_srcdir != "");
// Use bazel's TEST_SRCDIR environment variable to locate the "test data" // Use bazel's TEST_SRCDIR environment variable to locate the "test data"
// binaries. // binaries.
char* test_srcdir = gpr_getenv("TEST_SRCDIR");
std::string const bin_dir = std::string const bin_dir =
gpr_getenv("TEST_SRCDIR") + test_srcdir + FLAGS_grpc_test_directory_relative_to_test_srcdir +
FLAGS_grpc_test_directory_relative_to_test_srcdir +
std::string("/test/cpp/naming"); std::string("/test/cpp/naming");
// Invoke bazel's executeable links to the .sh and .py scripts (don't use // Invoke bazel's executeable links to the .sh and .py scripts (don't use
// the .sh and .py suffixes) to make // the .sh and .py suffixes) to make
@ -177,6 +177,7 @@ int main(int argc, char** argv) {
bin_dir + "/" + FLAGS_test_bin_name, bin_dir + "/utils/dns_server", bin_dir + "/" + FLAGS_test_bin_name, bin_dir + "/utils/dns_server",
bin_dir + "/resolver_test_record_groups.yaml", bin_dir + "/resolver_test_record_groups.yaml",
bin_dir + "/utils/dns_resolver", bin_dir + "/utils/tcp_connect"); bin_dir + "/utils/dns_resolver", bin_dir + "/utils/tcp_connect");
gpr_free(test_srcdir);
} else { } else {
// Get the current binary's directory relative to repo root to invoke the // Get the current binary's directory relative to repo root to invoke the
// correct build config (asan/tsan/dbg, etc.). // correct build config (asan/tsan/dbg, etc.).

@ -39,7 +39,10 @@ grpc::string MakePort() {
return s.str(); return s.str();
} }
grpc::string g_port = MakePort(); const grpc::string& GetPort() {
static grpc::string g_port = MakePort();
return g_port;
}
TEST(ServerBuilderTest, NoOp) { ServerBuilder b; } TEST(ServerBuilderTest, NoOp) { ServerBuilder b; }
@ -50,7 +53,7 @@ TEST(ServerBuilderTest, CreateServerNoPorts) {
TEST(ServerBuilderTest, CreateServerOnePort) { TEST(ServerBuilderTest, CreateServerOnePort) {
ServerBuilder() ServerBuilder()
.RegisterService(&g_service) .RegisterService(&g_service)
.AddListeningPort(g_port, InsecureServerCredentials()) .AddListeningPort(GetPort(), InsecureServerCredentials())
.BuildAndStart() .BuildAndStart()
->Shutdown(); ->Shutdown();
} }
@ -58,8 +61,8 @@ TEST(ServerBuilderTest, CreateServerOnePort) {
TEST(ServerBuilderTest, CreateServerRepeatedPort) { TEST(ServerBuilderTest, CreateServerRepeatedPort) {
ServerBuilder() ServerBuilder()
.RegisterService(&g_service) .RegisterService(&g_service)
.AddListeningPort(g_port, InsecureServerCredentials()) .AddListeningPort(GetPort(), InsecureServerCredentials())
.AddListeningPort(g_port, InsecureServerCredentials()) .AddListeningPort(GetPort(), InsecureServerCredentials())
.BuildAndStart() .BuildAndStart()
->Shutdown(); ->Shutdown();
} }
@ -67,8 +70,8 @@ TEST(ServerBuilderTest, CreateServerRepeatedPort) {
TEST(ServerBuilderTest, CreateServerRepeatedPortWithDisallowedReusePort) { TEST(ServerBuilderTest, CreateServerRepeatedPortWithDisallowedReusePort) {
EXPECT_EQ(ServerBuilder() EXPECT_EQ(ServerBuilder()
.RegisterService(&g_service) .RegisterService(&g_service)
.AddListeningPort(g_port, InsecureServerCredentials()) .AddListeningPort(GetPort(), InsecureServerCredentials())
.AddListeningPort(g_port, InsecureServerCredentials()) .AddListeningPort(GetPort(), InsecureServerCredentials())
.AddChannelArgument(GRPC_ARG_ALLOW_REUSEPORT, 0) .AddChannelArgument(GRPC_ARG_ALLOW_REUSEPORT, 0)
.BuildAndStart(), .BuildAndStart(),
nullptr); nullptr);

@ -112,7 +112,7 @@ grpc_cc_library(
], ],
deps = [ deps = [
"//:grpc++_unsecure", "//:grpc++_unsecure",
"//test/core/util:grpc_test_util", "//test/core/util:grpc_test_util_unsecure",
], ],
) )

@ -16,7 +16,8 @@
* *
*/ */
#include <grpcpp/support/byte_buffer.h> #include <grpc++/support/byte_buffer.h>
#include <grpcpp/impl/grpc_library.h>
#include <cstring> #include <cstring>
#include <vector> #include <vector>
@ -27,6 +28,9 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
namespace grpc { namespace grpc {
static internal::GrpcLibraryInitializer g_gli_initializer;
namespace { namespace {
const char* kContent1 = "hello xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; const char* kContent1 = "hello xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

@ -22,6 +22,7 @@
#include <gflags/gflags.h> #include <gflags/gflags.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpcpp/channel.h> #include <grpcpp/channel.h>
#include <grpcpp/client_context.h> #include <grpcpp/client_context.h>
#include <grpcpp/create_channel.h> #include <grpcpp/create_channel.h>
@ -738,6 +739,8 @@ TEST_F(GrpcToolTest, CallCommandWithBadMetadata) {
FLAGS_metadata = ""; FLAGS_metadata = "";
FLAGS_protofiles = ""; FLAGS_protofiles = "";
gpr_free(test_srcdir);
} }
} // namespace testing } // namespace testing

@ -16,13 +16,17 @@
* *
*/ */
#include <grpcpp/support/slice.h> #include <grpc++/support/slice.h>
#include <grpcpp/impl/grpc_library.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/slice.h> #include <grpc/slice.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
namespace grpc { namespace grpc {
static internal::GrpcLibraryInitializer g_gli_initializer;
namespace { namespace {
const char* kContent = "hello xxxxxxxxxxxxxxxxxxxx world"; const char* kContent = "hello xxxxxxxxxxxxxxxxxxxx world";

@ -23,9 +23,9 @@ curl https://raw.githubusercontent.com/rake-compiler/rake-compiler/v1.0.3/tasks/
# See https://github.com/grpc/grpc/issues/12161 for verconf.h patch details # See https://github.com/grpc/grpc/issues/12161 for verconf.h patch details
patch "$CROSS_RUBY" << EOF patch "$CROSS_RUBY" << EOF
--- cross-ruby.rake 2017-09-27 16:46:00.311020325 +0200 --- cross-ruby.rake 2018-04-10 11:32:16.000000000 -0700
+++ patched 2017-09-27 16:49:46.127016895 +0200 +++ patched 2018-04-10 11:40:25.000000000 -0700
@@ -133,7 +133,8 @@ @@ -133,8 +133,10 @@
"--host=#{MINGW_HOST}", "--host=#{MINGW_HOST}",
"--target=#{MINGW_TARGET}", "--target=#{MINGW_TARGET}",
"--build=#{RUBY_BUILD}", "--build=#{RUBY_BUILD}",
@ -33,9 +33,11 @@ patch "$CROSS_RUBY" << EOF
+ '--enable-static', + '--enable-static',
+ '--disable-shared', + '--disable-shared',
'--disable-install-doc', '--disable-install-doc',
+ '--without-gmp',
'--with-ext=' '--with-ext='
] ]
@@ -151,6 +152,7 @@
@@ -151,6 +153,7 @@
# make # make
file "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/ruby.exe" => ["#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/Makefile"] do |t| file "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/ruby.exe" => ["#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/Makefile"] do |t|
chdir File.dirname(t.prerequisites.first) do chdir File.dirname(t.prerequisites.first) do

@ -29,7 +29,7 @@ VIRTUALENV=python_pylint_venv
virtualenv $VIRTUALENV virtualenv $VIRTUALENV
PYTHON=$(realpath $VIRTUALENV/bin/python) PYTHON=$(realpath $VIRTUALENV/bin/python)
$PYTHON -m pip install --upgrade pip==9.0.1 $PYTHON -m pip install --upgrade pip==9.0.2
$PYTHON -m pip install pylint==1.6.5 $PYTHON -m pip install pylint==1.6.5
for dir in "${DIRS[@]}"; do for dir in "${DIRS[@]}"; do

@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!!
VERSION = '1.11.0.dev0' VERSION = '1.12.0.dev0'

@ -32,7 +32,7 @@ VIRTUALENV=yapf_virtual_environment
virtualenv $VIRTUALENV virtualenv $VIRTUALENV
PYTHON=$(realpath "${VIRTUALENV}/bin/python") PYTHON=$(realpath "${VIRTUALENV}/bin/python")
$PYTHON -m pip install --upgrade pip==9.0.1 $PYTHON -m pip install --upgrade pip==9.0.2
$PYTHON -m pip install --upgrade futures $PYTHON -m pip install --upgrade futures
$PYTHON -m pip install yapf==0.20.0 $PYTHON -m pip install yapf==0.20.0

@ -33,7 +33,7 @@ RUN apt-get update && apt-get install -y \
python-pip python-pip
# Install Python packages from PyPI # Install Python packages from PyPI
RUN pip install --upgrade pip==9.0.1 RUN pip install --upgrade pip==9.0.2
RUN pip install virtualenv RUN pip install virtualenv
RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0 RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0

@ -1,78 +0,0 @@
# Copyright 2017 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM debian:jessie
# Install JDK 8 and Git
RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list && \
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
RUN apt-get update && apt-get -y install \
git \
libapr1 \
oracle-java8-installer \
&& \
apt-get clean && rm -r /var/cache/oracle-jdk8-installer/
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
ENV PATH $PATH:$JAVA_HOME/bin
# Install protobuf
RUN apt-get update && apt-get install -y \
autoconf \
build-essential \
curl \
gcc \
libtool \
unzip \
&& \
apt-get clean
WORKDIR /
RUN git clone https://github.com/google/protobuf.git
WORKDIR /protobuf
RUN git checkout v3.3.1 && \
./autogen.sh && \
./configure && \
make && \
make check && \
make install
# Install gcloud command line tools
ENV CLOUD_SDK_REPO "cloud-sdk-jessie"
RUN echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
apt-get update && apt-get install -y google-cloud-sdk && apt-get clean && \
gcloud config set component_manager/disable_update_check true
# Install Android SDK
WORKDIR /
RUN mkdir android-sdk
WORKDIR android-sdk
RUN wget -q https://dl.google.com/android/repository/tools_r25.2.5-linux.zip && \
unzip -qq tools_r25.2.5-linux.zip && \
rm tools_r25.2.5-linux.zip && \
echo y | tools/bin/sdkmanager "platforms;android-22" && \
echo y | tools/bin/sdkmanager "build-tools;25.0.2" && \
echo y | tools/bin/sdkmanager "extras;android;m2repository" && \
echo y | tools/bin/sdkmanager "extras;google;google_play_services" && \
echo y | tools/bin/sdkmanager "extras;google;m2repository" && \
echo y | tools/bin/sdkmanager "patcher;v4" && \
echo y | tools/bin/sdkmanager "platform-tools"
ENV ANDROID_HOME "/android-sdk"
# Reset the working directory
WORKDIR /
# Define the default command.
CMD ["bash"]

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save