Merge branch 'master' into removrun

reviewable/pr20906/r2
Yash Tibrewal 6 years ago
commit fe88f14410
  1. 2
      .github/ISSUE_TEMPLATE/bug_report.md
  2. 2
      .github/ISSUE_TEMPLATE/cleanup_request.md
  3. 2
      .github/ISSUE_TEMPLATE/feature_request.md
  4. 2
      .github/pull_request_template.md
  5. 12
      BUILD
  6. 32
      BUILD.gn
  7. 14192
      CMakeLists.txt
  8. 2
      MAINTAINERS.md
  9. 610
      Makefile
  10. 23
      WORKSPACE
  11. 17
      bazel/custom_exec_properties.bzl
  12. 36
      bazel/cython_library.bzl
  13. 1
      bazel/generate_cc.bzl
  14. 30
      bazel/generate_objc.bzl
  15. 41
      bazel/grpc_build_system.bzl
  16. 14
      bazel/grpc_deps.bzl
  17. 1
      bazel/grpc_python_deps.bzl
  18. 3
      bazel/objc_grpc_library.bzl
  19. 2
      bazel/protobuf.bzl
  20. 19
      bazel/python_rules.bzl
  21. 18
      bazel/test/python_test_repo/BUILD
  22. 100
      build.yaml
  23. 2
      build_config.rb
  24. 7
      cmake/benchmark.cmake
  25. 6
      cmake/cares.cmake
  26. 11
      cmake/gRPCConfigVersion.cmake.in
  27. 6
      cmake/gflags.cmake
  28. 6
      cmake/msvc_static_runtime.cmake
  29. 6
      cmake/protobuf.cmake
  30. 8
      cmake/ssl.cmake
  31. 2
      cmake/upb.cmake
  32. 8
      cmake/zlib.cmake
  33. 12
      config.m4
  34. 12
      config.w32
  35. 8
      doc/core/grpc-polling-engines.md
  36. 2
      examples/BUILD
  37. 28
      examples/objective-c/BUILD
  38. 9
      examples/objective-c/helloworld/main.m
  39. 3
      examples/objective-c/helloworld_macos/main.m
  40. 10
      examples/objective-c/route_guide/ViewControllers.m
  41. 18
      examples/python/auth/BUILD.bazel
  42. 18
      examples/python/cancellation/BUILD.bazel
  43. 16
      examples/python/compression/BUILD.bazel
  44. 22
      examples/python/debug/BUILD.bazel
  45. 18
      examples/python/errors/BUILD.bazel
  46. 18
      examples/python/multiprocessing/BUILD
  47. 6
      examples/python/wait_for_ready/BUILD.bazel
  48. 11
      gRPC-C++.podspec
  49. 2
      gRPC-Core.podspec
  50. 12
      grpc.bzl
  51. 2
      grpc.def
  52. 29
      grpc.gemspec
  53. 56
      grpc.gyp
  54. 7
      include/grpc/impl/codegen/port_platform.h
  55. 16
      include/grpc/support/alloc.h
  56. 12
      include/grpcpp/impl/codegen/rpc_service_method.h
  57. 29
      package.xml
  58. 2
      src/compiler/BUILD
  59. 4
      src/core/ext/filters/client_channel/backend_metric.cc
  60. 110
      src/core/ext/filters/client_channel/client_channel.cc
  61. 14
      src/core/ext/filters/client_channel/client_channel_channelz.cc
  62. 6
      src/core/ext/filters/client_channel/client_channel_channelz.h
  63. 10
      src/core/ext/filters/client_channel/global_subchannel_pool.cc
  64. 7
      src/core/ext/filters/client_channel/health/health_check_client.cc
  65. 36
      src/core/ext/filters/client_channel/http_connect_handshaker.cc
  66. 4
      src/core/ext/filters/client_channel/http_proxy.cc
  67. 11
      src/core/ext/filters/client_channel/lb_policy.h
  68. 27
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
  69. 4
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc
  70. 6
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc
  71. 8
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h
  72. 2
      src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
  73. 2
      src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
  74. 2
      src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
  75. 8
      src/core/ext/filters/client_channel/lb_policy/subchannel_list.h
  76. 12
      src/core/ext/filters/client_channel/lb_policy/xds/cds.cc
  77. 45
      src/core/ext/filters/client_channel/lb_policy/xds/xds.cc
  78. 10
      src/core/ext/filters/client_channel/lb_policy_registry.cc
  79. 2
      src/core/ext/filters/client_channel/lb_policy_registry.h
  80. 6
      src/core/ext/filters/client_channel/local_subchannel_pool.cc
  81. 8
      src/core/ext/filters/client_channel/parse_address.cc
  82. 3
      src/core/ext/filters/client_channel/resolver.cc
  83. 4
      src/core/ext/filters/client_channel/resolver.h
  84. 5
      src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
  85. 8
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc
  86. 2
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h
  87. 23
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc
  88. 5
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
  89. 17
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc
  90. 61
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
  91. 4
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h
  92. 8
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc
  93. 3
      src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
  94. 18
      src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
  95. 7
      src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
  96. 2
      src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc
  97. 6
      src/core/ext/filters/client_channel/resolver_factory.h
  98. 24
      src/core/ext/filters/client_channel/resolver_registry.cc
  99. 9
      src/core/ext/filters/client_channel/resolver_registry.h
  100. 12
      src/core/ext/filters/client_channel/resolver_result_parsing.cc
  101. Some files were not shown because too many files have changed in this diff Show More

@ -2,7 +2,7 @@
name: Report a bug name: Report a bug
about: Create a report to help us improve about: Create a report to help us improve
labels: kind/bug, priority/P2 labels: kind/bug, priority/P2
assignees: sheenaqotj assignees: hcaseyal
--- ---

@ -2,7 +2,7 @@
name: Request a cleanup name: Request a cleanup
about: Suggest a cleanup in our repository about: Suggest a cleanup in our repository
labels: kind/internal cleanup, priority/P2 labels: kind/internal cleanup, priority/P2
assignees: sheenaqotj assignees: hcaseyal
--- ---

@ -2,7 +2,7 @@
name: Request a feature name: Request a feature
about: Suggest an idea for this project about: Suggest an idea for this project
labels: kind/enhancement, priority/P2 labels: kind/enhancement, priority/P2
assignees: sheenaqotj assignees: hcaseyal
--- ---

@ -8,4 +8,4 @@ If you know who should review your pull request, please remove the mentioning be
--> -->
@sheenaqotj @hcaseyal

12
BUILD

@ -69,12 +69,17 @@ config_setting(
values = {"cpu": "darwin"}, values = {"cpu": "darwin"},
) )
config_setting(
name = "grpc_use_absl",
values = {"define": "GRPC_USE_ABSL=1"},
)
python_config_settings() python_config_settings()
# This should be updated along with build.yaml # This should be updated along with build.yaml
g_stands_for = "gon" g_stands_for = "gon"
core_version = "7.0.0" core_version = "9.0.0"
version = "1.26.0-dev" version = "1.26.0-dev"
@ -318,9 +323,9 @@ grpc_cc_library(
standalone = True, standalone = True,
deps = [ deps = [
"grpc_common", "grpc_common",
"grpc_lb_policy_cds",
"grpc_lb_policy_grpclb", "grpc_lb_policy_grpclb",
"grpc_lb_policy_xds", "grpc_lb_policy_xds",
"grpc_lb_policy_cds",
"grpc_resolver_xds", "grpc_resolver_xds",
], ],
) )
@ -336,9 +341,9 @@ grpc_cc_library(
standalone = True, standalone = True,
deps = [ deps = [
"grpc_common", "grpc_common",
"grpc_lb_policy_cds_secure",
"grpc_lb_policy_grpclb_secure", "grpc_lb_policy_grpclb_secure",
"grpc_lb_policy_xds_secure", "grpc_lb_policy_xds_secure",
"grpc_lb_policy_cds_secure",
"grpc_resolver_xds_secure", "grpc_resolver_xds_secure",
"grpc_secure", "grpc_secure",
"grpc_transport_chttp2_client_secure", "grpc_transport_chttp2_client_secure",
@ -530,7 +535,6 @@ grpc_cc_library(
"src/core/lib/gprpp/map.h", "src/core/lib/gprpp/map.h",
"src/core/lib/gprpp/memory.h", "src/core/lib/gprpp/memory.h",
"src/core/lib/gprpp/mpscq.h", "src/core/lib/gprpp/mpscq.h",
"src/core/lib/gprpp/set.h",
"src/core/lib/gprpp/string_view.h", "src/core/lib/gprpp/string_view.h",
"src/core/lib/gprpp/sync.h", "src/core/lib/gprpp/sync.h",
"src/core/lib/gprpp/thd.h", "src/core/lib/gprpp/thd.h",

@ -149,7 +149,6 @@ config("grpc_config") {
"src/core/lib/gprpp/memory.h", "src/core/lib/gprpp/memory.h",
"src/core/lib/gprpp/mpscq.cc", "src/core/lib/gprpp/mpscq.cc",
"src/core/lib/gprpp/mpscq.h", "src/core/lib/gprpp/mpscq.h",
"src/core/lib/gprpp/set.h",
"src/core/lib/gprpp/sync.h", "src/core/lib/gprpp/sync.h",
"src/core/lib/gprpp/thd.h", "src/core/lib/gprpp/thd.h",
"src/core/lib/gprpp/thd_posix.cc", "src/core/lib/gprpp/thd_posix.cc",
@ -904,25 +903,12 @@ config("grpc_config") {
"src/core/tsi/transport_security_grpc.cc", "src/core/tsi/transport_security_grpc.cc",
"src/core/tsi/transport_security_grpc.h", "src/core/tsi/transport_security_grpc.h",
"src/core/tsi/transport_security_interface.h", "src/core/tsi/transport_security_interface.h",
"third_party/upb/upb/decode.c",
"third_party/upb/upb/decode.h",
"third_party/upb/upb/encode.c",
"third_party/upb/upb/encode.h",
"third_party/upb/upb/generated_util.h",
"third_party/upb/upb/msg.c",
"third_party/upb/upb/msg.h",
"third_party/upb/upb/port.c",
"third_party/upb/upb/port_def.inc",
"third_party/upb/upb/port_undef.inc",
"third_party/upb/upb/table.c",
"third_party/upb/upb/table.int.h",
"third_party/upb/upb/upb.c",
"third_party/upb/upb/upb.h",
] ]
deps = [ deps = [
"//third_party/boringssl", "//third_party/boringssl",
"//third_party/zlib", "//third_party/zlib",
":gpr", ":gpr",
":upb",
"//third_party/cares", "//third_party/cares",
":address_sorting", ":address_sorting",
] ]
@ -1263,7 +1249,6 @@ config("grpc_config") {
"src/core/lib/gprpp/orphanable.h", "src/core/lib/gprpp/orphanable.h",
"src/core/lib/gprpp/ref_counted.h", "src/core/lib/gprpp/ref_counted.h",
"src/core/lib/gprpp/ref_counted_ptr.h", "src/core/lib/gprpp/ref_counted_ptr.h",
"src/core/lib/gprpp/set.h",
"src/core/lib/gprpp/string_view.h", "src/core/lib/gprpp/string_view.h",
"src/core/lib/gprpp/sync.h", "src/core/lib/gprpp/sync.h",
"src/core/lib/gprpp/thd.h", "src/core/lib/gprpp/thd.h",
@ -1438,26 +1423,13 @@ config("grpc_config") {
"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",
"third_party/upb/upb/decode.c",
"third_party/upb/upb/decode.h",
"third_party/upb/upb/encode.c",
"third_party/upb/upb/encode.h",
"third_party/upb/upb/generated_util.h",
"third_party/upb/upb/msg.c",
"third_party/upb/upb/msg.h",
"third_party/upb/upb/port.c",
"third_party/upb/upb/port_def.inc",
"third_party/upb/upb/port_undef.inc",
"third_party/upb/upb/table.c",
"third_party/upb/upb/table.int.h",
"third_party/upb/upb/upb.c",
"third_party/upb/upb/upb.h",
] ]
deps = [ deps = [
"//third_party/boringssl", "//third_party/boringssl",
"//third_party/protobuf:protobuf_lite", "//third_party/protobuf:protobuf_lite",
":grpc", ":grpc",
":gpr", ":gpr",
":upb",
] ]
public_configs = [ public_configs = [

File diff suppressed because it is too large Load Diff

@ -18,6 +18,7 @@ for general contribution guidelines.
- [dfawley](https://github.com/dfawley), Google LLC - [dfawley](https://github.com/dfawley), Google LLC
- [dklempner](https://github.com/dklempner), Google LLC - [dklempner](https://github.com/dklempner), Google LLC
- [ejona86](https://github.com/ejona86), Google LLC - [ejona86](https://github.com/ejona86), Google LLC
- [ericgribkoff](https://github.com/ericgribkoff), Google LLC
- [gnossen](https://github.com/gnossen), Google LLC - [gnossen](https://github.com/gnossen), Google LLC
- [guantaol](https://github.com/guantaol), Google LLC - [guantaol](https://github.com/guantaol), Google LLC
- [hcaseyal](https://github.com/hcaseyal), Google LLC - [hcaseyal](https://github.com/hcaseyal), Google LLC
@ -64,7 +65,6 @@ for general contribution guidelines.
- [billfeng327](https://github.com/billfeng327), Google LLC - [billfeng327](https://github.com/billfeng327), Google LLC
- [ctiller](https://github.com/ctiller), Google LLC - [ctiller](https://github.com/ctiller), Google LLC
- [dgquintas](https://github.com/dgquintas), Google LLC - [dgquintas](https://github.com/dgquintas), Google LLC
- [ericgribkoff](https://github.com/ericgribkoff), Google LLC
- [fengli79](https://github.com/fengli79), Google LLC - [fengli79](https://github.com/fengli79), Google LLC
- [jcanizales](https://github.com/jcanizales), Google LLC - [jcanizales](https://github.com/jcanizales), Google LLC
- [jpalmerLinuxFoundation](https://github.com/jpalmerLinuxFoundation), Linux Foundation - [jpalmerLinuxFoundation](https://github.com/jpalmerLinuxFoundation), Linux Foundation

File diff suppressed because it is too large Load Diff

@ -11,8 +11,6 @@ load("//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
grpc_extra_deps() grpc_extra_deps()
register_execution_platforms( register_execution_platforms(
"//third_party/toolchains:local",
"//third_party/toolchains:local_large",
"//third_party/toolchains:rbe_windows", "//third_party/toolchains:rbe_windows",
) )
@ -20,11 +18,28 @@ register_toolchains(
"//third_party/toolchains/bazel_0.26.0_rbe_windows:cc-toolchain-x64_windows", "//third_party/toolchains/bazel_0.26.0_rbe_windows:cc-toolchain-x64_windows",
) )
load("@bazel_toolchains//rules/exec_properties:exec_properties.bzl", "create_exec_properties_dict", "custom_exec_properties")
custom_exec_properties(
name = "grpc_custom_exec_properties",
constants = {
"LARGE_MACHINE": create_exec_properties_dict(gce_machine_type = "n1-standard-8"),
},
)
load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig") load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")
# Create toolchain configuration for remote execution. # Create toolchain configuration for remote execution.
rbe_autoconfig( rbe_autoconfig(
name = "rbe_default", name = "rbe_default",
exec_properties = create_exec_properties_dict(
docker_add_capabilities = "SYS_PTRACE",
docker_privileged = True,
# n1-highmem-2 is the default (small machine) machine type. Targets
# that want to use other machines (such as LARGE_MACHINE) will override
# this value.
gce_machine_type = "n1-highmem-2",
),
# use exec_properties instead of deprecated remote_execution_properties # use exec_properties instead of deprecated remote_execution_properties
use_legacy_platform_definition = False, use_legacy_platform_definition = False,
) )
@ -43,7 +58,7 @@ rbe_autoconfig(
), ),
) )
load("@io_bazel_rules_python//python:pip.bzl", "pip_repositories", "pip_import") load("@io_bazel_rules_python//python:pip.bzl", "pip_import", "pip_repositories")
pip_import( pip_import(
name = "grpc_python_dependencies", name = "grpc_python_dependencies",
@ -51,5 +66,7 @@ pip_import(
) )
load("@grpc_python_dependencies//:requirements.bzl", "pip_install") load("@grpc_python_dependencies//:requirements.bzl", "pip_install")
pip_repositories() pip_repositories()
pip_install() pip_install()

@ -0,0 +1,17 @@
# Copyright 2019 The 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.
load("@grpc_custom_exec_properties//:constants.bzl", _LARGE_MACHINE = "LARGE_MACHINE")
LARGE_MACHINE = _LARGE_MACHINE

@ -1,13 +1,12 @@
"""Custom rules for gRPC Python""" """Custom rules for gRPC Python"""
# Adapted with modifications from # Adapted with modifications from
# tensorflow/tensorflow/core/platform/default/build_config.bzl # tensorflow/tensorflow/core/platform/default/build_config.bzl
# Native Bazel rules don't exist yet to compile Cython code, but rules have # Native Bazel rules don't exist yet to compile Cython code, but rules have
# been written at cython/cython and tensorflow/tensorflow. We branch from # been written at cython/cython and tensorflow/tensorflow. We branch from
# Tensorflow's version as it is more actively maintained and works for gRPC # Tensorflow's version as it is more actively maintained and works for gRPC
# Python's needs. # Python's needs.
def pyx_library(name, deps=[], py_deps=[], srcs=[], **kwargs): def pyx_library(name, deps = [], py_deps = [], srcs = [], **kwargs):
"""Compiles a group of .pyx / .pxd / .py files. """Compiles a group of .pyx / .pxd / .py files.
First runs Cython to create .cpp files for each input .pyx or .py + .pxd First runs Cython to create .cpp files for each input .pyx or .py + .pxd
@ -23,6 +22,7 @@ def pyx_library(name, deps=[], py_deps=[], srcs=[], **kwargs):
srcs: .py, .pyx, or .pxd files to either compile or pass through. srcs: .py, .pyx, or .pxd files to either compile or pass through.
**kwargs: Extra keyword arguments passed to the py_library. **kwargs: Extra keyword arguments passed to the py_library.
""" """
# First filter out files that should be run compiled vs. passed through. # First filter out files that should be run compiled vs. passed through.
py_srcs = [] py_srcs = []
pyx_srcs = [] pyx_srcs = []
@ -41,14 +41,14 @@ def pyx_library(name, deps=[], py_deps=[], srcs=[], **kwargs):
# Invoke cython to produce the shared object libraries. # Invoke cython to produce the shared object libraries.
for filename in pyx_srcs: for filename in pyx_srcs:
native.genrule( native.genrule(
name=filename + "_cython_translation", name = filename + "_cython_translation",
srcs=[filename], srcs = [filename],
outs=[filename.split(".")[0] + ".cpp"], outs = [filename.split(".")[0] + ".cpp"],
# Optionally use PYTHON_BIN_PATH on Linux platforms so that python 3 # Optionally use PYTHON_BIN_PATH on Linux platforms so that python 3
# works. Windows has issues with cython_binary so skip PYTHON_BIN_PATH. # works. Windows has issues with cython_binary so skip PYTHON_BIN_PATH.
cmd= cmd =
"PYTHONHASHSEED=0 $(location @cython//:cython_binary) --cplus $(SRCS) --output-file $(OUTS)", "PYTHONHASHSEED=0 $(location @cython//:cython_binary) --cplus $(SRCS) --output-file $(OUTS)",
tools=["@cython//:cython_binary"] + pxd_srcs, tools = ["@cython//:cython_binary"] + pxd_srcs,
) )
shared_objects = [] shared_objects = []
@ -56,19 +56,19 @@ def pyx_library(name, deps=[], py_deps=[], srcs=[], **kwargs):
stem = src.split(".")[0] stem = src.split(".")[0]
shared_object_name = stem + ".so" shared_object_name = stem + ".so"
native.cc_binary( native.cc_binary(
name=shared_object_name, name = shared_object_name,
srcs=[stem + ".cpp"], srcs = [stem + ".cpp"],
deps=deps + ["@local_config_python//:python_headers"], deps = deps + ["@local_config_python//:python_headers"],
linkshared=1, linkshared = 1,
) )
shared_objects.append(shared_object_name) shared_objects.append(shared_object_name)
# Now create a py_library with these shared objects as data. # Now create a py_library with these shared objects as data.
native.py_library( native.py_library(
name=name, name = name,
srcs=py_srcs, srcs = py_srcs,
deps=py_deps, deps = py_deps,
srcs_version="PY2AND3", srcs_version = "PY2AND3",
data=shared_objects, data = shared_objects,
**kwargs) **kwargs
)

@ -111,6 +111,7 @@ def generate_cc_impl(ctx):
"--proto_path={}".format(get_include_directory(i)) "--proto_path={}".format(get_include_directory(i))
for i in includes for i in includes
] ]
# Include the output directory so that protoc puts the generated code in the # Include the output directory so that protoc puts the generated code in the
# right directory. # right directory.
arguments += ["--proto_path={0}{1}".format(dir_out, proto_root)] arguments += ["--proto_path={0}{1}".format(dir_out, proto_root)]

@ -4,7 +4,7 @@ load(
"get_plugin_args", "get_plugin_args",
"proto_path_to_generated_filename", "proto_path_to_generated_filename",
) )
load(":grpc_util.bzl", "to_upper_camel_with_extension",) load(":grpc_util.bzl", "to_upper_camel_with_extension")
_GRPC_PROTO_HEADER_FMT = "{}.pbrpc.h" _GRPC_PROTO_HEADER_FMT = "{}.pbrpc.h"
_GRPC_PROTO_SRC_FMT = "{}.pbrpc.m" _GRPC_PROTO_SRC_FMT = "{}.pbrpc.m"
@ -40,7 +40,9 @@ def _generate_objc_impl(ctx):
out_files = [ctx.actions.declare_file(out) for out in outs] out_files = [ctx.actions.declare_file(out) for out in outs]
dir_out = _join_directories([ dir_out = _join_directories([
str(ctx.genfiles_dir.path), target_package, _GENERATED_PROTOS_DIR str(ctx.genfiles_dir.path),
target_package,
_GENERATED_PROTOS_DIR,
]) ])
arguments = [] arguments = []
@ -70,6 +72,7 @@ def _generate_objc_impl(ctx):
well_known_proto_files = [] well_known_proto_files = []
if ctx.attr.use_well_known_protos: if ctx.attr.use_well_known_protos:
f = ctx.attr.well_known_protos.files.to_list()[0].dirname f = ctx.attr.well_known_protos.files.to_list()[0].dirname
# go two levels up so that #import "google/protobuf/..." is correct # go two levels up so that #import "google/protobuf/..." is correct
arguments += ["-I{0}".format(f + "/../..")] arguments += ["-I{0}".format(f + "/../..")]
well_known_proto_files = ctx.attr.well_known_protos.files.to_list() well_known_proto_files = ctx.attr.well_known_protos.files.to_list()
@ -90,6 +93,7 @@ def _label_to_full_file_path(src, package):
# "a.proto" -> ":a.proto" # "a.proto" -> ":a.proto"
src = ":" + src src = ":" + src
src = "//" + package + src src = "//" + package + src
# Converts //path/to/package:File.ext to path/to/package/File.ext. # Converts //path/to/package:File.ext to path/to/package/File.ext.
src = src.replace("//", "") src = src.replace("//", "")
src = src.replace(":", "/") src = src.replace(":", "/")
@ -119,6 +123,7 @@ def _get_directory_from_proto(proto):
def _get_full_path_from_file(file): def _get_full_path_from_file(file):
gen_dir_length = 0 gen_dir_length = 0
# if file is generated, then prepare to remote its root # if file is generated, then prepare to remote its root
# (including CPU architecture...) # (including CPU architecture...)
if not file.is_source: if not file.is_source:
@ -130,7 +135,6 @@ def _join_directories(directories):
massaged_directories = [directory for directory in directories if len(directory) != 0] massaged_directories = [directory for directory in directories if len(directory) != 0]
return "/".join(massaged_directories) return "/".join(massaged_directories)
generate_objc = rule( generate_objc = rule(
attrs = { attrs = {
"deps": attr.label_list( "deps": attr.label_list(
@ -146,14 +150,14 @@ generate_objc = rule(
), ),
"srcs": attr.string_list( "srcs": attr.string_list(
mandatory = False, mandatory = False,
allow_empty = True allow_empty = True,
), ),
"use_well_known_protos": attr.bool( "use_well_known_protos": attr.bool(
mandatory = False, mandatory = False,
default = False default = False,
), ),
"well_known_protos": attr.label( "well_known_protos": attr.label(
default = "@com_google_protobuf//:well_known_protos" default = "@com_google_protobuf//:well_known_protos",
), ),
"_protoc": attr.label( "_protoc": attr.label(
default = Label("//external:protocol_compiler"), default = Label("//external:protocol_compiler"),
@ -162,7 +166,7 @@ generate_objc = rule(
), ),
}, },
output_to_genfiles = True, output_to_genfiles = True,
implementation = _generate_objc_impl implementation = _generate_objc_impl,
) )
def _group_objc_files_impl(ctx): def _group_objc_files_impl(ctx):
@ -189,9 +193,9 @@ generate_objc_hdrs = rule(
), ),
"gen_mode": attr.int( "gen_mode": attr.int(
default = _GENERATE_HDRS, default = _GENERATE_HDRS,
) ),
}, },
implementation = _group_objc_files_impl implementation = _group_objc_files_impl,
) )
generate_objc_srcs = rule( generate_objc_srcs = rule(
@ -201,9 +205,9 @@ generate_objc_srcs = rule(
), ),
"gen_mode": attr.int( "gen_mode": attr.int(
default = _GENERATE_SRCS, default = _GENERATE_SRCS,
) ),
}, },
implementation = _group_objc_files_impl implementation = _group_objc_files_impl,
) )
generate_objc_non_arc_srcs = rule( generate_objc_non_arc_srcs = rule(
@ -213,7 +217,7 @@ generate_objc_non_arc_srcs = rule(
), ),
"gen_mode": attr.int( "gen_mode": attr.int(
default = _GENERATE_NON_ARC_SRCS, default = _GENERATE_NON_ARC_SRCS,
) ),
}, },
implementation = _group_objc_files_impl implementation = _group_objc_files_impl,
) )

@ -27,14 +27,9 @@ load("//bazel:cc_grpc_library.bzl", "cc_grpc_library")
load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library") load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
# The set of pollers to test against if a test exercises polling # The set of pollers to test against if a test exercises polling
POLLERS = ["epollex", "epoll1", "poll"] POLLERS = ["epollex", "epoll1", "poll"]
# set exec_properties = LARGE_MACHINE, to run the test on a large machine
# see //third_party/toolchains/machine_size for details
LARGE_MACHINE = { "gceMachineType" : "n1-standard-8"}
def if_not_windows(a): def if_not_windows(a):
return select({ return select({
"//:windows": [], "//:windows": [],
@ -60,6 +55,8 @@ def _get_external_deps(external_deps):
}) })
elif dep == "cronet_c_for_grpc": elif dep == "cronet_c_for_grpc":
ret += ["//third_party/objective_c/Cronet:cronet_c_for_grpc"] ret += ["//third_party/objective_c/Cronet:cronet_c_for_grpc"]
elif dep.startswith("absl/"):
ret += ["@com_google_absl//" + dep]
else: else:
ret += ["//external:" + dep] ret += ["//external:" + dep]
return ret return ret
@ -87,6 +84,24 @@ def grpc_cc_library(
linkopts = if_not_windows(["-pthread"]) linkopts = if_not_windows(["-pthread"])
if use_cfstream: if use_cfstream:
linkopts = linkopts + if_mac(["-framework CoreFoundation"]) linkopts = linkopts + if_mac(["-framework CoreFoundation"])
# This is a temporary solution to enable absl dependency only for
# Bazel-build with grpc_use_absl enabled to abseilfy in-house classes
# such as inlined_vector before absl is fully supported.
# When https://github.com/grpc/grpc/pull/20184 is merged, it will
# be removed.
more_external_deps = []
if name == "inlined_vector":
more_external_deps += select({
"//:grpc_use_absl": ["@com_google_absl//absl/container:inlined_vector"],
"//conditions:default": [],
})
if name == "gpr_base":
more_external_deps += select({
"//:grpc_use_absl": ["@com_google_absl//absl/strings:strings"],
"//conditions:default": [],
})
native.cc_library( native.cc_library(
name = name, name = name,
srcs = srcs, srcs = srcs,
@ -102,9 +117,13 @@ def grpc_cc_library(
"//:grpc_allow_exceptions": ["GRPC_ALLOW_EXCEPTIONS=1"], "//:grpc_allow_exceptions": ["GRPC_ALLOW_EXCEPTIONS=1"],
"//:grpc_disallow_exceptions": ["GRPC_ALLOW_EXCEPTIONS=0"], "//:grpc_disallow_exceptions": ["GRPC_ALLOW_EXCEPTIONS=0"],
"//conditions:default": [], "//conditions:default": [],
}) +
select({
"//:grpc_use_absl": ["GRPC_USE_ABSL=1"],
"//conditions:default": [],
}), }),
hdrs = hdrs + public_hdrs, hdrs = hdrs + public_hdrs,
deps = deps + _get_external_deps(external_deps), deps = deps + _get_external_deps(external_deps) + more_external_deps,
copts = copts, copts = copts,
visibility = visibility, visibility = visibility,
testonly = testonly, testonly = testonly,
@ -142,11 +161,12 @@ def grpc_proto_library(
use_external = use_external, use_external = use_external,
generate_mocks = generate_mocks, generate_mocks = generate_mocks,
) )
def ios_cc_test( def ios_cc_test(
name, name,
tags = [], tags = [],
**kwargs): **kwargs):
ios_test_adapter = "//third_party/objective_c/google_toolbox_for_mac:GTM_GoogleTestRunner_GTM_USING_XCTEST"; ios_test_adapter = "//third_party/objective_c/google_toolbox_for_mac:GTM_GoogleTestRunner_GTM_USING_XCTEST"
test_lib_ios = name + "_test_lib_ios" test_lib_ios = name + "_test_lib_ios"
ios_tags = tags + ["manual", "ios_cc_test"] ios_tags = tags + ["manual", "ios_cc_test"]
@ -196,6 +216,7 @@ def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data
]), ]),
**args **args
) )
# on linux we run the same test multiple times, once for each poller # on linux we run the same test multiple times, once for each poller
for poller in POLLERS: for poller in POLLERS:
native.sh_test( native.sh_test(
@ -223,7 +244,6 @@ def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data
**args **args
) )
def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++", testonly = False, linkshared = False, linkopts = [], tags = []): def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++", testonly = False, linkshared = False, linkopts = [], tags = []):
copts = [] copts = []
if language.upper() == "C": if language.upper() == "C":
@ -266,7 +286,8 @@ def grpc_sh_binary(name, srcs, data = []):
data = data, data = data,
) )
def grpc_py_binary(name, def grpc_py_binary(
name,
srcs, srcs,
data = [], data = [],
deps = [], deps = [],
@ -339,10 +360,8 @@ def grpc_objc_library(
def grpc_upb_proto_library(name, deps): def grpc_upb_proto_library(name, deps):
upb_proto_library(name = name, deps = deps) upb_proto_library(name = name, deps = deps)
def python_config_settings(): def python_config_settings():
native.config_setting( native.config_setting(
name = "python3", name = "python3",
flag_values = {"@bazel_tools//tools/python:python_version": "PY3"}, flag_values = {"@bazel_tools//tools/python:python_version": "PY3"},
) )

@ -165,20 +165,20 @@ def grpc_deps():
if "com_google_absl" not in native.existing_rules(): if "com_google_absl" not in native.existing_rules():
http_archive( http_archive(
name = "com_google_absl", name = "com_google_absl",
sha256 = "fd4edc10767c28b23bf9f41114c6bcd9625c165a31baa0e6939f01058029a912", sha256 = "c5f6429c067e6b8f3c6d13d1ab2bdcd559c6f8b85317aa5b0dc8c364c37d1742",
strip_prefix = "abseil-cpp-74d91756c11bc22f9b0108b94da9326f7f9e376f", strip_prefix = "abseil-cpp-846e5dbedac123d12455adcfe6f53c8b5dcbfeef",
url = "https://github.com/abseil/abseil-cpp/archive/74d91756c11bc22f9b0108b94da9326f7f9e376f.tar.gz", url = "https://github.com/abseil/abseil-cpp/archive/846e5dbedac123d12455adcfe6f53c8b5dcbfeef.tar.gz",
) )
if "bazel_toolchains" not in native.existing_rules(): if "bazel_toolchains" not in native.existing_rules():
# list of releases is at https://releases.bazel.build/bazel-toolchains.html # list of releases is at https://releases.bazel.build/bazel-toolchains.html
http_archive( http_archive(
name = "bazel_toolchains", name = "bazel_toolchains",
sha256 = "e9bab54199722935f239cb1cd56a80be2ac3c3843e1a6d3492e2bc11f9c21daf", sha256 = "0b36eef8a66f39c8dbae88e522d5bbbef49d5e66e834a982402c79962281be10",
strip_prefix = "bazel-toolchains-1.0.0", strip_prefix = "bazel-toolchains-1.0.1",
urls = [ urls = [
"https://github.com/bazelbuild/bazel-toolchains/releases/download/1.0.0/bazel-toolchains-1.0.0.tar.gz", "https://github.com/bazelbuild/bazel-toolchains/releases/download/1.0.1/bazel-toolchains-1.0.1.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/1.0.0.tar.gz", "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/1.0.1.tar.gz",
], ],
) )

@ -71,4 +71,3 @@ def grpc_python_deps():
"https://github.com/cython/cython/archive/c2b80d87658a8525ce091cbe146cb7eaa29fed5c.tar.gz", "https://github.com/cython/cython/archive/c2b80d87658a8525ce091cbe146cb7eaa29fed5c.tar.gz",
], ],
) )

@ -2,8 +2,8 @@ load(
"//bazel:generate_objc.bzl", "//bazel:generate_objc.bzl",
"generate_objc", "generate_objc",
"generate_objc_hdrs", "generate_objc_hdrs",
"generate_objc_non_arc_srcs",
"generate_objc_srcs", "generate_objc_srcs",
"generate_objc_non_arc_srcs"
) )
load("//bazel:protobuf.bzl", "well_known_proto_libs") load("//bazel:protobuf.bzl", "well_known_proto_libs")
@ -66,4 +66,3 @@ def objc_grpc_library(name, deps, srcs = [], use_well_known_protos = False, **kw
], ],
**kwargs **kwargs
) )

@ -123,7 +123,7 @@ def get_plugin_args(
"--{plugin_name}_out={dir_out}".format( "--{plugin_name}_out={dir_out}".format(
plugin_name = plugin_name, plugin_name = plugin_name,
dir_out = augmented_dir_out, dir_out = augmented_dir_out,
) ),
] ]
def _get_staged_proto_file(context, source_file): def _get_staged_proto_file(context, source_file):

@ -2,13 +2,13 @@
load( load(
"//bazel:protobuf.bzl", "//bazel:protobuf.bzl",
"declare_out_files",
"get_include_directory", "get_include_directory",
"get_out_dir",
"get_plugin_args", "get_plugin_args",
"protos_from_context",
"includes_from_deps",
"get_proto_arguments", "get_proto_arguments",
"declare_out_files", "includes_from_deps",
"get_out_dir", "protos_from_context",
) )
_GENERATED_PROTO_FORMAT = "{}_pb2.py" _GENERATED_PROTO_FORMAT = "{}_pb2.py"
@ -35,7 +35,7 @@ def _generate_py_impl(context):
[], [],
out_dir.path, out_dir.path,
False, False,
context.attr.plugin.label.name context.attr.plugin.label.name,
) )
tools.append(context.executable.plugin) tools.append(context.executable.plugin)
@ -104,7 +104,6 @@ def py_proto_library(
if len(deps) != 1: if len(deps) != 1:
fail("Can only compile a single proto at a time.") fail("Can only compile a single proto at a time.")
_generate_pb2_src( _generate_pb2_src(
name = codegen_target, name = codegen_target,
deps = deps, deps = deps,
@ -144,7 +143,7 @@ def _generate_pb2_grpc_src_impl(context):
[], [],
out_dir.path, out_dir.path,
False, False,
context.attr.plugin.label.name context.attr.plugin.label.name,
) )
tools.append(context.executable.plugin) tools.append(context.executable.plugin)
@ -253,13 +252,13 @@ def py_grpc_library(
deps = [ deps = [
Label("//src/python/grpcio/grpc:grpcio"), Label("//src/python/grpcio/grpc:grpcio"),
] + deps + [ ] + deps + [
":{}".format(codegen_grpc_target) ":{}".format(codegen_grpc_target),
], ],
**kwargs **kwargs
) )
def py2and3_test(
def py2and3_test(name, name,
py_test = native.py_test, py_test = native.py_test,
**kwargs): **kwargs):
"""Runs a Python test under both Python 2 and Python 3. """Runs a Python test under both Python 2 and Python 3.

@ -16,9 +16,9 @@
load( load(
"@com_github_grpc_grpc//bazel:python_rules.bzl", "@com_github_grpc_grpc//bazel:python_rules.bzl",
"py_proto_library",
"py_grpc_library",
"py2and3_test", "py2and3_test",
"py_grpc_library",
"py_proto_library",
) )
package(default_testonly = 1) package(default_testonly = 1)
@ -55,12 +55,12 @@ py_proto_library(
py2and3_test( py2and3_test(
name = "import_test", name = "import_test",
main = "helloworld.py",
srcs = ["helloworld.py"], srcs = ["helloworld.py"],
main = "helloworld.py",
deps = [ deps = [
":duration_py_pb2",
":helloworld_py_pb2", ":helloworld_py_pb2",
":helloworld_py_pb2_grpc", ":helloworld_py_pb2_grpc",
":duration_py_pb2",
":timestamp_py_pb2", ":timestamp_py_pb2",
], ],
) )
@ -71,19 +71,19 @@ py2and3_test(
proto_library( proto_library(
name = "helloworld_moved_proto", name = "helloworld_moved_proto",
srcs = ["helloworld.proto"], srcs = ["helloworld.proto"],
import_prefix = "google/cloud",
strip_import_prefix = "",
deps = [ deps = [
"@com_google_protobuf//:duration_proto", "@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:timestamp_proto", "@com_google_protobuf//:timestamp_proto",
], ],
import_prefix = "google/cloud",
strip_import_prefix = ""
) )
# Also test the custom plugin execution parameter # Also test the custom plugin execution parameter
py_proto_library( py_proto_library(
name = "helloworld_moved_py_pb2", name = "helloworld_moved_py_pb2",
plugin = ":dummy_plugin",
deps = [":helloworld_moved_proto"], deps = [":helloworld_moved_proto"],
plugin = ":dummy_plugin"
) )
py_grpc_library( py_grpc_library(
@ -94,12 +94,12 @@ py_grpc_library(
py2and3_test( py2and3_test(
name = "import_moved_test", name = "import_moved_test",
main = "helloworld_moved.py",
srcs = ["helloworld_moved.py"], srcs = ["helloworld_moved.py"],
main = "helloworld_moved.py",
deps = [ deps = [
":duration_py_pb2",
":helloworld_moved_py_pb2", ":helloworld_moved_py_pb2",
":helloworld_moved_py_pb2_grpc", ":helloworld_moved_py_pb2_grpc",
":duration_py_pb2",
":timestamp_py_pb2", ":timestamp_py_pb2",
], ],
) )

@ -12,7 +12,7 @@ settings:
'#08': Use "-preN" suffixes to identify pre-release versions '#08': Use "-preN" suffixes to identify pre-release versions
'#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: 8.0.0 core_version: 9.0.0
csharp_major_version: 2 csharp_major_version: 2
g_stands_for: gon g_stands_for: gon
version: 1.26.0-dev version: 1.26.0-dev
@ -69,7 +69,7 @@ filegroups:
- src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c - src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c
- src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c - src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c
- src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c - src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c
uses: deps:
- upb - upb
- name: alts_util - name: alts_util
public_headers: public_headers:
@ -89,11 +89,12 @@ filegroups:
- src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc - src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc
- src/core/tsi/alts/handshaker/alts_tsi_utils.cc - src/core/tsi/alts/handshaker/alts_tsi_utils.cc
- src/core/tsi/alts/handshaker/transport_security_common_api.cc - src/core/tsi/alts/handshaker/transport_security_common_api.cc
deps:
- upb
uses: uses:
- alts_upb - alts_upb
- grpc_base - grpc_base
- tsi_interface - tsi_interface
- upb
- name: census - name: census
public_headers: public_headers:
- include/grpc/census.h - include/grpc/census.h
@ -201,7 +202,7 @@ filegroups:
- src/core/ext/upb-generated/google/protobuf/timestamp.upb.c - src/core/ext/upb-generated/google/protobuf/timestamp.upb.c
- src/core/ext/upb-generated/google/protobuf/wrappers.upb.c - src/core/ext/upb-generated/google/protobuf/wrappers.upb.c
- src/core/ext/upb-generated/google/rpc/status.upb.c - src/core/ext/upb-generated/google/rpc/status.upb.c
uses: deps:
- upb - upb
- name: gpr_base - name: gpr_base
src: src:
@ -293,7 +294,6 @@ filegroups:
- src/core/lib/gprpp/map.h - src/core/lib/gprpp/map.h
- src/core/lib/gprpp/memory.h - src/core/lib/gprpp/memory.h
- src/core/lib/gprpp/mpscq.h - src/core/lib/gprpp/mpscq.h
- src/core/lib/gprpp/set.h
- src/core/lib/gprpp/sync.h - src/core/lib/gprpp/sync.h
- src/core/lib/gprpp/thd.h - src/core/lib/gprpp/thd.h
- src/core/lib/profiling/timers.h - src/core/lib/profiling/timers.h
@ -1052,7 +1052,7 @@ filegroups:
- src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h
src: src:
- src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c - src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c
uses: deps:
- upb - upb
- name: grpc_http_filters - name: grpc_http_filters
headers: headers:
@ -1096,13 +1096,14 @@ filegroups:
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc
- src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc - src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
deps:
- upb
plugin: grpc_lb_policy_grpclb plugin: grpc_lb_policy_grpclb
uses: uses:
- grpc_base - grpc_base
- grpc_client_channel - grpc_client_channel
- grpc_lb_upb - grpc_lb_upb
- grpc_resolver_fake - grpc_resolver_fake
- upb
- name: grpc_lb_policy_grpclb_secure - name: grpc_lb_policy_grpclb_secure
headers: headers:
- src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h - src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h
@ -1116,6 +1117,8 @@ filegroups:
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc
- src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc - src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
deps:
- upb
plugin: grpc_lb_policy_grpclb plugin: grpc_lb_policy_grpclb
uses: uses:
- grpc_base - grpc_base
@ -1123,7 +1126,6 @@ filegroups:
- grpc_lb_upb - grpc_lb_upb
- grpc_resolver_fake - grpc_resolver_fake
- grpc_secure - grpc_secure
- upb
- name: grpc_lb_policy_pick_first - name: grpc_lb_policy_pick_first
src: src:
- src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc - src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
@ -1171,9 +1173,10 @@ filegroups:
- src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h - src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h
src: src:
- src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c - src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c
deps:
- upb
uses: uses:
- google_api_upb - google_api_upb
- upb
- name: grpc_max_age_filter - name: grpc_max_age_filter
headers: headers:
- src/core/ext/filters/max_age/max_age_filter.h - src/core/ext/filters/max_age/max_age_filter.h
@ -3317,41 +3320,6 @@ targets:
- mac - mac
- linux - linux
- posix - posix
- name: memory_usage_client
build: test
run: false
language: c
src:
- test/core/memory_usage/client.cc
deps:
- grpc_test_util
- grpc
- gpr
uses_polling: false
- name: memory_usage_server
build: test
run: false
language: c
src:
- test/core/memory_usage/server.cc
deps:
- grpc_test_util
- grpc
- gpr
- name: memory_usage_test
cpu_cost: 1.5
build: test
language: c
src:
- test/core/memory_usage/memory_usage_test.cc
deps:
- grpc_test_util
- grpc
- gpr
platforms:
- mac
- linux
- posix
- name: message_compress_test - name: message_compress_test
build: test build: test
language: c language: c
@ -3946,6 +3914,25 @@ targets:
- grpc++_unsecure - grpc++_unsecure
- grpc_unsecure - grpc_unsecure
- gpr - gpr
- name: alts_concurrent_connectivity_test
build: test
language: c++
headers:
- test/core/tsi/alts/fake_handshaker/fake_handshaker_server.h
src:
- test/core/tsi/alts/fake_handshaker/handshaker.proto
- test/core/tsi/alts/fake_handshaker/transport_security_common.proto
- test/core/tsi/alts/fake_handshaker/fake_handshaker_server.cc
- test/core/tsi/alts/handshaker/alts_concurrent_connectivity_test.cc
deps:
- grpc++_test_util
- grpc_test_util
- grpc++
- grpc
- gpr
- grpc++_test_config
platforms:
- linux
- name: alts_counter_test - name: alts_counter_test
build: test build: test
language: c++ language: c++
@ -5360,18 +5347,6 @@ targets:
- mac - mac
- linux - linux
- posix - posix
- name: memory_test
gtest: true
build: test
language: c++
src:
- test/core/gprpp/memory_test.cc
deps:
- grpc_test_util
- grpc++
- grpc
- gpr
uses_polling: false
- name: message_allocator_end2end_test - name: message_allocator_end2end_test
gtest: true gtest: true
cpu_cost: 0.5 cpu_cost: 0.5
@ -6146,6 +6121,10 @@ configs:
counters: counters:
CPPFLAGS: -O2 -DGPR_LOW_LEVEL_COUNTERS CPPFLAGS: -O2 -DGPR_LOW_LEVEL_COUNTERS
DEFINES: NDEBUG DEFINES: NDEBUG
counters_with_memory_counter:
CPPFLAGS: -O2 -DGPR_LOW_LEVEL_COUNTERS -DGPR_WRAP_MEMORY_COUNTER
DEFINES: NDEBUG
LDFLAGS: -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free
dbg: dbg:
CPPFLAGS: -O0 CPPFLAGS: -O0
DEFINES: _DEBUG DEBUG DEFINES: _DEBUG DEBUG
@ -6253,9 +6232,10 @@ php_config_m4:
deps: deps:
- grpc - grpc
- gpr - gpr
- address_sorting
- boringssl - boringssl
- upb
- z - z
- address_sorting
headers: headers:
- src/php/ext/grpc/byte_buffer.h - src/php/ext/grpc/byte_buffer.h
- src/php/ext/grpc/call.h - src/php/ext/grpc/call.h
@ -6284,15 +6264,17 @@ python_dependencies:
deps: deps:
- grpc - grpc
- gpr - gpr
- address_sorting
- ares - ares
- boringssl - boringssl
- upb
- z - z
- address_sorting
ruby_gem: ruby_gem:
deps: deps:
- grpc - grpc
- gpr - gpr
- address_sorting
- ares - ares
- boringssl - boringssl
- upb
- z - z
- address_sorting

@ -13,5 +13,5 @@
# limitations under the License. # limitations under the License.
module GrpcBuildConfig module GrpcBuildConfig
CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-8.dll' CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-9.dll'
end end

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if("${gRPC_BENCHMARK_PROVIDER}" STREQUAL "module") if(gRPC_BENCHMARK_PROVIDER STREQUAL "module")
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Turn off gTest in gBenchmark") set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Turn off gTest in gBenchmark")
if(NOT BENCHMARK_ROOT_DIR) if(NOT BENCHMARK_ROOT_DIR)
set(BENCHMARK_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/benchmark) set(BENCHMARK_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/benchmark)
@ -21,18 +21,15 @@ if("${gRPC_BENCHMARK_PROVIDER}" STREQUAL "module")
add_subdirectory(${BENCHMARK_ROOT_DIR} third_party/benchmark) add_subdirectory(${BENCHMARK_ROOT_DIR} third_party/benchmark)
if(TARGET benchmark) if(TARGET benchmark)
set(_gRPC_BENCHMARK_LIBRARIES benchmark) set(_gRPC_BENCHMARK_LIBRARIES benchmark)
set(_gRPC_BENCHMARK_INCLUDE_DIR "${BENCHMARK_ROOT_DIR}/include")
endif() endif()
else() else()
message(WARNING "gRPC_BENCHMARK_PROVIDER is \"module\" but BENCHMARK_ROOT_DIR is wrong") message(WARNING "gRPC_BENCHMARK_PROVIDER is \"module\" but BENCHMARK_ROOT_DIR is wrong")
endif() endif()
elseif("${gRPC_BENCHMARK_PROVIDER}" STREQUAL "package") elseif(gRPC_BENCHMARK_PROVIDER STREQUAL "package")
# Use "CONFIG" as there is no built-in cmake module for benchmark. # Use "CONFIG" as there is no built-in cmake module for benchmark.
find_package(benchmark REQUIRED CONFIG) find_package(benchmark REQUIRED CONFIG)
if(TARGET benchmark::benchmark) if(TARGET benchmark::benchmark)
set(_gRPC_BENCHMARK_LIBRARIES benchmark::benchmark) set(_gRPC_BENCHMARK_LIBRARIES benchmark::benchmark)
# extract the include dir from target's properties
get_target_property(_gRPC_BENCHMARK_INCLUDE_DIR benchmark::benchmark INTERFACE_INCLUDE_DIRECTORIES)
endif() endif()
set(_gRPC_FIND_BENCHMARK "if(NOT benchmark_FOUND)\n find_package(benchmark CONFIG)\nendif()") set(_gRPC_FIND_BENCHMARK "if(NOT benchmark_FOUND)\n find_package(benchmark CONFIG)\nendif()")
endif() endif()

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if("${gRPC_CARES_PROVIDER}" STREQUAL "module") if(gRPC_CARES_PROVIDER STREQUAL "module")
if(NOT CARES_ROOT_DIR) if(NOT CARES_ROOT_DIR)
set(CARES_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/cares/cares) set(CARES_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/cares/cares)
endif() endif()
@ -26,19 +26,17 @@ if("${gRPC_CARES_PROVIDER}" STREQUAL "module")
if(TARGET c-ares) if(TARGET c-ares)
set(_gRPC_CARES_LIBRARIES c-ares) set(_gRPC_CARES_LIBRARIES c-ares)
set(_gRPC_CARES_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/cares/cares" "${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares")
endif() endif()
if(gRPC_INSTALL) if(gRPC_INSTALL)
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_CARES_PROVIDER is \"module\"") message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_CARES_PROVIDER is \"module\"")
set(gRPC_INSTALL FALSE) set(gRPC_INSTALL FALSE)
endif() endif()
elseif("${gRPC_CARES_PROVIDER}" STREQUAL "package") elseif(gRPC_CARES_PROVIDER STREQUAL "package")
# Use "CONFIG" as there is no built-in cmake module for c-ares. # Use "CONFIG" as there is no built-in cmake module for c-ares.
find_package(c-ares REQUIRED CONFIG) find_package(c-ares REQUIRED CONFIG)
if(TARGET c-ares::cares) if(TARGET c-ares::cares)
set(_gRPC_CARES_LIBRARIES c-ares::cares) set(_gRPC_CARES_LIBRARIES c-ares::cares)
set(_gRPC_CARES_INCLUDE_DIR ${c-ares_INCLUDE_DIR})
endif() endif()
set(_gRPC_FIND_CARES "if(NOT c-ares_FOUND)\n find_package(c-ares CONFIG)\nendif()") set(_gRPC_FIND_CARES "if(NOT c-ares_FOUND)\n find_package(c-ares CONFIG)\nendif()")
endif() endif()

@ -1,11 +0,0 @@
set(PACKAGE_VERSION "@PACKAGE_VERSION@")
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

@ -12,23 +12,21 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if("${gRPC_GFLAGS_PROVIDER}" STREQUAL "module") if(gRPC_GFLAGS_PROVIDER STREQUAL "module")
if(NOT GFLAGS_ROOT_DIR) if(NOT GFLAGS_ROOT_DIR)
set(GFLAGS_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/gflags) set(GFLAGS_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/gflags)
endif() endif()
if(EXISTS "${GFLAGS_ROOT_DIR}/CMakeLists.txt") if(EXISTS "${GFLAGS_ROOT_DIR}/CMakeLists.txt")
add_subdirectory(${GFLAGS_ROOT_DIR} third_party/gflags) add_subdirectory(${GFLAGS_ROOT_DIR} third_party/gflags)
set(_gRPC_GFLAGS_LIBRARIES gflags::gflags) set(_gRPC_GFLAGS_LIBRARIES gflags::gflags)
set(_gRPC_GFLAGS_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include")
else() else()
message(WARNING "gRPC_GFLAGS_PROVIDER is \"module\" but GFLAGS_ROOT_DIR is wrong") message(WARNING "gRPC_GFLAGS_PROVIDER is \"module\" but GFLAGS_ROOT_DIR is wrong")
endif() endif()
elseif("${gRPC_GFLAGS_PROVIDER}" STREQUAL "package") elseif(gRPC_GFLAGS_PROVIDER STREQUAL "package")
# Use "CONFIG" as there is no built-in cmake module for gflags. # Use "CONFIG" as there is no built-in cmake module for gflags.
find_package(gflags REQUIRED CONFIG) find_package(gflags REQUIRED CONFIG)
if(TARGET gflags::gflags) if(TARGET gflags::gflags)
set(_gRPC_GFLAGS_LIBRARIES gflags::gflags) set(_gRPC_GFLAGS_LIBRARIES gflags::gflags)
set(_gRPC_GFLAGS_INCLUDE_DIR ${GFLAGS_INCLUDE_DIR})
endif() endif()
set(_gRPC_FIND_GFLAGS "if(NOT gflags_FOUND)\n find_package(gflags CONFIG)\nendif()") set(_gRPC_FIND_GFLAGS "if(NOT gflags_FOUND)\n find_package(gflags CONFIG)\nendif()")
endif() endif()

@ -22,9 +22,9 @@ if(gRPC_MSVC_STATIC_RUNTIME)
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD") if(flag_var MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MD") endif()
endforeach(flag_var) endforeach()
endif() endif()

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module") if(gRPC_PROTOBUF_PROVIDER STREQUAL "module")
# Building the protobuf tests require gmock what is not part of a standard protobuf checkout. # Building the protobuf tests require gmock what is not part of a standard protobuf checkout.
# Disable them unless they are explicitly requested from the cmake command line (when we assume # Disable them unless they are explicitly requested from the cmake command line (when we assume
# gmock is downloaded to the right location inside protobuf). # gmock is downloaded to the right location inside protobuf).
@ -41,7 +41,6 @@ if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module")
set(_gRPC_PROTOBUF_PROTOC protoc) set(_gRPC_PROTOBUF_PROTOC protoc)
set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE $<TARGET_FILE:protoc>) set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE $<TARGET_FILE:protoc>)
endif() endif()
set(_gRPC_PROTOBUF_INCLUDE_DIR "${PROTOBUF_ROOT_DIR}")
# For well-known .proto files distributed with protobuf # For well-known .proto files distributed with protobuf
set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR "${PROTOBUF_ROOT_DIR}/src") set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR "${PROTOBUF_ROOT_DIR}/src")
else() else()
@ -51,7 +50,7 @@ if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module")
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_PROTOBUF_PROVIDER is \"module\"") message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_PROTOBUF_PROVIDER is \"module\"")
set(gRPC_INSTALL FALSE) set(gRPC_INSTALL FALSE)
endif() endif()
elseif("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "package") elseif(gRPC_PROTOBUF_PROVIDER STREQUAL "package")
find_package(Protobuf REQUIRED ${gRPC_PROTOBUF_PACKAGE_TYPE}) find_package(Protobuf REQUIRED ${gRPC_PROTOBUF_PACKAGE_TYPE})
# {Protobuf,PROTOBUF}_FOUND is defined based on find_package type ("MODULE" vs "CONFIG"). # {Protobuf,PROTOBUF}_FOUND is defined based on find_package type ("MODULE" vs "CONFIG").
@ -79,7 +78,6 @@ elseif("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "package")
set(_gRPC_PROTOBUF_PROTOC ${PROTOBUF_PROTOC_EXECUTABLE}) set(_gRPC_PROTOBUF_PROTOC ${PROTOBUF_PROTOC_EXECUTABLE})
set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE}) set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE})
endif() endif()
set(_gRPC_PROTOBUF_INCLUDE_DIR ${PROTOBUF_INCLUDE_DIRS})
set(_gRPC_FIND_PROTOBUF "if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)\n find_package(Protobuf ${gRPC_PROTOBUF_PACKAGE_TYPE})\nendif()") set(_gRPC_FIND_PROTOBUF "if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)\n find_package(Protobuf ${gRPC_PROTOBUF_PACKAGE_TYPE})\nendif()")
endif() endif()
endif() endif()

@ -12,7 +12,11 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if("${gRPC_SSL_PROVIDER}" STREQUAL "module") # The CMakeLists.txt for BoringSSL doesn't propagate include directories
# transitively so `_gRPC_SSL_INCLUDE_DIR` should be set for gRPC
# to find header files.
if(gRPC_SSL_PROVIDER STREQUAL "module")
if(NOT BORINGSSL_ROOT_DIR) if(NOT BORINGSSL_ROOT_DIR)
set(BORINGSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/boringssl) set(BORINGSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/boringssl)
endif() endif()
@ -37,7 +41,7 @@ if("${gRPC_SSL_PROVIDER}" STREQUAL "module")
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_SSL_PROVIDER is \"module\"") message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_SSL_PROVIDER is \"module\"")
set(gRPC_INSTALL FALSE) set(gRPC_INSTALL FALSE)
endif() endif()
elseif("${gRPC_SSL_PROVIDER}" STREQUAL "package") elseif(gRPC_SSL_PROVIDER STREQUAL "package")
# OpenSSL installation directory can be configured by setting OPENSSL_ROOT_DIR # OpenSSL installation directory can be configured by setting OPENSSL_ROOT_DIR
# We expect to locate OpenSSL using the built-in cmake module as the openssl # We expect to locate OpenSSL using the built-in cmake module as the openssl
# project itself does not provide installation support in its CMakeLists.txt # project itself does not provide installation support in its CMakeLists.txt

@ -16,3 +16,5 @@ set(UPB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/upb)
set(_gRPC_UPB_INCLUDE_DIR "${UPB_ROOT_DIR}") set(_gRPC_UPB_INCLUDE_DIR "${UPB_ROOT_DIR}")
set(_gRPC_UPB_GRPC_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/core/ext/upb-generated") set(_gRPC_UPB_GRPC_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/core/ext/upb-generated")
set(_gRPC_UPB_LIBRARIES upb)

@ -12,7 +12,11 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if("${gRPC_ZLIB_PROVIDER}" STREQUAL "module") # The CMakeLists.txt for zlib doesn't propagate include directories
# transitively so `_gRPC_ZLIB_INCLUDE_DIR` should be set for gRPC
# to find header files.
if(gRPC_ZLIB_PROVIDER STREQUAL "module")
if(NOT ZLIB_ROOT_DIR) if(NOT ZLIB_ROOT_DIR)
set(ZLIB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib) set(ZLIB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib)
endif() endif()
@ -32,7 +36,7 @@ if("${gRPC_ZLIB_PROVIDER}" STREQUAL "module")
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_ZLIB_PROVIDER is \"module\"") message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_ZLIB_PROVIDER is \"module\"")
set(gRPC_INSTALL FALSE) set(gRPC_INSTALL FALSE)
endif() endif()
elseif("${gRPC_ZLIB_PROVIDER}" STREQUAL "package") elseif(gRPC_ZLIB_PROVIDER STREQUAL "package")
# zlib installation directory can be configured by setting ZLIB_ROOT # zlib installation directory can be configured by setting ZLIB_ROOT
# We allow locating zlib using both "CONFIG" and "MODULE" as the expectation # We allow locating zlib using both "CONFIG" and "MODULE" as the expectation
# is that many Linux systems will have zlib installed via a distribution # is that many Linux systems will have zlib installed via a distribution

@ -343,12 +343,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c \ src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c \
src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c \ src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c \
src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c \ src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c \
third_party/upb/upb/decode.c \
third_party/upb/upb/encode.c \
third_party/upb/upb/msg.c \
third_party/upb/upb/port.c \
third_party/upb/upb/table.c \
third_party/upb/upb/upb.c \
src/core/tsi/transport_security.cc \ src/core/tsi/transport_security.cc \
src/core/ext/transport/chttp2/client/insecure/channel_create.cc \ src/core/ext/transport/chttp2/client/insecure/channel_create.cc \
src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \
@ -732,6 +726,12 @@ if test "$PHP_GRPC" != "no"; then
third_party/boringssl/ssl/tls_method.cc \ third_party/boringssl/ssl/tls_method.cc \
third_party/boringssl/ssl/tls_record.cc \ third_party/boringssl/ssl/tls_record.cc \
third_party/boringssl/third_party/fiat/curve25519.c \ third_party/boringssl/third_party/fiat/curve25519.c \
third_party/upb/upb/decode.c \
third_party/upb/upb/encode.c \
third_party/upb/upb/msg.c \
third_party/upb/upb/port.c \
third_party/upb/upb/table.c \
third_party/upb/upb/upb.c \
, $ext_shared, , -fvisibility=hidden \ , $ext_shared, , -fvisibility=hidden \
-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_HAS_EXCEPTIONS=0 -DNOMINMAX -DGRPC_ARES=0 \

@ -313,12 +313,6 @@ if (PHP_GRPC != "no") {
"src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp\\altscontext.upb.c " + "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp\\altscontext.upb.c " +
"src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp\\handshaker.upb.c " + "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp\\handshaker.upb.c " +
"src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp\\transport_security_common.upb.c " + "src\\core\\ext\\upb-generated\\src\\proto\\grpc\\gcp\\transport_security_common.upb.c " +
"third_party\\upb\\upb\\decode.c " +
"third_party\\upb\\upb\\encode.c " +
"third_party\\upb\\upb\\msg.c " +
"third_party\\upb\\upb\\port.c " +
"third_party\\upb\\upb\\table.c " +
"third_party\\upb\\upb\\upb.c " +
"src\\core\\tsi\\transport_security.cc " + "src\\core\\tsi\\transport_security.cc " +
"src\\core\\ext\\transport\\chttp2\\client\\insecure\\channel_create.cc " + "src\\core\\ext\\transport\\chttp2\\client\\insecure\\channel_create.cc " +
"src\\core\\ext\\transport\\chttp2\\client\\insecure\\channel_create_posix.cc " + "src\\core\\ext\\transport\\chttp2\\client\\insecure\\channel_create_posix.cc " +
@ -702,6 +696,12 @@ if (PHP_GRPC != "no") {
"third_party\\boringssl\\ssl\\tls_method.cc " + "third_party\\boringssl\\ssl\\tls_method.cc " +
"third_party\\boringssl\\ssl\\tls_record.cc " + "third_party\\boringssl\\ssl\\tls_record.cc " +
"third_party\\boringssl\\third_party\\fiat\\curve25519.c " + "third_party\\boringssl\\third_party\\fiat\\curve25519.c " +
"third_party\\upb\\upb\\decode.c " +
"third_party\\upb\\upb\\encode.c " +
"third_party\\upb\\upb\\msg.c " +
"third_party\\upb\\upb\\port.c " +
"third_party\\upb\\upb\\table.c " +
"third_party\\upb\\upb\\upb.c " +
"third_party\\zlib\\adler32.c " + "third_party\\zlib\\adler32.c " +
"third_party\\zlib\\compress.c " + "third_party\\zlib\\compress.c " +
"third_party\\zlib\\crc32.c " + "third_party\\zlib\\crc32.c " +

@ -36,7 +36,7 @@ The following are the **Opaque** structures exposed by Polling Engine interface
- **grpc_fd:** Structure representing a file descriptor - **grpc_fd:** Structure representing a file descriptor
- **grpc_pollset:** A set of one or more grpc_fds that are ‘polled’ for readable/writable/error events. One grpc_fd can be in multiple `grpc_pollset`s - **grpc_pollset:** A set of one or more grpc_fds that are ‘polled’ for readable/writable/error events. One grpc_fd can be in multiple `grpc_pollset`s
- **grpc_pollset_worker:** Structure representing a ‘polling thread’ - more specifically, the thread that calls `grpc_pollset_work()` API - **grpc_pollset_worker:** Structure representing a ‘polling thread’ - more specifically, the thread that calls `grpc_pollset_work()` API
- **grpc_pollset_set:** A group of `grpc_fds`, `grpc_pollsets` and `grpc_pollset_sets` (yes, a `grpc_pollset_set` can contain other `grpc_pollset_sets`) - **grpc_pollset_set:** A group of `grpc_fd`s, `grpc_pollset`s and `grpc_pollset_set`s (yes, a `grpc_pollset_set` can contain other `grpc_pollset_set`s)
### Polling engine API ### Polling engine API
@ -58,12 +58,12 @@ The following are the **Opaque** structures exposed by Polling Engine interface
#### grpc_pollset #### grpc_pollset
- **grpc_pollset_add_fd ** - **grpc_pollset_add_fd**
- Signature: `grpc_pollset_add_fd(grpc_pollset* ps, grpc_fd *fd)` - Signature: `grpc_pollset_add_fd(grpc_pollset* ps, grpc_fd *fd)`
- Add fd to pollset - Add fd to pollset
> **NOTE**: There is no `grpc_pollset_remove_fd`. This is because calling `grpc_fd_orphan()` will effectively remove the fd from all the pollsets it’s a part of > **NOTE**: There is no `grpc_pollset_remove_fd`. This is because calling `grpc_fd_orphan()` will effectively remove the fd from all the pollsets it’s a part of
- ** grpc_pollset_work ** - **grpc_pollset_work**
- Signature: `grpc_pollset_work(grpc_pollset* ps, grpc_pollset_worker** worker, grpc_millis deadline)` - Signature: `grpc_pollset_work(grpc_pollset* ps, grpc_pollset_worker** worker, grpc_millis deadline)`
> **NOTE**: `grpc_pollset_work()` requires the pollset mutex to be locked before calling it. Shortly after calling `grpc_pollset_work()`, the function populates the `*worker` pointer (among other things) and releases the mutex. Once `grpc_pollset_work()` returns, the `*worker` pointer is **invalid** and should not be used anymore. See the code in `completion_queue.cc` to see how this is used. > **NOTE**: `grpc_pollset_work()` requires the pollset mutex to be locked before calling it. Shortly after calling `grpc_pollset_work()`, the function populates the `*worker` pointer (among other things) and releases the mutex. Once `grpc_pollset_work()` returns, the `*worker` pointer is **invalid** and should not be used anymore. See the code in `completion_queue.cc` to see how this is used.
- Poll the fds in the pollset for events AND return when ANY of the following is true: - Poll the fds in the pollset for events AND return when ANY of the following is true:
@ -80,7 +80,7 @@ The following are the **Opaque** structures exposed by Polling Engine interface
- **grpc\_pollset\_set\_[add|del]\_fd** - **grpc\_pollset\_set\_[add|del]\_fd**
- Signature: `grpc_pollset_set_[add|del]_fd(grpc_pollset_set* pss, grpc_fd *fd)` - Signature: `grpc_pollset_set_[add|del]_fd(grpc_pollset_set* pss, grpc_fd *fd)`
Add/Remove fd to the `grpc_pollset_set` - Add/Remove fd to the `grpc_pollset_set`
- **grpc\_pollset\_set_[add|del]\_pollset** - **grpc\_pollset\_set_[add|del]\_pollset**
- Signature: `grpc_pollset_set_[add|del]_pollset(grpc_pollset_set* pss, grpc_pollset* ps)` - Signature: `grpc_pollset_set_[add|del]_pollset(grpc_pollset_set* pss, grpc_pollset* ps)`

@ -18,7 +18,7 @@ package(default_visibility = ["//visibility:public"])
load("//bazel:grpc_build_system.bzl", "grpc_proto_library") load("//bazel:grpc_build_system.bzl", "grpc_proto_library")
load("//bazel:cc_grpc_library.bzl", "cc_grpc_library") load("//bazel:cc_grpc_library.bzl", "cc_grpc_library")
load("//bazel:python_rules.bzl", "py_proto_library", "py_grpc_library") load("//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library")
load("@grpc_python_dependencies//:requirements.bzl", "requirement") load("@grpc_python_dependencies//:requirements.bzl", "requirement")
grpc_proto_library( grpc_proto_library(

@ -23,29 +23,29 @@ load("@build_bazel_rules_apple//apple:macos.bzl", "macos_application")
objc_grpc_library( objc_grpc_library(
name = "HelloWorld_grpc_proto", name = "HelloWorld_grpc_proto",
srcs = ["//examples:protos/helloworld.proto"], srcs = ["//examples:protos/helloworld.proto"],
deps = ["//examples:helloworld_proto"],
tags = ["manual"], tags = ["manual"],
deps = ["//examples:helloworld_proto"],
) )
# This one works with import "external/com_github_grpc_grpc/examples/protos/Helloworld.pbrpc.h" # This one works with import "external/com_github_grpc_grpc/examples/protos/Helloworld.pbrpc.h"
objc_grpc_library( objc_grpc_library(
name = "HelloWorld_grpc_proto_external", name = "HelloWorld_grpc_proto_external",
srcs = ["//external/com_github_grpc_grpc/examples:protos/helloworld.proto"], srcs = ["//external/com_github_grpc_grpc/examples:protos/helloworld.proto"],
deps = ["@com_github_grpc_grpc//examples:helloworld_proto"],
tags = ["manual"], tags = ["manual"],
deps = ["@com_github_grpc_grpc//examples:helloworld_proto"],
) )
objc_library( objc_library(
name = "HelloWorld-lib", name = "HelloWorld-lib",
srcs = glob(["helloworld/**/*.m",]), srcs = glob(["helloworld/**/*.m"]),
hdrs = glob(["helloworld/**/*.h"]), hdrs = glob(["helloworld/**/*.h"]),
data = glob([ data = glob([
"helloworld/HelloWorld/Base.lproj/**", "helloworld/HelloWorld/Base.lproj/**",
"helloworld/HelloWorld/Images.xcassets/**", "helloworld/HelloWorld/Images.xcassets/**",
]), ]),
includes = ["helloworld/HelloWorld"], includes = ["helloworld/HelloWorld"],
deps = [":HelloWorld_grpc_proto"],
tags = ["manual"], tags = ["manual"],
deps = [":HelloWorld_grpc_proto"],
) )
ios_application( ios_application(
@ -55,40 +55,40 @@ ios_application(
"iphone", "iphone",
"ipad", "ipad",
], ],
minimum_os_version = "8.0",
infoplists = ["helloworld/HelloWorld/Info.plist"], infoplists = ["helloworld/HelloWorld/Info.plist"],
deps = [":HelloWorld-lib"], minimum_os_version = "8.0",
tags = ["manual"], tags = ["manual"],
deps = [":HelloWorld-lib"],
) )
objc_library( objc_library(
name = "HelloWorldMacos-lib", name = "HelloWorldMacos-lib",
srcs = glob(["helloworld_macos/**/*.m",]), srcs = glob(["helloworld_macos/**/*.m"]),
hdrs = glob(["helloworld_macos/**/*.h"]), hdrs = glob(["helloworld_macos/**/*.h"]),
data = glob([ data = glob([
"helloworld_macos/HelloWorld/Base.lproj/**", "helloworld_macos/HelloWorld/Base.lproj/**",
"helloworld_macos/HelloWorld/Images.xcassets/**", "helloworld_macos/HelloWorld/Images.xcassets/**",
]), ]),
includes = ["helloworld_macos/HelloWorld"], includes = ["helloworld_macos/HelloWorld"],
deps = [":HelloWorld_grpc_proto"],
tags = ["manual"], tags = ["manual"],
deps = [":HelloWorld_grpc_proto"],
) )
macos_application( macos_application(
name = "HelloWorldMacos", name = "HelloWorldMacos",
bundle_id = "io.grpc.HelloWorld", bundle_id = "io.grpc.HelloWorld",
minimum_os_version = "10.13",
entitlements = "helloworld_macos/HelloWorld/Helloworld.entitlements", entitlements = "helloworld_macos/HelloWorld/Helloworld.entitlements",
infoplists = ["helloworld_macos/HelloWorld/Info.plist"], infoplists = ["helloworld_macos/HelloWorld/Info.plist"],
deps = [":HelloWorldMacos-lib"], minimum_os_version = "10.13",
tags = ["manual"], tags = ["manual"],
deps = [":HelloWorldMacos-lib"],
) )
objc_grpc_library( objc_grpc_library(
name = "RouteGuide", name = "RouteGuide",
srcs = ["//examples:protos/route_guide.proto"], srcs = ["//examples:protos/route_guide.proto"],
deps = ["//examples:route_guide_proto"],
tags = ["manual"], tags = ["manual"],
deps = ["//examples:route_guide_proto"],
) )
objc_library( objc_library(
@ -101,8 +101,8 @@ objc_library(
"route_guide/route_guide_db.json", "route_guide/route_guide_db.json",
]), ]),
includes = ["route_guide/Misc"], includes = ["route_guide/Misc"],
deps = [":RouteGuide"],
tags = ["manual"], tags = ["manual"],
deps = [":RouteGuide"],
) )
ios_application( ios_application(
@ -112,8 +112,8 @@ ios_application(
"iphone", "iphone",
"ipad", "ipad",
], ],
minimum_os_version = "8.0",
infoplists = ["route_guide/Misc/Info.plist"], infoplists = ["route_guide/Misc/Info.plist"],
deps = [":RouteGuideClient-lib"], minimum_os_version = "8.0",
tags = ["manual"], tags = ["manual"],
deps = [":RouteGuideClient-lib"],
) )

@ -21,6 +21,7 @@
#import <GRPCClient/GRPCCall+ChannelArg.h> #import <GRPCClient/GRPCCall+ChannelArg.h>
#import <GRPCClient/GRPCCall+Tests.h> #import <GRPCClient/GRPCCall+Tests.h>
#import <GRPCClient/GRPCTransport.h>
#if COCOAPODS #if COCOAPODS
#import <HelloWorld/Helloworld.pbrpc.h> #import <HelloWorld/Helloworld.pbrpc.h>
#else #else
@ -55,14 +56,12 @@ int main(int argc, char * argv[]) {
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
// this example does not use TLS (secure channel); use insecure channel instead // this example does not use TLS (secure channel); use insecure channel instead
options.transportType = GRPCTransportTypeInsecure; options.transport = GRPCDefaultTransportImplList.core_insecure;
options.userAgentPrefix = @"HelloWorld/1.0"; options.userAgentPrefix = @"HelloWorld/1.0";
GRPCUnaryProtoCall *call = [client sayHelloWithMessage:request [[client sayHelloWithMessage:request
responseHandler:[[HLWResponseHandler alloc] init] responseHandler:[[HLWResponseHandler alloc] init]
callOptions:options]; callOptions:options] start];
[call start];
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
} }

@ -20,6 +20,7 @@
#import <GRPCClient/GRPCCall+ChannelArg.h> #import <GRPCClient/GRPCCall+ChannelArg.h>
#import <GRPCClient/GRPCCall+Tests.h> #import <GRPCClient/GRPCCall+Tests.h>
#import <GRPCClient/GRPCTransport.h>
#if COCOAPODS #if COCOAPODS
#import <HelloWorld/Helloworld.pbrpc.h> #import <HelloWorld/Helloworld.pbrpc.h>
#else #else
@ -54,7 +55,7 @@ int main(int argc, const char * argv[]) {
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
// this example does not use TLS (secure channel); use insecure channel instead // this example does not use TLS (secure channel); use insecure channel instead
options.transportType = GRPCTransportTypeInsecure; options.transport = GRPCDefaultTransportImplList.core_insecure;
options.userAgentPrefix = @"HelloWorld/1.0"; options.userAgentPrefix = @"HelloWorld/1.0";
GRPCUnaryProtoCall *call = [client sayHelloWithMessage:request GRPCUnaryProtoCall *call = [client sayHelloWithMessage:request

@ -23,6 +23,8 @@
#import "examples/protos/RouteGuide.pbrpc.h" #import "examples/protos/RouteGuide.pbrpc.h"
#endif #endif
#import <GRPCClient/GRPCTransport.h>
static NSString * const kHostAddress = @"localhost:50051"; static NSString * const kHostAddress = @"localhost:50051";
/** Category to override RTGPoint's description. */ /** Category to override RTGPoint's description. */
@ -123,7 +125,7 @@ static NSString * const kHostAddress = @"localhost:50051";
[super viewDidLoad]; [super viewDidLoad];
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
options.transportType = GRPCTransportTypeInsecure; options.transport = GRPCDefaultTransportImplList.core_insecure;
_service = [[RTGRouteGuide alloc] initWithHost:kHostAddress callOptions:options]; _service = [[RTGRouteGuide alloc] initWithHost:kHostAddress callOptions:options];
} }
@ -193,7 +195,7 @@ static NSString * const kHostAddress = @"localhost:50051";
[super viewDidLoad]; [super viewDidLoad];
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
options.transportType = GRPCTransportTypeInsecure; options.transport = GRPCDefaultTransportImplList.core_insecure;
_service = [[RTGRouteGuide alloc] initWithHost:kHostAddress callOptions:options]; _service = [[RTGRouteGuide alloc] initWithHost:kHostAddress callOptions:options];
} }
@ -286,7 +288,7 @@ static NSString * const kHostAddress = @"localhost:50051";
[super viewDidLoad]; [super viewDidLoad];
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
options.transportType = GRPCTransportTypeInsecure; options.transport = GRPCDefaultTransportImplList.core_insecure;
_service = [[RTGRouteGuide alloc] initWithHost:kHostAddress callOptions:options]; _service = [[RTGRouteGuide alloc] initWithHost:kHostAddress callOptions:options];
} }
@ -360,7 +362,7 @@ static NSString * const kHostAddress = @"localhost:50051";
[super viewDidLoad]; [super viewDidLoad];
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
options.transportType = GRPCTransportTypeInsecure; options.transport = GRPCDefaultTransportImplList.core_insecure;
_service = [[RTGRouteGuide alloc] initWithHost:kHostAddress callOptions:options]; _service = [[RTGRouteGuide alloc] initWithHost:kHostAddress callOptions:options];
} }

@ -16,8 +16,8 @@ filegroup(
name = "_credentials_files", name = "_credentials_files",
testonly = 1, testonly = 1,
srcs = [ srcs = [
"credentials/localhost.key",
"credentials/localhost.crt", "credentials/localhost.crt",
"credentials/localhost.key",
"credentials/root.crt", "credentials/root.crt",
], ],
) )
@ -33,37 +33,37 @@ py_binary(
name = "customized_auth_client", name = "customized_auth_client",
testonly = 1, testonly = 1,
srcs = ["customized_auth_client.py"], srcs = ["customized_auth_client.py"],
python_version = "PY3",
deps = [ deps = [
":_credentials", ":_credentials",
"//src/python/grpcio/grpc:grpcio",
"//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2",
"//examples:helloworld_py_pb2_grpc", "//examples:helloworld_py_pb2_grpc",
"//src/python/grpcio/grpc:grpcio",
], ],
python_version = "PY3",
) )
py_binary( py_binary(
name = "customized_auth_server", name = "customized_auth_server",
testonly = 1, testonly = 1,
srcs = ["customized_auth_server.py"], srcs = ["customized_auth_server.py"],
python_version = "PY3",
deps = [ deps = [
":_credentials", ":_credentials",
"//src/python/grpcio/grpc:grpcio",
"//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2",
"//examples:helloworld_py_pb2_grpc", "//examples:helloworld_py_pb2_grpc",
"//src/python/grpcio/grpc:grpcio",
], ],
python_version = "PY3",
) )
py_test( py_test(
name = "_auth_example_test", name = "_auth_example_test",
srcs = ["test/_auth_example_test.py"], srcs = ["test/_auth_example_test.py"],
python_version = "PY3",
deps = [ deps = [
"//src/python/grpcio/grpc:grpcio", ":_credentials",
"//examples:helloworld_py_pb2",
":customized_auth_client", ":customized_auth_client",
":customized_auth_server", ":customized_auth_server",
":_credentials", "//examples:helloworld_py_pb2",
"//src/python/grpcio/grpc:grpcio",
], ],
python_version = "PY3",
) )

@ -15,7 +15,7 @@
# limitations under the License. # limitations under the License.
load("@grpc_python_dependencies//:requirements.bzl", "requirement") load("@grpc_python_dependencies//:requirements.bzl", "requirement")
load("//bazel:python_rules.bzl", "py_proto_library", "py_grpc_library") load("//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library")
package(default_testonly = 1) package(default_testonly = 1)
@ -38,14 +38,14 @@ py_grpc_library(
py_binary( py_binary(
name = "client", name = "client",
srcs = ["client.py"], srcs = ["client.py"],
python_version = "PY3",
srcs_version = "PY2AND3",
deps = [ deps = [
"//src/python/grpcio/grpc:grpcio",
":hash_name_py_pb2", ":hash_name_py_pb2",
":hash_name_py_pb2_grpc", ":hash_name_py_pb2_grpc",
"//external:six" "//external:six",
"//src/python/grpcio/grpc:grpcio",
], ],
srcs_version = "PY2AND3",
python_version = "PY3",
) )
py_library( py_library(
@ -60,6 +60,8 @@ py_library(
py_binary( py_binary(
name = "server", name = "server",
srcs = ["server.py"], srcs = ["server.py"],
python_version = "PY3",
srcs_version = "PY2AND3",
deps = [ deps = [
"//src/python/grpcio/grpc:grpcio", "//src/python/grpcio/grpc:grpcio",
":hash_name_py_pb2", ":hash_name_py_pb2",
@ -68,17 +70,15 @@ py_binary(
"//conditions:default": ["@futures//:futures"], "//conditions:default": ["@futures//:futures"],
"//:python3": [], "//:python3": [],
}), }),
srcs_version = "PY2AND3",
python_version = "PY3",
) )
py_test( py_test(
name = "test/_cancellation_example_test", name = "test/_cancellation_example_test",
size = "small",
srcs = ["test/_cancellation_example_test.py"], srcs = ["test/_cancellation_example_test.py"],
data = [ data = [
":client", ":client",
":server" ":server",
], ],
size = "small",
python_version = "PY3", python_version = "PY3",
) )

@ -15,35 +15,35 @@
py_binary( py_binary(
name = "server", name = "server",
srcs = ["server.py"], srcs = ["server.py"],
python_version = "PY3",
srcs_version = "PY2AND3",
deps = [ deps = [
"//src/python/grpcio/grpc:grpcio",
"//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2",
"//examples:helloworld_py_pb2_grpc", "//examples:helloworld_py_pb2_grpc",
"//src/python/grpcio/grpc:grpcio",
], ],
srcs_version = "PY2AND3",
python_version = "PY3",
) )
py_binary( py_binary(
name = "client", name = "client",
srcs = ["client.py"], srcs = ["client.py"],
python_version = "PY3",
srcs_version = "PY2AND3",
deps = [ deps = [
"//src/python/grpcio/grpc:grpcio",
"//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2",
"//examples:helloworld_py_pb2_grpc", "//examples:helloworld_py_pb2_grpc",
"//src/python/grpcio/grpc:grpcio",
], ],
srcs_version = "PY2AND3",
python_version = "PY3",
) )
py_test( py_test(
name = "test/compression_example_test", name = "test/compression_example_test",
size = "small",
srcs = ["test/compression_example_test.py"], srcs = ["test/compression_example_test.py"],
srcs_version = "PY2AND3",
data = [ data = [
":client", ":client",
":server", ":server",
], ],
size = "small",
python_version = "PY3", python_version = "PY3",
srcs_version = "PY2AND3",
) )

@ -19,10 +19,10 @@ py_binary(
testonly = 1, testonly = 1,
srcs = ["debug_server.py"], srcs = ["debug_server.py"],
deps = [ deps = [
"//src/python/grpcio/grpc:grpcio",
"//src/python/grpcio_channelz/grpc_channelz/v1:grpc_channelz",
"//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2",
"//examples:helloworld_py_pb2_grpc", "//examples:helloworld_py_pb2_grpc",
"//src/python/grpcio/grpc:grpcio",
"//src/python/grpcio_channelz/grpc_channelz/v1:grpc_channelz",
], ],
) )
@ -30,36 +30,36 @@ py_binary(
name = "send_message", name = "send_message",
testonly = 1, testonly = 1,
srcs = ["send_message.py"], srcs = ["send_message.py"],
python_version = "PY3",
deps = [ deps = [
"//src/python/grpcio/grpc:grpcio",
"//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2",
"//examples:helloworld_py_pb2_grpc", "//examples:helloworld_py_pb2_grpc",
"//src/python/grpcio/grpc:grpcio",
], ],
python_version = "PY3",
) )
py_binary( py_binary(
name = "get_stats", name = "get_stats",
testonly = 1, testonly = 1,
srcs = ["get_stats.py"], srcs = ["get_stats.py"],
python_version = "PY3",
deps = [ deps = [
"//src/python/grpcio/grpc:grpcio", "//src/python/grpcio/grpc:grpcio",
"//src/python/grpcio_channelz/grpc_channelz/v1:grpc_channelz", "//src/python/grpcio_channelz/grpc_channelz/v1:grpc_channelz",
], ],
python_version = "PY3",
) )
py_test( py_test(
name = "_debug_example_test", name = "_debug_example_test",
srcs = ["test/_debug_example_test.py"], srcs = ["test/_debug_example_test.py"],
python_version = "PY3",
deps = [ deps = [
"//src/python/grpcio/grpc:grpcio",
"//src/python/grpcio_channelz/grpc_channelz/v1:grpc_channelz",
"//examples:helloworld_py_pb2",
"//examples:helloworld_py_pb2_grpc",
":debug_server", ":debug_server",
":send_message",
":get_stats", ":get_stats",
":send_message",
"//examples:helloworld_py_pb2",
"//examples:helloworld_py_pb2_grpc",
"//src/python/grpcio/grpc:grpcio",
"//src/python/grpcio_channelz/grpc_channelz/v1:grpc_channelz",
], ],
python_version = "PY3",
) )

@ -19,11 +19,11 @@ py_library(
testonly = 1, testonly = 1,
srcs = ["client.py"], srcs = ["client.py"],
deps = [ deps = [
"//src/python/grpcio/grpc:grpcio",
"//src/python/grpcio_status/grpc_status:grpc_status",
"//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2",
"//examples:helloworld_py_pb2_grpc", "//examples:helloworld_py_pb2_grpc",
requirement('googleapis-common-protos'), "//src/python/grpcio/grpc:grpcio",
"//src/python/grpcio_status/grpc_status",
requirement("googleapis-common-protos"),
], ],
) )
@ -44,16 +44,16 @@ py_library(
py_test( py_test(
name = "test/_error_handling_example_test", name = "test/_error_handling_example_test",
srcs = ["test/_error_handling_example_test.py"],
deps = [
":client",
":server",
"//src/python/grpcio_tests/tests:bazel_namespace_package_hack",
],
size = "small", size = "small",
srcs = ["test/_error_handling_example_test.py"],
imports = [ imports = [
"../../../src/python/grpcio_status", "../../../src/python/grpcio_status",
"../../../src/python/grpcio_tests", "../../../src/python/grpcio_tests",
], ],
python_version = "PY3", python_version = "PY3",
deps = [
":client",
":server",
"//src/python/grpcio_tests/tests:bazel_namespace_package_hack",
],
) )

@ -14,11 +14,11 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
load("//bazel:python_rules.bzl", "py_proto_library", "py_grpc_library") load("//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library")
proto_library( proto_library(
name = "prime_proto", name = "prime_proto",
srcs = ["prime.proto"] srcs = ["prime.proto"],
) )
py_proto_library( py_proto_library(
@ -36,19 +36,21 @@ py_binary(
name = "client", name = "client",
testonly = 1, testonly = 1,
srcs = ["client.py"], srcs = ["client.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [ deps = [
"//src/python/grpcio/grpc:grpcio",
":prime_proto_pb2", ":prime_proto_pb2",
":prime_proto_pb2_grpc", ":prime_proto_pb2_grpc",
"//src/python/grpcio/grpc:grpcio",
], ],
srcs_version = "PY3",
python_version = "PY3",
) )
py_binary( py_binary(
name = "server", name = "server",
testonly = 1, testonly = 1,
srcs = ["server.py"], srcs = ["server.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [ deps = [
"//src/python/grpcio/grpc:grpcio", "//src/python/grpcio/grpc:grpcio",
":prime_proto_pb2", ":prime_proto_pb2",
@ -57,17 +59,15 @@ py_binary(
"//conditions:default": ["@futures//:futures"], "//conditions:default": ["@futures//:futures"],
"//:python3": [], "//:python3": [],
}), }),
srcs_version = "PY3",
python_version = "PY3",
) )
py_test( py_test(
name = "test/_multiprocessing_example_test", name = "test/_multiprocessing_example_test",
size = "small",
srcs = ["test/_multiprocessing_example_test.py"], srcs = ["test/_multiprocessing_example_test.py"],
data = [ data = [
":client", ":client",
":server" ":server",
], ],
size = "small",
python_version = "PY3", python_version = "PY3",
) )

@ -19,16 +19,16 @@ py_library(
testonly = 1, testonly = 1,
srcs = ["wait_for_ready_example.py"], srcs = ["wait_for_ready_example.py"],
deps = [ deps = [
"//src/python/grpcio/grpc:grpcio",
"//examples:helloworld_py_pb2", "//examples:helloworld_py_pb2",
"//examples:helloworld_py_pb2_grpc", "//examples:helloworld_py_pb2_grpc",
"//src/python/grpcio/grpc:grpcio",
], ],
) )
py_test( py_test(
name = "test/_wait_for_ready_example_test", name = "test/_wait_for_ready_example_test",
srcs = ["test/_wait_for_ready_example_test.py"],
deps = [":wait_for_ready_example",],
size = "small", size = "small",
srcs = ["test/_wait_for_ready_example_test.py"],
python_version = "PY3", python_version = "PY3",
deps = [":wait_for_ready_example"],
) )

@ -337,7 +337,6 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/orphanable.h', 'src/core/lib/gprpp/orphanable.h',
'src/core/lib/gprpp/ref_counted.h', 'src/core/lib/gprpp/ref_counted.h',
'src/core/lib/gprpp/ref_counted_ptr.h', 'src/core/lib/gprpp/ref_counted_ptr.h',
'src/core/lib/gprpp/set.h',
'src/core/lib/gprpp/string_view.h', 'src/core/lib/gprpp/string_view.h',
'src/core/lib/gprpp/sync.h', 'src/core/lib/gprpp/sync.h',
'src/core/lib/gprpp/thd.h', 'src/core/lib/gprpp/thd.h',
@ -465,15 +464,7 @@ Pod::Spec.new do |s|
'src/cpp/server/health/default_health_check_service.h', 'src/cpp/server/health/default_health_check_service.h',
'src/cpp/server/secure_server_credentials.h', 'src/cpp/server/secure_server_credentials.h',
'src/cpp/server/thread_pool_interface.h', 'src/cpp/server/thread_pool_interface.h',
'src/cpp/thread_manager/thread_manager.h', 'src/cpp/thread_manager/thread_manager.h'
'third_party/upb/upb/decode.h',
'third_party/upb/upb/encode.h',
'third_party/upb/upb/generated_util.h',
'third_party/upb/upb/msg.h',
'third_party/upb/upb/port_def.inc',
'third_party/upb/upb/port_undef.inc',
'third_party/upb/upb/table.int.h',
'third_party/upb/upb/upb.h'
end end
s.subspec 'Protobuf' do |ss| s.subspec 'Protobuf' do |ss|

@ -563,7 +563,6 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/orphanable.h', 'src/core/lib/gprpp/orphanable.h',
'src/core/lib/gprpp/ref_counted.h', 'src/core/lib/gprpp/ref_counted.h',
'src/core/lib/gprpp/ref_counted_ptr.h', 'src/core/lib/gprpp/ref_counted_ptr.h',
'src/core/lib/gprpp/set.h',
'src/core/lib/gprpp/string_view.h', 'src/core/lib/gprpp/string_view.h',
'src/core/lib/gprpp/sync.h', 'src/core/lib/gprpp/sync.h',
'src/core/lib/gprpp/thd.h', 'src/core/lib/gprpp/thd.h',
@ -1146,7 +1145,6 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/orphanable.h', 'src/core/lib/gprpp/orphanable.h',
'src/core/lib/gprpp/ref_counted.h', 'src/core/lib/gprpp/ref_counted.h',
'src/core/lib/gprpp/ref_counted_ptr.h', 'src/core/lib/gprpp/ref_counted_ptr.h',
'src/core/lib/gprpp/set.h',
'src/core/lib/gprpp/string_view.h', 'src/core/lib/gprpp/string_view.h',
'src/core/lib/gprpp/sync.h', 'src/core/lib/gprpp/sync.h',
'src/core/lib/gprpp/thd.h', 'src/core/lib/gprpp/thd.h',

@ -22,18 +22,18 @@ This file declares two macros:
def _lower_underscore_to_upper_camel(str): def _lower_underscore_to_upper_camel(str):
humps = [] humps = []
for hump in str.split('_'): for hump in str.split("_"):
humps += [hump[0].upper() + hump[1:]] humps += [hump[0].upper() + hump[1:]]
return "".join(humps) return "".join(humps)
def _file_to_upper_camel(src): def _file_to_upper_camel(src):
elements = src.rpartition('/') elements = src.rpartition("/")
upper_camel = _lower_underscore_to_upper_camel(elements[-1]) upper_camel = _lower_underscore_to_upper_camel(elements[-1])
return "".join(elements[:-1] + [upper_camel]) return "".join(elements[:-1] + [upper_camel])
def _file_with_extension(src, ext): def _file_with_extension(src, ext):
elements = src.rpartition('/') elements = src.rpartition("/")
basename = elements[-1].partition('.')[0] basename = elements[-1].partition(".")[0]
return "".join(elements[:-1] + [basename, ext]) return "".join(elements[:-1] + [basename, ext])
def _protoc_invocation(srcs, flags): def _protoc_invocation(srcs, flags):
@ -46,7 +46,7 @@ def _protoc_invocation(srcs, flags):
srcs_params += " $(location %s)" % (src) srcs_params += " $(location %s)" % (src)
return protoc_command + flags + srcs_params return protoc_command + flags + srcs_params
def objc_proto_library(name, srcs, visibility=None): def objc_proto_library(name, srcs, visibility = None):
"""Declares an objc_library for the code generated by protoc from the given """Declares an objc_library for the code generated by protoc from the given
proto sources. This generated code doesn't include proto services. proto sources. This generated code doesn't include proto services.
""" """
@ -74,7 +74,7 @@ def objc_proto_library(name, srcs, visibility=None):
visibility = visibility, visibility = visibility,
) )
def objc_grpc_library(name, services, other_messages, visibility=None): def objc_grpc_library(name, services, other_messages, visibility = None):
"""Declares an objc_library for the code generated by gRPC and protoc from the """Declares an objc_library for the code generated by gRPC and protoc from the
given proto sources (services and other_messages). The generated code doesn't given proto sources (services and other_messages). The generated code doesn't
include proto services of the files passed as other_messages. include proto services of the files passed as other_messages.

@ -217,8 +217,6 @@ EXPORTS
gpr_realloc gpr_realloc
gpr_malloc_aligned gpr_malloc_aligned
gpr_free_aligned gpr_free_aligned
gpr_set_allocation_functions
gpr_get_allocation_functions
gpr_cpu_num_cores gpr_cpu_num_cores
gpr_cpu_current_cpu gpr_cpu_current_cpu
gpr_format_message gpr_format_message

@ -108,7 +108,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/gprpp/map.h ) s.files += %w( src/core/lib/gprpp/map.h )
s.files += %w( src/core/lib/gprpp/memory.h ) s.files += %w( src/core/lib/gprpp/memory.h )
s.files += %w( src/core/lib/gprpp/mpscq.h ) s.files += %w( src/core/lib/gprpp/mpscq.h )
s.files += %w( src/core/lib/gprpp/set.h )
s.files += %w( src/core/lib/gprpp/sync.h ) s.files += %w( src/core/lib/gprpp/sync.h )
s.files += %w( src/core/lib/gprpp/thd.h ) s.files += %w( src/core/lib/gprpp/thd.h )
s.files += %w( src/core/lib/profiling/timers.h ) s.files += %w( src/core/lib/profiling/timers.h )
@ -270,14 +269,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h ) s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h )
s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h ) s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h )
s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h ) s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h )
s.files += %w( third_party/upb/upb/decode.h )
s.files += %w( third_party/upb/upb/encode.h )
s.files += %w( third_party/upb/upb/generated_util.h )
s.files += %w( third_party/upb/upb/msg.h )
s.files += %w( third_party/upb/upb/port_def.inc )
s.files += %w( third_party/upb/upb/port_undef.inc )
s.files += %w( third_party/upb/upb/table.int.h )
s.files += %w( third_party/upb/upb/upb.h )
s.files += %w( src/core/tsi/transport_security.h ) s.files += %w( src/core/tsi/transport_security.h )
s.files += %w( src/core/tsi/transport_security_interface.h ) s.files += %w( src/core/tsi/transport_security_interface.h )
s.files += %w( src/core/ext/transport/chttp2/client/authority.h ) s.files += %w( src/core/ext/transport/chttp2/client/authority.h )
@ -775,12 +766,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c ) s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c )
s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c ) s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c )
s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c ) s.files += %w( src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c )
s.files += %w( third_party/upb/upb/decode.c )
s.files += %w( third_party/upb/upb/encode.c )
s.files += %w( third_party/upb/upb/msg.c )
s.files += %w( third_party/upb/upb/port.c )
s.files += %w( third_party/upb/upb/table.c )
s.files += %w( third_party/upb/upb/upb.c )
s.files += %w( src/core/tsi/transport_security.cc ) s.files += %w( src/core/tsi/transport_security.cc )
s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create.cc ) s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create.cc )
s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc ) s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc )
@ -1354,6 +1339,20 @@ Gem::Specification.new do |s|
s.files += %w( third_party/boringssl/ssl/tls_method.cc ) s.files += %w( third_party/boringssl/ssl/tls_method.cc )
s.files += %w( third_party/boringssl/ssl/tls_record.cc ) s.files += %w( third_party/boringssl/ssl/tls_record.cc )
s.files += %w( third_party/boringssl/third_party/fiat/curve25519.c ) s.files += %w( third_party/boringssl/third_party/fiat/curve25519.c )
s.files += %w( third_party/upb/upb/decode.h )
s.files += %w( third_party/upb/upb/encode.h )
s.files += %w( third_party/upb/upb/generated_util.h )
s.files += %w( third_party/upb/upb/msg.h )
s.files += %w( third_party/upb/upb/port_def.inc )
s.files += %w( third_party/upb/upb/port_undef.inc )
s.files += %w( third_party/upb/upb/table.int.h )
s.files += %w( third_party/upb/upb/upb.h )
s.files += %w( third_party/upb/upb/decode.c )
s.files += %w( third_party/upb/upb/encode.c )
s.files += %w( third_party/upb/upb/msg.c )
s.files += %w( third_party/upb/upb/port.c )
s.files += %w( third_party/upb/upb/table.c )
s.files += %w( third_party/upb/upb/upb.c )
s.files += %w( third_party/zlib/crc32.h ) s.files += %w( third_party/zlib/crc32.h )
s.files += %w( third_party/zlib/deflate.h ) s.files += %w( third_party/zlib/deflate.h )
s.files += %w( third_party/zlib/gzguts.h ) s.files += %w( third_party/zlib/gzguts.h )

@ -225,6 +225,7 @@
'type': 'static_library', 'type': 'static_library',
'dependencies': [ 'dependencies': [
'gpr', 'gpr',
'upb',
], ],
'sources': [ 'sources': [
'src/core/lib/surface/init.cc', 'src/core/lib/surface/init.cc',
@ -481,12 +482,6 @@
'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c', 'src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c',
'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c', 'src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c',
'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c', 'src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c',
'third_party/upb/upb/decode.c',
'third_party/upb/upb/encode.c',
'third_party/upb/upb/msg.c',
'third_party/upb/upb/port.c',
'third_party/upb/upb/table.c',
'third_party/upb/upb/upb.c',
'src/core/tsi/transport_security.cc', 'src/core/tsi/transport_security.cc',
'src/core/ext/transport/chttp2/client/insecure/channel_create.cc', 'src/core/ext/transport/chttp2/client/insecure/channel_create.cc',
'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc', 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc',
@ -614,6 +609,7 @@
'dependencies': [ 'dependencies': [
'gpr', 'gpr',
'grpc', 'grpc',
'upb',
], ],
'sources': [ 'sources': [
'test/core/end2end/data/client_certs.cc', 'test/core/end2end/data/client_certs.cc',
@ -833,12 +829,6 @@
'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc',
'src/core/ext/filters/deadline/deadline_filter.cc', 'src/core/ext/filters/deadline/deadline_filter.cc',
'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c',
'third_party/upb/upb/decode.c',
'third_party/upb/upb/encode.c',
'third_party/upb/upb/msg.c',
'third_party/upb/upb/port.c',
'third_party/upb/upb/table.c',
'third_party/upb/upb/upb.c',
'src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c', 'src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c',
'src/core/ext/upb-generated/gogoproto/gogo.upb.c', 'src/core/ext/upb-generated/gogoproto/gogo.upb.c',
'src/core/ext/upb-generated/validate/validate.upb.c', 'src/core/ext/upb-generated/validate/validate.upb.c',
@ -888,6 +878,7 @@
'dependencies': [ 'dependencies': [
'gpr', 'gpr',
'grpc_unsecure', 'grpc_unsecure',
'upb',
], ],
'sources': [ 'sources': [
'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc',
@ -1102,12 +1093,6 @@
'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc',
'src/core/ext/filters/deadline/deadline_filter.cc', 'src/core/ext/filters/deadline/deadline_filter.cc',
'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c',
'third_party/upb/upb/decode.c',
'third_party/upb/upb/encode.c',
'third_party/upb/upb/msg.c',
'third_party/upb/upb/port.c',
'third_party/upb/upb/table.c',
'third_party/upb/upb/upb.c',
'src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c', 'src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c',
'src/core/ext/upb-generated/gogoproto/gogo.upb.c', 'src/core/ext/upb-generated/gogoproto/gogo.upb.c',
'src/core/ext/upb-generated/validate/validate.upb.c', 'src/core/ext/upb-generated/validate/validate.upb.c',
@ -1156,6 +1141,7 @@
'type': 'static_library', 'type': 'static_library',
'dependencies': [ 'dependencies': [
'gpr', 'gpr',
'upb',
], ],
'sources': [ 'sources': [
'src/core/lib/surface/init.cc', 'src/core/lib/surface/init.cc',
@ -1382,12 +1368,6 @@
'src/core/ext/filters/client_channel/subchannel_pool_interface.cc', 'src/core/ext/filters/client_channel/subchannel_pool_interface.cc',
'src/core/ext/filters/deadline/deadline_filter.cc', 'src/core/ext/filters/deadline/deadline_filter.cc',
'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c',
'third_party/upb/upb/decode.c',
'third_party/upb/upb/encode.c',
'third_party/upb/upb/msg.c',
'third_party/upb/upb/port.c',
'third_party/upb/upb/table.c',
'third_party/upb/upb/upb.c',
'src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c', 'src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c',
'src/core/ext/upb-generated/gogoproto/gogo.upb.c', 'src/core/ext/upb-generated/gogoproto/gogo.upb.c',
'src/core/ext/upb-generated/validate/validate.upb.c', 'src/core/ext/upb-generated/validate/validate.upb.c',
@ -1522,6 +1502,7 @@
'dependencies': [ 'dependencies': [
'grpc', 'grpc',
'gpr', 'gpr',
'upb',
], ],
'sources': [ 'sources': [
'src/cpp/client/insecure_credentials.cc', 'src/cpp/client/insecure_credentials.cc',
@ -1570,12 +1551,6 @@
'src/cpp/util/string_ref.cc', 'src/cpp/util/string_ref.cc',
'src/cpp/util/time_cc.cc', 'src/cpp/util/time_cc.cc',
'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c',
'third_party/upb/upb/decode.c',
'third_party/upb/upb/encode.c',
'third_party/upb/upb/msg.c',
'third_party/upb/upb/port.c',
'third_party/upb/upb/table.c',
'third_party/upb/upb/upb.c',
'src/cpp/codegen/codegen_init.cc', 'src/cpp/codegen/codegen_init.cc',
], ],
}, },
@ -1689,6 +1664,7 @@
'dependencies': [ 'dependencies': [
'gpr', 'gpr',
'grpc_unsecure', 'grpc_unsecure',
'upb',
], ],
'sources': [ 'sources': [
'src/cpp/client/insecure_credentials.cc', 'src/cpp/client/insecure_credentials.cc',
@ -1730,12 +1706,6 @@
'src/cpp/util/string_ref.cc', 'src/cpp/util/string_ref.cc',
'src/cpp/util/time_cc.cc', 'src/cpp/util/time_cc.cc',
'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c', 'src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c',
'third_party/upb/upb/decode.c',
'third_party/upb/upb/encode.c',
'third_party/upb/upb/msg.c',
'third_party/upb/upb/port.c',
'third_party/upb/upb/table.c',
'third_party/upb/upb/upb.c',
'src/cpp/codegen/codegen_init.cc', 'src/cpp/codegen/codegen_init.cc',
], ],
}, },
@ -2247,6 +2217,20 @@
'third_party/benchmark/src/timers.cc', 'third_party/benchmark/src/timers.cc',
], ],
}, },
{
'target_name': 'upb',
'type': 'static_library',
'dependencies': [
],
'sources': [
'third_party/upb/upb/decode.c',
'third_party/upb/upb/encode.c',
'third_party/upb/upb/msg.c',
'third_party/upb/upb/port.c',
'third_party/upb/upb/table.c',
'third_party/upb/upb/upb.c',
],
},
{ {
'target_name': 'z', 'target_name': 'z',
'type': 'static_library', 'type': 'static_library',

@ -27,6 +27,13 @@
* - some syscalls to be made directly * - some syscalls to be made directly
*/ */
/*
* Defines GRPC_USE_ABSL to use Abseil Common Libraries (C++)
*/
#ifndef GRPC_USE_ABSL
#define GRPC_USE_ABSL 0
#endif
/* Get windows.h included everywhere (we need it) */ /* Get windows.h included everywhere (we need it) */
#if defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32) #if defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32)
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN

@ -27,13 +27,6 @@
extern "C" { extern "C" {
#endif #endif
typedef struct gpr_allocation_functions {
void* (*malloc_fn)(size_t size);
void* (*zalloc_fn)(size_t size); /** if NULL, uses malloc_fn then memset */
void* (*realloc_fn)(void* ptr, size_t size);
void (*free_fn)(void* ptr);
} gpr_allocation_functions;
/** malloc. /** malloc.
* If size==0, always returns NULL. Otherwise this function never returns NULL. * If size==0, always returns NULL. Otherwise this function never returns NULL.
* The pointer returned is suitably aligned for any kind of variable it could * The pointer returned is suitably aligned for any kind of variable it could
@ -52,15 +45,6 @@ GPRAPI void* gpr_malloc_aligned(size_t size, size_t alignment);
/** free memory allocated by gpr_malloc_aligned */ /** free memory allocated by gpr_malloc_aligned */
GPRAPI void gpr_free_aligned(void* ptr); GPRAPI void gpr_free_aligned(void* ptr);
/** Request the family of allocation functions in \a functions be used. NOTE
* that this request will be honored in a *best effort* basis and that no
* guarantees are made about the default functions (eg, malloc) being called.
* The functions.free_fn implementation must be a no-op for NULL input. */
GPRAPI void gpr_set_allocation_functions(gpr_allocation_functions functions);
/** Return the family of allocation functions currently in effect. */
GPRAPI gpr_allocation_functions gpr_get_allocation_functions(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

@ -62,12 +62,12 @@ class MethodHandler {
internal_data(handler_data), internal_data(handler_data),
call_requester(std::move(requester)) {} call_requester(std::move(requester)) {}
~HandlerParameter() {} ~HandlerParameter() {}
Call* call; Call* const call;
::grpc_impl::ServerContext* server_context; ::grpc_impl::ServerContext* const server_context;
void* request; void* const request;
Status status; const Status status;
void* internal_data; void* const internal_data;
std::function<void()> call_requester; const std::function<void()> call_requester;
}; };
virtual void RunHandler(const HandlerParameter& param) = 0; virtual void RunHandler(const HandlerParameter& param) = 0;

@ -113,7 +113,6 @@
<file baseinstalldir="/" name="src/core/lib/gprpp/map.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/gprpp/map.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/memory.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/gprpp/memory.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/mpscq.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/gprpp/mpscq.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/set.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/sync.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/gprpp/sync.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/thd.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/gprpp/thd.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/profiling/timers.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/profiling/timers.h" role="src" />
@ -275,14 +274,6 @@
<file baseinstalldir="/" name="src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/decode.h" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/encode.h" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/generated_util.h" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/msg.h" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/port_def.inc" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/port_undef.inc" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/table.int.h" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/upb.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/transport_security.h" role="src" /> <file baseinstalldir="/" name="src/core/tsi/transport_security.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/transport_security_interface.h" role="src" /> <file baseinstalldir="/" name="src/core/tsi/transport_security_interface.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/authority.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/authority.h" role="src" />
@ -780,12 +771,6 @@
<file baseinstalldir="/" name="src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/decode.c" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/encode.c" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/msg.c" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/port.c" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/table.c" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/upb.c" role="src" />
<file baseinstalldir="/" name="src/core/tsi/transport_security.cc" role="src" /> <file baseinstalldir="/" name="src/core/tsi/transport_security.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create.cc" role="src" /> <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc" role="src" /> <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc" role="src" />
@ -1359,6 +1344,20 @@
<file baseinstalldir="/" name="third_party/boringssl/ssl/tls_method.cc" role="src" /> <file baseinstalldir="/" name="third_party/boringssl/ssl/tls_method.cc" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/ssl/tls_record.cc" role="src" /> <file baseinstalldir="/" name="third_party/boringssl/ssl/tls_record.cc" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/third_party/fiat/curve25519.c" role="src" /> <file baseinstalldir="/" name="third_party/boringssl/third_party/fiat/curve25519.c" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/decode.h" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/encode.h" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/generated_util.h" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/msg.h" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/port_def.inc" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/port_undef.inc" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/table.int.h" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/upb.h" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/decode.c" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/encode.c" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/msg.c" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/port.c" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/table.c" role="src" />
<file baseinstalldir="/" name="third_party/upb/upb/upb.c" role="src" />
<file baseinstalldir="/" name="third_party/zlib/crc32.h" role="src" /> <file baseinstalldir="/" name="third_party/zlib/crc32.h" role="src" />
<file baseinstalldir="/" name="third_party/zlib/deflate.h" role="src" /> <file baseinstalldir="/" name="third_party/zlib/deflate.h" role="src" />
<file baseinstalldir="/" name="third_party/zlib/gzguts.h" role="src" /> <file baseinstalldir="/" name="third_party/zlib/gzguts.h" role="src" />

@ -44,8 +44,8 @@ grpc_cc_library(
"ruby_generator.cc", "ruby_generator.cc",
], ],
hdrs = [ hdrs = [
"config_protobuf.h",
"config.h", "config.h",
"config_protobuf.h",
"cpp_generator.h", "cpp_generator.h",
"cpp_generator_helpers.h", "cpp_generator_helpers.h",
"cpp_plugin.h", "cpp_plugin.h",

@ -26,12 +26,12 @@ namespace grpc_core {
namespace { namespace {
template <typename EntryType> template <typename EntryType>
Map<StringView, double, StringLess> ParseMap( std::map<StringView, double, StringLess> ParseMap(
udpa_data_orca_v1_OrcaLoadReport* msg, udpa_data_orca_v1_OrcaLoadReport* msg,
EntryType** (*entry_func)(udpa_data_orca_v1_OrcaLoadReport*, size_t*), EntryType** (*entry_func)(udpa_data_orca_v1_OrcaLoadReport*, size_t*),
upb_strview (*key_func)(const EntryType*), upb_strview (*key_func)(const EntryType*),
double (*value_func)(const EntryType*), Arena* arena) { double (*value_func)(const EntryType*), Arena* arena) {
Map<StringView, double, StringLess> result; std::map<StringView, double, StringLess> result;
size_t size; size_t size;
const auto* const* entries = entry_func(msg, &size); const auto* const* entries = entry_func(msg, &size);
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {

@ -26,6 +26,8 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <set>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
@ -53,7 +55,6 @@
#include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/inlined_vector.h"
#include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/gprpp/map.h" #include "src/core/lib/gprpp/map.h"
#include "src/core/lib/gprpp/set.h"
#include "src/core/lib/gprpp/sync.h" #include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/iomgr/iomgr.h"
@ -161,7 +162,7 @@ class ChannelData {
MutexLock lock(&external_watchers_mu_); MutexLock lock(&external_watchers_mu_);
// Will be deleted when the watch is complete. // Will be deleted when the watch is complete.
GPR_ASSERT(external_watchers_[on_complete] == nullptr); GPR_ASSERT(external_watchers_[on_complete] == nullptr);
external_watchers_[on_complete] = New<ExternalConnectivityWatcher>( external_watchers_[on_complete] = new ExternalConnectivityWatcher(
this, pollent, state, on_complete, watcher_timer_init); this, pollent, state, on_complete, watcher_timer_init);
} }
@ -227,7 +228,7 @@ class ChannelData {
void UpdateStateAndPickerLocked( void UpdateStateAndPickerLocked(
grpc_connectivity_state state, const char* reason, grpc_connectivity_state state, const char* reason,
UniquePtr<LoadBalancingPolicy::SubchannelPicker> picker); std::unique_ptr<LoadBalancingPolicy::SubchannelPicker> picker);
void UpdateServiceConfigLocked( void UpdateServiceConfigLocked(
RefCountedPtr<ServerRetryThrottleData> retry_throttle_data, RefCountedPtr<ServerRetryThrottleData> retry_throttle_data,
@ -251,7 +252,7 @@ class ChannelData {
void ProcessLbPolicy( void ProcessLbPolicy(
const Resolver::Result& resolver_result, const Resolver::Result& resolver_result,
const internal::ClientChannelGlobalParsedConfig* parsed_service_config, const internal::ClientChannelGlobalParsedConfig* parsed_service_config,
UniquePtr<char>* lb_policy_name, std::unique_ptr<char>* lb_policy_name,
RefCountedPtr<LoadBalancingPolicy::Config>* lb_policy_config); RefCountedPtr<LoadBalancingPolicy::Config>* lb_policy_config);
// //
@ -264,15 +265,15 @@ class ChannelData {
ClientChannelFactory* client_channel_factory_; ClientChannelFactory* client_channel_factory_;
const grpc_channel_args* channel_args_; const grpc_channel_args* channel_args_;
RefCountedPtr<ServiceConfig> default_service_config_; RefCountedPtr<ServiceConfig> default_service_config_;
UniquePtr<char> server_name_; std::unique_ptr<char> server_name_;
UniquePtr<char> target_uri_; std::unique_ptr<char> target_uri_;
channelz::ChannelNode* channelz_node_; channelz::ChannelNode* channelz_node_;
// //
// Fields used in the data plane. Guarded by data_plane_mu. // Fields used in the data plane. Guarded by data_plane_mu.
// //
mutable Mutex data_plane_mu_; mutable Mutex data_plane_mu_;
UniquePtr<LoadBalancingPolicy::SubchannelPicker> picker_; std::unique_ptr<LoadBalancingPolicy::SubchannelPicker> picker_;
QueuedPick* queued_picks_ = nullptr; // Linked list of queued picks. QueuedPick* queued_picks_ = nullptr; // Linked list of queued picks.
// Data from service config. // Data from service config.
bool received_service_config_data_ = false; bool received_service_config_data_ = false;
@ -287,19 +288,19 @@ class ChannelData {
RefCountedPtr<SubchannelPoolInterface> subchannel_pool_; RefCountedPtr<SubchannelPoolInterface> subchannel_pool_;
OrphanablePtr<ResolvingLoadBalancingPolicy> resolving_lb_policy_; OrphanablePtr<ResolvingLoadBalancingPolicy> resolving_lb_policy_;
ConnectivityStateTracker state_tracker_; ConnectivityStateTracker state_tracker_;
UniquePtr<char> health_check_service_name_; std::unique_ptr<char> health_check_service_name_;
RefCountedPtr<ServiceConfig> saved_service_config_; RefCountedPtr<ServiceConfig> saved_service_config_;
bool received_first_resolver_result_ = false; bool received_first_resolver_result_ = false;
// The number of SubchannelWrapper instances referencing a given Subchannel. // The number of SubchannelWrapper instances referencing a given Subchannel.
Map<Subchannel*, int> subchannel_refcount_map_; std::map<Subchannel*, int> subchannel_refcount_map_;
// The set of SubchannelWrappers that currently exist. // The set of SubchannelWrappers that currently exist.
// No need to hold a ref, since the map is updated in the control-plane // No need to hold a ref, since the map is updated in the control-plane
// combiner when the SubchannelWrappers are created and destroyed. // combiner when the SubchannelWrappers are created and destroyed.
Set<SubchannelWrapper*> subchannel_wrappers_; std::set<SubchannelWrapper*> subchannel_wrappers_;
// Pending ConnectedSubchannel updates for each SubchannelWrapper. // Pending ConnectedSubchannel updates for each SubchannelWrapper.
// Updates are queued here in the control plane combiner and then applied // Updates are queued here in the control plane combiner and then applied
// in the data plane mutex when the picker is updated. // in the data plane mutex when the picker is updated.
Map<RefCountedPtr<SubchannelWrapper>, RefCountedPtr<ConnectedSubchannel>, std::map<RefCountedPtr<SubchannelWrapper>, RefCountedPtr<ConnectedSubchannel>,
RefCountedPtrLess<SubchannelWrapper>> RefCountedPtrLess<SubchannelWrapper>>
pending_subchannel_updates_; pending_subchannel_updates_;
@ -313,15 +314,15 @@ class ChannelData {
// synchronously via get_channel_info(). // synchronously via get_channel_info().
// //
gpr_mu info_mu_; gpr_mu info_mu_;
UniquePtr<char> info_lb_policy_name_; std::unique_ptr<char> info_lb_policy_name_;
UniquePtr<char> info_service_config_json_; std::unique_ptr<char> info_service_config_json_;
// //
// Fields guarded by a mutex, since they need to be accessed // Fields guarded by a mutex, since they need to be accessed
// synchronously via grpc_channel_num_external_connectivity_watchers(). // synchronously via grpc_channel_num_external_connectivity_watchers().
// //
mutable Mutex external_watchers_mu_; mutable Mutex external_watchers_mu_;
Map<grpc_closure*, ExternalConnectivityWatcher*> external_watchers_; std::map<grpc_closure*, ExternalConnectivityWatcher*> external_watchers_;
}; };
// //
@ -403,8 +404,9 @@ class CallData {
intptr_t handle) const override { intptr_t handle) const override {
grpc_linked_mdelem* linked_mdelem = grpc_linked_mdelem* linked_mdelem =
reinterpret_cast<grpc_linked_mdelem*>(handle); reinterpret_cast<grpc_linked_mdelem*>(handle);
return std::make_pair(StringView(GRPC_MDKEY(linked_mdelem->md)), return std::make_pair(
StringView(GRPC_MDVALUE(linked_mdelem->md))); StringViewFromSlice(GRPC_MDKEY(linked_mdelem->md)),
StringViewFromSlice(GRPC_MDVALUE(linked_mdelem->md)));
} }
CallData* calld_; CallData* calld_;
@ -841,7 +843,7 @@ class CallData {
class ChannelData::SubchannelWrapper : public SubchannelInterface { class ChannelData::SubchannelWrapper : public SubchannelInterface {
public: public:
SubchannelWrapper(ChannelData* chand, Subchannel* subchannel, SubchannelWrapper(ChannelData* chand, Subchannel* subchannel,
UniquePtr<char> health_check_service_name) std::unique_ptr<char> health_check_service_name)
: SubchannelInterface(&grpc_client_channel_routing_trace), : SubchannelInterface(&grpc_client_channel_routing_trace),
chand_(chand), chand_(chand),
subchannel_(subchannel), subchannel_(subchannel),
@ -896,15 +898,15 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface {
void WatchConnectivityState( void WatchConnectivityState(
grpc_connectivity_state initial_state, grpc_connectivity_state initial_state,
UniquePtr<ConnectivityStateWatcherInterface> watcher) override { std::unique_ptr<ConnectivityStateWatcherInterface> watcher) override {
auto& watcher_wrapper = watcher_map_[watcher.get()]; auto& watcher_wrapper = watcher_map_[watcher.get()];
GPR_ASSERT(watcher_wrapper == nullptr); GPR_ASSERT(watcher_wrapper == nullptr);
watcher_wrapper = New<WatcherWrapper>(std::move(watcher), watcher_wrapper = new WatcherWrapper(std::move(watcher),
Ref(DEBUG_LOCATION, "WatcherWrapper"), Ref(DEBUG_LOCATION, "WatcherWrapper"),
initial_state); initial_state);
subchannel_->WatchConnectivityState( subchannel_->WatchConnectivityState(
initial_state, initial_state,
UniquePtr<char>(gpr_strdup(health_check_service_name_.get())), std::unique_ptr<char>(gpr_strdup(health_check_service_name_.get())),
OrphanablePtr<Subchannel::ConnectivityStateWatcherInterface>( OrphanablePtr<Subchannel::ConnectivityStateWatcherInterface>(
watcher_wrapper)); watcher_wrapper));
} }
@ -926,7 +928,8 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface {
return subchannel_->channel_args(); return subchannel_->channel_args();
} }
void UpdateHealthCheckServiceName(UniquePtr<char> health_check_service_name) { void UpdateHealthCheckServiceName(
std::unique_ptr<char> health_check_service_name) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"chand=%p: subchannel wrapper %p: updating health check service " "chand=%p: subchannel wrapper %p: updating health check service "
@ -952,7 +955,7 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface {
watcher_wrapper = replacement; watcher_wrapper = replacement;
subchannel_->WatchConnectivityState( subchannel_->WatchConnectivityState(
replacement->last_seen_state(), replacement->last_seen_state(),
UniquePtr<char>(gpr_strdup(health_check_service_name.get())), std::unique_ptr<char>(gpr_strdup(health_check_service_name.get())),
OrphanablePtr<Subchannel::ConnectivityStateWatcherInterface>( OrphanablePtr<Subchannel::ConnectivityStateWatcherInterface>(
replacement)); replacement));
} }
@ -992,7 +995,7 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface {
class WatcherWrapper : public Subchannel::ConnectivityStateWatcherInterface { class WatcherWrapper : public Subchannel::ConnectivityStateWatcherInterface {
public: public:
WatcherWrapper( WatcherWrapper(
UniquePtr<SubchannelInterface::ConnectivityStateWatcherInterface> std::unique_ptr<SubchannelInterface::ConnectivityStateWatcherInterface>
watcher, watcher,
RefCountedPtr<SubchannelWrapper> parent, RefCountedPtr<SubchannelWrapper> parent,
grpc_connectivity_state initial_state) grpc_connectivity_state initial_state)
@ -1016,7 +1019,7 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface {
connected_subchannel.get(), ConnectivityStateName(new_state)); connected_subchannel.get(), ConnectivityStateName(new_state));
} }
// Will delete itself. // Will delete itself.
New<Updater>(Ref(), new_state, std::move(connected_subchannel)); new Updater(Ref(), new_state, std::move(connected_subchannel));
} }
grpc_pollset_set* interested_parties() override { grpc_pollset_set* interested_parties() override {
@ -1028,7 +1031,7 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface {
WatcherWrapper* MakeReplacement() { WatcherWrapper* MakeReplacement() {
auto* replacement = auto* replacement =
New<WatcherWrapper>(std::move(watcher_), parent_, last_seen_state_); new WatcherWrapper(std::move(watcher_), parent_, last_seen_state_);
replacement_ = replacement; replacement_ = replacement;
return replacement; return replacement;
} }
@ -1072,7 +1075,7 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface {
self->parent_->parent_->MaybeUpdateConnectedSubchannel( self->parent_->parent_->MaybeUpdateConnectedSubchannel(
std::move(self->connected_subchannel_)); std::move(self->connected_subchannel_));
self->parent_->watcher_->OnConnectivityStateChange(self->state_); self->parent_->watcher_->OnConnectivityStateChange(self->state_);
Delete(self); delete self;
} }
RefCountedPtr<WatcherWrapper> parent_; RefCountedPtr<WatcherWrapper> parent_;
@ -1081,7 +1084,8 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface {
grpc_closure closure_; grpc_closure closure_;
}; };
UniquePtr<SubchannelInterface::ConnectivityStateWatcherInterface> watcher_; std::unique_ptr<SubchannelInterface::ConnectivityStateWatcherInterface>
watcher_;
RefCountedPtr<SubchannelWrapper> parent_; RefCountedPtr<SubchannelWrapper> parent_;
grpc_connectivity_state last_seen_state_; grpc_connectivity_state last_seen_state_;
WatcherWrapper* replacement_ = nullptr; WatcherWrapper* replacement_ = nullptr;
@ -1110,13 +1114,13 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface {
ChannelData* chand_; ChannelData* chand_;
Subchannel* subchannel_; Subchannel* subchannel_;
UniquePtr<char> health_check_service_name_; std::unique_ptr<char> health_check_service_name_;
// Maps from the address of the watcher passed to us by the LB policy // Maps from the address of the watcher passed to us by the LB policy
// to the address of the WrapperWatcher that we passed to the underlying // to the address of the WrapperWatcher that we passed to the underlying
// subchannel. This is needed so that when the LB policy calls // subchannel. This is needed so that when the LB policy calls
// CancelConnectivityStateWatch() with its watcher, we know the // CancelConnectivityStateWatch() with its watcher, we know the
// corresponding WrapperWatcher to cancel on the underlying subchannel. // corresponding WrapperWatcher to cancel on the underlying subchannel.
Map<ConnectivityStateWatcherInterface*, WatcherWrapper*> watcher_map_; std::map<ConnectivityStateWatcherInterface*, WatcherWrapper*> watcher_map_;
// To be accessed only in the control plane combiner. // To be accessed only in the control plane combiner.
RefCountedPtr<ConnectedSubchannel> connected_subchannel_; RefCountedPtr<ConnectedSubchannel> connected_subchannel_;
// To be accessed only in the data plane mutex. // To be accessed only in the data plane mutex.
@ -1163,7 +1167,7 @@ void ChannelData::ExternalConnectivityWatcher::Notify(
chand_->RemoveExternalConnectivityWatcher(on_complete_, /*cancel=*/false); chand_->RemoveExternalConnectivityWatcher(on_complete_, /*cancel=*/false);
// Report new state to the user. // Report new state to the user.
*state_ = state; *state_ = state;
GRPC_CLOSURE_SCHED(on_complete_, GRPC_ERROR_NONE); ExecCtx::Run(DEBUG_LOCATION, on_complete_, GRPC_ERROR_NONE);
// Hop back into the combiner to clean up. // Hop back into the combiner to clean up.
// Not needed in state SHUTDOWN, because the tracker will // Not needed in state SHUTDOWN, because the tracker will
// automatically remove all watchers in that case. // automatically remove all watchers in that case.
@ -1180,7 +1184,7 @@ void ChannelData::ExternalConnectivityWatcher::Cancel() {
MemoryOrder::RELAXED)) { MemoryOrder::RELAXED)) {
return; // Already done. return; // Already done.
} }
GRPC_CLOSURE_SCHED(on_complete_, GRPC_ERROR_CANCELLED); ExecCtx::Run(DEBUG_LOCATION, on_complete_, GRPC_ERROR_CANCELLED);
// Hop back into the combiner to clean up. // Hop back into the combiner to clean up.
chand_->combiner_->Run( chand_->combiner_->Run(
GRPC_CLOSURE_INIT(&remove_closure_, RemoveWatcherLocked, this, nullptr), GRPC_CLOSURE_INIT(&remove_closure_, RemoveWatcherLocked, this, nullptr),
@ -1234,7 +1238,7 @@ class ChannelData::ConnectivityWatcherAdder {
std::move(self->watcher_)); std::move(self->watcher_));
GRPC_CHANNEL_STACK_UNREF(self->chand_->owning_stack_, GRPC_CHANNEL_STACK_UNREF(self->chand_->owning_stack_,
"ConnectivityWatcherAdder"); "ConnectivityWatcherAdder");
Delete(self); delete self;
} }
ChannelData* chand_; ChannelData* chand_;
@ -1267,7 +1271,7 @@ class ChannelData::ConnectivityWatcherRemover {
self->chand_->state_tracker_.RemoveWatcher(self->watcher_); self->chand_->state_tracker_.RemoveWatcher(self->watcher_);
GRPC_CHANNEL_STACK_UNREF(self->chand_->owning_stack_, GRPC_CHANNEL_STACK_UNREF(self->chand_->owning_stack_,
"ConnectivityWatcherRemover"); "ConnectivityWatcherRemover");
Delete(self); delete self;
} }
ChannelData* chand_; ChannelData* chand_;
@ -1295,7 +1299,7 @@ class ChannelData::ClientChannelControlHelper
const grpc_channel_args& args) override { const grpc_channel_args& args) override {
bool inhibit_health_checking = grpc_channel_arg_get_bool( bool inhibit_health_checking = grpc_channel_arg_get_bool(
grpc_channel_args_find(&args, GRPC_ARG_INHIBIT_HEALTH_CHECKING), false); grpc_channel_args_find(&args, GRPC_ARG_INHIBIT_HEALTH_CHECKING), false);
UniquePtr<char> health_check_service_name; std::unique_ptr<char> health_check_service_name;
if (!inhibit_health_checking) { if (!inhibit_health_checking) {
health_check_service_name.reset( health_check_service_name.reset(
gpr_strdup(chand_->health_check_service_name_.get())); gpr_strdup(chand_->health_check_service_name_.get()));
@ -1318,7 +1322,7 @@ class ChannelData::ClientChannelControlHelper
void UpdateState( void UpdateState(
grpc_connectivity_state state, grpc_connectivity_state state,
UniquePtr<LoadBalancingPolicy::SubchannelPicker> picker) override { std::unique_ptr<LoadBalancingPolicy::SubchannelPicker> picker) override {
grpc_error* disconnect_error = chand_->disconnect_error(); grpc_error* disconnect_error = chand_->disconnect_error();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
const char* extra = disconnect_error == GRPC_ERROR_NONE const char* extra = disconnect_error == GRPC_ERROR_NONE
@ -1491,7 +1495,7 @@ ChannelData::~ChannelData() {
void ChannelData::UpdateStateAndPickerLocked( void ChannelData::UpdateStateAndPickerLocked(
grpc_connectivity_state state, const char* reason, grpc_connectivity_state state, const char* reason,
UniquePtr<LoadBalancingPolicy::SubchannelPicker> picker) { std::unique_ptr<LoadBalancingPolicy::SubchannelPicker> picker) {
// Clean the control plane when entering IDLE. // Clean the control plane when entering IDLE.
if (picker_ == nullptr) { if (picker_ == nullptr) {
health_check_service_name_.reset(); health_check_service_name_.reset();
@ -1591,8 +1595,8 @@ void ChannelData::CreateResolvingLoadBalancingPolicyLocked() {
lb_args.combiner = combiner_; lb_args.combiner = combiner_;
lb_args.channel_control_helper = MakeUnique<ClientChannelControlHelper>(this); lb_args.channel_control_helper = MakeUnique<ClientChannelControlHelper>(this);
lb_args.args = channel_args_; lb_args.args = channel_args_;
UniquePtr<char> target_uri(gpr_strdup(target_uri_.get())); std::unique_ptr<char> target_uri(gpr_strdup(target_uri_.get()));
resolving_lb_policy_.reset(New<ResolvingLoadBalancingPolicy>( resolving_lb_policy_.reset(new ResolvingLoadBalancingPolicy(
std::move(lb_args), &grpc_client_channel_routing_trace, std::move(lb_args), &grpc_client_channel_routing_trace,
std::move(target_uri), ProcessResolverResultLocked, this)); std::move(target_uri), ProcessResolverResultLocked, this));
grpc_pollset_set_add_pollset_set(resolving_lb_policy_->interested_parties(), grpc_pollset_set_add_pollset_set(resolving_lb_policy_->interested_parties(),
@ -1614,7 +1618,7 @@ void ChannelData::DestroyResolvingLoadBalancingPolicyLocked() {
void ChannelData::ProcessLbPolicy( void ChannelData::ProcessLbPolicy(
const Resolver::Result& resolver_result, const Resolver::Result& resolver_result,
const internal::ClientChannelGlobalParsedConfig* parsed_service_config, const internal::ClientChannelGlobalParsedConfig* parsed_service_config,
UniquePtr<char>* lb_policy_name, std::unique_ptr<char>* lb_policy_name,
RefCountedPtr<LoadBalancingPolicy::Config>* lb_policy_config) { RefCountedPtr<LoadBalancingPolicy::Config>* lb_policy_config) {
// Prefer the LB policy name found in the service config. // Prefer the LB policy name found in the service config.
if (parsed_service_config != nullptr && if (parsed_service_config != nullptr &&
@ -1709,7 +1713,7 @@ bool ChannelData::ProcessResolverResultLocked(
return false; return false;
} }
// Process service config. // Process service config.
UniquePtr<char> service_config_json; std::unique_ptr<char> service_config_json;
const internal::ClientChannelGlobalParsedConfig* parsed_service_config = const internal::ClientChannelGlobalParsedConfig* parsed_service_config =
nullptr; nullptr;
if (service_config != nullptr) { if (service_config != nullptr) {
@ -1743,8 +1747,8 @@ bool ChannelData::ProcessResolverResultLocked(
} }
// Update health check service name used by existing subchannel wrappers. // Update health check service name used by existing subchannel wrappers.
for (auto* subchannel_wrapper : chand->subchannel_wrappers_) { for (auto* subchannel_wrapper : chand->subchannel_wrappers_) {
subchannel_wrapper->UpdateHealthCheckServiceName( subchannel_wrapper->UpdateHealthCheckServiceName(std::unique_ptr<char>(
UniquePtr<char>(gpr_strdup(chand->health_check_service_name_.get()))); gpr_strdup(chand->health_check_service_name_.get())));
} }
// Save service config. // Save service config.
chand->saved_service_config_ = std::move(service_config); chand->saved_service_config_ = std::move(service_config);
@ -1769,7 +1773,7 @@ bool ChannelData::ProcessResolverResultLocked(
chand->UpdateServiceConfigLocked(std::move(retry_throttle_data), chand->UpdateServiceConfigLocked(std::move(retry_throttle_data),
chand->saved_service_config_); chand->saved_service_config_);
} }
UniquePtr<char> processed_lb_policy_name; std::unique_ptr<char> processed_lb_policy_name;
chand->ProcessLbPolicy(result, parsed_service_config, chand->ProcessLbPolicy(result, parsed_service_config,
&processed_lb_policy_name, lb_policy_config); &processed_lb_policy_name, lb_policy_config);
// Swap out the data used by GetChannelInfo(). // Swap out the data used by GetChannelInfo().
@ -1825,8 +1829,9 @@ void ChannelData::StartTransportOpLocked(void* arg, grpc_error* /*ignored*/) {
if (op->send_ping.on_initiate != nullptr || op->send_ping.on_ack != nullptr) { if (op->send_ping.on_initiate != nullptr || op->send_ping.on_ack != nullptr) {
grpc_error* error = chand->DoPingLocked(op); grpc_error* error = chand->DoPingLocked(op);
if (error != GRPC_ERROR_NONE) { if (error != GRPC_ERROR_NONE) {
GRPC_CLOSURE_SCHED(op->send_ping.on_initiate, GRPC_ERROR_REF(error)); ExecCtx::Run(DEBUG_LOCATION, op->send_ping.on_initiate,
GRPC_CLOSURE_SCHED(op->send_ping.on_ack, error); GRPC_ERROR_REF(error));
ExecCtx::Run(DEBUG_LOCATION, op->send_ping.on_ack, error);
} }
op->bind_pollset = nullptr; op->bind_pollset = nullptr;
op->send_ping.on_initiate = nullptr; op->send_ping.on_initiate = nullptr;
@ -1868,7 +1873,7 @@ void ChannelData::StartTransportOpLocked(void* arg, grpc_error* /*ignored*/) {
} }
} }
GRPC_CHANNEL_STACK_UNREF(chand->owning_stack_, "start_transport_op"); GRPC_CHANNEL_STACK_UNREF(chand->owning_stack_, "start_transport_op");
GRPC_CLOSURE_SCHED(op->on_consumed, GRPC_ERROR_NONE); ExecCtx::Run(DEBUG_LOCATION, op->on_consumed, GRPC_ERROR_NONE);
} }
void ChannelData::StartTransportOp(grpc_channel_element* elem, void ChannelData::StartTransportOp(grpc_channel_element* elem,
@ -1960,12 +1965,12 @@ grpc_connectivity_state ChannelData::CheckConnectivityState(
void ChannelData::AddConnectivityWatcher( void ChannelData::AddConnectivityWatcher(
grpc_connectivity_state initial_state, grpc_connectivity_state initial_state,
OrphanablePtr<AsyncConnectivityStateWatcherInterface> watcher) { OrphanablePtr<AsyncConnectivityStateWatcherInterface> watcher) {
New<ConnectivityWatcherAdder>(this, initial_state, std::move(watcher)); new ConnectivityWatcherAdder(this, initial_state, std::move(watcher));
} }
void ChannelData::RemoveConnectivityWatcher( void ChannelData::RemoveConnectivityWatcher(
AsyncConnectivityStateWatcherInterface* watcher) { AsyncConnectivityStateWatcherInterface* watcher) {
New<ConnectivityWatcherRemover>(this, watcher); new ConnectivityWatcherRemover(this, watcher);
} }
// //
@ -2057,7 +2062,8 @@ void CallData::Destroy(grpc_call_element* elem,
then_schedule_closure = nullptr; then_schedule_closure = nullptr;
} }
calld->~CallData(); calld->~CallData();
GRPC_CLOSURE_SCHED(then_schedule_closure, GRPC_ERROR_NONE); // TODO(yashkt) : This can potentially be a Closure::Run
ExecCtx::Run(DEBUG_LOCATION, then_schedule_closure, GRPC_ERROR_NONE);
} }
void CallData::StartTransportStreamOpBatch( void CallData::StartTransportStreamOpBatch(
@ -3681,7 +3687,7 @@ void CallData::CreateSubchannelCall(grpc_call_element* elem) {
void CallData::AsyncPickDone(grpc_call_element* elem, grpc_error* error) { void CallData::AsyncPickDone(grpc_call_element* elem, grpc_error* error) {
GRPC_CLOSURE_INIT(&pick_closure_, PickDone, elem, grpc_schedule_on_exec_ctx); GRPC_CLOSURE_INIT(&pick_closure_, PickDone, elem, grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_SCHED(&pick_closure_, error); ExecCtx::Run(DEBUG_LOCATION, &pick_closure_, error);
} }
void CallData::PickDone(void* arg, grpc_error* error) { void CallData::PickDone(void* arg, grpc_error* error) {
@ -3733,7 +3739,7 @@ class CallData::QueuedPickCanceller {
YieldCallCombinerIfPendingBatchesFound); YieldCallCombinerIfPendingBatchesFound);
} }
GRPC_CALL_STACK_UNREF(calld->owning_call_, "QueuedPickCanceller"); GRPC_CALL_STACK_UNREF(calld->owning_call_, "QueuedPickCanceller");
Delete(self); delete self;
} }
grpc_call_element* elem_; grpc_call_element* elem_;
@ -3762,7 +3768,7 @@ void CallData::AddCallToQueuedPicksLocked(grpc_call_element* elem) {
pick_.elem = elem; pick_.elem = elem;
chand->AddQueuedPick(&pick_, pollent_); chand->AddQueuedPick(&pick_, pollent_);
// Register call combiner cancellation callback. // Register call combiner cancellation callback.
pick_canceller_ = New<QueuedPickCanceller>(elem); pick_canceller_ = new QueuedPickCanceller(elem);
} }
void CallData::ApplyServiceConfigToCallLocked(grpc_call_element* elem) { void CallData::ApplyServiceConfigToCallLocked(grpc_call_element* elem) {

@ -30,11 +30,10 @@
namespace grpc_core { namespace grpc_core {
namespace channelz { namespace channelz {
SubchannelNode::SubchannelNode(const char* target_address, SubchannelNode::SubchannelNode(std::string target_address,
size_t channel_tracer_max_nodes) size_t channel_tracer_max_nodes)
: BaseNode(EntityType::kSubchannel, : BaseNode(EntityType::kSubchannel, target_address),
UniquePtr<char>(gpr_strdup(target_address))), target_(std::move(target_address)),
target_(UniquePtr<char>(gpr_strdup(target_address))),
trace_(channel_tracer_max_nodes) {} trace_(channel_tracer_max_nodes) {}
SubchannelNode::~SubchannelNode() {} SubchannelNode::~SubchannelNode() {}
@ -76,8 +75,8 @@ grpc_json* SubchannelNode::RenderJson() {
json = data; json = data;
json_iterator = nullptr; json_iterator = nullptr;
PopulateConnectivityState(json); PopulateConnectivityState(json);
GPR_ASSERT(target_.get() != nullptr); GPR_ASSERT(!target_.empty());
grpc_json_create_child(nullptr, json, "target", target_.get(), grpc_json_create_child(nullptr, json, "target", target_.c_str(),
GRPC_JSON_STRING, false); GRPC_JSON_STRING, false);
// fill in the channel trace if applicable // fill in the channel trace if applicable
grpc_json* trace_json = trace_.RenderJson(); grpc_json* trace_json = trace_.RenderJson();
@ -102,7 +101,8 @@ grpc_json* SubchannelNode::RenderJson() {
grpc_json* sibling_iterator = grpc_json_add_number_string_child( grpc_json* sibling_iterator = grpc_json_add_number_string_child(
json_iterator, nullptr, "socketId", child_socket->uuid()); json_iterator, nullptr, "socketId", child_socket->uuid());
grpc_json_create_child(sibling_iterator, json_iterator, "name", grpc_json_create_child(sibling_iterator, json_iterator, "name",
child_socket->name(), GRPC_JSON_STRING, false); child_socket->name().c_str(), GRPC_JSON_STRING,
false);
} }
return top_level_json; return top_level_json;
} }

@ -21,6 +21,8 @@
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <string>
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/channel/channel_trace.h"
@ -34,7 +36,7 @@ namespace channelz {
class SubchannelNode : public BaseNode { class SubchannelNode : public BaseNode {
public: public:
SubchannelNode(const char* target_address, size_t channel_tracer_max_nodes); SubchannelNode(std::string target_address, size_t channel_tracer_max_nodes);
~SubchannelNode() override; ~SubchannelNode() override;
// Sets the subchannel's connectivity state without health checking. // Sets the subchannel's connectivity state without health checking.
@ -67,7 +69,7 @@ class SubchannelNode : public BaseNode {
Atomic<grpc_connectivity_state> connectivity_state_{GRPC_CHANNEL_IDLE}; Atomic<grpc_connectivity_state> connectivity_state_{GRPC_CHANNEL_IDLE};
Mutex socket_mu_; Mutex socket_mu_;
RefCountedPtr<SocketNode> child_socket_; RefCountedPtr<SocketNode> child_socket_;
UniquePtr<char> target_; std::string target_;
CallCountingHelper call_counter_; CallCountingHelper call_counter_;
ChannelTrace trace_; ChannelTrace trace_;
}; };

@ -35,7 +35,7 @@ GlobalSubchannelPool::~GlobalSubchannelPool() {
} }
void GlobalSubchannelPool::Init() { void GlobalSubchannelPool::Init() {
instance_ = New<RefCountedPtr<GlobalSubchannelPool>>( instance_ = new RefCountedPtr<GlobalSubchannelPool>(
MakeRefCounted<GlobalSubchannelPool>()); MakeRefCounted<GlobalSubchannelPool>());
} }
@ -45,7 +45,7 @@ void GlobalSubchannelPool::Shutdown() {
// To ensure Shutdown() was not called before. // To ensure Shutdown() was not called before.
GPR_ASSERT(*instance_ != nullptr); GPR_ASSERT(*instance_ != nullptr);
instance_->reset(); instance_->reset();
Delete(instance_); delete instance_;
} }
RefCountedPtr<GlobalSubchannelPool> GlobalSubchannelPool::instance() { RefCountedPtr<GlobalSubchannelPool> GlobalSubchannelPool::instance() {
@ -78,7 +78,7 @@ Subchannel* GlobalSubchannelPool::RegisterSubchannel(SubchannelKey* key,
// Note that we should ref the old map first because grpc_avl_add() will // Note that we should ref the old map first because grpc_avl_add() will
// unref it while we still need to access it later. // unref it while we still need to access it later.
grpc_avl new_map = grpc_avl_add( grpc_avl new_map = grpc_avl_add(
grpc_avl_ref(old_map, nullptr), New<SubchannelKey>(*key), grpc_avl_ref(old_map, nullptr), new SubchannelKey(*key),
GRPC_SUBCHANNEL_WEAK_REF(constructed, "subchannel_register+new"), GRPC_SUBCHANNEL_WEAK_REF(constructed, "subchannel_register+new"),
nullptr); nullptr);
// Try to publish the change to the shared map. It may happen (but // Try to publish the change to the shared map. It may happen (but
@ -142,12 +142,12 @@ namespace {
void sck_avl_destroy(void* p, void* /*user_data*/) { void sck_avl_destroy(void* p, void* /*user_data*/) {
SubchannelKey* key = static_cast<SubchannelKey*>(p); SubchannelKey* key = static_cast<SubchannelKey*>(p);
Delete(key); delete key;
} }
void* sck_avl_copy(void* p, void* /*unused*/) { void* sck_avl_copy(void* p, void* /*unused*/) {
const SubchannelKey* key = static_cast<const SubchannelKey*>(p); const SubchannelKey* key = static_cast<const SubchannelKey*>(p);
auto* new_key = New<SubchannelKey>(*key); auto* new_key = new SubchannelKey(*key);
return static_cast<void*>(new_key); return static_cast<void*>(new_key);
} }

@ -200,7 +200,7 @@ bool DecodeResponse(grpc_slice_buffer* slice_buffer, grpc_error** error) {
return false; return false;
} }
// Concatenate the slices to form a single string. // Concatenate the slices to form a single string.
UniquePtr<uint8_t> recv_message_deleter; std::unique_ptr<uint8_t> recv_message_deleter;
uint8_t* recv_message; uint8_t* recv_message;
if (slice_buffer->count == 1) { if (slice_buffer->count == 1) {
recv_message = GRPC_SLICE_START_PTR(slice_buffer->slices[0]); recv_message = GRPC_SLICE_START_PTR(slice_buffer->slices[0]);
@ -300,7 +300,8 @@ void HealthCheckClient::CallState::StartCall() {
// Schedule instead of running directly, since we must not be // Schedule instead of running directly, since we must not be
// holding health_check_client_->mu_ when CallEnded() is called. // holding health_check_client_->mu_ when CallEnded() is called.
call_->Ref(DEBUG_LOCATION, "call_end_closure").release(); call_->Ref(DEBUG_LOCATION, "call_end_closure").release();
GRPC_CLOSURE_SCHED( ExecCtx::Run(
DEBUG_LOCATION,
GRPC_CLOSURE_INIT(&batch_.handler_private.closure, CallEndedRetry, this, GRPC_CLOSURE_INIT(&batch_.handler_private.closure, CallEndedRetry, this,
grpc_schedule_on_exec_ctx), grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE); GRPC_ERROR_NONE);
@ -399,7 +400,7 @@ void HealthCheckClient::CallState::AfterCallStackDestruction(
void* arg, grpc_error* /*error*/) { void* arg, grpc_error* /*error*/) {
HealthCheckClient::CallState* self = HealthCheckClient::CallState* self =
static_cast<HealthCheckClient::CallState*>(arg); static_cast<HealthCheckClient::CallState*>(arg);
Delete(self); delete self;
} }
void HealthCheckClient::CallState::OnCancelComplete(void* arg, void HealthCheckClient::CallState::OnCancelComplete(void* arg,

@ -58,7 +58,7 @@ class HttpConnectHandshaker : public Handshaker {
static void OnWriteDone(void* arg, grpc_error* error); static void OnWriteDone(void* arg, grpc_error* error);
static void OnReadDone(void* arg, grpc_error* error); static void OnReadDone(void* arg, grpc_error* error);
gpr_mu mu_; Mutex mu_;
bool is_shutdown_ = false; bool is_shutdown_ = false;
// Endpoint and read buffer to destroy after a shutdown. // Endpoint and read buffer to destroy after a shutdown.
@ -78,7 +78,6 @@ class HttpConnectHandshaker : public Handshaker {
}; };
HttpConnectHandshaker::~HttpConnectHandshaker() { HttpConnectHandshaker::~HttpConnectHandshaker() {
gpr_mu_destroy(&mu_);
if (endpoint_to_destroy_ != nullptr) { if (endpoint_to_destroy_ != nullptr) {
grpc_endpoint_destroy(endpoint_to_destroy_); grpc_endpoint_destroy(endpoint_to_destroy_);
} }
@ -125,34 +124,33 @@ void HttpConnectHandshaker::HandshakeFailedLocked(grpc_error* error) {
is_shutdown_ = true; is_shutdown_ = true;
} }
// Invoke callback. // Invoke callback.
GRPC_CLOSURE_SCHED(on_handshake_done_, error); ExecCtx::Run(DEBUG_LOCATION, on_handshake_done_, error);
} }
// Callback invoked when finished writing HTTP CONNECT request. // Callback invoked when finished writing HTTP CONNECT request.
void HttpConnectHandshaker::OnWriteDone(void* arg, grpc_error* error) { void HttpConnectHandshaker::OnWriteDone(void* arg, grpc_error* error) {
auto* handshaker = static_cast<HttpConnectHandshaker*>(arg); auto* handshaker = static_cast<HttpConnectHandshaker*>(arg);
gpr_mu_lock(&handshaker->mu_); ReleasableMutexLock lock(&handshaker->mu_);
if (error != GRPC_ERROR_NONE || handshaker->is_shutdown_) { if (error != GRPC_ERROR_NONE || handshaker->is_shutdown_) {
// If the write failed or we're shutting down, clean up and invoke the // If the write failed or we're shutting down, clean up and invoke the
// callback with the error. // callback with the error.
handshaker->HandshakeFailedLocked(GRPC_ERROR_REF(error)); handshaker->HandshakeFailedLocked(GRPC_ERROR_REF(error));
gpr_mu_unlock(&handshaker->mu_); lock.Unlock();
handshaker->Unref(); handshaker->Unref();
} else { } else {
// Otherwise, read the response. // Otherwise, read the response.
// The read callback inherits our ref to the handshaker. // The read callback inherits our ref to the handshaker.
lock.Unlock();
grpc_endpoint_read(handshaker->args_->endpoint, grpc_endpoint_read(handshaker->args_->endpoint,
handshaker->args_->read_buffer, handshaker->args_->read_buffer,
&handshaker->response_read_closure_, /*urgent=*/true); &handshaker->response_read_closure_, /*urgent=*/true);
gpr_mu_unlock(&handshaker->mu_);
} }
} }
// Callback invoked for reading HTTP CONNECT response. // Callback invoked for reading HTTP CONNECT response.
void HttpConnectHandshaker::OnReadDone(void* arg, grpc_error* error) { void HttpConnectHandshaker::OnReadDone(void* arg, grpc_error* error) {
auto* handshaker = static_cast<HttpConnectHandshaker*>(arg); auto* handshaker = static_cast<HttpConnectHandshaker*>(arg);
ReleasableMutexLock lock(&handshaker->mu_);
gpr_mu_lock(&handshaker->mu_);
if (error != GRPC_ERROR_NONE || handshaker->is_shutdown_) { if (error != GRPC_ERROR_NONE || handshaker->is_shutdown_) {
// If the read failed or we're shutting down, clean up and invoke the // If the read failed or we're shutting down, clean up and invoke the
// callback with the error. // callback with the error.
@ -204,10 +202,10 @@ void HttpConnectHandshaker::OnReadDone(void* arg, grpc_error* error) {
// at the Content-Length: header). // at the Content-Length: header).
if (handshaker->http_parser_.state != GRPC_HTTP_BODY) { if (handshaker->http_parser_.state != GRPC_HTTP_BODY) {
grpc_slice_buffer_reset_and_unref_internal(handshaker->args_->read_buffer); grpc_slice_buffer_reset_and_unref_internal(handshaker->args_->read_buffer);
lock.Unlock();
grpc_endpoint_read(handshaker->args_->endpoint, grpc_endpoint_read(handshaker->args_->endpoint,
handshaker->args_->read_buffer, handshaker->args_->read_buffer,
&handshaker->response_read_closure_, /*urgent=*/true); &handshaker->response_read_closure_, /*urgent=*/true);
gpr_mu_unlock(&handshaker->mu_);
return; return;
} }
// Make sure we got a 2xx response. // Make sure we got a 2xx response.
@ -222,12 +220,12 @@ void HttpConnectHandshaker::OnReadDone(void* arg, grpc_error* error) {
goto done; goto done;
} }
// Success. Invoke handshake-done callback. // Success. Invoke handshake-done callback.
GRPC_CLOSURE_SCHED(handshaker->on_handshake_done_, error); ExecCtx::Run(DEBUG_LOCATION, handshaker->on_handshake_done_, error);
done: done:
// Set shutdown to true so that subsequent calls to // Set shutdown to true so that subsequent calls to
// http_connect_handshaker_shutdown() do nothing. // http_connect_handshaker_shutdown() do nothing.
handshaker->is_shutdown_ = true; handshaker->is_shutdown_ = true;
gpr_mu_unlock(&handshaker->mu_); lock.Unlock();
handshaker->Unref(); handshaker->Unref();
} }
@ -236,13 +234,14 @@ done:
// //
void HttpConnectHandshaker::Shutdown(grpc_error* why) { void HttpConnectHandshaker::Shutdown(grpc_error* why) {
gpr_mu_lock(&mu_); {
MutexLock lock(&mu_);
if (!is_shutdown_) { if (!is_shutdown_) {
is_shutdown_ = true; is_shutdown_ = true;
grpc_endpoint_shutdown(args_->endpoint, GRPC_ERROR_REF(why)); grpc_endpoint_shutdown(args_->endpoint, GRPC_ERROR_REF(why));
CleanupArgsForFailureLocked(); CleanupArgsForFailureLocked();
} }
gpr_mu_unlock(&mu_); }
GRPC_ERROR_UNREF(why); GRPC_ERROR_UNREF(why);
} }
@ -257,10 +256,11 @@ void HttpConnectHandshaker::DoHandshake(grpc_tcp_server_acceptor* /*acceptor*/,
if (server_name == nullptr) { if (server_name == nullptr) {
// Set shutdown to true so that subsequent calls to // Set shutdown to true so that subsequent calls to
// http_connect_handshaker_shutdown() do nothing. // http_connect_handshaker_shutdown() do nothing.
gpr_mu_lock(&mu_); {
MutexLock lock(&mu_);
is_shutdown_ = true; is_shutdown_ = true;
gpr_mu_unlock(&mu_); }
GRPC_CLOSURE_SCHED(on_handshake_done, GRPC_ERROR_NONE); ExecCtx::Run(DEBUG_LOCATION, on_handshake_done, GRPC_ERROR_NONE);
return; return;
} }
// Get headers from channel args. // Get headers from channel args.
@ -290,7 +290,7 @@ void HttpConnectHandshaker::DoHandshake(grpc_tcp_server_acceptor* /*acceptor*/,
} }
} }
// Save state in the handshaker object. // Save state in the handshaker object.
MutexLock lock(&mu_); ReleasableMutexLock lock(&mu_);
args_ = args; args_ = args;
on_handshake_done_ = on_handshake_done; on_handshake_done_ = on_handshake_done;
// Log connection via proxy. // Log connection via proxy.
@ -320,12 +320,12 @@ void HttpConnectHandshaker::DoHandshake(grpc_tcp_server_acceptor* /*acceptor*/,
gpr_free(header_strings); gpr_free(header_strings);
// Take a new ref to be held by the write callback. // Take a new ref to be held by the write callback.
Ref().release(); Ref().release();
lock.Unlock();
grpc_endpoint_write(args->endpoint, &write_buffer_, &request_done_closure_, grpc_endpoint_write(args->endpoint, &write_buffer_, &request_done_closure_,
nullptr); nullptr);
} }
HttpConnectHandshaker::HttpConnectHandshaker() { HttpConnectHandshaker::HttpConnectHandshaker() {
gpr_mu_init(&mu_);
grpc_slice_buffer_init(&write_buffer_); grpc_slice_buffer_init(&write_buffer_);
GRPC_CLOSURE_INIT(&request_done_closure_, &HttpConnectHandshaker::OnWriteDone, GRPC_CLOSURE_INIT(&request_done_closure_, &HttpConnectHandshaker::OnWriteDone,
this, grpc_schedule_on_exec_ctx); this, grpc_schedule_on_exec_ctx);

@ -130,8 +130,8 @@ static bool proxy_mapper_map_name(grpc_proxy_mapper* /*mapper*/,
if (no_proxy_str != nullptr) { if (no_proxy_str != nullptr) {
static const char* NO_PROXY_SEPARATOR = ","; static const char* NO_PROXY_SEPARATOR = ",";
bool use_proxy = true; bool use_proxy = true;
grpc_core::UniquePtr<char> server_host; std::unique_ptr<char> server_host;
grpc_core::UniquePtr<char> server_port; std::unique_ptr<char> server_port;
if (!grpc_core::SplitHostPort( if (!grpc_core::SplitHostPort(
uri->path[0] == '/' ? uri->path + 1 : uri->path, &server_host, uri->path[0] == '/' ? uri->path + 1 : uri->path, &server_host,
&server_port)) { &server_port)) {

@ -21,6 +21,7 @@
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <functional>
#include <iterator> #include <iterator>
#include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/ext/filters/client_channel/server_address.h"
@ -92,11 +93,11 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
/// Application-specific requests cost metrics. Metric names are /// Application-specific requests cost metrics. Metric names are
/// determined by the application. Each value is an absolute cost /// determined by the application. Each value is an absolute cost
/// (e.g. 3487 bytes of storage) associated with the request. /// (e.g. 3487 bytes of storage) associated with the request.
Map<StringView, double, StringLess> request_cost; std::map<StringView, double, StringLess> request_cost;
/// Application-specific resource utilization metrics. Metric names /// Application-specific resource utilization metrics. Metric names
/// are determined by the application. Each value is expressed as a /// are determined by the application. Each value is expressed as a
/// fraction of total resources available. /// fraction of total resources available.
Map<StringView, double, StringLess> utilization; std::map<StringView, double, StringLess> utilization;
}; };
/// Interface for accessing per-call state. /// Interface for accessing per-call state.
@ -268,7 +269,7 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
/// Sets the connectivity state and returns a new picker to be used /// Sets the connectivity state and returns a new picker to be used
/// by the client channel. /// by the client channel.
virtual void UpdateState(grpc_connectivity_state state, virtual void UpdateState(grpc_connectivity_state state,
UniquePtr<SubchannelPicker>) = 0; std::unique_ptr<SubchannelPicker>) = 0;
/// Requests that the resolver re-resolve. /// Requests that the resolver re-resolve.
virtual void RequestReresolution() = 0; virtual void RequestReresolution() = 0;
@ -317,7 +318,7 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
/// Channel control helper. /// Channel control helper.
/// Note: LB policies MUST NOT call any method on the helper from /// Note: LB policies MUST NOT call any method on the helper from
/// their constructor. /// their constructor.
UniquePtr<ChannelControlHelper> channel_control_helper; std::unique_ptr<ChannelControlHelper> channel_control_helper;
/// Channel args. /// Channel args.
// TODO(roth): Find a better channel args representation for this API. // TODO(roth): Find a better channel args representation for this API.
// TODO(roth): Clarify ownership semantics here -- currently, this // TODO(roth): Clarify ownership semantics here -- currently, this
@ -403,7 +404,7 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
/// Owned pointer to interested parties in load balancing decisions. /// Owned pointer to interested parties in load balancing decisions.
grpc_pollset_set* interested_parties_; grpc_pollset_set* interested_parties_;
/// Channel control helper. /// Channel control helper.
UniquePtr<ChannelControlHelper> channel_control_helper_; std::unique_ptr<ChannelControlHelper> channel_control_helper_;
}; };
} // namespace grpc_core } // namespace grpc_core

@ -237,7 +237,7 @@ class GrpcLb : public LoadBalancingPolicy {
const grpc_grpclb_serverlist* serverlist() const { return serverlist_; } const grpc_grpclb_serverlist* serverlist() const { return serverlist_; }
// Returns a text representation suitable for logging. // Returns a text representation suitable for logging.
UniquePtr<char> AsText() const; std::unique_ptr<char> AsText() const;
// Extracts all non-drop entries into a ServerAddressList. // Extracts all non-drop entries into a ServerAddressList.
ServerAddressList GetServerAddressList( ServerAddressList GetServerAddressList(
@ -268,7 +268,7 @@ class GrpcLb : public LoadBalancingPolicy {
class Picker : public SubchannelPicker { class Picker : public SubchannelPicker {
public: public:
Picker(GrpcLb* parent, RefCountedPtr<Serverlist> serverlist, Picker(GrpcLb* parent, RefCountedPtr<Serverlist> serverlist,
UniquePtr<SubchannelPicker> child_picker, std::unique_ptr<SubchannelPicker> child_picker,
RefCountedPtr<GrpcLbClientStats> client_stats) RefCountedPtr<GrpcLbClientStats> client_stats)
: parent_(parent), : parent_(parent),
serverlist_(std::move(serverlist)), serverlist_(std::move(serverlist)),
@ -285,7 +285,7 @@ class GrpcLb : public LoadBalancingPolicy {
// Serverlist to be used for determining drops. // Serverlist to be used for determining drops.
RefCountedPtr<Serverlist> serverlist_; RefCountedPtr<Serverlist> serverlist_;
UniquePtr<SubchannelPicker> child_picker_; std::unique_ptr<SubchannelPicker> child_picker_;
RefCountedPtr<GrpcLbClientStats> client_stats_; RefCountedPtr<GrpcLbClientStats> client_stats_;
}; };
@ -297,7 +297,7 @@ class GrpcLb : public LoadBalancingPolicy {
RefCountedPtr<SubchannelInterface> CreateSubchannel( RefCountedPtr<SubchannelInterface> CreateSubchannel(
const grpc_channel_args& args) override; const grpc_channel_args& args) override;
void UpdateState(grpc_connectivity_state state, void UpdateState(grpc_connectivity_state state,
UniquePtr<SubchannelPicker> picker) override; std::unique_ptr<SubchannelPicker> picker) override;
void RequestReresolution() override; void RequestReresolution() override;
void AddTraceEvent(TraceSeverity severity, StringView message) override; void AddTraceEvent(TraceSeverity severity, StringView message) override;
@ -430,7 +430,7 @@ void ParseServer(const grpc_grpclb_server* server,
} }
} }
UniquePtr<char> GrpcLb::Serverlist::AsText() const { std::unique_ptr<char> GrpcLb::Serverlist::AsText() const {
gpr_strvec entries; gpr_strvec entries;
gpr_strvec_init(&entries); gpr_strvec_init(&entries);
for (size_t i = 0; i < serverlist_->num_servers; ++i) { for (size_t i = 0; i < serverlist_->num_servers; ++i) {
@ -449,7 +449,7 @@ UniquePtr<char> GrpcLb::Serverlist::AsText() const {
gpr_free(ipport); gpr_free(ipport);
gpr_strvec_add(&entries, entry); gpr_strvec_add(&entries, entry);
} }
UniquePtr<char> result(gpr_strvec_flatten(&entries, nullptr)); std::unique_ptr<char> result(gpr_strvec_flatten(&entries, nullptr));
gpr_strvec_destroy(&entries); gpr_strvec_destroy(&entries);
return result; return result;
} }
@ -479,8 +479,7 @@ int equal_cmp(void* /*p1*/, void* /*p2*/) {
// token or client stats. A better approach might be to find somewhere // token or client stats. A better approach might be to find somewhere
// other than the subchannel args to store the LB token and client // other than the subchannel args to store the LB token and client
// stats. They could be stored in a map and then looked up for each // stats. They could be stored in a map and then looked up for each
// call (although we'd need to make sure our Map<> implementation is // call. Or we could do something more complicated whereby
// performant enough). Or we could do something more complicated whereby
// we create our own subchannel wrapper to store them, although that would // we create our own subchannel wrapper to store them, although that would
// involve a lot of refcounting overhead. // involve a lot of refcounting overhead.
// Given that we're trying to move from grpclb to xds at this point, // Given that we're trying to move from grpclb to xds at this point,
@ -658,7 +657,7 @@ RefCountedPtr<SubchannelInterface> GrpcLb::Helper::CreateSubchannel(
} }
void GrpcLb::Helper::UpdateState(grpc_connectivity_state state, void GrpcLb::Helper::UpdateState(grpc_connectivity_state state,
UniquePtr<SubchannelPicker> picker) { std::unique_ptr<SubchannelPicker> picker) {
if (parent_->shutting_down_) return; if (parent_->shutting_down_) return;
// If this request is from the pending child policy, ignore it until // If this request is from the pending child policy, ignore it until
// it reports READY, at which point we swap it into place. // it reports READY, at which point we swap it into place.
@ -1100,7 +1099,7 @@ void GrpcLb::BalancerCallState::OnBalancerMessageReceivedLocked(
GPR_ASSERT(lb_calld->lb_call_ != nullptr); GPR_ASSERT(lb_calld->lb_call_ != nullptr);
auto serverlist_wrapper = MakeRefCounted<Serverlist>(serverlist); auto serverlist_wrapper = MakeRefCounted<Serverlist>(serverlist);
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
UniquePtr<char> serverlist_text = serverlist_wrapper->AsText(); std::unique_ptr<char> serverlist_text = serverlist_wrapper->AsText();
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"[grpclb %p] lb_calld=%p: Serverlist with %" PRIuPTR "[grpclb %p] lb_calld=%p: Serverlist with %" PRIuPTR
" servers received:\n%s", " servers received:\n%s",
@ -1725,12 +1724,12 @@ grpc_channel_args* GrpcLb::CreateChildPolicyArgsLocked(
OrphanablePtr<LoadBalancingPolicy> GrpcLb::CreateChildPolicyLocked( OrphanablePtr<LoadBalancingPolicy> GrpcLb::CreateChildPolicyLocked(
const char* name, const grpc_channel_args* args) { const char* name, const grpc_channel_args* args) {
Helper* helper = New<Helper>(Ref()); Helper* helper = new Helper(Ref());
LoadBalancingPolicy::Args lb_policy_args; LoadBalancingPolicy::Args lb_policy_args;
lb_policy_args.combiner = combiner(); lb_policy_args.combiner = combiner();
lb_policy_args.args = args; lb_policy_args.args = args;
lb_policy_args.channel_control_helper = lb_policy_args.channel_control_helper =
UniquePtr<ChannelControlHelper>(helper); std::unique_ptr<ChannelControlHelper>(helper);
OrphanablePtr<LoadBalancingPolicy> lb_policy = OrphanablePtr<LoadBalancingPolicy> lb_policy =
LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy( LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
name, std::move(lb_policy_args)); name, std::move(lb_policy_args));
@ -1884,7 +1883,7 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
if (json == nullptr) { if (json == nullptr) {
return RefCountedPtr<LoadBalancingPolicy::Config>( return RefCountedPtr<LoadBalancingPolicy::Config>(
New<ParsedGrpcLbConfig>(nullptr)); new ParsedGrpcLbConfig(nullptr));
} }
InlinedVector<grpc_error*, 2> error_list; InlinedVector<grpc_error*, 2> error_list;
RefCountedPtr<LoadBalancingPolicy::Config> child_policy; RefCountedPtr<LoadBalancingPolicy::Config> child_policy;
@ -1906,7 +1905,7 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory {
} }
if (error_list.empty()) { if (error_list.empty()) {
return RefCountedPtr<LoadBalancingPolicy::Config>( return RefCountedPtr<LoadBalancingPolicy::Config>(
New<ParsedGrpcLbConfig>(std::move(child_policy))); new ParsedGrpcLbConfig(std::move(child_policy)));
} else { } else {
*error = GRPC_ERROR_CREATE_FROM_VECTOR("GrpcLb Parser", &error_list); *error = GRPC_ERROR_CREATE_FROM_VECTOR("GrpcLb Parser", &error_list);
return nullptr; return nullptr;

@ -39,8 +39,8 @@ namespace grpc_core {
namespace { namespace {
int BalancerNameCmp(const grpc_core::UniquePtr<char>& a, int BalancerNameCmp(const std::unique_ptr<char>& a,
const grpc_core::UniquePtr<char>& b) { const std::unique_ptr<char>& b) {
return strcmp(a.get(), b.get()); return strcmp(a.get(), b.get());
} }

@ -52,7 +52,7 @@ void GrpcLbClientStats::AddCallDropped(const char* token) {
// Record the drop. // Record the drop.
MutexLock lock(&drop_count_mu_); MutexLock lock(&drop_count_mu_);
if (drop_token_counts_ == nullptr) { if (drop_token_counts_ == nullptr) {
drop_token_counts_.reset(New<DroppedCallCounts>()); drop_token_counts_.reset(new DroppedCallCounts());
} }
for (size_t i = 0; i < drop_token_counts_->size(); ++i) { for (size_t i = 0; i < drop_token_counts_->size(); ++i) {
if (strcmp((*drop_token_counts_)[i].token.get(), token) == 0) { if (strcmp((*drop_token_counts_)[i].token.get(), token) == 0) {
@ -61,7 +61,7 @@ void GrpcLbClientStats::AddCallDropped(const char* token) {
} }
} }
// Not found, so add a new entry. // Not found, so add a new entry.
drop_token_counts_->emplace_back(UniquePtr<char>(gpr_strdup(token)), 1); drop_token_counts_->emplace_back(std::unique_ptr<char>(gpr_strdup(token)), 1);
} }
namespace { namespace {
@ -76,7 +76,7 @@ void GrpcLbClientStats::Get(
int64_t* num_calls_started, int64_t* num_calls_finished, int64_t* num_calls_started, int64_t* num_calls_finished,
int64_t* num_calls_finished_with_client_failed_to_send, int64_t* num_calls_finished_with_client_failed_to_send,
int64_t* num_calls_finished_known_received, int64_t* num_calls_finished_known_received,
UniquePtr<DroppedCallCounts>* drop_token_counts) { std::unique_ptr<DroppedCallCounts>* drop_token_counts) {
AtomicGetAndResetCounter(num_calls_started, &num_calls_started_); AtomicGetAndResetCounter(num_calls_started, &num_calls_started_);
AtomicGetAndResetCounter(num_calls_finished, &num_calls_finished_); AtomicGetAndResetCounter(num_calls_finished, &num_calls_finished_);
AtomicGetAndResetCounter(num_calls_finished_with_client_failed_to_send, AtomicGetAndResetCounter(num_calls_finished_with_client_failed_to_send,

@ -33,10 +33,10 @@ namespace grpc_core {
class GrpcLbClientStats : public RefCounted<GrpcLbClientStats> { class GrpcLbClientStats : public RefCounted<GrpcLbClientStats> {
public: public:
struct DropTokenCount { struct DropTokenCount {
UniquePtr<char> token; std::unique_ptr<char> token;
int64_t count; int64_t count;
DropTokenCount(UniquePtr<char> token, int64_t count) DropTokenCount(std::unique_ptr<char> token, int64_t count)
: token(std::move(token)), count(count) {} : token(std::move(token)), count(count) {}
}; };
@ -51,7 +51,7 @@ class GrpcLbClientStats : public RefCounted<GrpcLbClientStats> {
void Get(int64_t* num_calls_started, int64_t* num_calls_finished, void Get(int64_t* num_calls_started, int64_t* num_calls_finished,
int64_t* num_calls_finished_with_client_failed_to_send, int64_t* num_calls_finished_with_client_failed_to_send,
int64_t* num_calls_finished_known_received, int64_t* num_calls_finished_known_received,
UniquePtr<DroppedCallCounts>* drop_token_counts); std::unique_ptr<DroppedCallCounts>* drop_token_counts);
// A destruction function to use as the user_data key when attaching // A destruction function to use as the user_data key when attaching
// client stats to a grpc_mdelem. // client stats to a grpc_mdelem.
@ -65,7 +65,7 @@ class GrpcLbClientStats : public RefCounted<GrpcLbClientStats> {
gpr_atm num_calls_finished_with_client_failed_to_send_ = 0; gpr_atm num_calls_finished_with_client_failed_to_send_ = 0;
gpr_atm num_calls_finished_known_received_ = 0; gpr_atm num_calls_finished_known_received_ = 0;
Mutex drop_count_mu_; // Guards drop_token_counts_. Mutex drop_count_mu_; // Guards drop_token_counts_.
UniquePtr<DroppedCallCounts> drop_token_counts_; std::unique_ptr<DroppedCallCounts> drop_token_counts_;
}; };
} // namespace grpc_core } // namespace grpc_core

@ -63,7 +63,7 @@ grpc_grpclb_request* grpc_grpclb_load_report_request_create(
int64_t num_calls_finished; int64_t num_calls_finished;
int64_t num_calls_finished_with_client_failed_to_send; int64_t num_calls_finished_with_client_failed_to_send;
int64_t num_calls_finished_known_received; int64_t num_calls_finished_known_received;
UniquePtr<GrpcLbClientStats::DroppedCallCounts> drop_token_counts; std::unique_ptr<GrpcLbClientStats::DroppedCallCounts> drop_token_counts;
client_stats->Get(&num_calls_started, &num_calls_finished, client_stats->Get(&num_calls_started, &num_calls_finished,
&num_calls_finished_with_client_failed_to_send, &num_calls_finished_with_client_failed_to_send,
&num_calls_finished_known_received, &drop_token_counts); &num_calls_finished_known_received, &drop_token_counts);

@ -495,7 +495,7 @@ class PickFirstFactory : public LoadBalancingPolicyFactory {
GPR_DEBUG_ASSERT(strcmp(json->key, name()) == 0); GPR_DEBUG_ASSERT(strcmp(json->key, name()) == 0);
} }
return RefCountedPtr<LoadBalancingPolicy::Config>( return RefCountedPtr<LoadBalancingPolicy::Config>(
New<ParsedPickFirstConfig>()); new ParsedPickFirstConfig());
} }
}; };

@ -491,7 +491,7 @@ class RoundRobinFactory : public LoadBalancingPolicyFactory {
GPR_DEBUG_ASSERT(strcmp(json->key, name()) == 0); GPR_DEBUG_ASSERT(strcmp(json->key, name()) == 0);
} }
return RefCountedPtr<LoadBalancingPolicy::Config>( return RefCountedPtr<LoadBalancingPolicy::Config>(
New<ParsedRoundRobinConfig>()); new ParsedRoundRobinConfig());
} }
}; };

@ -206,10 +206,6 @@ class SubchannelList : public InternallyRefCounted<SubchannelListType> {
virtual ~SubchannelList(); virtual ~SubchannelList();
private: private:
// So New() can call our private ctor.
template <typename T, typename... Args>
friend T* New(Args&&... args);
// For accessing Ref() and Unref(). // For accessing Ref() and Unref().
friend class SubchannelData<SubchannelListType, SubchannelDataType>; friend class SubchannelData<SubchannelListType, SubchannelDataType>;
@ -317,10 +313,10 @@ void SubchannelData<SubchannelListType,
} }
GPR_ASSERT(pending_watcher_ == nullptr); GPR_ASSERT(pending_watcher_ == nullptr);
pending_watcher_ = pending_watcher_ =
New<Watcher>(this, subchannel_list()->Ref(DEBUG_LOCATION, "Watcher")); new Watcher(this, subchannel_list()->Ref(DEBUG_LOCATION, "Watcher"));
subchannel_->WatchConnectivityState( subchannel_->WatchConnectivityState(
connectivity_state_, connectivity_state_,
UniquePtr<SubchannelInterface::ConnectivityStateWatcherInterface>( std::unique_ptr<SubchannelInterface::ConnectivityStateWatcherInterface>(
pending_watcher_)); pending_watcher_));
} }

@ -39,13 +39,13 @@ constexpr char kCds[] = "cds_experimental";
// Parsed config for this LB policy. // Parsed config for this LB policy.
class ParsedCdsConfig : public LoadBalancingPolicy::Config { class ParsedCdsConfig : public LoadBalancingPolicy::Config {
public: public:
explicit ParsedCdsConfig(UniquePtr<char> cluster) explicit ParsedCdsConfig(std::unique_ptr<char> cluster)
: cluster_(std::move(cluster)) {} : cluster_(std::move(cluster)) {}
const char* cluster() const { return cluster_.get(); } const char* cluster() const { return cluster_.get(); }
const char* name() const override { return kCds; } const char* name() const override { return kCds; }
private: private:
UniquePtr<char> cluster_; std::unique_ptr<char> cluster_;
}; };
// CDS LB policy. // CDS LB policy.
@ -78,7 +78,7 @@ class CdsLb : public LoadBalancingPolicy {
RefCountedPtr<SubchannelInterface> CreateSubchannel( RefCountedPtr<SubchannelInterface> CreateSubchannel(
const grpc_channel_args& args) override; const grpc_channel_args& args) override;
void UpdateState(grpc_connectivity_state state, void UpdateState(grpc_connectivity_state state,
UniquePtr<SubchannelPicker> picker) override; std::unique_ptr<SubchannelPicker> picker) override;
void RequestReresolution() override; void RequestReresolution() override;
void AddTraceEvent(TraceSeverity severity, StringView message) override; void AddTraceEvent(TraceSeverity severity, StringView message) override;
@ -136,7 +136,7 @@ void CdsLb::ClusterWatcher::OnClusterChanged(CdsUpdate cluster_data) {
? parent_->config_->cluster() ? parent_->config_->cluster()
: cluster_data.eds_service_name.get())); : cluster_data.eds_service_name.get()));
gpr_free(lrs_str); gpr_free(lrs_str);
UniquePtr<char> json_str_deleter(json_str); std::unique_ptr<char> json_str_deleter(json_str);
if (GRPC_TRACE_FLAG_ENABLED(grpc_cds_lb_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_cds_lb_trace)) {
gpr_log(GPR_INFO, "[cdslb %p] generated config for child policy: %s", gpr_log(GPR_INFO, "[cdslb %p] generated config for child policy: %s",
parent_.get(), json_str); parent_.get(), json_str);
@ -203,7 +203,7 @@ RefCountedPtr<SubchannelInterface> CdsLb::Helper::CreateSubchannel(
} }
void CdsLb::Helper::UpdateState(grpc_connectivity_state state, void CdsLb::Helper::UpdateState(grpc_connectivity_state state,
UniquePtr<SubchannelPicker> picker) { std::unique_ptr<SubchannelPicker> picker) {
if (parent_->shutting_down_) return; if (parent_->shutting_down_) return;
if (GRPC_TRACE_FLAG_ENABLED(grpc_cds_lb_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_cds_lb_trace)) {
gpr_log(GPR_INFO, "[cdslb %p] state updated by child: %s", this, gpr_log(GPR_INFO, "[cdslb %p] state updated by child: %s", this,
@ -343,7 +343,7 @@ class CdsFactory : public LoadBalancingPolicyFactory {
} }
if (error_list.empty()) { if (error_list.empty()) {
return MakeRefCounted<ParsedCdsConfig>( return MakeRefCounted<ParsedCdsConfig>(
UniquePtr<char>(gpr_strdup(cluster))); std::unique_ptr<char>(gpr_strdup(cluster)));
} else { } else {
*error = GRPC_ERROR_CREATE_FROM_VECTOR("Cds Parser", &error_list); *error = GRPC_ERROR_CREATE_FROM_VECTOR("Cds Parser", &error_list);
return nullptr; return nullptr;

@ -78,8 +78,8 @@ class ParsedXdsConfig : public LoadBalancingPolicy::Config {
public: public:
ParsedXdsConfig(RefCountedPtr<LoadBalancingPolicy::Config> child_policy, ParsedXdsConfig(RefCountedPtr<LoadBalancingPolicy::Config> child_policy,
RefCountedPtr<LoadBalancingPolicy::Config> fallback_policy, RefCountedPtr<LoadBalancingPolicy::Config> fallback_policy,
UniquePtr<char> eds_service_name, std::unique_ptr<char> eds_service_name,
UniquePtr<char> lrs_load_reporting_server_name) std::unique_ptr<char> lrs_load_reporting_server_name)
: child_policy_(std::move(child_policy)), : child_policy_(std::move(child_policy)),
fallback_policy_(std::move(fallback_policy)), fallback_policy_(std::move(fallback_policy)),
eds_service_name_(std::move(eds_service_name)), eds_service_name_(std::move(eds_service_name)),
@ -105,8 +105,8 @@ class ParsedXdsConfig : public LoadBalancingPolicy::Config {
private: private:
RefCountedPtr<LoadBalancingPolicy::Config> child_policy_; RefCountedPtr<LoadBalancingPolicy::Config> child_policy_;
RefCountedPtr<LoadBalancingPolicy::Config> fallback_policy_; RefCountedPtr<LoadBalancingPolicy::Config> fallback_policy_;
UniquePtr<char> eds_service_name_; std::unique_ptr<char> eds_service_name_;
UniquePtr<char> lrs_load_reporting_server_name_; std::unique_ptr<char> lrs_load_reporting_server_name_;
}; };
class XdsLb : public LoadBalancingPolicy { class XdsLb : public LoadBalancingPolicy {
@ -123,12 +123,13 @@ class XdsLb : public LoadBalancingPolicy {
// We need this wrapper for the following reasons: // We need this wrapper for the following reasons:
// 1. To process per-locality load reporting. // 1. To process per-locality load reporting.
// 2. Since pickers are UniquePtrs we use this RefCounted wrapper to control // 2. Since pickers are std::unique_ptrs we use this RefCounted wrapper to
// control
// references to it by the xds picker and the locality. // references to it by the xds picker and the locality.
class EndpointPickerWrapper : public RefCounted<EndpointPickerWrapper> { class EndpointPickerWrapper : public RefCounted<EndpointPickerWrapper> {
public: public:
EndpointPickerWrapper( EndpointPickerWrapper(
UniquePtr<SubchannelPicker> picker, std::unique_ptr<SubchannelPicker> picker,
RefCountedPtr<XdsClientStats::LocalityStats> locality_stats) RefCountedPtr<XdsClientStats::LocalityStats> locality_stats)
: picker_(std::move(picker)), : picker_(std::move(picker)),
locality_stats_(std::move(locality_stats)) { locality_stats_(std::move(locality_stats)) {
@ -139,7 +140,7 @@ class XdsLb : public LoadBalancingPolicy {
PickResult Pick(PickArgs args); PickResult Pick(PickArgs args);
private: private:
UniquePtr<SubchannelPicker> picker_; std::unique_ptr<SubchannelPicker> picker_;
RefCountedPtr<XdsClientStats::LocalityStats> locality_stats_; RefCountedPtr<XdsClientStats::LocalityStats> locality_stats_;
}; };
@ -180,7 +181,7 @@ class XdsLb : public LoadBalancingPolicy {
RefCountedPtr<SubchannelInterface> CreateSubchannel( RefCountedPtr<SubchannelInterface> CreateSubchannel(
const grpc_channel_args& args) override; const grpc_channel_args& args) override;
void UpdateState(grpc_connectivity_state state, void UpdateState(grpc_connectivity_state state,
UniquePtr<SubchannelPicker> picker) override; std::unique_ptr<SubchannelPicker> picker) override;
void RequestReresolution() override; void RequestReresolution() override;
void AddTraceEvent(TraceSeverity severity, StringView message) override; void AddTraceEvent(TraceSeverity severity, StringView message) override;
@ -238,7 +239,7 @@ class XdsLb : public LoadBalancingPolicy {
RefCountedPtr<SubchannelInterface> CreateSubchannel( RefCountedPtr<SubchannelInterface> CreateSubchannel(
const grpc_channel_args& args) override; const grpc_channel_args& args) override;
void UpdateState(grpc_connectivity_state state, void UpdateState(grpc_connectivity_state state,
UniquePtr<SubchannelPicker> picker) override; std::unique_ptr<SubchannelPicker> picker) override;
// This is a no-op, because we get the addresses from the xds // This is a no-op, because we get the addresses from the xds
// client, which is a watch-based API. // client, which is a watch-based API.
void RequestReresolution() override {} void RequestReresolution() override {}
@ -327,7 +328,7 @@ class XdsLb : public LoadBalancingPolicy {
RefCountedPtr<XdsLb> xds_policy_; RefCountedPtr<XdsLb> xds_policy_;
Map<RefCountedPtr<XdsLocalityName>, OrphanablePtr<Locality>, std::map<RefCountedPtr<XdsLocalityName>, OrphanablePtr<Locality>,
XdsLocalityName::Less> XdsLocalityName::Less>
localities_; localities_;
const uint32_t priority_; const uint32_t priority_;
@ -405,7 +406,7 @@ class XdsLb : public LoadBalancingPolicy {
} }
// Server name from target URI. // Server name from target URI.
UniquePtr<char> server_name_; std::unique_ptr<char> server_name_;
// Current channel args and config from the resolver. // Current channel args and config from the resolver.
const grpc_channel_args* args_ = nullptr; const grpc_channel_args* args_ = nullptr;
@ -494,7 +495,7 @@ LoadBalancingPolicy::PickResult XdsLb::EndpointPickerWrapper::Pick(
XdsLb::PickResult XdsLb::LocalityPicker::Pick(PickArgs args) { XdsLb::PickResult XdsLb::LocalityPicker::Pick(PickArgs args) {
// Handle drop. // Handle drop.
const UniquePtr<char>* drop_category; const std::unique_ptr<char>* drop_category;
if (drop_config_->ShouldDrop(&drop_category)) { if (drop_config_->ShouldDrop(&drop_category)) {
xds_policy_->client_stats_.AddCallDropped(*drop_category); xds_policy_->client_stats_.AddCallDropped(*drop_category);
PickResult result; PickResult result;
@ -553,8 +554,8 @@ RefCountedPtr<SubchannelInterface> XdsLb::FallbackHelper::CreateSubchannel(
return parent_->channel_control_helper()->CreateSubchannel(args); return parent_->channel_control_helper()->CreateSubchannel(args);
} }
void XdsLb::FallbackHelper::UpdateState(grpc_connectivity_state state, void XdsLb::FallbackHelper::UpdateState(
UniquePtr<SubchannelPicker> picker) { grpc_connectivity_state state, std::unique_ptr<SubchannelPicker> picker) {
if (parent_->shutting_down_) return; if (parent_->shutting_down_) return;
// If this request is from the pending fallback policy, ignore it until // If this request is from the pending fallback policy, ignore it until
// it reports READY, at which point we swap it into place. // it reports READY, at which point we swap it into place.
@ -992,12 +993,12 @@ void XdsLb::UpdateFallbackPolicyLocked() {
OrphanablePtr<LoadBalancingPolicy> XdsLb::CreateFallbackPolicyLocked( OrphanablePtr<LoadBalancingPolicy> XdsLb::CreateFallbackPolicyLocked(
const char* name, const grpc_channel_args* args) { const char* name, const grpc_channel_args* args) {
FallbackHelper* helper = FallbackHelper* helper =
New<FallbackHelper>(Ref(DEBUG_LOCATION, "FallbackHelper")); new FallbackHelper(Ref(DEBUG_LOCATION, "FallbackHelper"));
LoadBalancingPolicy::Args lb_policy_args; LoadBalancingPolicy::Args lb_policy_args;
lb_policy_args.combiner = combiner(); lb_policy_args.combiner = combiner();
lb_policy_args.args = args; lb_policy_args.args = args;
lb_policy_args.channel_control_helper = lb_policy_args.channel_control_helper =
UniquePtr<ChannelControlHelper>(helper); std::unique_ptr<ChannelControlHelper>(helper);
OrphanablePtr<LoadBalancingPolicy> lb_policy = OrphanablePtr<LoadBalancingPolicy> lb_policy =
LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy( LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
name, std::move(lb_policy_args)); name, std::move(lb_policy_args));
@ -1081,7 +1082,7 @@ void XdsLb::PriorityList::UpdateXdsPickerLocked() {
void XdsLb::PriorityList::MaybeCreateLocalityMapLocked(uint32_t priority) { void XdsLb::PriorityList::MaybeCreateLocalityMapLocked(uint32_t priority) {
// Exhausted priorities in the update. // Exhausted priorities in the update.
if (!priority_list_update().Contains(priority)) return; if (!priority_list_update().Contains(priority)) return;
auto new_locality_map = New<LocalityMap>( auto new_locality_map = new LocalityMap(
xds_policy_->Ref(DEBUG_LOCATION, "XdsLb+LocalityMap"), priority); xds_policy_->Ref(DEBUG_LOCATION, "XdsLb+LocalityMap"), priority);
priorities_.emplace_back(OrphanablePtr<LocalityMap>(new_locality_map)); priorities_.emplace_back(OrphanablePtr<LocalityMap>(new_locality_map));
new_locality_map->UpdateLocked(*priority_list_update().Find(priority)); new_locality_map->UpdateLocked(*priority_list_update().Find(priority));
@ -1500,12 +1501,12 @@ XdsLb::PriorityList::LocalityMap::Locality::CreateChildPolicyArgsLocked(
OrphanablePtr<LoadBalancingPolicy> OrphanablePtr<LoadBalancingPolicy>
XdsLb::PriorityList::LocalityMap::Locality::CreateChildPolicyLocked( XdsLb::PriorityList::LocalityMap::Locality::CreateChildPolicyLocked(
const char* name, const grpc_channel_args* args) { const char* name, const grpc_channel_args* args) {
Helper* helper = New<Helper>(this->Ref(DEBUG_LOCATION, "Helper")); Helper* helper = new Helper(this->Ref(DEBUG_LOCATION, "Helper"));
LoadBalancingPolicy::Args lb_policy_args; LoadBalancingPolicy::Args lb_policy_args;
lb_policy_args.combiner = xds_policy()->combiner(); lb_policy_args.combiner = xds_policy()->combiner();
lb_policy_args.args = args; lb_policy_args.args = args;
lb_policy_args.channel_control_helper = lb_policy_args.channel_control_helper =
UniquePtr<ChannelControlHelper>(helper); std::unique_ptr<ChannelControlHelper>(helper);
OrphanablePtr<LoadBalancingPolicy> lb_policy = OrphanablePtr<LoadBalancingPolicy> lb_policy =
LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy( LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
name, std::move(lb_policy_args)); name, std::move(lb_policy_args));
@ -1741,7 +1742,7 @@ XdsLb::PriorityList::LocalityMap::Locality::Helper::CreateSubchannel(
} }
void XdsLb::PriorityList::LocalityMap::Locality::Helper::UpdateState( void XdsLb::PriorityList::LocalityMap::Locality::Helper::UpdateState(
grpc_connectivity_state state, UniquePtr<SubchannelPicker> picker) { grpc_connectivity_state state, std::unique_ptr<SubchannelPicker> picker) {
if (locality_->xds_policy()->shutting_down_) return; if (locality_->xds_policy()->shutting_down_) return;
// If this request is from the pending child policy, ignore it until // If this request is from the pending child policy, ignore it until
// it reports READY, at which point we swap it into place. // it reports READY, at which point we swap it into place.
@ -1870,8 +1871,8 @@ class XdsFactory : public LoadBalancingPolicyFactory {
if (error_list.empty()) { if (error_list.empty()) {
return MakeRefCounted<ParsedXdsConfig>( return MakeRefCounted<ParsedXdsConfig>(
std::move(child_policy), std::move(fallback_policy), std::move(child_policy), std::move(fallback_policy),
UniquePtr<char>(gpr_strdup(eds_service_name)), std::unique_ptr<char>(gpr_strdup(eds_service_name)),
UniquePtr<char>(gpr_strdup(lrs_load_reporting_server_name))); std::unique_ptr<char>(gpr_strdup(lrs_load_reporting_server_name)));
} else { } else {
*error = GRPC_ERROR_CREATE_FROM_VECTOR("Xds Parser", &error_list); *error = GRPC_ERROR_CREATE_FROM_VECTOR("Xds Parser", &error_list);
return nullptr; return nullptr;

@ -34,7 +34,7 @@ class RegistryState {
RegistryState() {} RegistryState() {}
void RegisterLoadBalancingPolicyFactory( void RegisterLoadBalancingPolicyFactory(
UniquePtr<LoadBalancingPolicyFactory> factory) { std::unique_ptr<LoadBalancingPolicyFactory> factory) {
for (size_t i = 0; i < factories_.size(); ++i) { for (size_t i = 0; i < factories_.size(); ++i) {
GPR_ASSERT(strcmp(factories_[i]->name(), factory->name()) != 0); GPR_ASSERT(strcmp(factories_[i]->name(), factory->name()) != 0);
} }
@ -52,7 +52,7 @@ class RegistryState {
} }
private: private:
InlinedVector<UniquePtr<LoadBalancingPolicyFactory>, 10> factories_; InlinedVector<std::unique_ptr<LoadBalancingPolicyFactory>, 10> factories_;
}; };
RegistryState* g_state = nullptr; RegistryState* g_state = nullptr;
@ -64,16 +64,16 @@ RegistryState* g_state = nullptr;
// //
void LoadBalancingPolicyRegistry::Builder::InitRegistry() { void LoadBalancingPolicyRegistry::Builder::InitRegistry() {
if (g_state == nullptr) g_state = New<RegistryState>(); if (g_state == nullptr) g_state = new RegistryState();
} }
void LoadBalancingPolicyRegistry::Builder::ShutdownRegistry() { void LoadBalancingPolicyRegistry::Builder::ShutdownRegistry() {
Delete(g_state); delete g_state;
g_state = nullptr; g_state = nullptr;
} }
void LoadBalancingPolicyRegistry::Builder::RegisterLoadBalancingPolicyFactory( void LoadBalancingPolicyRegistry::Builder::RegisterLoadBalancingPolicyFactory(
UniquePtr<LoadBalancingPolicyFactory> factory) { std::unique_ptr<LoadBalancingPolicyFactory> factory) {
InitRegistry(); InitRegistry();
g_state->RegisterLoadBalancingPolicyFactory(std::move(factory)); g_state->RegisterLoadBalancingPolicyFactory(std::move(factory));
} }

@ -41,7 +41,7 @@ class LoadBalancingPolicyRegistry {
/// Registers an LB policy factory. The factory will be used to create an /// Registers an LB policy factory. The factory will be used to create an
/// LB policy whose name matches that of the factory. /// LB policy whose name matches that of the factory.
static void RegisterLoadBalancingPolicyFactory( static void RegisterLoadBalancingPolicyFactory(
UniquePtr<LoadBalancingPolicyFactory> factory); std::unique_ptr<LoadBalancingPolicyFactory> factory);
}; };
/// Creates an LB policy of the type specified by \a name. /// Creates an LB policy of the type specified by \a name.

@ -43,7 +43,7 @@ Subchannel* LocalSubchannelPool::RegisterSubchannel(SubchannelKey* key,
GRPC_SUBCHANNEL_UNREF(constructed, "subchannel_register+found_existing"); GRPC_SUBCHANNEL_UNREF(constructed, "subchannel_register+found_existing");
} else { } else {
// There hasn't been such subchannel. Add one. // There hasn't been such subchannel. Add one.
subchannel_map_ = grpc_avl_add(subchannel_map_, New<SubchannelKey>(*key), subchannel_map_ = grpc_avl_add(subchannel_map_, new SubchannelKey(*key),
constructed, nullptr); constructed, nullptr);
c = constructed; c = constructed;
} }
@ -64,12 +64,12 @@ namespace {
void sck_avl_destroy(void* p, void* /*user_data*/) { void sck_avl_destroy(void* p, void* /*user_data*/) {
SubchannelKey* key = static_cast<SubchannelKey*>(p); SubchannelKey* key = static_cast<SubchannelKey*>(p);
Delete(key); delete key;
} }
void* sck_avl_copy(void* p, void* /*unused*/) { void* sck_avl_copy(void* p, void* /*unused*/) {
const SubchannelKey* key = static_cast<const SubchannelKey*>(p); const SubchannelKey* key = static_cast<const SubchannelKey*>(p);
auto new_key = New<SubchannelKey>(*key); auto new_key = new SubchannelKey(*key);
return static_cast<void*>(new_key); return static_cast<void*>(new_key);
} }

@ -73,8 +73,8 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr,
bool log_errors) { bool log_errors) {
bool success = false; bool success = false;
// Split host and port. // Split host and port.
grpc_core::UniquePtr<char> host; std::unique_ptr<char> host;
grpc_core::UniquePtr<char> port; std::unique_ptr<char> port;
if (!grpc_core::SplitHostPort(hostport, &host, &port)) { if (!grpc_core::SplitHostPort(hostport, &host, &port)) {
if (log_errors) { if (log_errors) {
gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport); gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport);
@ -125,8 +125,8 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr,
bool log_errors) { bool log_errors) {
bool success = false; bool success = false;
// Split host and port. // Split host and port.
grpc_core::UniquePtr<char> host; std::unique_ptr<char> host;
grpc_core::UniquePtr<char> port; std::unique_ptr<char> port;
if (!grpc_core::SplitHostPort(hostport, &host, &port)) { if (!grpc_core::SplitHostPort(hostport, &host, &port)) {
if (log_errors) { if (log_errors) {
gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport); gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport);

@ -30,7 +30,8 @@ namespace grpc_core {
// Resolver // Resolver
// //
Resolver::Resolver(Combiner* combiner, UniquePtr<ResultHandler> result_handler) Resolver::Resolver(Combiner* combiner,
std::unique_ptr<ResultHandler> result_handler)
: InternallyRefCounted(&grpc_trace_resolver_refcount), : InternallyRefCounted(&grpc_trace_resolver_refcount),
result_handler_(std::move(result_handler)), result_handler_(std::move(result_handler)),
combiner_(GRPC_COMBINER_REF(combiner, "resolver")) {} combiner_(GRPC_COMBINER_REF(combiner, "resolver")) {}

@ -127,7 +127,7 @@ class Resolver : public InternallyRefCounted<Resolver> {
// API should change to take a RefCountedPtr<>, so that we always take // API should change to take a RefCountedPtr<>, so that we always take
// ownership of a new ref. // ownership of a new ref.
explicit Resolver(Combiner* combiner, explicit Resolver(Combiner* combiner,
UniquePtr<ResultHandler> result_handler); std::unique_ptr<ResultHandler> result_handler);
/// Shuts down the resolver. /// Shuts down the resolver.
virtual void ShutdownLocked() = 0; virtual void ShutdownLocked() = 0;
@ -137,7 +137,7 @@ class Resolver : public InternallyRefCounted<Resolver> {
ResultHandler* result_handler() const { return result_handler_.get(); } ResultHandler* result_handler() const { return result_handler_.get(); }
private: private:
UniquePtr<ResultHandler> result_handler_; std::unique_ptr<ResultHandler> result_handler_;
Combiner* combiner_; Combiner* combiner_;
}; };

@ -108,7 +108,7 @@ class AresDnsResolver : public Resolver {
/// retry backoff state /// retry backoff state
BackOff backoff_; BackOff backoff_;
/// currently resolving addresses /// currently resolving addresses
UniquePtr<ServerAddressList> addresses_; std::unique_ptr<ServerAddressList> addresses_;
/// currently resolving service config /// currently resolving service config
char* service_config_json_ = nullptr; char* service_config_json_ = nullptr;
// has shutdown been initiated // has shutdown been initiated
@ -496,8 +496,7 @@ static bool should_use_ares(const char* resolver_env) {
static bool g_use_ares_dns_resolver; static bool g_use_ares_dns_resolver;
void grpc_resolver_dns_ares_init() { void grpc_resolver_dns_ares_init() {
grpc_core::UniquePtr<char> resolver = std::unique_ptr<char> resolver = GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver);
GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver);
if (should_use_ares(resolver.get())) { if (should_use_ares(resolver.get())) {
g_use_ares_dns_resolver = true; g_use_ares_dns_resolver = true;
gpr_log(GPR_DEBUG, "Using ares dns resolver"); gpr_log(GPR_DEBUG, "Using ares dns resolver");

@ -77,7 +77,7 @@ struct grpc_ares_ev_driver {
/** request object that's using this ev driver */ /** request object that's using this ev driver */
grpc_ares_request* request; grpc_ares_request* request;
/** Owned by the ev_driver. Creates new GrpcPolledFd's */ /** Owned by the ev_driver. Creates new GrpcPolledFd's */
grpc_core::UniquePtr<grpc_core::GrpcPolledFdFactory> polled_fd_factory; std::unique_ptr<grpc_core::GrpcPolledFdFactory> polled_fd_factory;
/** query timeout in milliseconds */ /** query timeout in milliseconds */
int query_timeout_ms; int query_timeout_ms;
/** alarm to cancel active queries */ /** alarm to cancel active queries */
@ -110,7 +110,7 @@ static void grpc_ares_ev_driver_unref(grpc_ares_ev_driver* ev_driver) {
GRPC_COMBINER_UNREF(ev_driver->combiner, "free ares event driver"); GRPC_COMBINER_UNREF(ev_driver->combiner, "free ares event driver");
ares_destroy(ev_driver->channel); ares_destroy(ev_driver->channel);
grpc_ares_complete_request_locked(ev_driver->request); grpc_ares_complete_request_locked(ev_driver->request);
grpc_core::Delete(ev_driver); delete ev_driver;
} }
} }
@ -120,7 +120,7 @@ static void fd_node_destroy_locked(fd_node* fdn) {
GPR_ASSERT(!fdn->readable_registered); GPR_ASSERT(!fdn->readable_registered);
GPR_ASSERT(!fdn->writable_registered); GPR_ASSERT(!fdn->writable_registered);
GPR_ASSERT(fdn->already_shutdown); GPR_ASSERT(fdn->already_shutdown);
grpc_core::Delete(fdn->grpc_polled_fd); delete fdn->grpc_polled_fd;
gpr_free(fdn); gpr_free(fdn);
} }
@ -148,7 +148,7 @@ grpc_error* grpc_ares_ev_driver_create_locked(grpc_ares_ev_driver** ev_driver,
int query_timeout_ms, int query_timeout_ms,
grpc_core::Combiner* combiner, grpc_core::Combiner* combiner,
grpc_ares_request* request) { grpc_ares_request* request) {
*ev_driver = grpc_core::New<grpc_ares_ev_driver>(); *ev_driver = new grpc_ares_ev_driver();
ares_options opts; ares_options opts;
memset(&opts, 0, sizeof(opts)); memset(&opts, 0, sizeof(opts));
opts.flags |= ARES_FLAG_STAYOPEN; opts.flags |= ARES_FLAG_STAYOPEN;

@ -95,7 +95,7 @@ class GrpcPolledFdFactory {
virtual void ConfigureAresChannelLocked(ares_channel channel) = 0; virtual void ConfigureAresChannelLocked(ares_channel channel) = 0;
}; };
UniquePtr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(Combiner* combiner); std::unique_ptr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(Combiner* combiner);
} // namespace grpc_core } // namespace grpc_core

@ -37,14 +37,14 @@ namespace grpc_core {
void ares_uv_poll_cb(uv_poll_t* handle, int status, int events); void ares_uv_poll_cb(uv_poll_t* handle, int status, int events);
void ares_uv_poll_close_cb(uv_handle_t* handle) { Delete(handle); } void ares_uv_poll_close_cb(uv_handle_t* handle) { delete handle; }
class GrpcPolledFdLibuv : public GrpcPolledFd { class GrpcPolledFdLibuv : public GrpcPolledFd {
public: public:
GrpcPolledFdLibuv(ares_socket_t as, Combiner* combiner) GrpcPolledFdLibuv(ares_socket_t as, Combiner* combiner)
: as_(as), combiner_(combiner) { : as_(as), combiner_(combiner) {
gpr_asprintf(&name_, "c-ares socket: %" PRIdPTR, (intptr_t)as); gpr_asprintf(&name_, "c-ares socket: %" PRIdPTR, (intptr_t)as);
handle_ = New<uv_poll_t>(); handle_ = new uv_poll_t();
uv_poll_init_socket(uv_default_loop(), handle_, as); uv_poll_init_socket(uv_default_loop(), handle_, as);
handle_->data = this; handle_->data = this;
GRPC_COMBINER_REF(combiner_, "libuv ares event driver"); GRPC_COMBINER_REF(combiner_, "libuv ares event driver");
@ -81,10 +81,12 @@ class GrpcPolledFdLibuv : public GrpcPolledFd {
uv_poll_stop(handle_); uv_poll_stop(handle_);
uv_close(reinterpret_cast<uv_handle_t*>(handle_), ares_uv_poll_close_cb); uv_close(reinterpret_cast<uv_handle_t*>(handle_), ares_uv_poll_close_cb);
if (read_closure_ != nullptr) { if (read_closure_ != nullptr) {
GRPC_CLOSURE_SCHED(read_closure_, GRPC_ERROR_CANCELLED); grpc_core::ExecCtx::Run(DEBUG_LOCATION, read_closure_,
GRPC_ERROR_CANCELLED);
} }
if (write_closure_ != nullptr) { if (write_closure_ != nullptr) {
GRPC_CLOSURE_SCHED(write_closure_, GRPC_ERROR_CANCELLED); grpc_core::ExecCtx::Run(DEBUG_LOCATION, write_closure_,
GRPC_ERROR_CANCELLED);
} }
} }
@ -120,7 +122,7 @@ struct AresUvPollCbArg {
}; };
static void ares_uv_poll_cb_locked(void* arg, grpc_error* error) { static void ares_uv_poll_cb_locked(void* arg, grpc_error* error) {
grpc_core::UniquePtr<AresUvPollCbArg> arg_struct( std::unique_ptr<AresUvPollCbArg> arg_struct(
reinterpret_cast<AresUvPollCbArg*>(arg)); reinterpret_cast<AresUvPollCbArg*>(arg));
uv_poll_t* handle = arg_struct->handle; uv_poll_t* handle = arg_struct->handle;
int status = arg_struct->status; int status = arg_struct->status;
@ -135,13 +137,13 @@ static void ares_uv_poll_cb_locked(void* arg, grpc_error* error) {
} }
if (events & UV_READABLE) { if (events & UV_READABLE) {
GPR_ASSERT(polled_fd->read_closure_ != nullptr); GPR_ASSERT(polled_fd->read_closure_ != nullptr);
GRPC_CLOSURE_SCHED(polled_fd->read_closure_, error); grpc_core::ExecCtx::Run(DEBUG_LOCATION, polled_fd->read_closure_, error);
polled_fd->read_closure_ = nullptr; polled_fd->read_closure_ = nullptr;
polled_fd->poll_events_ &= ~UV_READABLE; polled_fd->poll_events_ &= ~UV_READABLE;
} }
if (events & UV_WRITABLE) { if (events & UV_WRITABLE) {
GPR_ASSERT(polled_fd->write_closure_ != nullptr); GPR_ASSERT(polled_fd->write_closure_ != nullptr);
GRPC_CLOSURE_SCHED(polled_fd->write_closure_, error); grpc_core::ExecCtx::Run(DEBUG_LOCATION, polled_fd->write_closure_, error);
polled_fd->write_closure_ = nullptr; polled_fd->write_closure_ = nullptr;
polled_fd->poll_events_ &= ~UV_WRITABLE; polled_fd->poll_events_ &= ~UV_WRITABLE;
} }
@ -152,7 +154,7 @@ void ares_uv_poll_cb(uv_poll_t* handle, int status, int events) {
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
GrpcPolledFdLibuv* polled_fd = GrpcPolledFdLibuv* polled_fd =
reinterpret_cast<GrpcPolledFdLibuv*>(handle->data); reinterpret_cast<GrpcPolledFdLibuv*>(handle->data);
AresUvPollCbArg* arg = New<AresUvPollCbArg>(handle, status, events); AresUvPollCbArg* arg = new AresUvPollCbArg(handle, status, events);
polled_fd->combiner_->Run( polled_fd->combiner_->Run(
GRPC_CLOSURE_CREATE(ares_uv_poll_cb_locked, arg, nullptr), GRPC_CLOSURE_CREATE(ares_uv_poll_cb_locked, arg, nullptr),
GRPC_ERROR_NONE); GRPC_ERROR_NONE);
@ -163,13 +165,14 @@ class GrpcPolledFdFactoryLibuv : public GrpcPolledFdFactory {
GrpcPolledFd* NewGrpcPolledFdLocked(ares_socket_t as, GrpcPolledFd* NewGrpcPolledFdLocked(ares_socket_t as,
grpc_pollset_set* driver_pollset_set, grpc_pollset_set* driver_pollset_set,
Combiner* combiner) override { Combiner* combiner) override {
return New<GrpcPolledFdLibuv>(as, combiner); return new GrpcPolledFdLibuv(as, combiner);
} }
void ConfigureAresChannelLocked(ares_channel channel) override {} void ConfigureAresChannelLocked(ares_channel channel) override {}
}; };
UniquePtr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(Combiner* combiner) { std::unique_ptr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(
Combiner* combiner) {
return MakeUnique<GrpcPolledFdFactoryLibuv>(); return MakeUnique<GrpcPolledFdFactoryLibuv>();
} }

@ -91,13 +91,14 @@ class GrpcPolledFdFactoryPosix : public GrpcPolledFdFactory {
GrpcPolledFd* NewGrpcPolledFdLocked(ares_socket_t as, GrpcPolledFd* NewGrpcPolledFdLocked(ares_socket_t as,
grpc_pollset_set* driver_pollset_set, grpc_pollset_set* driver_pollset_set,
Combiner* /*combiner*/) override { Combiner* /*combiner*/) override {
return New<GrpcPolledFdPosix>(as, driver_pollset_set); return new GrpcPolledFdPosix(as, driver_pollset_set);
} }
void ConfigureAresChannelLocked(ares_channel /*channel*/) override {} void ConfigureAresChannelLocked(ares_channel /*channel*/) override {}
}; };
UniquePtr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(Combiner* /*combiner*/) { std::unique_ptr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(
Combiner* /*combiner*/) {
return MakeUnique<GrpcPolledFdFactoryPosix>(); return MakeUnique<GrpcPolledFdFactoryPosix>();
} }

@ -128,12 +128,12 @@ class GrpcPolledFdWindows {
} }
void ScheduleAndNullReadClosure(grpc_error* error) { void ScheduleAndNullReadClosure(grpc_error* error) {
GRPC_CLOSURE_SCHED(read_closure_, error); grpc_core::ExecCtx::Run(DEBUG_LOCATION, read_closure_, error);
read_closure_ = nullptr; read_closure_ = nullptr;
} }
void ScheduleAndNullWriteClosure(grpc_error* error) { void ScheduleAndNullWriteClosure(grpc_error* error) {
GRPC_CLOSURE_SCHED(write_closure_, error); grpc_core::ExecCtx::Run(DEBUG_LOCATION, write_closure_, error);
write_closure_ = nullptr; write_closure_ = nullptr;
} }
@ -752,7 +752,7 @@ class SockToPolledFdMap {
} }
void AddNewSocket(SOCKET s, GrpcPolledFdWindows* polled_fd) { void AddNewSocket(SOCKET s, GrpcPolledFdWindows* polled_fd) {
SockToPolledFdEntry* new_node = New<SockToPolledFdEntry>(s, polled_fd); SockToPolledFdEntry* new_node = new SockToPolledFdEntry(s, polled_fd);
new_node->next = head_; new_node->next = head_;
head_ = new_node; head_ = new_node;
} }
@ -775,7 +775,7 @@ class SockToPolledFdMap {
node = node->next) { node = node->next) {
if (node->socket == s) { if (node->socket == s) {
*prev = node->next; *prev = node->next;
Delete(node); delete node;
return; return;
} }
prev = &node->next; prev = &node->next;
@ -805,7 +805,7 @@ class SockToPolledFdMap {
} }
grpc_tcp_set_non_block(s); grpc_tcp_set_non_block(s);
GrpcPolledFdWindows* polled_fd = GrpcPolledFdWindows* polled_fd =
New<GrpcPolledFdWindows>(s, map->combiner_, af, type); new GrpcPolledFdWindows(s, map->combiner_, af, type);
GRPC_CARES_TRACE_LOG( GRPC_CARES_TRACE_LOG(
"fd:|%s| created with params af:%d type:%d protocol:%d", "fd:|%s| created with params af:%d type:%d protocol:%d",
polled_fd->GetName(), af, type, protocol); polled_fd->GetName(), af, type, protocol);
@ -855,7 +855,7 @@ class SockToPolledFdMap {
"Shut down c-ares fd before without it ever having made it into the " "Shut down c-ares fd before without it ever having made it into the "
"driver's list")); "driver's list"));
} }
grpc_core::Delete(polled_fd); delete polled_fd;
return 0; return 0;
} }
@ -920,7 +920,7 @@ class GrpcPolledFdFactoryWindows : public GrpcPolledFdFactory {
// Set a flag so that the virtual socket "close" method knows it // Set a flag so that the virtual socket "close" method knows it
// doesn't need to call ShutdownLocked, since now the driver will. // doesn't need to call ShutdownLocked, since now the driver will.
polled_fd->set_gotten_into_driver_list(); polled_fd->set_gotten_into_driver_list();
return grpc_core::New<GrpcPolledFdWindowsWrapper>(polled_fd); return new GrpcPolledFdWindowsWrapper(polled_fd);
} }
void ConfigureAresChannelLocked(ares_channel channel) override { void ConfigureAresChannelLocked(ares_channel channel) override {
@ -932,7 +932,8 @@ class GrpcPolledFdFactoryWindows : public GrpcPolledFdFactory {
SockToPolledFdMap sock_to_polled_fd_map_; SockToPolledFdMap sock_to_polled_fd_map_;
}; };
UniquePtr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(Combiner* combiner) { std::unique_ptr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(
Combiner* combiner) {
return MakeUnique<GrpcPolledFdFactoryWindows>(combiner); return MakeUnique<GrpcPolledFdFactoryWindows>(combiner);
} }

@ -59,7 +59,7 @@ struct grpc_ares_request {
/** closure to call when the request completes */ /** closure to call when the request completes */
grpc_closure* on_done; grpc_closure* on_done;
/** the pointer to receive the resolved addresses */ /** the pointer to receive the resolved addresses */
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addresses_out; std::unique_ptr<grpc_core::ServerAddressList>* addresses_out;
/** the pointer to receive the service config in JSON */ /** the pointer to receive the service config in JSON */
char** service_config_json_out; char** service_config_json_out;
/** the evernt driver used by this request */ /** the evernt driver used by this request */
@ -148,7 +148,7 @@ void grpc_ares_complete_request_locked(grpc_ares_request* r) {
// TODO(apolcyn): allow c-ares to return a service config // TODO(apolcyn): allow c-ares to return a service config
// with no addresses along side it // with no addresses along side it
} }
GRPC_CLOSURE_SCHED(r->on_done, r->error); grpc_core::ExecCtx::Run(DEBUG_LOCATION, r->on_done, r->error);
} }
static grpc_ares_hostbyname_request* create_hostbyname_request_locked( static grpc_ares_hostbyname_request* create_hostbyname_request_locked(
@ -355,8 +355,8 @@ void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked(
grpc_ares_hostbyname_request* hr = nullptr; grpc_ares_hostbyname_request* hr = nullptr;
ares_channel* channel = nullptr; ares_channel* channel = nullptr;
/* parse name, splitting it into host and port parts */ /* parse name, splitting it into host and port parts */
grpc_core::UniquePtr<char> host; std::unique_ptr<char> host;
grpc_core::UniquePtr<char> port; std::unique_ptr<char> port;
grpc_core::SplitHostPort(name, &host, &port); grpc_core::SplitHostPort(name, &host, &port);
if (host == nullptr) { if (host == nullptr) {
error = grpc_error_set_str( error = grpc_error_set_str(
@ -447,14 +447,14 @@ void grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked(
return; return;
error_cleanup: error_cleanup:
GRPC_CLOSURE_SCHED(r->on_done, error); grpc_core::ExecCtx::Run(DEBUG_LOCATION, r->on_done, error);
} }
static bool inner_resolve_as_ip_literal_locked( static bool inner_resolve_as_ip_literal_locked(
const char* name, const char* default_port, const char* name, const char* default_port,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs, std::unique_ptr<grpc_core::ServerAddressList>* addrs,
grpc_core::UniquePtr<char>* host, grpc_core::UniquePtr<char>* port, std::unique_ptr<char>* host, std::unique_ptr<char>* port,
grpc_core::UniquePtr<char>* hostport) { std::unique_ptr<char>* hostport) {
grpc_core::SplitHostPort(name, host, port); grpc_core::SplitHostPort(name, host, port);
if (*host == nullptr) { if (*host == nullptr) {
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
@ -489,18 +489,18 @@ static bool inner_resolve_as_ip_literal_locked(
static bool resolve_as_ip_literal_locked( static bool resolve_as_ip_literal_locked(
const char* name, const char* default_port, const char* name, const char* default_port,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs) { std::unique_ptr<grpc_core::ServerAddressList>* addrs) {
grpc_core::UniquePtr<char> host; std::unique_ptr<char> host;
grpc_core::UniquePtr<char> port; std::unique_ptr<char> port;
grpc_core::UniquePtr<char> hostport; std::unique_ptr<char> hostport;
bool out = inner_resolve_as_ip_literal_locked(name, default_port, addrs, bool out = inner_resolve_as_ip_literal_locked(name, default_port, addrs,
&host, &port, &hostport); &host, &port, &hostport);
return out; return out;
} }
static bool target_matches_localhost_inner(const char* name, static bool target_matches_localhost_inner(const char* name,
grpc_core::UniquePtr<char>* host, std::unique_ptr<char>* host,
grpc_core::UniquePtr<char>* port) { std::unique_ptr<char>* port) {
if (!grpc_core::SplitHostPort(name, host, port)) { if (!grpc_core::SplitHostPort(name, host, port)) {
gpr_log(GPR_ERROR, "Unable to split host and port for name: %s", name); gpr_log(GPR_ERROR, "Unable to split host and port for name: %s", name);
return false; return false;
@ -513,16 +513,16 @@ static bool target_matches_localhost_inner(const char* name,
} }
static bool target_matches_localhost(const char* name) { static bool target_matches_localhost(const char* name) {
grpc_core::UniquePtr<char> host; std::unique_ptr<char> host;
grpc_core::UniquePtr<char> port; std::unique_ptr<char> port;
return target_matches_localhost_inner(name, &host, &port); return target_matches_localhost_inner(name, &host, &port);
} }
#ifdef GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY #ifdef GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY
static bool inner_maybe_resolve_localhost_manually_locked( static bool inner_maybe_resolve_localhost_manually_locked(
const char* name, const char* default_port, const char* name, const char* default_port,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs, std::unique_ptr<grpc_core::ServerAddressList>* addrs,
grpc_core::UniquePtr<char>* host, grpc_core::UniquePtr<char>* port) { std::unique_ptr<char>* host, std::unique_ptr<char>* port) {
grpc_core::SplitHostPort(name, host, port); grpc_core::SplitHostPort(name, host, port);
if (*host == nullptr) { if (*host == nullptr) {
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
@ -571,16 +571,16 @@ static bool inner_maybe_resolve_localhost_manually_locked(
static bool grpc_ares_maybe_resolve_localhost_manually_locked( static bool grpc_ares_maybe_resolve_localhost_manually_locked(
const char* name, const char* default_port, const char* name, const char* default_port,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs) { std::unique_ptr<grpc_core::ServerAddressList>* addrs) {
grpc_core::UniquePtr<char> host; std::unique_ptr<char> host;
grpc_core::UniquePtr<char> port; std::unique_ptr<char> port;
return inner_maybe_resolve_localhost_manually_locked(name, default_port, return inner_maybe_resolve_localhost_manually_locked(name, default_port,
addrs, &host, &port); addrs, &host, &port);
} }
#else /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ #else /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */
static bool grpc_ares_maybe_resolve_localhost_manually_locked( static bool grpc_ares_maybe_resolve_localhost_manually_locked(
const char* /*name*/, const char* /*default_port*/, const char* /*name*/, const char* /*default_port*/,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* /*addrs*/) { std::unique_ptr<grpc_core::ServerAddressList>* /*addrs*/) {
return false; return false;
} }
#endif /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */ #endif /* GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY */
@ -588,8 +588,8 @@ static bool grpc_ares_maybe_resolve_localhost_manually_locked(
static grpc_ares_request* grpc_dns_lookup_ares_locked_impl( static grpc_ares_request* grpc_dns_lookup_ares_locked_impl(
const char* dns_server, const char* name, const char* default_port, const char* dns_server, const char* name, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done, grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs, std::unique_ptr<grpc_core::ServerAddressList>* addrs, bool check_grpclb,
bool check_grpclb, char** service_config_json, int query_timeout_ms, char** service_config_json, int query_timeout_ms,
grpc_core::Combiner* combiner) { grpc_core::Combiner* combiner) {
grpc_ares_request* r = grpc_ares_request* r =
static_cast<grpc_ares_request*>(gpr_zalloc(sizeof(grpc_ares_request))); static_cast<grpc_ares_request*>(gpr_zalloc(sizeof(grpc_ares_request)));
@ -631,8 +631,8 @@ static grpc_ares_request* grpc_dns_lookup_ares_locked_impl(
grpc_ares_request* (*grpc_dns_lookup_ares_locked)( grpc_ares_request* (*grpc_dns_lookup_ares_locked)(
const char* dns_server, const char* name, const char* default_port, const char* dns_server, const char* name, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done, grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs, std::unique_ptr<grpc_core::ServerAddressList>* addrs, bool check_grpclb,
bool check_grpclb, char** service_config_json, int query_timeout_ms, char** service_config_json, int query_timeout_ms,
grpc_core::Combiner* combiner) = grpc_dns_lookup_ares_locked_impl; grpc_core::Combiner* combiner) = grpc_dns_lookup_ares_locked_impl;
static void grpc_cancel_ares_request_locked_impl(grpc_ares_request* r) { static void grpc_cancel_ares_request_locked_impl(grpc_ares_request* r) {
@ -678,7 +678,7 @@ typedef struct grpc_resolve_address_ares_request {
/** the pointer to receive the resolved addresses */ /** the pointer to receive the resolved addresses */
grpc_resolved_addresses** addrs_out; grpc_resolved_addresses** addrs_out;
/** currently resolving addresses */ /** currently resolving addresses */
grpc_core::UniquePtr<ServerAddressList> addresses; std::unique_ptr<ServerAddressList> addresses;
/** closure to call when the resolve_address_ares request completes */ /** closure to call when the resolve_address_ares request completes */
grpc_closure* on_resolve_address_done; grpc_closure* on_resolve_address_done;
/** a closure wrapping on_resolve_address_done, which should be invoked when /** a closure wrapping on_resolve_address_done, which should be invoked when
@ -714,9 +714,10 @@ static void on_dns_lookup_done_locked(void* arg, grpc_error* error) {
sizeof(grpc_resolved_address)); sizeof(grpc_resolved_address));
} }
} }
GRPC_CLOSURE_SCHED(r->on_resolve_address_done, GRPC_ERROR_REF(error)); grpc_core::ExecCtx::Run(DEBUG_LOCATION, r->on_resolve_address_done,
GRPC_ERROR_REF(error));
GRPC_COMBINER_UNREF(r->combiner, "on_dns_lookup_done_cb"); GRPC_COMBINER_UNREF(r->combiner, "on_dns_lookup_done_cb");
grpc_core::Delete(r); delete r;
} }
static void on_dns_lookup_done(void* arg, grpc_error* error) { static void on_dns_lookup_done(void* arg, grpc_error* error) {
@ -746,7 +747,7 @@ static void grpc_resolve_address_ares_impl(const char* name,
grpc_closure* on_done, grpc_closure* on_done,
grpc_resolved_addresses** addrs) { grpc_resolved_addresses** addrs) {
grpc_resolve_address_ares_request* r = grpc_resolve_address_ares_request* r =
grpc_core::New<grpc_resolve_address_ares_request>(); new grpc_resolve_address_ares_request();
r->combiner = grpc_combiner_create(); r->combiner = grpc_combiner_create();
r->addrs_out = addrs; r->addrs_out = addrs;
r->on_resolve_address_done = on_done; r->on_resolve_address_done = on_done;

@ -63,8 +63,8 @@ extern void (*grpc_resolve_address_ares)(const char* name,
extern grpc_ares_request* (*grpc_dns_lookup_ares_locked)( extern grpc_ares_request* (*grpc_dns_lookup_ares_locked)(
const char* dns_server, const char* name, const char* default_port, const char* dns_server, const char* name, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done, grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addresses, std::unique_ptr<grpc_core::ServerAddressList>* addresses, bool check_grpclb,
bool check_grpclb, char** service_config_json, int query_timeout_ms, char** service_config_json, int query_timeout_ms,
grpc_core::Combiner* combiner); grpc_core::Combiner* combiner);
/* Cancel the pending grpc_ares_request \a request */ /* Cancel the pending grpc_ares_request \a request */

@ -29,8 +29,8 @@ struct grpc_ares_request {
static grpc_ares_request* grpc_dns_lookup_ares_locked_impl( static grpc_ares_request* grpc_dns_lookup_ares_locked_impl(
const char* dns_server, const char* name, const char* default_port, const char* dns_server, const char* name, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done, grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs, std::unique_ptr<grpc_core::ServerAddressList>* addrs, bool check_grpclb,
bool check_grpclb, char** service_config_json, int query_timeout_ms, char** service_config_json, int query_timeout_ms,
grpc_core::Combiner* combiner) { grpc_core::Combiner* combiner) {
return NULL; return NULL;
} }
@ -38,8 +38,8 @@ static grpc_ares_request* grpc_dns_lookup_ares_locked_impl(
grpc_ares_request* (*grpc_dns_lookup_ares_locked)( grpc_ares_request* (*grpc_dns_lookup_ares_locked)(
const char* dns_server, const char* name, const char* default_port, const char* dns_server, const char* name, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done, grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_core::UniquePtr<grpc_core::ServerAddressList>* addrs, std::unique_ptr<grpc_core::ServerAddressList>* addrs, bool check_grpclb,
bool check_grpclb, char** service_config_json, int query_timeout_ms, char** service_config_json, int query_timeout_ms,
grpc_core::Combiner* combiner) = grpc_dns_lookup_ares_locked_impl; grpc_core::Combiner* combiner) = grpc_dns_lookup_ares_locked_impl;
static void grpc_cancel_ares_request_locked_impl(grpc_ares_request* r) {} static void grpc_cancel_ares_request_locked_impl(grpc_ares_request* r) {}

@ -300,8 +300,7 @@ class NativeDnsResolverFactory : public ResolverFactory {
} // namespace grpc_core } // namespace grpc_core
void grpc_resolver_dns_native_init() { void grpc_resolver_dns_native_init() {
grpc_core::UniquePtr<char> resolver = std::unique_ptr<char> resolver = GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver);
GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver);
if (gpr_stricmp(resolver.get(), "native") == 0) { if (gpr_stricmp(resolver.get(), "native") == 0) {
gpr_log(GPR_DEBUG, "Using native dns resolver"); gpr_log(GPR_DEBUG, "Using native dns resolver");
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory( grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(

@ -191,7 +191,7 @@ void FakeResolverResponseGenerator::SetResponseLocked(void* arg,
resolver->has_next_result_ = true; resolver->has_next_result_ = true;
resolver->MaybeSendResultLocked(); resolver->MaybeSendResultLocked();
} }
Delete(closure_arg); delete closure_arg;
} }
void FakeResolverResponseGenerator::SetResponse(Resolver::Result result) { void FakeResolverResponseGenerator::SetResponse(Resolver::Result result) {
@ -205,7 +205,7 @@ void FakeResolverResponseGenerator::SetResponse(Resolver::Result result) {
} }
resolver = resolver_->Ref(); resolver = resolver_->Ref();
} }
SetResponseClosureArg* closure_arg = New<SetResponseClosureArg>(); SetResponseClosureArg* closure_arg = new SetResponseClosureArg();
closure_arg->resolver = std::move(resolver); closure_arg->resolver = std::move(resolver);
closure_arg->result = std::move(result); closure_arg->result = std::move(result);
closure_arg->resolver->combiner()->Run( closure_arg->resolver->combiner()->Run(
@ -222,7 +222,7 @@ void FakeResolverResponseGenerator::SetReresolutionResponseLocked(
resolver->reresolution_result_ = std::move(closure_arg->result); resolver->reresolution_result_ = std::move(closure_arg->result);
resolver->has_reresolution_result_ = closure_arg->has_result; resolver->has_reresolution_result_ = closure_arg->has_result;
} }
Delete(closure_arg); delete closure_arg;
} }
void FakeResolverResponseGenerator::SetReresolutionResponse( void FakeResolverResponseGenerator::SetReresolutionResponse(
@ -233,7 +233,7 @@ void FakeResolverResponseGenerator::SetReresolutionResponse(
GPR_ASSERT(resolver_ != nullptr); GPR_ASSERT(resolver_ != nullptr);
resolver = resolver_->Ref(); resolver = resolver_->Ref();
} }
SetResponseClosureArg* closure_arg = New<SetResponseClosureArg>(); SetResponseClosureArg* closure_arg = new SetResponseClosureArg();
closure_arg->resolver = std::move(resolver); closure_arg->resolver = std::move(resolver);
closure_arg->result = std::move(result); closure_arg->result = std::move(result);
closure_arg->has_result = true; closure_arg->has_result = true;
@ -250,7 +250,7 @@ void FakeResolverResponseGenerator::UnsetReresolutionResponse() {
GPR_ASSERT(resolver_ != nullptr); GPR_ASSERT(resolver_ != nullptr);
resolver = resolver_->Ref(); resolver = resolver_->Ref();
} }
SetResponseClosureArg* closure_arg = New<SetResponseClosureArg>(); SetResponseClosureArg* closure_arg = new SetResponseClosureArg();
closure_arg->resolver = std::move(resolver); closure_arg->resolver = std::move(resolver);
closure_arg->resolver->combiner()->Run( closure_arg->resolver->combiner()->Run(
GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, GRPC_CLOSURE_INIT(&closure_arg->set_response_closure,
@ -266,7 +266,7 @@ void FakeResolverResponseGenerator::SetFailureLocked(void* arg,
resolver->return_failure_ = true; resolver->return_failure_ = true;
if (closure_arg->immediate) resolver->MaybeSendResultLocked(); if (closure_arg->immediate) resolver->MaybeSendResultLocked();
} }
Delete(closure_arg); delete closure_arg;
} }
void FakeResolverResponseGenerator::SetFailure() { void FakeResolverResponseGenerator::SetFailure() {
@ -276,7 +276,7 @@ void FakeResolverResponseGenerator::SetFailure() {
GPR_ASSERT(resolver_ != nullptr); GPR_ASSERT(resolver_ != nullptr);
resolver = resolver_->Ref(); resolver = resolver_->Ref();
} }
SetResponseClosureArg* closure_arg = New<SetResponseClosureArg>(); SetResponseClosureArg* closure_arg = new SetResponseClosureArg();
closure_arg->resolver = std::move(resolver); closure_arg->resolver = std::move(resolver);
closure_arg->resolver->combiner()->Run( closure_arg->resolver->combiner()->Run(
GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, SetFailureLocked, GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, SetFailureLocked,
@ -291,7 +291,7 @@ void FakeResolverResponseGenerator::SetFailureOnReresolution() {
GPR_ASSERT(resolver_ != nullptr); GPR_ASSERT(resolver_ != nullptr);
resolver = resolver_->Ref(); resolver = resolver_->Ref();
} }
SetResponseClosureArg* closure_arg = New<SetResponseClosureArg>(); SetResponseClosureArg* closure_arg = new SetResponseClosureArg();
closure_arg->resolver = std::move(resolver); closure_arg->resolver = std::move(resolver);
closure_arg->immediate = false; closure_arg->immediate = false;
closure_arg->resolver->combiner()->Run( closure_arg->resolver->combiner()->Run(
@ -306,7 +306,7 @@ void FakeResolverResponseGenerator::SetFakeResolver(
resolver_ = std::move(resolver); resolver_ = std::move(resolver);
if (resolver_ == nullptr) return; if (resolver_ == nullptr) return;
if (has_result_) { if (has_result_) {
SetResponseClosureArg* closure_arg = New<SetResponseClosureArg>(); SetResponseClosureArg* closure_arg = new SetResponseClosureArg();
closure_arg->resolver = resolver_->Ref(); closure_arg->resolver = resolver_->Ref();
closure_arg->result = std::move(result_); closure_arg->result = std::move(result_);
resolver_->combiner()->Run( resolver_->combiner()->Run(

@ -97,7 +97,8 @@ bool ParseUri(const grpc_uri* uri,
bool errors_found = false; bool errors_found = false;
for (size_t i = 0; i < path_parts.count; i++) { for (size_t i = 0; i < path_parts.count; i++) {
grpc_uri ith_uri = *uri; grpc_uri ith_uri = *uri;
UniquePtr<char> part_str(grpc_slice_to_c_string(path_parts.slices[i])); std::unique_ptr<char> part_str(
grpc_slice_to_c_string(path_parts.slices[i]));
ith_uri.path = part_str.get(); ith_uri.path = part_str.get();
grpc_resolved_address addr; grpc_resolved_address addr;
if (!parse(&ith_uri, &addr)) { if (!parse(&ith_uri, &addr)) {
@ -160,8 +161,8 @@ class UnixResolverFactory : public ResolverFactory {
return CreateSockaddrResolver(std::move(args), grpc_parse_unix); return CreateSockaddrResolver(std::move(args), grpc_parse_unix);
} }
UniquePtr<char> GetDefaultAuthority(grpc_uri* /*uri*/) const override { std::unique_ptr<char> GetDefaultAuthority(grpc_uri* /*uri*/) const override {
return UniquePtr<char>(gpr_strdup("localhost")); return std::unique_ptr<char>(gpr_strdup("localhost"));
} }
const char* scheme() const override { return "unix"; } const char* scheme() const override { return "unix"; }

@ -60,7 +60,7 @@ class XdsResolver : public Resolver {
RefCountedPtr<XdsResolver> resolver_; RefCountedPtr<XdsResolver> resolver_;
}; };
UniquePtr<char> server_name_; std::unique_ptr<char> server_name_;
const grpc_channel_args* args_; const grpc_channel_args* args_;
grpc_pollset_set* interested_parties_; grpc_pollset_set* interested_parties_;
OrphanablePtr<XdsClient> xds_client_; OrphanablePtr<XdsClient> xds_client_;

@ -41,7 +41,7 @@ struct ResolverArgs {
/// The combiner under which all resolver calls will be run. /// The combiner under which all resolver calls will be run.
Combiner* combiner = nullptr; Combiner* combiner = nullptr;
/// The result handler to be used by the resolver. /// The result handler to be used by the resolver.
UniquePtr<Resolver::ResultHandler> result_handler; std::unique_ptr<Resolver::ResultHandler> result_handler;
}; };
class ResolverFactory { class ResolverFactory {
@ -55,10 +55,10 @@ class ResolverFactory {
/// Returns a string representing the default authority to use for this /// Returns a string representing the default authority to use for this
/// scheme. /// scheme.
virtual UniquePtr<char> GetDefaultAuthority(grpc_uri* uri) const { virtual std::unique_ptr<char> GetDefaultAuthority(grpc_uri* uri) const {
const char* path = uri->path; const char* path = uri->path;
if (path[0] == '/') ++path; if (path[0] == '/') ++path;
return UniquePtr<char>(gpr_strdup(path)); return std::unique_ptr<char>(gpr_strdup(path));
} }
/// Returns the URI scheme that this factory implements. /// Returns the URI scheme that this factory implements.

@ -40,7 +40,7 @@ class RegistryState {
default_prefix_.reset(gpr_strdup(default_resolver_prefix)); default_prefix_.reset(gpr_strdup(default_resolver_prefix));
} }
void RegisterResolverFactory(UniquePtr<ResolverFactory> factory) { void RegisterResolverFactory(std::unique_ptr<ResolverFactory> factory) {
for (size_t i = 0; i < factories_.size(); ++i) { for (size_t i = 0; i < factories_.size(); ++i) {
GPR_ASSERT(strcmp(factories_[i]->scheme(), factory->scheme()) != 0); GPR_ASSERT(strcmp(factories_[i]->scheme(), factory->scheme()) != 0);
} }
@ -90,8 +90,8 @@ class RegistryState {
// more factories are needed and the additional allocations are // more factories are needed and the additional allocations are
// hurting performance (which is unlikely, since these allocations // hurting performance (which is unlikely, since these allocations
// only occur at gRPC initialization time). // only occur at gRPC initialization time).
InlinedVector<UniquePtr<ResolverFactory>, 10> factories_; InlinedVector<std::unique_ptr<ResolverFactory>, 10> factories_;
UniquePtr<char> default_prefix_; std::unique_ptr<char> default_prefix_;
}; };
static RegistryState* g_state = nullptr; static RegistryState* g_state = nullptr;
@ -103,11 +103,11 @@ static RegistryState* g_state = nullptr;
// //
void ResolverRegistry::Builder::InitRegistry() { void ResolverRegistry::Builder::InitRegistry() {
if (g_state == nullptr) g_state = New<RegistryState>(); if (g_state == nullptr) g_state = new RegistryState();
} }
void ResolverRegistry::Builder::ShutdownRegistry() { void ResolverRegistry::Builder::ShutdownRegistry() {
Delete(g_state); delete g_state;
g_state = nullptr; g_state = nullptr;
} }
@ -118,7 +118,7 @@ void ResolverRegistry::Builder::SetDefaultPrefix(
} }
void ResolverRegistry::Builder::RegisterResolverFactory( void ResolverRegistry::Builder::RegisterResolverFactory(
UniquePtr<ResolverFactory> factory) { std::unique_ptr<ResolverFactory> factory) {
InitRegistry(); InitRegistry();
g_state->RegisterResolverFactory(std::move(factory)); g_state->RegisterResolverFactory(std::move(factory));
} }
@ -146,7 +146,7 @@ bool ResolverRegistry::IsValidTarget(const char* target) {
OrphanablePtr<Resolver> ResolverRegistry::CreateResolver( OrphanablePtr<Resolver> ResolverRegistry::CreateResolver(
const char* target, const grpc_channel_args* args, const char* target, const grpc_channel_args* args,
grpc_pollset_set* pollset_set, Combiner* combiner, grpc_pollset_set* pollset_set, Combiner* combiner,
UniquePtr<Resolver::ResultHandler> result_handler) { std::unique_ptr<Resolver::ResultHandler> result_handler) {
GPR_ASSERT(g_state != nullptr); GPR_ASSERT(g_state != nullptr);
grpc_uri* uri = nullptr; grpc_uri* uri = nullptr;
char* canonical_target = nullptr; char* canonical_target = nullptr;
@ -166,26 +166,28 @@ OrphanablePtr<Resolver> ResolverRegistry::CreateResolver(
return resolver; return resolver;
} }
UniquePtr<char> ResolverRegistry::GetDefaultAuthority(const char* target) { std::unique_ptr<char> ResolverRegistry::GetDefaultAuthority(
const char* target) {
GPR_ASSERT(g_state != nullptr); GPR_ASSERT(g_state != nullptr);
grpc_uri* uri = nullptr; grpc_uri* uri = nullptr;
char* canonical_target = nullptr; char* canonical_target = nullptr;
ResolverFactory* factory = ResolverFactory* factory =
g_state->FindResolverFactory(target, &uri, &canonical_target); g_state->FindResolverFactory(target, &uri, &canonical_target);
UniquePtr<char> authority = std::unique_ptr<char> authority =
factory == nullptr ? nullptr : factory->GetDefaultAuthority(uri); factory == nullptr ? nullptr : factory->GetDefaultAuthority(uri);
grpc_uri_destroy(uri); grpc_uri_destroy(uri);
gpr_free(canonical_target); gpr_free(canonical_target);
return authority; return authority;
} }
UniquePtr<char> ResolverRegistry::AddDefaultPrefixIfNeeded(const char* target) { std::unique_ptr<char> ResolverRegistry::AddDefaultPrefixIfNeeded(
const char* target) {
GPR_ASSERT(g_state != nullptr); GPR_ASSERT(g_state != nullptr);
grpc_uri* uri = nullptr; grpc_uri* uri = nullptr;
char* canonical_target = nullptr; char* canonical_target = nullptr;
g_state->FindResolverFactory(target, &uri, &canonical_target); g_state->FindResolverFactory(target, &uri, &canonical_target);
grpc_uri_destroy(uri); grpc_uri_destroy(uri);
return UniquePtr<char>(canonical_target == nullptr ? gpr_strdup(target) return std::unique_ptr<char>(canonical_target == nullptr ? gpr_strdup(target)
: canonical_target); : canonical_target);
} }

@ -47,7 +47,8 @@ class ResolverRegistry {
/// Registers a resolver factory. The factory will be used to create a /// Registers a resolver factory. The factory will be used to create a
/// resolver for any URI whose scheme matches that of the factory. /// resolver for any URI whose scheme matches that of the factory.
/// Calls InitRegistry() if it has not already been called. /// Calls InitRegistry() if it has not already been called.
static void RegisterResolverFactory(UniquePtr<ResolverFactory> factory); static void RegisterResolverFactory(
std::unique_ptr<ResolverFactory> factory);
}; };
/// Checks whether the user input \a target is valid to create a resolver. /// Checks whether the user input \a target is valid to create a resolver.
@ -69,13 +70,13 @@ class ResolverRegistry {
static OrphanablePtr<Resolver> CreateResolver( static OrphanablePtr<Resolver> CreateResolver(
const char* target, const grpc_channel_args* args, const char* target, const grpc_channel_args* args,
grpc_pollset_set* pollset_set, Combiner* combiner, grpc_pollset_set* pollset_set, Combiner* combiner,
UniquePtr<Resolver::ResultHandler> result_handler); std::unique_ptr<Resolver::ResultHandler> result_handler);
/// Returns the default authority to pass from a client for \a target. /// Returns the default authority to pass from a client for \a target.
static UniquePtr<char> GetDefaultAuthority(const char* target); static std::unique_ptr<char> GetDefaultAuthority(const char* target);
/// Returns \a target with the default prefix prepended, if needed. /// Returns \a target with the default prefix prepended, if needed.
static UniquePtr<char> AddDefaultPrefixIfNeeded(const char* target); static std::unique_ptr<char> AddDefaultPrefixIfNeeded(const char* target);
/// Returns the resolver factory for \a scheme. /// Returns the resolver factory for \a scheme.
/// Caller does NOT own the return value. /// Caller does NOT own the return value.

@ -66,7 +66,7 @@ bool ParseDuration(grpc_json* field, grpc_millis* duration) {
if (field->type != GRPC_JSON_STRING) return false; if (field->type != GRPC_JSON_STRING) return false;
size_t len = strlen(field->value); size_t len = strlen(field->value);
if (field->value[len - 1] != 's') return false; if (field->value[len - 1] != 's') return false;
UniquePtr<char> buf(gpr_strdup(field->value)); std::unique_ptr<char> buf(gpr_strdup(field->value));
*(buf.get() + len - 1) = '\0'; // Remove trailing 's'. *(buf.get() + len - 1) = '\0'; // Remove trailing 's'.
char* decimal_point = strchr(buf.get(), '.'); char* decimal_point = strchr(buf.get(), '.');
int nanos = 0; int nanos = 0;
@ -91,7 +91,7 @@ bool ParseDuration(grpc_json* field, grpc_millis* duration) {
return true; return true;
} }
UniquePtr<ClientChannelMethodParsedConfig::RetryPolicy> ParseRetryPolicy( std::unique_ptr<ClientChannelMethodParsedConfig::RetryPolicy> ParseRetryPolicy(
grpc_json* field, grpc_error** error) { grpc_json* field, grpc_error** error) {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
auto retry_policy = auto retry_policy =
@ -262,13 +262,13 @@ const char* ParseHealthCheckConfig(const grpc_json* field, grpc_error** error) {
} // namespace } // namespace
UniquePtr<ServiceConfig::ParsedConfig> std::unique_ptr<ServiceConfig::ParsedConfig>
ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json, ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json,
grpc_error** error) { grpc_error** error) {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
InlinedVector<grpc_error*, 4> error_list; InlinedVector<grpc_error*, 4> error_list;
RefCountedPtr<LoadBalancingPolicy::Config> parsed_lb_config; RefCountedPtr<LoadBalancingPolicy::Config> parsed_lb_config;
UniquePtr<char> lb_policy_name; std::unique_ptr<char> lb_policy_name;
Optional<ClientChannelGlobalParsedConfig::RetryThrottling> retry_throttling; Optional<ClientChannelGlobalParsedConfig::RetryThrottling> retry_throttling;
const char* health_check_service_name = nullptr; const char* health_check_service_name = nullptr;
for (grpc_json* field = json->child; field != nullptr; field = field->next) { for (grpc_json* field = json->child; field != nullptr; field = field->next) {
@ -445,14 +445,14 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json,
return nullptr; return nullptr;
} }
UniquePtr<ServiceConfig::ParsedConfig> std::unique_ptr<ServiceConfig::ParsedConfig>
ClientChannelServiceConfigParser::ParsePerMethodParams(const grpc_json* json, ClientChannelServiceConfigParser::ParsePerMethodParams(const grpc_json* json,
grpc_error** error) { grpc_error** error) {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
InlinedVector<grpc_error*, 4> error_list; InlinedVector<grpc_error*, 4> error_list;
Optional<bool> wait_for_ready; Optional<bool> wait_for_ready;
grpc_millis timeout = 0; grpc_millis timeout = 0;
UniquePtr<ClientChannelMethodParsedConfig::RetryPolicy> retry_policy; std::unique_ptr<ClientChannelMethodParsedConfig::RetryPolicy> retry_policy;
for (grpc_json* field = json->child; field != nullptr; field = field->next) { for (grpc_json* field = json->child; field != nullptr; field = field->next) {
if (field->key == nullptr) continue; if (field->key == nullptr) continue;
if (strcmp(field->key, "waitForReady") == 0) { if (strcmp(field->key, "waitForReady") == 0) {

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

Loading…
Cancel
Save