Merge branch 'master' into cares_windows_platform_detection
This commit is contained in:
commit
70e850a023
|
|
@ -109,13 +109,14 @@ Podfile.lock
|
|||
# IDE specific folder for JetBrains IDEs
|
||||
.idea/
|
||||
|
||||
# Blaze files
|
||||
# Bazel files
|
||||
bazel-bin
|
||||
bazel-genfiles
|
||||
bazel-grpc
|
||||
bazel-out
|
||||
bazel-testlogs
|
||||
bazel_format_virtual_environment/
|
||||
tools/bazel-*
|
||||
|
||||
# Debug output
|
||||
gdb.txt
|
||||
|
|
|
|||
21
BUILD
21
BUILD
|
|
@ -74,11 +74,11 @@ config_setting(
|
|||
)
|
||||
|
||||
# This should be updated along with build.yaml
|
||||
g_stands_for = "gandalf"
|
||||
g_stands_for = "gale"
|
||||
|
||||
core_version = "7.0.0"
|
||||
|
||||
version = "1.21.0-dev"
|
||||
version = "1.22.0-dev"
|
||||
|
||||
GPR_PUBLIC_HDRS = [
|
||||
"include/grpc/support/alloc.h",
|
||||
|
|
@ -997,6 +997,7 @@ grpc_cc_library(
|
|||
"src/core/lib/slice/slice_hash_table.h",
|
||||
"src/core/lib/slice/slice_internal.h",
|
||||
"src/core/lib/slice/slice_string_helpers.h",
|
||||
"src/core/lib/slice/slice_utils.h",
|
||||
"src/core/lib/slice/slice_weak_hash_table.h",
|
||||
"src/core/lib/surface/api_trace.h",
|
||||
"src/core/lib/surface/call.h",
|
||||
|
|
@ -1561,20 +1562,6 @@ grpc_cc_library(
|
|||
],
|
||||
)
|
||||
|
||||
grpc_cc_library(
|
||||
name = "grpc_resolver_dns_selection",
|
||||
srcs = [
|
||||
"src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc",
|
||||
],
|
||||
hdrs = [
|
||||
"src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h",
|
||||
],
|
||||
language = "c++",
|
||||
deps = [
|
||||
"grpc_base",
|
||||
],
|
||||
)
|
||||
|
||||
grpc_cc_library(
|
||||
name = "grpc_resolver_dns_native",
|
||||
srcs = [
|
||||
|
|
@ -1584,7 +1571,6 @@ grpc_cc_library(
|
|||
deps = [
|
||||
"grpc_base",
|
||||
"grpc_client_channel",
|
||||
"grpc_resolver_dns_selection",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
@ -1614,7 +1600,6 @@ grpc_cc_library(
|
|||
deps = [
|
||||
"grpc_base",
|
||||
"grpc_client_channel",
|
||||
"grpc_resolver_dns_selection",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
|||
4
BUILD.gn
4
BUILD.gn
|
|
@ -324,8 +324,6 @@ config("grpc_config") {
|
|||
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc",
|
||||
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc",
|
||||
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc",
|
||||
"src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc",
|
||||
"src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h",
|
||||
"src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc",
|
||||
"src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc",
|
||||
"src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h",
|
||||
|
|
@ -737,6 +735,7 @@ config("grpc_config") {
|
|||
"src/core/lib/slice/slice_internal.h",
|
||||
"src/core/lib/slice/slice_string_helpers.cc",
|
||||
"src/core/lib/slice/slice_string_helpers.h",
|
||||
"src/core/lib/slice/slice_utils.h",
|
||||
"src/core/lib/slice/slice_weak_hash_table.h",
|
||||
"src/core/lib/surface/api_trace.cc",
|
||||
"src/core/lib/surface/api_trace.h",
|
||||
|
|
@ -1281,6 +1280,7 @@ config("grpc_config") {
|
|||
"src/core/lib/slice/slice_hash_table.h",
|
||||
"src/core/lib/slice/slice_internal.h",
|
||||
"src/core/lib/slice/slice_string_helpers.h",
|
||||
"src/core/lib/slice/slice_utils.h",
|
||||
"src/core/lib/slice/slice_weak_hash_table.h",
|
||||
"src/core/lib/surface/api_trace.h",
|
||||
"src/core/lib/surface/call.h",
|
||||
|
|
|
|||
163
CMakeLists.txt
163
CMakeLists.txt
|
|
@ -24,7 +24,7 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(PACKAGE_NAME "grpc")
|
||||
set(PACKAGE_VERSION "1.21.0-dev")
|
||||
set(PACKAGE_VERSION "1.22.0-dev")
|
||||
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
||||
set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}")
|
||||
set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/")
|
||||
|
|
@ -556,6 +556,12 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
|
|||
add_dependencies(buildtests_cxx bm_call_create)
|
||||
endif()
|
||||
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
|
||||
add_dependencies(buildtests_cxx bm_callback_streaming_ping_pong)
|
||||
endif()
|
||||
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
|
||||
add_dependencies(buildtests_cxx bm_callback_unary_ping_pong)
|
||||
endif()
|
||||
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
|
||||
add_dependencies(buildtests_cxx bm_channel)
|
||||
endif()
|
||||
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
|
||||
|
|
@ -1301,7 +1307,6 @@ add_library(grpc
|
|||
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc
|
||||
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc
|
||||
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc
|
||||
src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc
|
||||
src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
|
||||
src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
|
||||
src/core/ext/filters/census/grpc_context.cc
|
||||
|
|
@ -2697,7 +2702,6 @@ add_library(grpc_unsecure
|
|||
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc
|
||||
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc
|
||||
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc
|
||||
src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc
|
||||
src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
|
||||
src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
|
||||
src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
|
||||
|
|
@ -2906,6 +2910,67 @@ target_link_libraries(test_tcp_server
|
|||
)
|
||||
|
||||
|
||||
endif (gRPC_BUILD_TESTS)
|
||||
if (gRPC_BUILD_TESTS)
|
||||
|
||||
if (gRPC_BUILD_CODEGEN)
|
||||
add_library(bm_callback_test_service_impl
|
||||
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.pb.cc
|
||||
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.grpc.pb.cc
|
||||
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.pb.h
|
||||
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.grpc.pb.h
|
||||
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo_mock.grpc.pb.h
|
||||
test/cpp/microbenchmarks/callback_test_service.cc
|
||||
)
|
||||
|
||||
if(WIN32 AND MSVC)
|
||||
set_target_properties(bm_callback_test_service_impl PROPERTIES COMPILE_PDB_NAME "bm_callback_test_service_impl"
|
||||
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
|
||||
)
|
||||
if (gRPC_INSTALL)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bm_callback_test_service_impl.pdb
|
||||
DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
protobuf_generate_grpc_cpp(
|
||||
src/proto/grpc/testing/echo.proto
|
||||
)
|
||||
|
||||
target_include_directories(bm_callback_test_service_impl
|
||||
PUBLIC $<INSTALL_INTERFACE:${gRPC_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR}
|
||||
PRIVATE third_party/googletest/googletest/include
|
||||
PRIVATE third_party/googletest/googletest
|
||||
PRIVATE third_party/googletest/googlemock/include
|
||||
PRIVATE third_party/googletest/googlemock
|
||||
PRIVATE ${_gRPC_PROTO_GENS_DIR}
|
||||
)
|
||||
target_link_libraries(bm_callback_test_service_impl
|
||||
${_gRPC_PROTOBUF_LIBRARIES}
|
||||
${_gRPC_ALLTARGETS_LIBRARIES}
|
||||
grpc_benchmark
|
||||
${_gRPC_BENCHMARK_LIBRARIES}
|
||||
grpc++_test_util_unsecure
|
||||
grpc_test_util_unsecure
|
||||
grpc++_unsecure
|
||||
grpc_unsecure
|
||||
gpr
|
||||
grpc++_test_config
|
||||
${_gRPC_GFLAGS_LIBRARIES}
|
||||
)
|
||||
|
||||
endif (gRPC_BUILD_CODEGEN)
|
||||
|
||||
endif (gRPC_BUILD_TESTS)
|
||||
if (gRPC_BUILD_TESTS)
|
||||
|
||||
|
|
@ -11549,6 +11614,98 @@ target_link_libraries(bm_call_create
|
|||
)
|
||||
|
||||
|
||||
endif()
|
||||
endif (gRPC_BUILD_TESTS)
|
||||
if (gRPC_BUILD_TESTS)
|
||||
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
|
||||
|
||||
add_executable(bm_callback_streaming_ping_pong
|
||||
test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc
|
||||
third_party/googletest/googletest/src/gtest-all.cc
|
||||
third_party/googletest/googlemock/src/gmock-all.cc
|
||||
)
|
||||
|
||||
|
||||
target_include_directories(bm_callback_streaming_ping_pong
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR}
|
||||
PRIVATE third_party/googletest/googletest/include
|
||||
PRIVATE third_party/googletest/googletest
|
||||
PRIVATE third_party/googletest/googlemock/include
|
||||
PRIVATE third_party/googletest/googlemock
|
||||
PRIVATE ${_gRPC_PROTO_GENS_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(bm_callback_streaming_ping_pong
|
||||
${_gRPC_PROTOBUF_LIBRARIES}
|
||||
${_gRPC_ALLTARGETS_LIBRARIES}
|
||||
grpc_benchmark
|
||||
${_gRPC_BENCHMARK_LIBRARIES}
|
||||
grpc++_test_util_unsecure
|
||||
grpc_test_util_unsecure
|
||||
grpc++_unsecure
|
||||
grpc_unsecure
|
||||
gpr
|
||||
grpc++_test_config
|
||||
bm_callback_test_service_impl
|
||||
${_gRPC_GFLAGS_LIBRARIES}
|
||||
)
|
||||
|
||||
|
||||
endif()
|
||||
endif (gRPC_BUILD_TESTS)
|
||||
if (gRPC_BUILD_TESTS)
|
||||
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
|
||||
|
||||
add_executable(bm_callback_unary_ping_pong
|
||||
test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc
|
||||
third_party/googletest/googletest/src/gtest-all.cc
|
||||
third_party/googletest/googlemock/src/gmock-all.cc
|
||||
)
|
||||
|
||||
|
||||
target_include_directories(bm_callback_unary_ping_pong
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
|
||||
PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR}
|
||||
PRIVATE third_party/googletest/googletest/include
|
||||
PRIVATE third_party/googletest/googletest
|
||||
PRIVATE third_party/googletest/googlemock/include
|
||||
PRIVATE third_party/googletest/googlemock
|
||||
PRIVATE ${_gRPC_PROTO_GENS_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(bm_callback_unary_ping_pong
|
||||
${_gRPC_PROTOBUF_LIBRARIES}
|
||||
${_gRPC_ALLTARGETS_LIBRARIES}
|
||||
grpc_benchmark
|
||||
${_gRPC_BENCHMARK_LIBRARIES}
|
||||
grpc++_test_util_unsecure
|
||||
grpc_test_util_unsecure
|
||||
grpc++_unsecure
|
||||
grpc_unsecure
|
||||
gpr
|
||||
grpc++_test_config
|
||||
bm_callback_test_service_impl
|
||||
${_gRPC_GFLAGS_LIBRARIES}
|
||||
)
|
||||
|
||||
|
||||
endif()
|
||||
endif (gRPC_BUILD_TESTS)
|
||||
if (gRPC_BUILD_TESTS)
|
||||
|
|
|
|||
157
Makefile
157
Makefile
|
|
@ -460,8 +460,8 @@ Q = @
|
|||
endif
|
||||
|
||||
CORE_VERSION = 7.0.0
|
||||
CPP_VERSION = 1.21.0-dev
|
||||
CSHARP_VERSION = 1.21.0-dev
|
||||
CPP_VERSION = 1.22.0-dev
|
||||
CSHARP_VERSION = 1.22.0-dev
|
||||
|
||||
CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
|
||||
CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
|
||||
|
|
@ -1162,6 +1162,8 @@ bm_alarm: $(BINDIR)/$(CONFIG)/bm_alarm
|
|||
bm_arena: $(BINDIR)/$(CONFIG)/bm_arena
|
||||
bm_byte_buffer: $(BINDIR)/$(CONFIG)/bm_byte_buffer
|
||||
bm_call_create: $(BINDIR)/$(CONFIG)/bm_call_create
|
||||
bm_callback_streaming_ping_pong: $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong
|
||||
bm_callback_unary_ping_pong: $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong
|
||||
bm_channel: $(BINDIR)/$(CONFIG)/bm_channel
|
||||
bm_chttp2_hpack: $(BINDIR)/$(CONFIG)/bm_chttp2_hpack
|
||||
bm_chttp2_transport: $(BINDIR)/$(CONFIG)/bm_chttp2_transport
|
||||
|
|
@ -1641,6 +1643,8 @@ buildtests_cxx: privatelibs_cxx \
|
|||
$(BINDIR)/$(CONFIG)/bm_arena \
|
||||
$(BINDIR)/$(CONFIG)/bm_byte_buffer \
|
||||
$(BINDIR)/$(CONFIG)/bm_call_create \
|
||||
$(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong \
|
||||
$(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong \
|
||||
$(BINDIR)/$(CONFIG)/bm_channel \
|
||||
$(BINDIR)/$(CONFIG)/bm_chttp2_hpack \
|
||||
$(BINDIR)/$(CONFIG)/bm_chttp2_transport \
|
||||
|
|
@ -1788,6 +1792,8 @@ buildtests_cxx: privatelibs_cxx \
|
|||
$(BINDIR)/$(CONFIG)/bm_arena \
|
||||
$(BINDIR)/$(CONFIG)/bm_byte_buffer \
|
||||
$(BINDIR)/$(CONFIG)/bm_call_create \
|
||||
$(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong \
|
||||
$(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong \
|
||||
$(BINDIR)/$(CONFIG)/bm_channel \
|
||||
$(BINDIR)/$(CONFIG)/bm_chttp2_hpack \
|
||||
$(BINDIR)/$(CONFIG)/bm_chttp2_transport \
|
||||
|
|
@ -2241,6 +2247,10 @@ test_cxx: buildtests_cxx
|
|||
$(Q) $(BINDIR)/$(CONFIG)/bm_byte_buffer || ( echo test bm_byte_buffer failed ; exit 1 )
|
||||
$(E) "[RUN] Testing bm_call_create"
|
||||
$(Q) $(BINDIR)/$(CONFIG)/bm_call_create || ( echo test bm_call_create failed ; exit 1 )
|
||||
$(E) "[RUN] Testing bm_callback_streaming_ping_pong"
|
||||
$(Q) $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong || ( echo test bm_callback_streaming_ping_pong failed ; exit 1 )
|
||||
$(E) "[RUN] Testing bm_callback_unary_ping_pong"
|
||||
$(Q) $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong || ( echo test bm_callback_unary_ping_pong failed ; exit 1 )
|
||||
$(E) "[RUN] Testing bm_channel"
|
||||
$(Q) $(BINDIR)/$(CONFIG)/bm_channel || ( echo test bm_channel failed ; exit 1 )
|
||||
$(E) "[RUN] Testing bm_chttp2_hpack"
|
||||
|
|
@ -3773,7 +3783,6 @@ LIBGRPC_SRC = \
|
|||
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \
|
||||
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \
|
||||
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \
|
||||
src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \
|
||||
src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \
|
||||
src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \
|
||||
src/core/ext/filters/census/grpc_context.cc \
|
||||
|
|
@ -5117,7 +5126,6 @@ LIBGRPC_UNSECURE_SRC = \
|
|||
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \
|
||||
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \
|
||||
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \
|
||||
src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \
|
||||
src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \
|
||||
src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \
|
||||
src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \
|
||||
|
|
@ -5295,6 +5303,58 @@ endif
|
|||
endif
|
||||
|
||||
|
||||
LIBBM_CALLBACK_TEST_SERVICE_IMPL_SRC = \
|
||||
$(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc \
|
||||
test/cpp/microbenchmarks/callback_test_service.cc \
|
||||
|
||||
PUBLIC_HEADERS_CXX += \
|
||||
|
||||
LIBBM_CALLBACK_TEST_SERVICE_IMPL_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBM_CALLBACK_TEST_SERVICE_IMPL_SRC))))
|
||||
|
||||
$(LIBBM_CALLBACK_TEST_SERVICE_IMPL_OBJS): CPPFLAGS += -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX
|
||||
|
||||
ifeq ($(NO_SECURE),true)
|
||||
|
||||
# You can't build secure libraries if you don't have OpenSSL.
|
||||
|
||||
$(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a: openssl_dep_error
|
||||
|
||||
|
||||
else
|
||||
|
||||
ifeq ($(NO_PROTOBUF),true)
|
||||
|
||||
# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
|
||||
|
||||
$(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a: protobuf_dep_error
|
||||
|
||||
|
||||
else
|
||||
|
||||
$(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(PROTOBUF_DEP) $(LIBBM_CALLBACK_TEST_SERVICE_IMPL_OBJS)
|
||||
$(E) "[AR] Creating $@"
|
||||
$(Q) mkdir -p `dirname $@`
|
||||
$(Q) rm -f $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a
|
||||
$(Q) $(AR) $(AROPTS) $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a $(LIBBM_CALLBACK_TEST_SERVICE_IMPL_OBJS)
|
||||
ifeq ($(SYSTEM),Darwin)
|
||||
$(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a
|
||||
endif
|
||||
|
||||
|
||||
|
||||
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
ifneq ($(NO_SECURE),true)
|
||||
ifneq ($(NO_DEPS),true)
|
||||
-include $(LIBBM_CALLBACK_TEST_SERVICE_IMPL_OBJS:.o=.dep)
|
||||
endif
|
||||
endif
|
||||
$(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/callback_test_service.o: $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc
|
||||
|
||||
|
||||
LIBDNS_TEST_UTIL_SRC = \
|
||||
test/cpp/naming/dns_test_util.cc \
|
||||
|
||||
|
|
@ -14495,6 +14555,94 @@ endif
|
|||
endif
|
||||
|
||||
|
||||
BM_CALLBACK_STREAMING_PING_PONG_SRC = \
|
||||
test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc \
|
||||
|
||||
BM_CALLBACK_STREAMING_PING_PONG_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BM_CALLBACK_STREAMING_PING_PONG_SRC))))
|
||||
ifeq ($(NO_SECURE),true)
|
||||
|
||||
# You can't build secure targets if you don't have OpenSSL.
|
||||
|
||||
$(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong: openssl_dep_error
|
||||
|
||||
else
|
||||
|
||||
|
||||
|
||||
|
||||
ifeq ($(NO_PROTOBUF),true)
|
||||
|
||||
# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+.
|
||||
|
||||
$(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong: protobuf_dep_error
|
||||
|
||||
else
|
||||
|
||||
$(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong: $(PROTOBUF_DEP) $(BM_CALLBACK_STREAMING_PING_PONG_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a
|
||||
$(E) "[LD] Linking $@"
|
||||
$(Q) mkdir -p `dirname $@`
|
||||
$(Q) $(LDXX) $(LDFLAGS) $(BM_CALLBACK_STREAMING_PING_PONG_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/bm_callback_streaming_ping_pong
|
||||
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
$(BM_CALLBACK_STREAMING_PING_PONG_OBJS): CPPFLAGS += -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX
|
||||
$(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.o: $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a
|
||||
|
||||
deps_bm_callback_streaming_ping_pong: $(BM_CALLBACK_STREAMING_PING_PONG_OBJS:.o=.dep)
|
||||
|
||||
ifneq ($(NO_SECURE),true)
|
||||
ifneq ($(NO_DEPS),true)
|
||||
-include $(BM_CALLBACK_STREAMING_PING_PONG_OBJS:.o=.dep)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
BM_CALLBACK_UNARY_PING_PONG_SRC = \
|
||||
test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc \
|
||||
|
||||
BM_CALLBACK_UNARY_PING_PONG_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BM_CALLBACK_UNARY_PING_PONG_SRC))))
|
||||
ifeq ($(NO_SECURE),true)
|
||||
|
||||
# You can't build secure targets if you don't have OpenSSL.
|
||||
|
||||
$(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong: openssl_dep_error
|
||||
|
||||
else
|
||||
|
||||
|
||||
|
||||
|
||||
ifeq ($(NO_PROTOBUF),true)
|
||||
|
||||
# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+.
|
||||
|
||||
$(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong: protobuf_dep_error
|
||||
|
||||
else
|
||||
|
||||
$(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong: $(PROTOBUF_DEP) $(BM_CALLBACK_UNARY_PING_PONG_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a
|
||||
$(E) "[LD] Linking $@"
|
||||
$(Q) mkdir -p `dirname $@`
|
||||
$(Q) $(LDXX) $(LDFLAGS) $(BM_CALLBACK_UNARY_PING_PONG_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/bm_callback_unary_ping_pong
|
||||
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
$(BM_CALLBACK_UNARY_PING_PONG_OBJS): CPPFLAGS += -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX
|
||||
$(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/bm_callback_unary_ping_pong.o: $(LIBDIR)/$(CONFIG)/libgrpc_benchmark.a $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libbm_callback_test_service_impl.a
|
||||
|
||||
deps_bm_callback_unary_ping_pong: $(BM_CALLBACK_UNARY_PING_PONG_OBJS:.o=.dep)
|
||||
|
||||
ifneq ($(NO_SECURE),true)
|
||||
ifneq ($(NO_DEPS),true)
|
||||
-include $(BM_CALLBACK_UNARY_PING_PONG_OBJS:.o=.dep)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
BM_CHANNEL_SRC = \
|
||||
test/cpp/microbenchmarks/bm_channel.cc \
|
||||
|
||||
|
|
@ -22284,6 +22432,7 @@ test/cpp/interop/interop_client.cc: $(OPENSSL_DEP)
|
|||
test/cpp/interop/interop_server.cc: $(OPENSSL_DEP)
|
||||
test/cpp/interop/interop_server_bootstrap.cc: $(OPENSSL_DEP)
|
||||
test/cpp/interop/server_helper.cc: $(OPENSSL_DEP)
|
||||
test/cpp/microbenchmarks/callback_test_service.cc: $(OPENSSL_DEP)
|
||||
test/cpp/microbenchmarks/helpers.cc: $(OPENSSL_DEP)
|
||||
test/cpp/naming/dns_test_util.cc: $(OPENSSL_DEP)
|
||||
test/cpp/qps/benchmark_config.cc: $(OPENSSL_DEP)
|
||||
|
|
|
|||
78
build.yaml
78
build.yaml
|
|
@ -13,8 +13,8 @@ settings:
|
|||
'#09': Per-language overrides are possible with (eg) ruby_version tag here
|
||||
'#10': See the expand_version.py for all the quirks here
|
||||
core_version: 7.0.0
|
||||
g_stands_for: gandalf
|
||||
version: 1.21.0-dev
|
||||
g_stands_for: gale
|
||||
version: 1.22.0-dev
|
||||
filegroups:
|
||||
- name: alts_proto
|
||||
headers:
|
||||
|
|
@ -525,6 +525,7 @@ filegroups:
|
|||
- src/core/lib/slice/slice_hash_table.h
|
||||
- src/core/lib/slice/slice_internal.h
|
||||
- src/core/lib/slice/slice_string_helpers.h
|
||||
- src/core/lib/slice/slice_utils.h
|
||||
- src/core/lib/slice/slice_weak_hash_table.h
|
||||
- src/core/lib/surface/api_trace.h
|
||||
- src/core/lib/surface/call.h
|
||||
|
|
@ -795,7 +796,6 @@ filegroups:
|
|||
uses:
|
||||
- grpc_base
|
||||
- grpc_client_channel
|
||||
- grpc_resolver_dns_selection
|
||||
- name: grpc_resolver_dns_native
|
||||
src:
|
||||
- src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
|
||||
|
|
@ -803,14 +803,6 @@ filegroups:
|
|||
uses:
|
||||
- grpc_base
|
||||
- grpc_client_channel
|
||||
- grpc_resolver_dns_selection
|
||||
- name: grpc_resolver_dns_selection
|
||||
headers:
|
||||
- src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h
|
||||
src:
|
||||
- src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc
|
||||
uses:
|
||||
- grpc_base
|
||||
- name: grpc_resolver_fake
|
||||
headers:
|
||||
- src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h
|
||||
|
|
@ -1686,6 +1678,24 @@ libs:
|
|||
- grpc_test_util
|
||||
- grpc
|
||||
- gpr
|
||||
- name: bm_callback_test_service_impl
|
||||
build: test
|
||||
language: c++
|
||||
headers:
|
||||
- test/cpp/microbenchmarks/callback_test_service.h
|
||||
src:
|
||||
- src/proto/grpc/testing/echo.proto
|
||||
- test/cpp/microbenchmarks/callback_test_service.cc
|
||||
deps:
|
||||
- grpc_benchmark
|
||||
- benchmark
|
||||
- grpc++_test_util_unsecure
|
||||
- grpc_test_util_unsecure
|
||||
- grpc++_unsecure
|
||||
- grpc_unsecure
|
||||
- gpr
|
||||
- grpc++_test_config
|
||||
defaults: benchmark
|
||||
- name: dns_test_util
|
||||
build: private
|
||||
language: c++
|
||||
|
|
@ -4052,6 +4062,52 @@ targets:
|
|||
- linux
|
||||
- posix
|
||||
uses_polling: false
|
||||
- name: bm_callback_streaming_ping_pong
|
||||
build: test
|
||||
language: c++
|
||||
headers:
|
||||
- test/cpp/microbenchmarks/callback_streaming_ping_pong.h
|
||||
src:
|
||||
- test/cpp/microbenchmarks/bm_callback_streaming_ping_pong.cc
|
||||
deps:
|
||||
- grpc_benchmark
|
||||
- benchmark
|
||||
- grpc++_test_util_unsecure
|
||||
- grpc_test_util_unsecure
|
||||
- grpc++_unsecure
|
||||
- grpc_unsecure
|
||||
- gpr
|
||||
- grpc++_test_config
|
||||
- bm_callback_test_service_impl
|
||||
benchmark: true
|
||||
defaults: benchmark
|
||||
platforms:
|
||||
- mac
|
||||
- linux
|
||||
- posix
|
||||
- name: bm_callback_unary_ping_pong
|
||||
build: test
|
||||
language: c++
|
||||
headers:
|
||||
- test/cpp/microbenchmarks/callback_unary_ping_pong.h
|
||||
src:
|
||||
- test/cpp/microbenchmarks/bm_callback_unary_ping_pong.cc
|
||||
deps:
|
||||
- grpc_benchmark
|
||||
- benchmark
|
||||
- grpc++_test_util_unsecure
|
||||
- grpc_test_util_unsecure
|
||||
- grpc++_unsecure
|
||||
- grpc_unsecure
|
||||
- gpr
|
||||
- grpc++_test_config
|
||||
- bm_callback_test_service_impl
|
||||
benchmark: true
|
||||
defaults: benchmark
|
||||
platforms:
|
||||
- mac
|
||||
- linux
|
||||
- posix
|
||||
- name: bm_channel
|
||||
build: test
|
||||
language: c++
|
||||
|
|
|
|||
|
|
@ -411,7 +411,6 @@ if test "$PHP_GRPC" != "no"; then
|
|||
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc \
|
||||
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \
|
||||
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \
|
||||
src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc \
|
||||
src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \
|
||||
src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \
|
||||
src/core/ext/filters/census/grpc_context.cc \
|
||||
|
|
@ -695,7 +694,6 @@ if test "$PHP_GRPC" != "no"; then
|
|||
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/pick_first)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/round_robin)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy/xds)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns/c_ares)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns/native)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/fake)
|
||||
|
|
|
|||
|
|
@ -386,7 +386,6 @@ if (PHP_GRPC != "no") {
|
|||
"src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_libuv.cc " +
|
||||
"src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_posix.cc " +
|
||||
"src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows.cc " +
|
||||
"src\\core\\ext\\filters\\client_channel\\resolver\\dns\\dns_resolver_selection.cc " +
|
||||
"src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native\\dns_resolver.cc " +
|
||||
"src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr\\sockaddr_resolver.cc " +
|
||||
"src\\core\\ext\\filters\\census\\grpc_context.cc " +
|
||||
|
|
|
|||
|
|
@ -20,4 +20,5 @@
|
|||
- 1.18 'g' stands for ['goose'](https://github.com/grpc/grpc/tree/v1.18.x)
|
||||
- 1.19 'g' stands for ['gold'](https://github.com/grpc/grpc/tree/v1.19.x)
|
||||
- 1.20 'g' stands for ['godric'](https://github.com/grpc/grpc/tree/v1.20.x)
|
||||
- 1.21 'g' stands for ['gandalf'](https://github.com/grpc/grpc/tree/master)
|
||||
- 1.21 'g' stands for ['gandalf'](https://github.com/grpc/grpc/tree/v1.21.x)
|
||||
- 1.22 'g' stands for ['gale'](https://github.com/grpc/grpc/tree/master)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'gRPC-C++'
|
||||
# TODO (mxyan): use version that match gRPC version when pod is stabilized
|
||||
# version = '1.21.0-dev'
|
||||
# version = '1.22.0-dev'
|
||||
version = '0.0.8-dev'
|
||||
s.version = version
|
||||
s.summary = 'gRPC C++ library'
|
||||
|
|
@ -31,7 +31,7 @@ Pod::Spec.new do |s|
|
|||
s.license = 'Apache License, Version 2.0'
|
||||
s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
|
||||
|
||||
grpc_version = '1.21.0-dev'
|
||||
grpc_version = '1.22.0-dev'
|
||||
|
||||
s.source = {
|
||||
:git => 'https://github.com/grpc/grpc.git',
|
||||
|
|
@ -518,6 +518,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/lib/slice/slice_hash_table.h',
|
||||
'src/core/lib/slice/slice_internal.h',
|
||||
'src/core/lib/slice/slice_string_helpers.h',
|
||||
'src/core/lib/slice/slice_utils.h',
|
||||
'src/core/lib/slice/slice_weak_hash_table.h',
|
||||
'src/core/lib/surface/api_trace.h',
|
||||
'src/core/lib/surface/call.h',
|
||||
|
|
@ -562,7 +563,6 @@ Pod::Spec.new do |s|
|
|||
'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h',
|
||||
'src/core/ext/filters/max_age/max_age_filter.h',
|
||||
'src/core/ext/filters/message_size/message_size_filter.h',
|
||||
'src/core/ext/filters/http/client_authority_filter.h',
|
||||
|
|
@ -720,6 +720,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/lib/slice/slice_hash_table.h',
|
||||
'src/core/lib/slice/slice_internal.h',
|
||||
'src/core/lib/slice/slice_string_helpers.h',
|
||||
'src/core/lib/slice/slice_utils.h',
|
||||
'src/core/lib/slice/slice_weak_hash_table.h',
|
||||
'src/core/lib/surface/api_trace.h',
|
||||
'src/core/lib/surface/call.h',
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'gRPC-Core'
|
||||
version = '1.21.0-dev'
|
||||
version = '1.22.0-dev'
|
||||
s.version = version
|
||||
s.summary = 'Core cross-platform gRPC library, written in C'
|
||||
s.homepage = 'https://grpc.io'
|
||||
|
|
@ -494,6 +494,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/lib/slice/slice_hash_table.h',
|
||||
'src/core/lib/slice/slice_internal.h',
|
||||
'src/core/lib/slice/slice_string_helpers.h',
|
||||
'src/core/lib/slice/slice_utils.h',
|
||||
'src/core/lib/slice/slice_weak_hash_table.h',
|
||||
'src/core/lib/surface/api_trace.h',
|
||||
'src/core/lib/surface/call.h',
|
||||
|
|
@ -538,7 +539,6 @@ Pod::Spec.new do |s|
|
|||
'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h',
|
||||
'src/core/ext/filters/max_age/max_age_filter.h',
|
||||
'src/core/ext/filters/message_size/message_size_filter.h',
|
||||
'src/core/ext/filters/http/client_authority_filter.h',
|
||||
|
|
@ -868,7 +868,6 @@ Pod::Spec.new do |s|
|
|||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc',
|
||||
'src/core/ext/filters/census/grpc_context.cc',
|
||||
|
|
@ -1145,6 +1144,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/lib/slice/slice_hash_table.h',
|
||||
'src/core/lib/slice/slice_internal.h',
|
||||
'src/core/lib/slice/slice_string_helpers.h',
|
||||
'src/core/lib/slice/slice_utils.h',
|
||||
'src/core/lib/slice/slice_weak_hash_table.h',
|
||||
'src/core/lib/surface/api_trace.h',
|
||||
'src/core/lib/surface/call.h',
|
||||
|
|
@ -1189,7 +1189,6 @@ Pod::Spec.new do |s|
|
|||
'src/core/ext/filters/client_channel/lb_policy/subchannel_list.h',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h',
|
||||
'src/core/ext/filters/max_age/max_age_filter.h',
|
||||
'src/core/ext/filters/message_size/message_size_filter.h',
|
||||
'src/core/ext/filters/http/client_authority_filter.h',
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'gRPC-ProtoRPC'
|
||||
version = '1.21.0-dev'
|
||||
version = '1.22.0-dev'
|
||||
s.version = version
|
||||
s.summary = 'RPC library for Protocol Buffers, based on gRPC'
|
||||
s.homepage = 'https://grpc.io'
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'gRPC-RxLibrary'
|
||||
version = '1.21.0-dev'
|
||||
version = '1.22.0-dev'
|
||||
s.version = version
|
||||
s.summary = 'Reactive Extensions library for iOS/OSX.'
|
||||
s.homepage = 'https://grpc.io'
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'gRPC'
|
||||
version = '1.21.0-dev'
|
||||
version = '1.22.0-dev'
|
||||
s.version = version
|
||||
s.summary = 'gRPC client library for iOS/OSX'
|
||||
s.homepage = 'https://grpc.io'
|
||||
|
|
|
|||
|
|
@ -428,6 +428,7 @@ Gem::Specification.new do |s|
|
|||
s.files += %w( src/core/lib/slice/slice_hash_table.h )
|
||||
s.files += %w( src/core/lib/slice/slice_internal.h )
|
||||
s.files += %w( src/core/lib/slice/slice_string_helpers.h )
|
||||
s.files += %w( src/core/lib/slice/slice_utils.h )
|
||||
s.files += %w( src/core/lib/slice/slice_weak_hash_table.h )
|
||||
s.files += %w( src/core/lib/surface/api_trace.h )
|
||||
s.files += %w( src/core/lib/surface/call.h )
|
||||
|
|
@ -472,7 +473,6 @@ Gem::Specification.new do |s|
|
|||
s.files += %w( src/core/ext/filters/client_channel/lb_policy/subchannel_list.h )
|
||||
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h )
|
||||
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h )
|
||||
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h )
|
||||
s.files += %w( src/core/ext/filters/max_age/max_age_filter.h )
|
||||
s.files += %w( src/core/ext/filters/message_size/message_size_filter.h )
|
||||
s.files += %w( src/core/ext/filters/http/client_authority_filter.h )
|
||||
|
|
@ -805,7 +805,6 @@ Gem::Specification.new do |s|
|
|||
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc )
|
||||
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc )
|
||||
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc )
|
||||
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc )
|
||||
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc )
|
||||
s.files += %w( src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc )
|
||||
s.files += %w( src/core/ext/filters/census/grpc_context.cc )
|
||||
|
|
|
|||
20
grpc.gyp
20
grpc.gyp
|
|
@ -593,7 +593,6 @@
|
|||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc',
|
||||
'src/core/ext/filters/census/grpc_context.cc',
|
||||
|
|
@ -1353,7 +1352,6 @@
|
|||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc',
|
||||
|
|
@ -1405,6 +1403,24 @@
|
|||
'test/core/util/test_tcp_server.cc',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'bm_callback_test_service_impl',
|
||||
'type': 'static_library',
|
||||
'dependencies': [
|
||||
'grpc_benchmark',
|
||||
'benchmark',
|
||||
'grpc++_test_util_unsecure',
|
||||
'grpc_test_util_unsecure',
|
||||
'grpc++_unsecure',
|
||||
'grpc_unsecure',
|
||||
'gpr',
|
||||
'grpc++_test_config',
|
||||
],
|
||||
'sources': [
|
||||
'src/proto/grpc/testing/echo.proto',
|
||||
'test/cpp/microbenchmarks/callback_test_service.cc',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'dns_test_util',
|
||||
'type': 'static_library',
|
||||
|
|
|
|||
|
|
@ -641,7 +641,7 @@ typedef struct grpc_tls_credentials_options grpc_tls_credentials_options;
|
|||
|
||||
/** Create an empty TLS credentials options. It is used for
|
||||
* experimental purpose for now and subject to change. */
|
||||
GRPCAPI grpc_tls_credentials_options* grpc_tls_credentials_options_create();
|
||||
GRPCAPI grpc_tls_credentials_options* grpc_tls_credentials_options_create(void);
|
||||
|
||||
/** Set grpc_ssl_client_certificate_request_type field in credentials options
|
||||
with the provided type. options should not be NULL.
|
||||
|
|
@ -683,7 +683,8 @@ GRPCAPI int grpc_tls_credentials_options_set_server_authorization_check_config(
|
|||
|
||||
/** Create an empty grpc_tls_key_materials_config instance.
|
||||
* It is used for experimental purpose for now and subject to change. */
|
||||
GRPCAPI grpc_tls_key_materials_config* grpc_tls_key_materials_config_create();
|
||||
GRPCAPI grpc_tls_key_materials_config* grpc_tls_key_materials_config_create(
|
||||
void);
|
||||
|
||||
/** Set grpc_tls_key_materials_config instance with provided a TLS certificate.
|
||||
config will take the ownership of pem_root_certs and pem_key_cert_pairs.
|
||||
|
|
|
|||
|
|
@ -200,6 +200,18 @@ class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen {
|
|||
|
||||
grpc_server* server() override { return server_; }
|
||||
|
||||
protected:
|
||||
/// NOTE: This method is not part of the public API for this class.
|
||||
void set_health_check_service(
|
||||
std::unique_ptr<grpc::HealthCheckServiceInterface> service) {
|
||||
health_check_service_ = std::move(service);
|
||||
}
|
||||
|
||||
/// NOTE: This method is not part of the public API for this class.
|
||||
bool health_check_service_disabled() const {
|
||||
return health_check_service_disabled_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<
|
||||
std::unique_ptr<grpc::experimental::ServerInterceptorFactoryInterface>>*
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@
|
|||
<date>2018-01-19</date>
|
||||
<time>16:06:07</time>
|
||||
<version>
|
||||
<release>1.21.0dev</release>
|
||||
<api>1.21.0dev</api>
|
||||
<release>1.22.0dev</release>
|
||||
<api>1.22.0dev</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
|
|
@ -433,6 +433,7 @@
|
|||
<file baseinstalldir="/" name="src/core/lib/slice/slice_hash_table.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/slice/slice_internal.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/slice/slice_string_helpers.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/slice/slice_utils.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/slice/slice_weak_hash_table.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/surface/api_trace.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/surface/call.h" role="src" />
|
||||
|
|
@ -477,7 +478,6 @@
|
|||
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/subchannel_list.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/filters/max_age/max_age_filter.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/filters/message_size/message_size_filter.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/filters/http/client_authority_filter.h" role="src" />
|
||||
|
|
@ -810,7 +810,6 @@
|
|||
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/filters/census/grpc_context.cc" role="src" />
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
#include <grpcpp/grpcpp.h>
|
||||
#include <jni.h>
|
||||
#include <src/core/lib/gpr/env.h>
|
||||
|
||||
#include "src/core/lib/security/security_connector/ssl_utils.h"
|
||||
#include "test/cpp/interop/interop_client.h"
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
|
|
@ -28,7 +28,7 @@ Java_io_grpc_interop_cpp_InteropActivity_configureSslRoots(JNIEnv* env,
|
|||
jstring path_raw) {
|
||||
const char* path = env->GetStringUTFChars(path_raw, (jboolean*)0);
|
||||
|
||||
GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, path);
|
||||
gpr_setenv("GRPC_DEFAULT_SSL_ROOTS_FILE_PATH", path);
|
||||
}
|
||||
|
||||
std::shared_ptr<grpc::testing::InteropClient> GetClient(const char* host,
|
||||
|
|
@ -45,7 +45,7 @@ std::shared_ptr<grpc::testing::InteropClient> GetClient(const char* host,
|
|||
credentials = grpc::InsecureChannelCredentials();
|
||||
}
|
||||
|
||||
grpc::testing::ChannelCreationFunc channel_creation_func =
|
||||
grpc::testing::ChannelCreationFunc channel_creation_func =
|
||||
std::bind(grpc::CreateChannel, host_port, credentials);
|
||||
return std::shared_ptr<grpc::testing::InteropClient>(
|
||||
new grpc::testing::InteropClient(channel_creation_func, true, false));
|
||||
|
|
|
|||
|
|
@ -56,14 +56,9 @@ static backup_poller* g_poller = nullptr; // guarded by g_poller_mu
|
|||
// treated as const.
|
||||
static int g_poll_interval_ms = DEFAULT_POLL_INTERVAL_MS;
|
||||
|
||||
GPR_GLOBAL_CONFIG_DEFINE_INT32(
|
||||
grpc_client_channel_backup_poll_interval_ms, DEFAULT_POLL_INTERVAL_MS,
|
||||
"Declares the interval in ms between two backup polls on client channels. "
|
||||
"These polls are run in the timer thread so that gRPC can process "
|
||||
"connection failures while there is no active polling thread. "
|
||||
"They help reconnect disconnected client channels (mostly due to "
|
||||
"idleness), so that the next RPC on this channel won't fail. Set to 0 to "
|
||||
"turn off the backup polls.");
|
||||
GPR_GLOBAL_CONFIG_DEFINE_INT32(grpc_client_channel_backup_poll_interval_ms,
|
||||
DEFAULT_POLL_INTERVAL_MS,
|
||||
"Client channel backup poll interval (ms)");
|
||||
|
||||
static void init_globals() {
|
||||
gpr_mu_init(&g_poller_mu);
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ class ChannelData {
|
|||
~ChannelData();
|
||||
|
||||
static bool ProcessResolverResultLocked(
|
||||
void* arg, const Resolver::Result& result, const char** lb_policy_name,
|
||||
void* arg, Resolver::Result* result, const char** lb_policy_name,
|
||||
RefCountedPtr<ParsedLoadBalancingConfig>* lb_policy_config,
|
||||
grpc_error** service_config_error);
|
||||
|
||||
|
|
@ -271,7 +271,6 @@ class ChannelData {
|
|||
OrphanablePtr<LoadBalancingPolicy> resolving_lb_policy_;
|
||||
grpc_connectivity_state_tracker state_tracker_;
|
||||
ExternalConnectivityWatcher::WatcherList external_connectivity_watcher_list_;
|
||||
UniquePtr<char> health_check_service_name_;
|
||||
RefCountedPtr<ServiceConfig> saved_service_config_;
|
||||
bool received_first_resolver_result_ = false;
|
||||
|
||||
|
|
@ -951,18 +950,10 @@ class ChannelData::ClientChannelControlHelper
|
|||
}
|
||||
|
||||
Subchannel* CreateSubchannel(const grpc_channel_args& args) override {
|
||||
grpc_arg args_to_add[2];
|
||||
int num_args_to_add = 0;
|
||||
if (chand_->health_check_service_name_ != nullptr) {
|
||||
args_to_add[0] = grpc_channel_arg_string_create(
|
||||
const_cast<char*>("grpc.temp.health_check"),
|
||||
const_cast<char*>(chand_->health_check_service_name_.get()));
|
||||
num_args_to_add++;
|
||||
}
|
||||
args_to_add[num_args_to_add++] = SubchannelPoolInterface::CreateChannelArg(
|
||||
grpc_arg arg = SubchannelPoolInterface::CreateChannelArg(
|
||||
chand_->subchannel_pool_.get());
|
||||
grpc_channel_args* new_args =
|
||||
grpc_channel_args_copy_and_add(&args, args_to_add, num_args_to_add);
|
||||
grpc_channel_args_copy_and_add(&args, &arg, 1);
|
||||
Subchannel* subchannel =
|
||||
chand_->client_channel_factory_->CreateSubchannel(new_args);
|
||||
grpc_channel_args_destroy(new_args);
|
||||
|
|
@ -1078,8 +1069,6 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error)
|
|||
// Get default service config
|
||||
const char* service_config_json = grpc_channel_arg_get_string(
|
||||
grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVICE_CONFIG));
|
||||
// TODO(yashkt): Make sure we set the channel in TRANSIENT_FAILURE on an
|
||||
// invalid default service config
|
||||
if (service_config_json != nullptr) {
|
||||
*error = GRPC_ERROR_NONE;
|
||||
default_service_config_ = ServiceConfig::Create(service_config_json, error);
|
||||
|
|
@ -1201,14 +1190,14 @@ void ChannelData::ProcessLbPolicy(
|
|||
// Synchronous callback from ResolvingLoadBalancingPolicy to process a
|
||||
// resolver result update.
|
||||
bool ChannelData::ProcessResolverResultLocked(
|
||||
void* arg, const Resolver::Result& result, const char** lb_policy_name,
|
||||
void* arg, Resolver::Result* result, const char** lb_policy_name,
|
||||
RefCountedPtr<ParsedLoadBalancingConfig>* lb_policy_config,
|
||||
grpc_error** service_config_error) {
|
||||
ChannelData* chand = static_cast<ChannelData*>(arg);
|
||||
RefCountedPtr<ServiceConfig> service_config;
|
||||
// If resolver did not return a service config or returned an invalid service
|
||||
// config, we need a fallback service config.
|
||||
if (result.service_config_error != GRPC_ERROR_NONE) {
|
||||
if (result->service_config_error != GRPC_ERROR_NONE) {
|
||||
// If the service config was invalid, then fallback to the saved service
|
||||
// config. If there is no saved config either, use the default service
|
||||
// config.
|
||||
|
|
@ -1229,7 +1218,7 @@ bool ChannelData::ProcessResolverResultLocked(
|
|||
}
|
||||
service_config = chand->default_service_config_;
|
||||
}
|
||||
} else if (result.service_config == nullptr) {
|
||||
} else if (result->service_config == nullptr) {
|
||||
if (chand->default_service_config_ != nullptr) {
|
||||
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
|
||||
gpr_log(GPR_INFO,
|
||||
|
|
@ -1240,15 +1229,15 @@ bool ChannelData::ProcessResolverResultLocked(
|
|||
service_config = chand->default_service_config_;
|
||||
}
|
||||
} else {
|
||||
service_config = result.service_config;
|
||||
service_config = result->service_config;
|
||||
}
|
||||
*service_config_error = GRPC_ERROR_REF(result.service_config_error);
|
||||
*service_config_error = GRPC_ERROR_REF(result->service_config_error);
|
||||
if (service_config == nullptr &&
|
||||
result.service_config_error != GRPC_ERROR_NONE) {
|
||||
result->service_config_error != GRPC_ERROR_NONE) {
|
||||
return false;
|
||||
}
|
||||
UniquePtr<char> service_config_json;
|
||||
// Process service config.
|
||||
UniquePtr<char> service_config_json;
|
||||
const internal::ClientChannelGlobalParsedObject* parsed_service_config =
|
||||
nullptr;
|
||||
if (service_config != nullptr) {
|
||||
|
|
@ -1257,6 +1246,20 @@ bool ChannelData::ProcessResolverResultLocked(
|
|||
service_config->GetParsedGlobalServiceConfigObject(
|
||||
internal::ClientChannelServiceConfigParser::ParserIndex()));
|
||||
}
|
||||
// TODO(roth): Eliminate this hack as part of hiding health check
|
||||
// service name from LB policy API. As part of this, change the API
|
||||
// for this function to pass in result as a const reference.
|
||||
if (parsed_service_config != nullptr &&
|
||||
parsed_service_config->health_check_service_name() != nullptr) {
|
||||
grpc_arg new_arg = grpc_channel_arg_string_create(
|
||||
const_cast<char*>("grpc.temp.health_check"),
|
||||
const_cast<char*>(parsed_service_config->health_check_service_name()));
|
||||
grpc_channel_args* new_args =
|
||||
grpc_channel_args_copy_and_add(result->args, &new_arg, 1);
|
||||
grpc_channel_args_destroy(result->args);
|
||||
result->args = new_args;
|
||||
}
|
||||
// Check if the config has changed.
|
||||
const bool service_config_changed =
|
||||
((service_config == nullptr) !=
|
||||
(chand->saved_service_config_ == nullptr)) ||
|
||||
|
|
@ -1273,12 +1276,6 @@ bool ChannelData::ProcessResolverResultLocked(
|
|||
chand, service_config_json.get());
|
||||
}
|
||||
chand->saved_service_config_ = std::move(service_config);
|
||||
if (parsed_service_config != nullptr) {
|
||||
chand->health_check_service_name_.reset(
|
||||
gpr_strdup(parsed_service_config->health_check_service_name()));
|
||||
} else {
|
||||
chand->health_check_service_name_.reset();
|
||||
}
|
||||
}
|
||||
// We want to set the service config at least once. This should not really be
|
||||
// needed, but we are doing it as a defensive approach. This can be removed,
|
||||
|
|
@ -1296,7 +1293,7 @@ bool ChannelData::ProcessResolverResultLocked(
|
|||
chand->saved_service_config_);
|
||||
}
|
||||
UniquePtr<char> processed_lb_policy_name;
|
||||
chand->ProcessLbPolicy(result, parsed_service_config,
|
||||
chand->ProcessLbPolicy(*result, parsed_service_config,
|
||||
&processed_lb_policy_name, lb_policy_config);
|
||||
// Swap out the data used by GetChannelInfo().
|
||||
{
|
||||
|
|
|
|||
|
|
@ -127,7 +127,9 @@ void SubchannelNode::PopulateConnectivityState(grpc_json* json) {
|
|||
if (subchannel_ == nullptr) {
|
||||
state = GRPC_CHANNEL_SHUTDOWN;
|
||||
} else {
|
||||
state = subchannel_->CheckConnectivity(true /* inhibit_health_checking */);
|
||||
state = subchannel_->CheckConnectivityState(
|
||||
nullptr /* health_check_service_name */,
|
||||
nullptr /* connected_subchannel */);
|
||||
}
|
||||
json = grpc_json_create_child(nullptr, json, "state", nullptr,
|
||||
GRPC_JSON_OBJECT, false);
|
||||
|
|
|
|||
|
|
@ -323,6 +323,11 @@ void HealthCheckClient::CallState::StartCall() {
|
|||
grpc_error* error = GRPC_ERROR_NONE;
|
||||
call_ = health_check_client_->connected_subchannel_->CreateCall(args, &error)
|
||||
.release();
|
||||
// Register after-destruction callback.
|
||||
GRPC_CLOSURE_INIT(&after_call_stack_destruction_, AfterCallStackDestruction,
|
||||
this, grpc_schedule_on_exec_ctx);
|
||||
call_->SetAfterCallStackDestroy(&after_call_stack_destruction_);
|
||||
// Check if creation failed.
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
gpr_log(GPR_ERROR,
|
||||
"HealthCheckClient %p CallState %p: error creating health "
|
||||
|
|
@ -338,10 +343,6 @@ void HealthCheckClient::CallState::StartCall() {
|
|||
GRPC_ERROR_NONE);
|
||||
return;
|
||||
}
|
||||
// Register after-destruction callback.
|
||||
GRPC_CLOSURE_INIT(&after_call_stack_destruction_, AfterCallStackDestruction,
|
||||
this, grpc_schedule_on_exec_ctx);
|
||||
call_->SetAfterCallStackDestroy(&after_call_stack_destruction_);
|
||||
// Initialize payload and batch.
|
||||
payload_.context = context_;
|
||||
batch_.payload = &payload_;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "src/core/ext/filters/client_channel/resolver_registry.h"
|
||||
#include "src/core/lib/channel/channel_args.h"
|
||||
#include "src/core/lib/channel/handshaker_registry.h"
|
||||
#include "src/core/lib/gpr/env.h"
|
||||
#include "src/core/lib/gpr/string.h"
|
||||
#include "src/core/lib/gprpp/sync.h"
|
||||
#include "src/core/lib/http/format_request.h"
|
||||
|
|
|
|||
|
|
@ -68,9 +68,8 @@ class PickFirst : public LoadBalancingPolicy {
|
|||
PickFirstSubchannelData(
|
||||
SubchannelList<PickFirstSubchannelList, PickFirstSubchannelData>*
|
||||
subchannel_list,
|
||||
const ServerAddress& address, Subchannel* subchannel,
|
||||
grpc_combiner* combiner)
|
||||
: SubchannelData(subchannel_list, address, subchannel, combiner) {}
|
||||
const ServerAddress& address, Subchannel* subchannel)
|
||||
: SubchannelData(subchannel_list, address, subchannel) {}
|
||||
|
||||
void ProcessConnectivityChangeLocked(
|
||||
grpc_connectivity_state connectivity_state) override;
|
||||
|
|
@ -312,6 +311,7 @@ void PickFirst::UpdateLocked(UpdateArgs args) {
|
|||
// here, since we've already checked the initial connectivity
|
||||
// state of all subchannels above.
|
||||
subchannel_list_->subchannel(0)->StartConnectivityWatchLocked();
|
||||
subchannel_list_->subchannel(0)->subchannel()->AttemptToConnect();
|
||||
}
|
||||
} else {
|
||||
// We do have a selected subchannel (which means it's READY), so keep
|
||||
|
|
@ -334,6 +334,9 @@ void PickFirst::UpdateLocked(UpdateArgs args) {
|
|||
// state of all subchannels above.
|
||||
latest_pending_subchannel_list_->subchannel(0)
|
||||
->StartConnectivityWatchLocked();
|
||||
latest_pending_subchannel_list_->subchannel(0)
|
||||
->subchannel()
|
||||
->AttemptToConnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -366,7 +369,8 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked(
|
|||
p->subchannel_list_.get());
|
||||
}
|
||||
p->selected_ = nullptr;
|
||||
StopConnectivityWatchLocked();
|
||||
CancelConnectivityWatchLocked(
|
||||
"selected subchannel failed; switching to pending update");
|
||||
p->subchannel_list_ = std::move(p->latest_pending_subchannel_list_);
|
||||
// Set our state to that of the pending subchannel list.
|
||||
if (p->subchannel_list_->in_transient_failure()) {
|
||||
|
|
@ -391,7 +395,7 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked(
|
|||
p->idle_ = true;
|
||||
p->channel_control_helper()->RequestReresolution();
|
||||
p->selected_ = nullptr;
|
||||
StopConnectivityWatchLocked();
|
||||
CancelConnectivityWatchLocked("selected subchannel failed; going IDLE");
|
||||
p->channel_control_helper()->UpdateState(
|
||||
GRPC_CHANNEL_IDLE,
|
||||
UniquePtr<SubchannelPicker>(New<QueuePicker>(p->Ref())));
|
||||
|
|
@ -408,8 +412,6 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked(
|
|||
connectivity_state,
|
||||
UniquePtr<SubchannelPicker>(New<QueuePicker>(p->Ref())));
|
||||
}
|
||||
// Renew notification.
|
||||
RenewConnectivityWatchLocked();
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
@ -426,13 +428,11 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked(
|
|||
subchannel_list()->set_in_transient_failure(false);
|
||||
switch (connectivity_state) {
|
||||
case GRPC_CHANNEL_READY: {
|
||||
// Renew notification.
|
||||
RenewConnectivityWatchLocked();
|
||||
ProcessUnselectedReadyLocked();
|
||||
break;
|
||||
}
|
||||
case GRPC_CHANNEL_TRANSIENT_FAILURE: {
|
||||
StopConnectivityWatchLocked();
|
||||
CancelConnectivityWatchLocked("connection attempt failed");
|
||||
PickFirstSubchannelData* sd = this;
|
||||
size_t next_index =
|
||||
(sd->Index() + 1) % subchannel_list()->num_subchannels();
|
||||
|
|
@ -468,8 +468,6 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked(
|
|||
GRPC_CHANNEL_CONNECTING,
|
||||
UniquePtr<SubchannelPicker>(New<QueuePicker>(p->Ref())));
|
||||
}
|
||||
// Renew notification.
|
||||
RenewConnectivityWatchLocked();
|
||||
break;
|
||||
}
|
||||
case GRPC_CHANNEL_SHUTDOWN:
|
||||
|
|
@ -521,8 +519,11 @@ void PickFirst::PickFirstSubchannelData::
|
|||
// If current state is READY, select the subchannel now, since we started
|
||||
// watching from this state and will not get a notification of it
|
||||
// transitioning into this state.
|
||||
if (p->selected_ != this && current_state == GRPC_CHANNEL_READY) {
|
||||
ProcessUnselectedReadyLocked();
|
||||
// If the current state is not READY, attempt to connect.
|
||||
if (current_state == GRPC_CHANNEL_READY) {
|
||||
if (p->selected_ != this) ProcessUnselectedReadyLocked();
|
||||
} else {
|
||||
subchannel()->AttemptToConnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,9 +83,8 @@ class RoundRobin : public LoadBalancingPolicy {
|
|||
RoundRobinSubchannelData(
|
||||
SubchannelList<RoundRobinSubchannelList, RoundRobinSubchannelData>*
|
||||
subchannel_list,
|
||||
const ServerAddress& address, Subchannel* subchannel,
|
||||
grpc_combiner* combiner)
|
||||
: SubchannelData(subchannel_list, address, subchannel, combiner) {}
|
||||
const ServerAddress& address, Subchannel* subchannel)
|
||||
: SubchannelData(subchannel_list, address, subchannel) {}
|
||||
|
||||
grpc_connectivity_state connectivity_state() const {
|
||||
return last_connectivity_state_;
|
||||
|
|
@ -320,6 +319,7 @@ void RoundRobin::RoundRobinSubchannelList::StartWatchingLocked() {
|
|||
for (size_t i = 0; i < num_subchannels(); i++) {
|
||||
if (subchannel(i)->subchannel() != nullptr) {
|
||||
subchannel(i)->StartConnectivityWatchLocked();
|
||||
subchannel(i)->subchannel()->AttemptToConnect();
|
||||
}
|
||||
}
|
||||
// Now set the LB policy's state based on the subchannels' states.
|
||||
|
|
@ -448,6 +448,7 @@ void RoundRobin::RoundRobinSubchannelData::ProcessConnectivityChangeLocked(
|
|||
// Otherwise, if the subchannel was already in state TRANSIENT_FAILURE
|
||||
// when the subchannel list was created, we'd wind up in a constant
|
||||
// loop of re-resolution.
|
||||
// Also attempt to reconnect.
|
||||
if (connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
|
||||
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_round_robin_trace)) {
|
||||
gpr_log(GPR_INFO,
|
||||
|
|
@ -456,9 +457,8 @@ void RoundRobin::RoundRobinSubchannelData::ProcessConnectivityChangeLocked(
|
|||
p, subchannel());
|
||||
}
|
||||
p->channel_control_helper()->RequestReresolution();
|
||||
subchannel()->AttemptToConnect();
|
||||
}
|
||||
// Renew connectivity watch.
|
||||
RenewConnectivityWatchLocked();
|
||||
// Update state counters.
|
||||
UpdateConnectivityStateLocked(connectivity_state);
|
||||
// Update overall state and renew notification.
|
||||
|
|
|
|||
|
|
@ -98,15 +98,13 @@ class SubchannelData {
|
|||
|
||||
// Synchronously checks the subchannel's connectivity state.
|
||||
// Must not be called while there is a connectivity notification
|
||||
// pending (i.e., between calling StartConnectivityWatchLocked() or
|
||||
// RenewConnectivityWatchLocked() and the resulting invocation of
|
||||
// ProcessConnectivityChangeLocked()).
|
||||
// pending (i.e., between calling StartConnectivityWatchLocked() and
|
||||
// calling CancelConnectivityWatchLocked()).
|
||||
grpc_connectivity_state CheckConnectivityStateLocked() {
|
||||
GPR_ASSERT(!connectivity_notification_pending_);
|
||||
pending_connectivity_state_unsafe_ = subchannel()->CheckConnectivity(
|
||||
subchannel_list_->inhibit_health_checking());
|
||||
UpdateConnectedSubchannelLocked();
|
||||
return pending_connectivity_state_unsafe_;
|
||||
GPR_ASSERT(pending_watcher_ == nullptr);
|
||||
connectivity_state_ = subchannel()->CheckConnectivityState(
|
||||
subchannel_list_->health_check_service_name(), &connected_subchannel_);
|
||||
return connectivity_state_;
|
||||
}
|
||||
|
||||
// Resets the connection backoff.
|
||||
|
|
@ -115,23 +113,11 @@ class SubchannelData {
|
|||
void ResetBackoffLocked();
|
||||
|
||||
// Starts watching the connectivity state of the subchannel.
|
||||
// ProcessConnectivityChangeLocked() will be called when the
|
||||
// ProcessConnectivityChangeLocked() will be called whenever the
|
||||
// connectivity state changes.
|
||||
void StartConnectivityWatchLocked();
|
||||
|
||||
// Renews watching the connectivity state of the subchannel.
|
||||
void RenewConnectivityWatchLocked();
|
||||
|
||||
// Stops watching the connectivity state of the subchannel.
|
||||
void StopConnectivityWatchLocked();
|
||||
|
||||
// Cancels watching the connectivity state of the subchannel.
|
||||
// Must be called only while there is a connectivity notification
|
||||
// pending (i.e., between calling StartConnectivityWatchLocked() or
|
||||
// RenewConnectivityWatchLocked() and the resulting invocation of
|
||||
// ProcessConnectivityChangeLocked()).
|
||||
// From within ProcessConnectivityChangeLocked(), use
|
||||
// StopConnectivityWatchLocked() instead.
|
||||
void CancelConnectivityWatchLocked(const char* reason);
|
||||
|
||||
// Cancels any pending connectivity watch and unrefs the subchannel.
|
||||
|
|
@ -142,44 +128,80 @@ class SubchannelData {
|
|||
protected:
|
||||
SubchannelData(
|
||||
SubchannelList<SubchannelListType, SubchannelDataType>* subchannel_list,
|
||||
const ServerAddress& address, Subchannel* subchannel,
|
||||
grpc_combiner* combiner);
|
||||
const ServerAddress& address, Subchannel* subchannel);
|
||||
|
||||
virtual ~SubchannelData();
|
||||
|
||||
// After StartConnectivityWatchLocked() or RenewConnectivityWatchLocked()
|
||||
// is called, this method will be invoked when the subchannel's connectivity
|
||||
// state changes.
|
||||
// Implementations must invoke either RenewConnectivityWatchLocked() or
|
||||
// StopConnectivityWatchLocked() before returning.
|
||||
// After StartConnectivityWatchLocked() is called, this method will be
|
||||
// invoked whenever the subchannel's connectivity state changes.
|
||||
// To stop watching, use CancelConnectivityWatchLocked().
|
||||
virtual void ProcessConnectivityChangeLocked(
|
||||
grpc_connectivity_state connectivity_state) GRPC_ABSTRACT;
|
||||
|
||||
private:
|
||||
// Watcher for subchannel connectivity state.
|
||||
class Watcher : public Subchannel::ConnectivityStateWatcher {
|
||||
public:
|
||||
Watcher(
|
||||
SubchannelData<SubchannelListType, SubchannelDataType>* subchannel_data,
|
||||
RefCountedPtr<SubchannelListType> subchannel_list)
|
||||
: subchannel_data_(subchannel_data),
|
||||
subchannel_list_(std::move(subchannel_list)) {}
|
||||
|
||||
~Watcher() { subchannel_list_.reset(DEBUG_LOCATION, "Watcher dtor"); }
|
||||
|
||||
void OnConnectivityStateChange(
|
||||
grpc_connectivity_state new_state,
|
||||
RefCountedPtr<ConnectedSubchannel> connected_subchannel) override;
|
||||
|
||||
grpc_pollset_set* interested_parties() override {
|
||||
return subchannel_list_->policy()->interested_parties();
|
||||
}
|
||||
|
||||
private:
|
||||
// A fire-and-forget class that bounces into the combiner to process
|
||||
// a connectivity state update.
|
||||
class Updater {
|
||||
public:
|
||||
Updater(
|
||||
SubchannelData<SubchannelListType, SubchannelDataType>*
|
||||
subchannel_data,
|
||||
RefCountedPtr<SubchannelList<SubchannelListType, SubchannelDataType>>
|
||||
subchannel_list,
|
||||
grpc_connectivity_state state,
|
||||
RefCountedPtr<ConnectedSubchannel> connected_subchannel);
|
||||
|
||||
~Updater() {
|
||||
subchannel_list_.reset(DEBUG_LOCATION, "Watcher::Updater dtor");
|
||||
}
|
||||
|
||||
private:
|
||||
static void OnUpdateLocked(void* arg, grpc_error* error);
|
||||
|
||||
SubchannelData<SubchannelListType, SubchannelDataType>* subchannel_data_;
|
||||
RefCountedPtr<SubchannelList<SubchannelListType, SubchannelDataType>>
|
||||
subchannel_list_;
|
||||
const grpc_connectivity_state state_;
|
||||
RefCountedPtr<ConnectedSubchannel> connected_subchannel_;
|
||||
grpc_closure closure_;
|
||||
};
|
||||
|
||||
SubchannelData<SubchannelListType, SubchannelDataType>* subchannel_data_;
|
||||
RefCountedPtr<SubchannelListType> subchannel_list_;
|
||||
};
|
||||
|
||||
// Unrefs the subchannel.
|
||||
void UnrefSubchannelLocked(const char* reason);
|
||||
|
||||
private:
|
||||
// Updates connected_subchannel_ based on pending_connectivity_state_unsafe_.
|
||||
// Returns true if the connectivity state should be reported.
|
||||
bool UpdateConnectedSubchannelLocked();
|
||||
|
||||
static void OnConnectivityChangedLocked(void* arg, grpc_error* error);
|
||||
|
||||
// Backpointer to owning subchannel list. Not owned.
|
||||
SubchannelList<SubchannelListType, SubchannelDataType>* subchannel_list_;
|
||||
|
||||
// The subchannel and connected subchannel.
|
||||
// The subchannel.
|
||||
Subchannel* subchannel_;
|
||||
// Will be non-null when the subchannel's state is being watched.
|
||||
Subchannel::ConnectivityStateWatcher* pending_watcher_ = nullptr;
|
||||
// Data updated by the watcher.
|
||||
grpc_connectivity_state connectivity_state_;
|
||||
RefCountedPtr<ConnectedSubchannel> connected_subchannel_;
|
||||
|
||||
// Notification that connectivity has changed on subchannel.
|
||||
grpc_closure connectivity_changed_closure_;
|
||||
// Is a connectivity notification pending?
|
||||
bool connectivity_notification_pending_ = false;
|
||||
// Connectivity state to be updated by
|
||||
// grpc_subchannel_notify_on_state_change(), not guarded by
|
||||
// the combiner.
|
||||
grpc_connectivity_state pending_connectivity_state_unsafe_;
|
||||
};
|
||||
|
||||
// A list of subchannels.
|
||||
|
|
@ -213,7 +235,9 @@ class SubchannelList : public InternallyRefCounted<SubchannelListType> {
|
|||
// Accessors.
|
||||
LoadBalancingPolicy* policy() const { return policy_; }
|
||||
TraceFlag* tracer() const { return tracer_; }
|
||||
bool inhibit_health_checking() const { return inhibit_health_checking_; }
|
||||
const char* health_check_service_name() const {
|
||||
return health_check_service_name_.get();
|
||||
}
|
||||
|
||||
// Resets connection backoff of all subchannels.
|
||||
// TODO(roth): We will probably need to rethink this as part of moving
|
||||
|
|
@ -251,7 +275,7 @@ class SubchannelList : public InternallyRefCounted<SubchannelListType> {
|
|||
|
||||
TraceFlag* tracer_;
|
||||
|
||||
bool inhibit_health_checking_;
|
||||
UniquePtr<char> health_check_service_name_;
|
||||
|
||||
grpc_combiner* combiner_;
|
||||
|
||||
|
|
@ -268,6 +292,67 @@ class SubchannelList : public InternallyRefCounted<SubchannelListType> {
|
|||
// implementation -- no user-servicable parts below
|
||||
//
|
||||
|
||||
//
|
||||
// SubchannelData::Watcher
|
||||
//
|
||||
|
||||
template <typename SubchannelListType, typename SubchannelDataType>
|
||||
void SubchannelData<SubchannelListType, SubchannelDataType>::Watcher::
|
||||
OnConnectivityStateChange(
|
||||
grpc_connectivity_state new_state,
|
||||
RefCountedPtr<ConnectedSubchannel> connected_subchannel) {
|
||||
// Will delete itself.
|
||||
New<Updater>(subchannel_data_,
|
||||
subchannel_list_->Ref(DEBUG_LOCATION, "Watcher::Updater"),
|
||||
new_state, std::move(connected_subchannel));
|
||||
}
|
||||
|
||||
template <typename SubchannelListType, typename SubchannelDataType>
|
||||
SubchannelData<SubchannelListType, SubchannelDataType>::Watcher::Updater::
|
||||
Updater(
|
||||
SubchannelData<SubchannelListType, SubchannelDataType>* subchannel_data,
|
||||
RefCountedPtr<SubchannelList<SubchannelListType, SubchannelDataType>>
|
||||
subchannel_list,
|
||||
grpc_connectivity_state state,
|
||||
RefCountedPtr<ConnectedSubchannel> connected_subchannel)
|
||||
: subchannel_data_(subchannel_data),
|
||||
subchannel_list_(std::move(subchannel_list)),
|
||||
state_(state),
|
||||
connected_subchannel_(std::move(connected_subchannel)) {
|
||||
GRPC_CLOSURE_INIT(&closure_, &OnUpdateLocked, this,
|
||||
grpc_combiner_scheduler(subchannel_list_->combiner_));
|
||||
GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE);
|
||||
}
|
||||
|
||||
template <typename SubchannelListType, typename SubchannelDataType>
|
||||
void SubchannelData<SubchannelListType, SubchannelDataType>::Watcher::Updater::
|
||||
OnUpdateLocked(void* arg, grpc_error* error) {
|
||||
Updater* self = static_cast<Updater*>(arg);
|
||||
SubchannelData* sd = self->subchannel_data_;
|
||||
if (GRPC_TRACE_FLAG_ENABLED(*sd->subchannel_list_->tracer())) {
|
||||
gpr_log(GPR_INFO,
|
||||
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
|
||||
" (subchannel %p): connectivity changed: state=%s, "
|
||||
"connected_subchannel=%p, shutting_down=%d, pending_watcher=%p",
|
||||
sd->subchannel_list_->tracer()->name(),
|
||||
sd->subchannel_list_->policy(), sd->subchannel_list_, sd->Index(),
|
||||
sd->subchannel_list_->num_subchannels(), sd->subchannel_,
|
||||
grpc_connectivity_state_name(self->state_),
|
||||
self->connected_subchannel_.get(),
|
||||
sd->subchannel_list_->shutting_down(), sd->pending_watcher_);
|
||||
}
|
||||
if (!sd->subchannel_list_->shutting_down() &&
|
||||
sd->pending_watcher_ != nullptr) {
|
||||
sd->connectivity_state_ = self->state_;
|
||||
// Get or release ref to connected subchannel.
|
||||
sd->connected_subchannel_ = std::move(self->connected_subchannel_);
|
||||
// Call the subclass's ProcessConnectivityChangeLocked() method.
|
||||
sd->ProcessConnectivityChangeLocked(sd->connectivity_state_);
|
||||
}
|
||||
// Clean up.
|
||||
Delete(self);
|
||||
}
|
||||
|
||||
//
|
||||
// SubchannelData
|
||||
//
|
||||
|
|
@ -275,23 +360,16 @@ class SubchannelList : public InternallyRefCounted<SubchannelListType> {
|
|||
template <typename SubchannelListType, typename SubchannelDataType>
|
||||
SubchannelData<SubchannelListType, SubchannelDataType>::SubchannelData(
|
||||
SubchannelList<SubchannelListType, SubchannelDataType>* subchannel_list,
|
||||
const ServerAddress& address, Subchannel* subchannel,
|
||||
grpc_combiner* combiner)
|
||||
const ServerAddress& address, Subchannel* subchannel)
|
||||
: subchannel_list_(subchannel_list),
|
||||
subchannel_(subchannel),
|
||||
// We assume that the current state is IDLE. If not, we'll get a
|
||||
// callback telling us that.
|
||||
pending_connectivity_state_unsafe_(GRPC_CHANNEL_IDLE) {
|
||||
GRPC_CLOSURE_INIT(
|
||||
&connectivity_changed_closure_,
|
||||
(&SubchannelData<SubchannelListType,
|
||||
SubchannelDataType>::OnConnectivityChangedLocked),
|
||||
this, grpc_combiner_scheduler(combiner));
|
||||
}
|
||||
connectivity_state_(GRPC_CHANNEL_IDLE) {}
|
||||
|
||||
template <typename SubchannelListType, typename SubchannelDataType>
|
||||
SubchannelData<SubchannelListType, SubchannelDataType>::~SubchannelData() {
|
||||
UnrefSubchannelLocked("subchannel_data_destroy");
|
||||
GPR_ASSERT(subchannel_ == nullptr);
|
||||
}
|
||||
|
||||
template <typename SubchannelListType, typename SubchannelDataType>
|
||||
|
|
@ -326,56 +404,19 @@ void SubchannelData<SubchannelListType,
|
|||
if (GRPC_TRACE_FLAG_ENABLED(*subchannel_list_->tracer())) {
|
||||
gpr_log(GPR_INFO,
|
||||
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
|
||||
" (subchannel %p): starting watch: requesting connectivity change "
|
||||
"notification (from %s)",
|
||||
" (subchannel %p): starting watch (from %s)",
|
||||
subchannel_list_->tracer()->name(), subchannel_list_->policy(),
|
||||
subchannel_list_, Index(), subchannel_list_->num_subchannels(),
|
||||
subchannel_,
|
||||
grpc_connectivity_state_name(pending_connectivity_state_unsafe_));
|
||||
subchannel_, grpc_connectivity_state_name(connectivity_state_));
|
||||
}
|
||||
GPR_ASSERT(!connectivity_notification_pending_);
|
||||
connectivity_notification_pending_ = true;
|
||||
subchannel_list()->Ref(DEBUG_LOCATION, "connectivity_watch").release();
|
||||
subchannel_->NotifyOnStateChange(
|
||||
subchannel_list_->policy()->interested_parties(),
|
||||
&pending_connectivity_state_unsafe_, &connectivity_changed_closure_,
|
||||
subchannel_list_->inhibit_health_checking());
|
||||
}
|
||||
|
||||
template <typename SubchannelListType, typename SubchannelDataType>
|
||||
void SubchannelData<SubchannelListType,
|
||||
SubchannelDataType>::RenewConnectivityWatchLocked() {
|
||||
if (GRPC_TRACE_FLAG_ENABLED(*subchannel_list_->tracer())) {
|
||||
gpr_log(GPR_INFO,
|
||||
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
|
||||
" (subchannel %p): renewing watch: requesting connectivity change "
|
||||
"notification (from %s)",
|
||||
subchannel_list_->tracer()->name(), subchannel_list_->policy(),
|
||||
subchannel_list_, Index(), subchannel_list_->num_subchannels(),
|
||||
subchannel_,
|
||||
grpc_connectivity_state_name(pending_connectivity_state_unsafe_));
|
||||
}
|
||||
GPR_ASSERT(connectivity_notification_pending_);
|
||||
subchannel_->NotifyOnStateChange(
|
||||
subchannel_list_->policy()->interested_parties(),
|
||||
&pending_connectivity_state_unsafe_, &connectivity_changed_closure_,
|
||||
subchannel_list_->inhibit_health_checking());
|
||||
}
|
||||
|
||||
template <typename SubchannelListType, typename SubchannelDataType>
|
||||
void SubchannelData<SubchannelListType,
|
||||
SubchannelDataType>::StopConnectivityWatchLocked() {
|
||||
if (GRPC_TRACE_FLAG_ENABLED(*subchannel_list_->tracer())) {
|
||||
gpr_log(GPR_INFO,
|
||||
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
|
||||
" (subchannel %p): stopping connectivity watch",
|
||||
subchannel_list_->tracer()->name(), subchannel_list_->policy(),
|
||||
subchannel_list_, Index(), subchannel_list_->num_subchannels(),
|
||||
subchannel_);
|
||||
}
|
||||
GPR_ASSERT(connectivity_notification_pending_);
|
||||
connectivity_notification_pending_ = false;
|
||||
subchannel_list()->Unref(DEBUG_LOCATION, "connectivity_watch");
|
||||
GPR_ASSERT(pending_watcher_ == nullptr);
|
||||
pending_watcher_ =
|
||||
New<Watcher>(this, subchannel_list()->Ref(DEBUG_LOCATION, "Watcher"));
|
||||
subchannel_->WatchConnectivityState(
|
||||
connectivity_state_,
|
||||
UniquePtr<char>(
|
||||
gpr_strdup(subchannel_list_->health_check_service_name())),
|
||||
UniquePtr<Subchannel::ConnectivityStateWatcher>(pending_watcher_));
|
||||
}
|
||||
|
||||
template <typename SubchannelListType, typename SubchannelDataType>
|
||||
|
|
@ -389,91 +430,17 @@ void SubchannelData<SubchannelListType, SubchannelDataType>::
|
|||
subchannel_list_, Index(), subchannel_list_->num_subchannels(),
|
||||
subchannel_, reason);
|
||||
}
|
||||
GPR_ASSERT(connectivity_notification_pending_);
|
||||
subchannel_->NotifyOnStateChange(nullptr, nullptr,
|
||||
&connectivity_changed_closure_,
|
||||
subchannel_list_->inhibit_health_checking());
|
||||
}
|
||||
|
||||
template <typename SubchannelListType, typename SubchannelDataType>
|
||||
bool SubchannelData<SubchannelListType,
|
||||
SubchannelDataType>::UpdateConnectedSubchannelLocked() {
|
||||
// If the subchannel is READY, take a ref to the connected subchannel.
|
||||
if (pending_connectivity_state_unsafe_ == GRPC_CHANNEL_READY) {
|
||||
connected_subchannel_ = subchannel_->connected_subchannel();
|
||||
// If the subchannel became disconnected between the time that READY
|
||||
// was reported and the time we got here (e.g., between when a
|
||||
// notification callback is scheduled and when it was actually run in
|
||||
// the combiner), then the connected subchannel may have disappeared out
|
||||
// from under us. In that case, we don't actually want to consider the
|
||||
// subchannel to be in state READY. Instead, we use IDLE as the
|
||||
// basis for any future connectivity watch; this is the one state that
|
||||
// the subchannel will never transition back into, so this ensures
|
||||
// that we will get a notification for the next state, even if that state
|
||||
// is READY again (e.g., if the subchannel has transitioned back to
|
||||
// READY before the next watch gets requested).
|
||||
if (connected_subchannel_ == nullptr) {
|
||||
if (GRPC_TRACE_FLAG_ENABLED(*subchannel_list_->tracer())) {
|
||||
gpr_log(GPR_INFO,
|
||||
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
|
||||
" (subchannel %p): state is READY but connected subchannel is "
|
||||
"null; moving to state IDLE",
|
||||
subchannel_list_->tracer()->name(), subchannel_list_->policy(),
|
||||
subchannel_list_, Index(), subchannel_list_->num_subchannels(),
|
||||
subchannel_);
|
||||
}
|
||||
pending_connectivity_state_unsafe_ = GRPC_CHANNEL_IDLE;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// For any state other than READY, unref the connected subchannel.
|
||||
connected_subchannel_.reset();
|
||||
if (pending_watcher_ != nullptr) {
|
||||
subchannel_->CancelConnectivityStateWatch(
|
||||
subchannel_list_->health_check_service_name(), pending_watcher_);
|
||||
pending_watcher_ = nullptr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename SubchannelListType, typename SubchannelDataType>
|
||||
void SubchannelData<SubchannelListType, SubchannelDataType>::
|
||||
OnConnectivityChangedLocked(void* arg, grpc_error* error) {
|
||||
SubchannelData* sd = static_cast<SubchannelData*>(arg);
|
||||
if (GRPC_TRACE_FLAG_ENABLED(*sd->subchannel_list_->tracer())) {
|
||||
gpr_log(
|
||||
GPR_INFO,
|
||||
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
|
||||
" (subchannel %p): connectivity changed: state=%s, error=%s, "
|
||||
"shutting_down=%d",
|
||||
sd->subchannel_list_->tracer()->name(), sd->subchannel_list_->policy(),
|
||||
sd->subchannel_list_, sd->Index(),
|
||||
sd->subchannel_list_->num_subchannels(), sd->subchannel_,
|
||||
grpc_connectivity_state_name(sd->pending_connectivity_state_unsafe_),
|
||||
grpc_error_string(error), sd->subchannel_list_->shutting_down());
|
||||
}
|
||||
// If shutting down, unref subchannel and stop watching.
|
||||
if (sd->subchannel_list_->shutting_down() || error == GRPC_ERROR_CANCELLED) {
|
||||
sd->UnrefSubchannelLocked("connectivity_shutdown");
|
||||
sd->StopConnectivityWatchLocked();
|
||||
return;
|
||||
}
|
||||
// Get or release ref to connected subchannel.
|
||||
if (!sd->UpdateConnectedSubchannelLocked()) {
|
||||
// We don't want to report this connectivity state, so renew the watch.
|
||||
sd->RenewConnectivityWatchLocked();
|
||||
return;
|
||||
}
|
||||
// Call the subclass's ProcessConnectivityChangeLocked() method.
|
||||
sd->ProcessConnectivityChangeLocked(sd->pending_connectivity_state_unsafe_);
|
||||
}
|
||||
|
||||
template <typename SubchannelListType, typename SubchannelDataType>
|
||||
void SubchannelData<SubchannelListType, SubchannelDataType>::ShutdownLocked() {
|
||||
// If there's a pending notification for this subchannel, cancel it;
|
||||
// the callback is responsible for unreffing the subchannel.
|
||||
// Otherwise, unref the subchannel directly.
|
||||
if (connectivity_notification_pending_) {
|
||||
CancelConnectivityWatchLocked("shutdown");
|
||||
} else if (subchannel_ != nullptr) {
|
||||
UnrefSubchannelLocked("shutdown");
|
||||
}
|
||||
if (pending_watcher_ != nullptr) CancelConnectivityWatchLocked("shutdown");
|
||||
UnrefSubchannelLocked("shutdown");
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -496,14 +463,25 @@ SubchannelList<SubchannelListType, SubchannelDataType>::SubchannelList(
|
|||
tracer_->name(), policy, this, addresses.size());
|
||||
}
|
||||
subchannels_.reserve(addresses.size());
|
||||
// Find health check service name.
|
||||
const bool inhibit_health_checking = grpc_channel_arg_get_bool(
|
||||
grpc_channel_args_find(&args, GRPC_ARG_INHIBIT_HEALTH_CHECKING), false);
|
||||
if (!inhibit_health_checking) {
|
||||
const char* health_check_service_name = grpc_channel_arg_get_string(
|
||||
grpc_channel_args_find(&args, "grpc.temp.health_check"));
|
||||
if (health_check_service_name != nullptr) {
|
||||
health_check_service_name_.reset(gpr_strdup(health_check_service_name));
|
||||
}
|
||||
}
|
||||
// We need to remove the LB addresses in order to be able to compare the
|
||||
// subchannel keys of subchannels from a different batch of addresses.
|
||||
// We also remove the inhibit-health-checking arg, since we are
|
||||
// We also remove the health-checking-related args, since we are
|
||||
// handling that here.
|
||||
inhibit_health_checking_ = grpc_channel_arg_get_bool(
|
||||
grpc_channel_args_find(&args, GRPC_ARG_INHIBIT_HEALTH_CHECKING), false);
|
||||
static const char* keys_to_remove[] = {GRPC_ARG_SUBCHANNEL_ADDRESS,
|
||||
GRPC_ARG_INHIBIT_HEALTH_CHECKING};
|
||||
// We remove the service config, since it will be passed into the
|
||||
// subchannel via call context.
|
||||
static const char* keys_to_remove[] = {
|
||||
GRPC_ARG_SUBCHANNEL_ADDRESS, "grpc.temp.health_check",
|
||||
GRPC_ARG_INHIBIT_HEALTH_CHECKING, GRPC_ARG_SERVICE_CONFIG};
|
||||
// Create a subchannel for each address.
|
||||
for (size_t i = 0; i < addresses.size(); i++) {
|
||||
// TODO(roth): we should ideally hide this from the LB policy code. In
|
||||
|
|
@ -549,7 +527,7 @@ SubchannelList<SubchannelListType, SubchannelDataType>::SubchannelList(
|
|||
address_uri);
|
||||
gpr_free(address_uri);
|
||||
}
|
||||
subchannels_.emplace_back(this, addresses[i], subchannel, combiner);
|
||||
subchannels_.emplace_back(this, addresses[i], subchannel);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,12 +32,12 @@
|
|||
#include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
|
||||
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
|
||||
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
|
||||
#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h"
|
||||
#include "src/core/ext/filters/client_channel/resolver_registry.h"
|
||||
#include "src/core/ext/filters/client_channel/server_address.h"
|
||||
#include "src/core/ext/filters/client_channel/service_config.h"
|
||||
#include "src/core/lib/backoff/backoff.h"
|
||||
#include "src/core/lib/channel/channel_args.h"
|
||||
#include "src/core/lib/gpr/env.h"
|
||||
#include "src/core/lib/gpr/host_port.h"
|
||||
#include "src/core/lib/gpr/string.h"
|
||||
#include "src/core/lib/gprpp/manual_constructor.h"
|
||||
|
|
@ -474,9 +474,8 @@ static bool should_use_ares(const char* resolver_env) {
|
|||
#endif /* GRPC_UV */
|
||||
|
||||
void grpc_resolver_dns_ares_init() {
|
||||
grpc_core::UniquePtr<char> resolver =
|
||||
GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver);
|
||||
if (should_use_ares(resolver.get())) {
|
||||
char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER");
|
||||
if (should_use_ares(resolver_env)) {
|
||||
gpr_log(GPR_DEBUG, "Using ares dns resolver");
|
||||
address_sorting_init();
|
||||
grpc_error* error = grpc_ares_init();
|
||||
|
|
@ -492,15 +491,16 @@ void grpc_resolver_dns_ares_init() {
|
|||
grpc_core::UniquePtr<grpc_core::ResolverFactory>(
|
||||
grpc_core::New<grpc_core::AresDnsResolverFactory>()));
|
||||
}
|
||||
gpr_free(resolver_env);
|
||||
}
|
||||
|
||||
void grpc_resolver_dns_ares_shutdown() {
|
||||
grpc_core::UniquePtr<char> resolver =
|
||||
GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver);
|
||||
if (should_use_ares(resolver.get())) {
|
||||
char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER");
|
||||
if (should_use_ares(resolver_env)) {
|
||||
address_sorting_shutdown();
|
||||
grpc_ares_cleanup();
|
||||
}
|
||||
gpr_free(resolver_env);
|
||||
}
|
||||
|
||||
#else /* GRPC_ARES == 1 */
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
//
|
||||
// Copyright 2019 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.
|
||||
//
|
||||
|
||||
// This is similar to the sockaddr resolver, except that it supports a
|
||||
// bunch of query args that are useful for dependency injection in tests.
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h"
|
||||
|
||||
GPR_GLOBAL_CONFIG_DEFINE_STRING(
|
||||
grpc_dns_resolver, "",
|
||||
"Declares which DNS resolver to use. The default is ares if gRPC is built "
|
||||
"with c-ares support. Otherwise, the value of this environment variable is "
|
||||
"ignored.")
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2019 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_DNS_RESOLVER_SELECTION_H
|
||||
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_DNS_RESOLVER_SELECTION_H
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#include "src/core/lib/gprpp/global_config.h"
|
||||
|
||||
GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_dns_resolver);
|
||||
|
||||
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_DNS_RESOLVER_SELECTION_H \
|
||||
*/
|
||||
|
|
@ -26,11 +26,11 @@
|
|||
#include <grpc/support/string_util.h>
|
||||
#include <grpc/support/time.h>
|
||||
|
||||
#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h"
|
||||
#include "src/core/ext/filters/client_channel/resolver_registry.h"
|
||||
#include "src/core/ext/filters/client_channel/server_address.h"
|
||||
#include "src/core/lib/backoff/backoff.h"
|
||||
#include "src/core/lib/channel/channel_args.h"
|
||||
#include "src/core/lib/gpr/env.h"
|
||||
#include "src/core/lib/gpr/host_port.h"
|
||||
#include "src/core/lib/gpr/string.h"
|
||||
#include "src/core/lib/gprpp/manual_constructor.h"
|
||||
|
|
@ -274,9 +274,8 @@ class NativeDnsResolverFactory : public ResolverFactory {
|
|||
} // namespace grpc_core
|
||||
|
||||
void grpc_resolver_dns_native_init() {
|
||||
grpc_core::UniquePtr<char> resolver =
|
||||
GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver);
|
||||
if (gpr_stricmp(resolver.get(), "native") == 0) {
|
||||
char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER");
|
||||
if (resolver_env != nullptr && gpr_stricmp(resolver_env, "native") == 0) {
|
||||
gpr_log(GPR_DEBUG, "Using native dns resolver");
|
||||
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
|
||||
grpc_core::UniquePtr<grpc_core::ResolverFactory>(
|
||||
|
|
@ -292,6 +291,7 @@ void grpc_resolver_dns_native_init() {
|
|||
grpc_core::New<grpc_core::NativeDnsResolverFactory>()));
|
||||
}
|
||||
}
|
||||
gpr_free(resolver_env);
|
||||
}
|
||||
|
||||
void grpc_resolver_dns_native_shutdown() {}
|
||||
|
|
|
|||
|
|
@ -536,7 +536,7 @@ void ResolvingLoadBalancingPolicy::OnResolverResultChangedLocked(
|
|||
if (process_resolver_result_ != nullptr) {
|
||||
grpc_error* service_config_error = GRPC_ERROR_NONE;
|
||||
service_config_changed = process_resolver_result_(
|
||||
process_resolver_result_user_data_, result, &lb_policy_name,
|
||||
process_resolver_result_user_data_, &result, &lb_policy_name,
|
||||
&lb_policy_config, &service_config_error);
|
||||
if (service_config_error != GRPC_ERROR_NONE) {
|
||||
service_config_error_string =
|
||||
|
|
|
|||
|
|
@ -69,8 +69,7 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy {
|
|||
// empty, it means that we don't have a valid service config to use, and we
|
||||
// should set the channel to be in TRANSIENT_FAILURE.
|
||||
typedef bool (*ProcessResolverResultCallback)(
|
||||
void* user_data, const Resolver::Result& result,
|
||||
const char** lb_policy_name,
|
||||
void* user_data, Resolver::Result* result, const char** lb_policy_name,
|
||||
RefCountedPtr<ParsedLoadBalancingConfig>* lb_policy_config,
|
||||
grpc_error** service_config_error);
|
||||
// If error is set when this returns, then construction failed, and
|
||||
|
|
|
|||
|
|
@ -303,8 +303,7 @@ void SubchannelCall::IncrementRefCount(const grpc_core::DebugLocation& location,
|
|||
// Subchannel::ConnectedSubchannelStateWatcher
|
||||
//
|
||||
|
||||
class Subchannel::ConnectedSubchannelStateWatcher
|
||||
: public InternallyRefCounted<ConnectedSubchannelStateWatcher> {
|
||||
class Subchannel::ConnectedSubchannelStateWatcher {
|
||||
public:
|
||||
// Must be instantiated while holding c->mu.
|
||||
explicit ConnectedSubchannelStateWatcher(Subchannel* c) : subchannel_(c) {
|
||||
|
|
@ -312,38 +311,17 @@ class Subchannel::ConnectedSubchannelStateWatcher
|
|||
GRPC_SUBCHANNEL_WEAK_REF(subchannel_, "state_watcher");
|
||||
GRPC_SUBCHANNEL_WEAK_UNREF(subchannel_, "connecting");
|
||||
// Start watching for connectivity state changes.
|
||||
// Callback uses initial ref to this.
|
||||
GRPC_CLOSURE_INIT(&on_connectivity_changed_, OnConnectivityChanged, this,
|
||||
grpc_schedule_on_exec_ctx);
|
||||
c->connected_subchannel_->NotifyOnStateChange(c->pollset_set_,
|
||||
&pending_connectivity_state_,
|
||||
&on_connectivity_changed_);
|
||||
// Start health check if needed.
|
||||
grpc_connectivity_state health_state = GRPC_CHANNEL_READY;
|
||||
if (c->health_check_service_name_ != nullptr) {
|
||||
health_check_client_ = MakeOrphanable<HealthCheckClient>(
|
||||
c->health_check_service_name_.get(), c->connected_subchannel_,
|
||||
c->pollset_set_, c->channelz_node_);
|
||||
GRPC_CLOSURE_INIT(&on_health_changed_, OnHealthChanged, this,
|
||||
grpc_schedule_on_exec_ctx);
|
||||
Ref().release(); // Ref for health callback tracked manually.
|
||||
health_check_client_->NotifyOnHealthChange(&health_state_,
|
||||
&on_health_changed_);
|
||||
health_state = GRPC_CHANNEL_CONNECTING;
|
||||
}
|
||||
// Report initial state.
|
||||
c->SetConnectivityStateLocked(GRPC_CHANNEL_READY, "subchannel_connected");
|
||||
grpc_connectivity_state_set(&c->state_and_health_tracker_, health_state,
|
||||
"subchannel_connected");
|
||||
}
|
||||
|
||||
~ConnectedSubchannelStateWatcher() {
|
||||
GRPC_SUBCHANNEL_WEAK_UNREF(subchannel_, "state_watcher");
|
||||
}
|
||||
|
||||
// Must be called while holding subchannel_->mu.
|
||||
void Orphan() override { health_check_client_.reset(); }
|
||||
|
||||
private:
|
||||
static void OnConnectivityChanged(void* arg, grpc_error* error) {
|
||||
auto* self = static_cast<ConnectedSubchannelStateWatcher*>(arg);
|
||||
|
|
@ -363,20 +341,10 @@ class Subchannel::ConnectedSubchannelStateWatcher
|
|||
self->pending_connectivity_state_));
|
||||
}
|
||||
c->connected_subchannel_.reset();
|
||||
c->connected_subchannel_watcher_.reset();
|
||||
self->last_connectivity_state_ = GRPC_CHANNEL_TRANSIENT_FAILURE;
|
||||
c->SetConnectivityStateLocked(GRPC_CHANNEL_TRANSIENT_FAILURE,
|
||||
"reflect_child");
|
||||
grpc_connectivity_state_set(&c->state_and_health_tracker_,
|
||||
GRPC_CHANNEL_TRANSIENT_FAILURE,
|
||||
"reflect_child");
|
||||
c->SetConnectivityStateLocked(GRPC_CHANNEL_TRANSIENT_FAILURE);
|
||||
c->backoff_begun_ = false;
|
||||
c->backoff_.Reset();
|
||||
c->MaybeStartConnectingLocked();
|
||||
} else {
|
||||
self->last_connectivity_state_ = GRPC_CHANNEL_SHUTDOWN;
|
||||
}
|
||||
self->health_check_client_.reset();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
|
@ -384,96 +352,246 @@ class Subchannel::ConnectedSubchannelStateWatcher
|
|||
// a callback for READY, because that was the state we started
|
||||
// this watch from. And a connected subchannel should never go
|
||||
// from READY to CONNECTING or IDLE.
|
||||
self->last_connectivity_state_ = self->pending_connectivity_state_;
|
||||
c->SetConnectivityStateLocked(self->pending_connectivity_state_,
|
||||
"reflect_child");
|
||||
if (self->pending_connectivity_state_ != GRPC_CHANNEL_READY) {
|
||||
grpc_connectivity_state_set(&c->state_and_health_tracker_,
|
||||
self->pending_connectivity_state_,
|
||||
"reflect_child");
|
||||
}
|
||||
c->SetConnectivityStateLocked(self->pending_connectivity_state_);
|
||||
c->connected_subchannel_->NotifyOnStateChange(
|
||||
nullptr, &self->pending_connectivity_state_,
|
||||
&self->on_connectivity_changed_);
|
||||
self = nullptr; // So we don't unref below.
|
||||
return; // So we don't delete ourself below.
|
||||
}
|
||||
}
|
||||
}
|
||||
// Don't unref until we've released the lock, because this might
|
||||
// Don't delete until we've released the lock, because this might
|
||||
// cause the subchannel (which contains the lock) to be destroyed.
|
||||
if (self != nullptr) self->Unref();
|
||||
}
|
||||
|
||||
static void OnHealthChanged(void* arg, grpc_error* error) {
|
||||
auto* self = static_cast<ConnectedSubchannelStateWatcher*>(arg);
|
||||
Subchannel* c = self->subchannel_;
|
||||
{
|
||||
MutexLock lock(&c->mu_);
|
||||
if (self->health_state_ != GRPC_CHANNEL_SHUTDOWN &&
|
||||
self->health_check_client_ != nullptr) {
|
||||
if (self->last_connectivity_state_ == GRPC_CHANNEL_READY) {
|
||||
grpc_connectivity_state_set(&c->state_and_health_tracker_,
|
||||
self->health_state_, "health_changed");
|
||||
}
|
||||
self->health_check_client_->NotifyOnHealthChange(
|
||||
&self->health_state_, &self->on_health_changed_);
|
||||
self = nullptr; // So we don't unref below.
|
||||
}
|
||||
}
|
||||
// Don't unref until we've released the lock, because this might
|
||||
// cause the subchannel (which contains the lock) to be destroyed.
|
||||
if (self != nullptr) self->Unref();
|
||||
Delete(self);
|
||||
}
|
||||
|
||||
Subchannel* subchannel_;
|
||||
grpc_closure on_connectivity_changed_;
|
||||
grpc_connectivity_state pending_connectivity_state_ = GRPC_CHANNEL_READY;
|
||||
grpc_connectivity_state last_connectivity_state_ = GRPC_CHANNEL_READY;
|
||||
};
|
||||
|
||||
//
|
||||
// Subchannel::ConnectivityStateWatcherList
|
||||
//
|
||||
|
||||
void Subchannel::ConnectivityStateWatcherList::AddWatcherLocked(
|
||||
UniquePtr<ConnectivityStateWatcher> watcher) {
|
||||
watcher->next_ = head_;
|
||||
head_ = watcher.release();
|
||||
}
|
||||
|
||||
void Subchannel::ConnectivityStateWatcherList::RemoveWatcherLocked(
|
||||
ConnectivityStateWatcher* watcher) {
|
||||
for (ConnectivityStateWatcher** w = &head_; *w != nullptr; w = &(*w)->next_) {
|
||||
if (*w == watcher) {
|
||||
*w = watcher->next_;
|
||||
Delete(watcher);
|
||||
return;
|
||||
}
|
||||
}
|
||||
GPR_UNREACHABLE_CODE(return );
|
||||
}
|
||||
|
||||
void Subchannel::ConnectivityStateWatcherList::NotifyLocked(
|
||||
Subchannel* subchannel, grpc_connectivity_state state) {
|
||||
for (ConnectivityStateWatcher* w = head_; w != nullptr; w = w->next_) {
|
||||
RefCountedPtr<ConnectedSubchannel> connected_subchannel;
|
||||
if (state == GRPC_CHANNEL_READY) {
|
||||
connected_subchannel = subchannel->connected_subchannel_;
|
||||
}
|
||||
// TODO(roth): In principle, it seems wrong to send this notification
|
||||
// to the watcher while holding the subchannel's mutex, since it could
|
||||
// lead to a deadlock if the watcher calls back into the subchannel
|
||||
// before returning back to us. In practice, this doesn't happen,
|
||||
// because the LB policy code that watches subchannels always bounces
|
||||
// the notification into the client_channel control-plane combiner
|
||||
// before processing it. But if we ever have any other callers here,
|
||||
// we will probably need to change this.
|
||||
w->OnConnectivityStateChange(state, std::move(connected_subchannel));
|
||||
}
|
||||
}
|
||||
|
||||
void Subchannel::ConnectivityStateWatcherList::Clear() {
|
||||
while (head_ != nullptr) {
|
||||
ConnectivityStateWatcher* next = head_->next_;
|
||||
Delete(head_);
|
||||
head_ = next;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Subchannel::HealthWatcherMap::HealthWatcher
|
||||
//
|
||||
|
||||
// State needed for tracking the connectivity state with a particular
|
||||
// health check service name.
|
||||
class Subchannel::HealthWatcherMap::HealthWatcher
|
||||
: public InternallyRefCounted<HealthWatcher> {
|
||||
public:
|
||||
HealthWatcher(Subchannel* c, UniquePtr<char> health_check_service_name,
|
||||
grpc_connectivity_state subchannel_state)
|
||||
: subchannel_(c),
|
||||
health_check_service_name_(std::move(health_check_service_name)),
|
||||
state_(subchannel_state == GRPC_CHANNEL_READY ? GRPC_CHANNEL_CONNECTING
|
||||
: subchannel_state) {
|
||||
GRPC_SUBCHANNEL_WEAK_REF(subchannel_, "health_watcher");
|
||||
GRPC_CLOSURE_INIT(&on_health_changed_, OnHealthChanged, this,
|
||||
grpc_schedule_on_exec_ctx);
|
||||
// If the subchannel is already connected, start health checking.
|
||||
if (subchannel_state == GRPC_CHANNEL_READY) StartHealthCheckingLocked();
|
||||
}
|
||||
|
||||
~HealthWatcher() {
|
||||
GRPC_SUBCHANNEL_WEAK_UNREF(subchannel_, "health_watcher");
|
||||
}
|
||||
|
||||
const char* health_check_service_name() const {
|
||||
return health_check_service_name_.get();
|
||||
}
|
||||
|
||||
grpc_connectivity_state state() const { return state_; }
|
||||
|
||||
void AddWatcherLocked(grpc_connectivity_state initial_state,
|
||||
UniquePtr<ConnectivityStateWatcher> watcher) {
|
||||
if (state_ != initial_state) {
|
||||
RefCountedPtr<ConnectedSubchannel> connected_subchannel;
|
||||
if (state_ == GRPC_CHANNEL_READY) {
|
||||
connected_subchannel = subchannel_->connected_subchannel_;
|
||||
}
|
||||
watcher->OnConnectivityStateChange(state_,
|
||||
std::move(connected_subchannel));
|
||||
}
|
||||
watcher_list_.AddWatcherLocked(std::move(watcher));
|
||||
}
|
||||
|
||||
void RemoveWatcherLocked(ConnectivityStateWatcher* watcher) {
|
||||
watcher_list_.RemoveWatcherLocked(watcher);
|
||||
}
|
||||
|
||||
bool HasWatchers() const { return !watcher_list_.empty(); }
|
||||
|
||||
void NotifyLocked(grpc_connectivity_state state) {
|
||||
if (state == GRPC_CHANNEL_READY) {
|
||||
// If we had not already notified for CONNECTING state, do so now.
|
||||
// (We may have missed this earlier, because if the transition
|
||||
// from IDLE to CONNECTING to READY was too quick, the connected
|
||||
// subchannel may not have sent us a notification for CONNECTING.)
|
||||
if (state_ != GRPC_CHANNEL_CONNECTING) {
|
||||
state_ = GRPC_CHANNEL_CONNECTING;
|
||||
watcher_list_.NotifyLocked(subchannel_, state_);
|
||||
}
|
||||
// If we've become connected, start health checking.
|
||||
StartHealthCheckingLocked();
|
||||
} else {
|
||||
state_ = state;
|
||||
watcher_list_.NotifyLocked(subchannel_, state_);
|
||||
// We're not connected, so stop health checking.
|
||||
health_check_client_.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void Orphan() override {
|
||||
watcher_list_.Clear();
|
||||
health_check_client_.reset();
|
||||
Unref();
|
||||
}
|
||||
|
||||
private:
|
||||
void StartHealthCheckingLocked() {
|
||||
GPR_ASSERT(health_check_client_ == nullptr);
|
||||
health_check_client_ = MakeOrphanable<HealthCheckClient>(
|
||||
health_check_service_name_.get(), subchannel_->connected_subchannel_,
|
||||
subchannel_->pollset_set_, subchannel_->channelz_node_);
|
||||
Ref().release(); // Ref for health callback tracked manually.
|
||||
health_check_client_->NotifyOnHealthChange(&state_, &on_health_changed_);
|
||||
}
|
||||
|
||||
static void OnHealthChanged(void* arg, grpc_error* error) {
|
||||
auto* self = static_cast<HealthWatcher*>(arg);
|
||||
Subchannel* c = self->subchannel_;
|
||||
{
|
||||
MutexLock lock(&c->mu_);
|
||||
if (self->state_ != GRPC_CHANNEL_SHUTDOWN &&
|
||||
self->health_check_client_ != nullptr) {
|
||||
self->watcher_list_.NotifyLocked(c, self->state_);
|
||||
// Renew watch.
|
||||
self->health_check_client_->NotifyOnHealthChange(
|
||||
&self->state_, &self->on_health_changed_);
|
||||
return; // So we don't unref below.
|
||||
}
|
||||
}
|
||||
// Don't unref until we've released the lock, because this might
|
||||
// cause the subchannel (which contains the lock) to be destroyed.
|
||||
self->Unref();
|
||||
}
|
||||
|
||||
Subchannel* subchannel_;
|
||||
UniquePtr<char> health_check_service_name_;
|
||||
OrphanablePtr<HealthCheckClient> health_check_client_;
|
||||
grpc_closure on_health_changed_;
|
||||
grpc_connectivity_state health_state_ = GRPC_CHANNEL_CONNECTING;
|
||||
grpc_connectivity_state state_;
|
||||
ConnectivityStateWatcherList watcher_list_;
|
||||
};
|
||||
|
||||
//
|
||||
// Subchannel::ExternalStateWatcher
|
||||
// Subchannel::HealthWatcherMap
|
||||
//
|
||||
|
||||
struct Subchannel::ExternalStateWatcher {
|
||||
ExternalStateWatcher(Subchannel* subchannel, grpc_pollset_set* pollset_set,
|
||||
grpc_closure* notify)
|
||||
: subchannel(subchannel), pollset_set(pollset_set), notify(notify) {
|
||||
GRPC_SUBCHANNEL_WEAK_REF(subchannel, "external_state_watcher+init");
|
||||
GRPC_CLOSURE_INIT(&on_state_changed, OnStateChanged, this,
|
||||
grpc_schedule_on_exec_ctx);
|
||||
void Subchannel::HealthWatcherMap::AddWatcherLocked(
|
||||
Subchannel* subchannel, grpc_connectivity_state initial_state,
|
||||
UniquePtr<char> health_check_service_name,
|
||||
UniquePtr<ConnectivityStateWatcher> watcher) {
|
||||
// If the health check service name is not already present in the map,
|
||||
// add it.
|
||||
auto it = map_.find(health_check_service_name.get());
|
||||
HealthWatcher* health_watcher;
|
||||
if (it == map_.end()) {
|
||||
const char* key = health_check_service_name.get();
|
||||
auto w = MakeOrphanable<HealthWatcher>(
|
||||
subchannel, std::move(health_check_service_name), subchannel->state_);
|
||||
health_watcher = w.get();
|
||||
map_[key] = std::move(w);
|
||||
} else {
|
||||
health_watcher = it->second.get();
|
||||
}
|
||||
// Add the watcher to the entry.
|
||||
health_watcher->AddWatcherLocked(initial_state, std::move(watcher));
|
||||
}
|
||||
|
||||
static void OnStateChanged(void* arg, grpc_error* error) {
|
||||
ExternalStateWatcher* w = static_cast<ExternalStateWatcher*>(arg);
|
||||
grpc_closure* follow_up = w->notify;
|
||||
if (w->pollset_set != nullptr) {
|
||||
grpc_pollset_set_del_pollset_set(w->subchannel->pollset_set_,
|
||||
w->pollset_set);
|
||||
}
|
||||
{
|
||||
MutexLock lock(&w->subchannel->mu_);
|
||||
if (w->subchannel->external_state_watcher_list_ == w) {
|
||||
w->subchannel->external_state_watcher_list_ = w->next;
|
||||
}
|
||||
if (w->next != nullptr) w->next->prev = w->prev;
|
||||
if (w->prev != nullptr) w->prev->next = w->next;
|
||||
}
|
||||
GRPC_SUBCHANNEL_WEAK_UNREF(w->subchannel, "external_state_watcher+done");
|
||||
Delete(w);
|
||||
GRPC_CLOSURE_SCHED(follow_up, GRPC_ERROR_REF(error));
|
||||
void Subchannel::HealthWatcherMap::RemoveWatcherLocked(
|
||||
const char* health_check_service_name, ConnectivityStateWatcher* watcher) {
|
||||
auto it = map_.find(health_check_service_name);
|
||||
GPR_ASSERT(it != map_.end());
|
||||
it->second->RemoveWatcherLocked(watcher);
|
||||
// If we just removed the last watcher for this service name, remove
|
||||
// the map entry.
|
||||
if (!it->second->HasWatchers()) map_.erase(it);
|
||||
}
|
||||
|
||||
void Subchannel::HealthWatcherMap::NotifyLocked(grpc_connectivity_state state) {
|
||||
for (const auto& p : map_) {
|
||||
p.second->NotifyLocked(state);
|
||||
}
|
||||
}
|
||||
|
||||
Subchannel* subchannel;
|
||||
grpc_pollset_set* pollset_set;
|
||||
grpc_closure* notify;
|
||||
grpc_closure on_state_changed;
|
||||
ExternalStateWatcher* next = nullptr;
|
||||
ExternalStateWatcher* prev = nullptr;
|
||||
};
|
||||
grpc_connectivity_state
|
||||
Subchannel::HealthWatcherMap::CheckConnectivityStateLocked(
|
||||
Subchannel* subchannel, const char* health_check_service_name) {
|
||||
auto it = map_.find(health_check_service_name);
|
||||
if (it == map_.end()) {
|
||||
// If the health check service name is not found in the map, we're
|
||||
// not currently doing a health check for that service name. If the
|
||||
// subchannel's state without health checking is READY, report
|
||||
// CONNECTING, since that's what we'd be in as soon as we do start a
|
||||
// watch. Otherwise, report the channel's state without health checking.
|
||||
return subchannel->state_ == GRPC_CHANNEL_READY ? GRPC_CHANNEL_CONNECTING
|
||||
: subchannel->state_;
|
||||
}
|
||||
HealthWatcher* health_watcher = it->second.get();
|
||||
return health_watcher->state();
|
||||
}
|
||||
|
||||
void Subchannel::HealthWatcherMap::ShutdownLocked() { map_.clear(); }
|
||||
|
||||
//
|
||||
// Subchannel
|
||||
|
|
@ -560,13 +678,6 @@ Subchannel::Subchannel(SubchannelKey* key, grpc_connector* connector,
|
|||
if (new_args != nullptr) grpc_channel_args_destroy(new_args);
|
||||
GRPC_CLOSURE_INIT(&on_connecting_finished_, OnConnectingFinished, this,
|
||||
grpc_schedule_on_exec_ctx);
|
||||
grpc_connectivity_state_init(&state_tracker_, GRPC_CHANNEL_IDLE,
|
||||
"subchannel");
|
||||
grpc_connectivity_state_init(&state_and_health_tracker_, GRPC_CHANNEL_IDLE,
|
||||
"subchannel");
|
||||
health_check_service_name_ =
|
||||
UniquePtr<char>(gpr_strdup(grpc_channel_arg_get_string(
|
||||
grpc_channel_args_find(args_, "grpc.temp.health_check"))));
|
||||
const grpc_arg* arg = grpc_channel_args_find(args_, GRPC_ARG_ENABLE_CHANNELZ);
|
||||
const bool channelz_enabled =
|
||||
grpc_channel_arg_get_bool(arg, GRPC_ENABLE_CHANNELZ_DEFAULT);
|
||||
|
|
@ -593,8 +704,6 @@ Subchannel::~Subchannel() {
|
|||
channelz_node_->MarkSubchannelDestroyed();
|
||||
}
|
||||
grpc_channel_args_destroy(args_);
|
||||
grpc_connectivity_state_destroy(&state_tracker_);
|
||||
grpc_connectivity_state_destroy(&state_and_health_tracker_);
|
||||
grpc_connector_unref(connector_);
|
||||
grpc_pollset_set_destroy(pollset_set_);
|
||||
Delete(key_);
|
||||
|
|
@ -698,53 +807,65 @@ const char* Subchannel::GetTargetAddress() {
|
|||
return addr_str;
|
||||
}
|
||||
|
||||
RefCountedPtr<ConnectedSubchannel> Subchannel::connected_subchannel() {
|
||||
MutexLock lock(&mu_);
|
||||
return connected_subchannel_;
|
||||
}
|
||||
|
||||
channelz::SubchannelNode* Subchannel::channelz_node() {
|
||||
return channelz_node_.get();
|
||||
}
|
||||
|
||||
grpc_connectivity_state Subchannel::CheckConnectivity(
|
||||
bool inhibit_health_checking) {
|
||||
grpc_connectivity_state_tracker* tracker =
|
||||
inhibit_health_checking ? &state_tracker_ : &state_and_health_tracker_;
|
||||
grpc_connectivity_state state = grpc_connectivity_state_check(tracker);
|
||||
grpc_connectivity_state Subchannel::CheckConnectivityState(
|
||||
const char* health_check_service_name,
|
||||
RefCountedPtr<ConnectedSubchannel>* connected_subchannel) {
|
||||
MutexLock lock(&mu_);
|
||||
grpc_connectivity_state state;
|
||||
if (health_check_service_name == nullptr) {
|
||||
state = state_;
|
||||
} else {
|
||||
state = health_watcher_map_.CheckConnectivityStateLocked(
|
||||
this, health_check_service_name);
|
||||
}
|
||||
if (connected_subchannel != nullptr && state == GRPC_CHANNEL_READY) {
|
||||
*connected_subchannel = connected_subchannel_;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
void Subchannel::NotifyOnStateChange(grpc_pollset_set* interested_parties,
|
||||
grpc_connectivity_state* state,
|
||||
grpc_closure* notify,
|
||||
bool inhibit_health_checking) {
|
||||
grpc_connectivity_state_tracker* tracker =
|
||||
inhibit_health_checking ? &state_tracker_ : &state_and_health_tracker_;
|
||||
ExternalStateWatcher* w;
|
||||
if (state == nullptr) {
|
||||
MutexLock lock(&mu_);
|
||||
for (w = external_state_watcher_list_; w != nullptr; w = w->next) {
|
||||
if (w->notify == notify) {
|
||||
grpc_connectivity_state_notify_on_state_change(tracker, nullptr,
|
||||
&w->on_state_changed);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
w = New<ExternalStateWatcher>(this, interested_parties, notify);
|
||||
if (interested_parties != nullptr) {
|
||||
grpc_pollset_set_add_pollset_set(pollset_set_, interested_parties);
|
||||
}
|
||||
MutexLock lock(&mu_);
|
||||
if (external_state_watcher_list_ != nullptr) {
|
||||
w->next = external_state_watcher_list_;
|
||||
w->next->prev = w;
|
||||
}
|
||||
external_state_watcher_list_ = w;
|
||||
grpc_connectivity_state_notify_on_state_change(tracker, state,
|
||||
&w->on_state_changed);
|
||||
MaybeStartConnectingLocked();
|
||||
void Subchannel::WatchConnectivityState(
|
||||
grpc_connectivity_state initial_state,
|
||||
UniquePtr<char> health_check_service_name,
|
||||
UniquePtr<ConnectivityStateWatcher> watcher) {
|
||||
MutexLock lock(&mu_);
|
||||
grpc_pollset_set* interested_parties = watcher->interested_parties();
|
||||
if (interested_parties != nullptr) {
|
||||
grpc_pollset_set_add_pollset_set(pollset_set_, interested_parties);
|
||||
}
|
||||
if (health_check_service_name == nullptr) {
|
||||
if (state_ != initial_state) {
|
||||
watcher->OnConnectivityStateChange(state_, connected_subchannel_);
|
||||
}
|
||||
watcher_list_.AddWatcherLocked(std::move(watcher));
|
||||
} else {
|
||||
health_watcher_map_.AddWatcherLocked(this, initial_state,
|
||||
std::move(health_check_service_name),
|
||||
std::move(watcher));
|
||||
}
|
||||
}
|
||||
|
||||
void Subchannel::CancelConnectivityStateWatch(
|
||||
const char* health_check_service_name, ConnectivityStateWatcher* watcher) {
|
||||
MutexLock lock(&mu_);
|
||||
grpc_pollset_set* interested_parties = watcher->interested_parties();
|
||||
if (interested_parties != nullptr) {
|
||||
grpc_pollset_set_del_pollset_set(pollset_set_, interested_parties);
|
||||
}
|
||||
if (health_check_service_name == nullptr) {
|
||||
watcher_list_.RemoveWatcherLocked(watcher);
|
||||
} else {
|
||||
health_watcher_map_.RemoveWatcherLocked(health_check_service_name, watcher);
|
||||
}
|
||||
}
|
||||
|
||||
void Subchannel::AttemptToConnect() {
|
||||
MutexLock lock(&mu_);
|
||||
MaybeStartConnectingLocked();
|
||||
}
|
||||
|
||||
void Subchannel::ResetBackoff() {
|
||||
|
|
@ -818,15 +939,19 @@ const char* SubchannelConnectivityStateChangeString(
|
|||
|
||||
} // namespace
|
||||
|
||||
void Subchannel::SetConnectivityStateLocked(grpc_connectivity_state state,
|
||||
const char* reason) {
|
||||
// Note: Must be called with a state that is different from the current state.
|
||||
void Subchannel::SetConnectivityStateLocked(grpc_connectivity_state state) {
|
||||
state_ = state;
|
||||
if (channelz_node_ != nullptr) {
|
||||
channelz_node_->AddTraceEvent(
|
||||
channelz::ChannelTrace::Severity::Info,
|
||||
grpc_slice_from_static_string(
|
||||
SubchannelConnectivityStateChangeString(state)));
|
||||
}
|
||||
grpc_connectivity_state_set(&state_tracker_, state, reason);
|
||||
// Notify non-health watchers.
|
||||
watcher_list_.NotifyLocked(this, state);
|
||||
// Notify health watchers.
|
||||
health_watcher_map_.NotifyLocked(state);
|
||||
}
|
||||
|
||||
void Subchannel::MaybeStartConnectingLocked() {
|
||||
|
|
@ -842,11 +967,6 @@ void Subchannel::MaybeStartConnectingLocked() {
|
|||
// Already connected: don't restart.
|
||||
return;
|
||||
}
|
||||
if (!grpc_connectivity_state_has_watchers(&state_tracker_) &&
|
||||
!grpc_connectivity_state_has_watchers(&state_and_health_tracker_)) {
|
||||
// Nobody is interested in connecting: so don't just yet.
|
||||
return;
|
||||
}
|
||||
connecting_ = true;
|
||||
GRPC_SUBCHANNEL_WEAK_REF(this, "connecting");
|
||||
if (!backoff_begun_) {
|
||||
|
|
@ -903,9 +1023,7 @@ void Subchannel::ContinueConnectingLocked() {
|
|||
next_attempt_deadline_ = backoff_.NextAttemptTime();
|
||||
args.deadline = std::max(next_attempt_deadline_, min_deadline);
|
||||
args.channel_args = args_;
|
||||
SetConnectivityStateLocked(GRPC_CHANNEL_CONNECTING, "connecting");
|
||||
grpc_connectivity_state_set(&state_and_health_tracker_,
|
||||
GRPC_CHANNEL_CONNECTING, "connecting");
|
||||
SetConnectivityStateLocked(GRPC_CHANNEL_CONNECTING);
|
||||
grpc_connector_connect(connector_, &args, &connecting_result_,
|
||||
&on_connecting_finished_);
|
||||
}
|
||||
|
|
@ -924,12 +1042,7 @@ void Subchannel::OnConnectingFinished(void* arg, grpc_error* error) {
|
|||
GRPC_SUBCHANNEL_WEAK_UNREF(c, "connecting");
|
||||
} else {
|
||||
gpr_log(GPR_INFO, "Connect failed: %s", grpc_error_string(error));
|
||||
c->SetConnectivityStateLocked(GRPC_CHANNEL_TRANSIENT_FAILURE,
|
||||
"connect_failed");
|
||||
grpc_connectivity_state_set(&c->state_and_health_tracker_,
|
||||
GRPC_CHANNEL_TRANSIENT_FAILURE,
|
||||
"connect_failed");
|
||||
c->MaybeStartConnectingLocked();
|
||||
c->SetConnectivityStateLocked(GRPC_CHANNEL_TRANSIENT_FAILURE);
|
||||
GRPC_SUBCHANNEL_WEAK_UNREF(c, "connecting");
|
||||
}
|
||||
}
|
||||
|
|
@ -982,8 +1095,9 @@ bool Subchannel::PublishTransportLocked() {
|
|||
gpr_log(GPR_INFO, "New connected subchannel at %p for subchannel %p",
|
||||
connected_subchannel_.get(), this);
|
||||
// Instantiate state watcher. Will clean itself up.
|
||||
connected_subchannel_watcher_ =
|
||||
MakeOrphanable<ConnectedSubchannelStateWatcher>(this);
|
||||
New<ConnectedSubchannelStateWatcher>(this);
|
||||
// Report initial state.
|
||||
SetConnectivityStateLocked(GRPC_CHANNEL_READY);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1000,7 +1114,7 @@ void Subchannel::Disconnect() {
|
|||
grpc_connector_shutdown(connector_, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
||||
"Subchannel disconnected"));
|
||||
connected_subchannel_.reset();
|
||||
connected_subchannel_watcher_.reset();
|
||||
health_watcher_map_.ShutdownLocked();
|
||||
}
|
||||
|
||||
gpr_atm Subchannel::RefMutate(
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "src/core/lib/backoff/backoff.h"
|
||||
#include "src/core/lib/channel/channel_stack.h"
|
||||
#include "src/core/lib/gprpp/arena.h"
|
||||
#include "src/core/lib/gprpp/map.h"
|
||||
#include "src/core/lib/gprpp/ref_counted.h"
|
||||
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
||||
#include "src/core/lib/gprpp/sync.h"
|
||||
|
|
@ -77,7 +78,7 @@ class ConnectedSubchannel : public RefCounted<ConnectedSubchannel> {
|
|||
grpc_millis deadline;
|
||||
Arena* arena;
|
||||
grpc_call_context_element* context;
|
||||
grpc_core::CallCombiner* call_combiner;
|
||||
CallCombiner* call_combiner;
|
||||
size_t parent_data_size;
|
||||
};
|
||||
|
||||
|
|
@ -175,7 +176,38 @@ class SubchannelCall {
|
|||
// A subchannel that knows how to connect to exactly one target address. It
|
||||
// provides a target for load balancing.
|
||||
class Subchannel {
|
||||
private:
|
||||
class ConnectivityStateWatcherList; // Forward declaration.
|
||||
|
||||
public:
|
||||
class ConnectivityStateWatcher {
|
||||
public:
|
||||
virtual ~ConnectivityStateWatcher() = default;
|
||||
|
||||
// Will be invoked whenever the subchannel's connectivity state
|
||||
// changes. There will be only one invocation of this method on a
|
||||
// given watcher instance at any given time.
|
||||
//
|
||||
// When the state changes to READY, connected_subchannel will
|
||||
// contain a ref to the connected subchannel. When it changes from
|
||||
// READY to some other state, the implementation must release its
|
||||
// ref to the connected subchannel.
|
||||
virtual void OnConnectivityStateChange(
|
||||
grpc_connectivity_state new_state,
|
||||
RefCountedPtr<ConnectedSubchannel> connected_subchannel) // NOLINT
|
||||
GRPC_ABSTRACT;
|
||||
|
||||
virtual grpc_pollset_set* interested_parties() GRPC_ABSTRACT;
|
||||
|
||||
GRPC_ABSTRACT_BASE_CLASS
|
||||
|
||||
private:
|
||||
// For access to next_.
|
||||
friend class Subchannel::ConnectivityStateWatcherList;
|
||||
|
||||
ConnectivityStateWatcher* next_ = nullptr;
|
||||
};
|
||||
|
||||
// The ctor and dtor are not intended to use directly.
|
||||
Subchannel(SubchannelKey* key, grpc_connector* connector,
|
||||
const grpc_channel_args* args);
|
||||
|
|
@ -201,20 +233,36 @@ class Subchannel {
|
|||
// Caller doesn't take ownership.
|
||||
const char* GetTargetAddress();
|
||||
|
||||
// Gets the connected subchannel - or nullptr if not connected (which may
|
||||
// happen before it initially connects or during transient failures).
|
||||
RefCountedPtr<ConnectedSubchannel> connected_subchannel();
|
||||
|
||||
channelz::SubchannelNode* channelz_node();
|
||||
|
||||
// Polls the current connectivity state of the subchannel.
|
||||
grpc_connectivity_state CheckConnectivity(bool inhibit_health_checking);
|
||||
// Returns the current connectivity state of the subchannel.
|
||||
// If health_check_service_name is non-null, the returned connectivity
|
||||
// state will be based on the state reported by the backend for that
|
||||
// service name.
|
||||
// If the return value is GRPC_CHANNEL_READY, also sets *connected_subchannel.
|
||||
grpc_connectivity_state CheckConnectivityState(
|
||||
const char* health_check_service_name,
|
||||
RefCountedPtr<ConnectedSubchannel>* connected_subchannel);
|
||||
|
||||
// When the connectivity state of the subchannel changes from \a *state,
|
||||
// invokes \a notify and updates \a *state with the new state.
|
||||
void NotifyOnStateChange(grpc_pollset_set* interested_parties,
|
||||
grpc_connectivity_state* state, grpc_closure* notify,
|
||||
bool inhibit_health_checking);
|
||||
// Starts watching the subchannel's connectivity state.
|
||||
// The first callback to the watcher will be delivered when the
|
||||
// subchannel's connectivity state becomes a value other than
|
||||
// initial_state, which may happen immediately.
|
||||
// Subsequent callbacks will be delivered as the subchannel's state
|
||||
// changes.
|
||||
// The watcher will be destroyed either when the subchannel is
|
||||
// destroyed or when CancelConnectivityStateWatch() is called.
|
||||
void WatchConnectivityState(grpc_connectivity_state initial_state,
|
||||
UniquePtr<char> health_check_service_name,
|
||||
UniquePtr<ConnectivityStateWatcher> watcher);
|
||||
|
||||
// Cancels a connectivity state watch.
|
||||
// If the watcher has already been destroyed, this is a no-op.
|
||||
void CancelConnectivityStateWatch(const char* health_check_service_name,
|
||||
ConnectivityStateWatcher* watcher);
|
||||
|
||||
// Attempt to connect to the backend. Has no effect if already connected.
|
||||
void AttemptToConnect();
|
||||
|
||||
// Resets the connection backoff of the subchannel.
|
||||
// TODO(roth): Move connection backoff out of subchannels and up into LB
|
||||
|
|
@ -236,12 +284,62 @@ class Subchannel {
|
|||
grpc_resolved_address* addr);
|
||||
|
||||
private:
|
||||
struct ExternalStateWatcher;
|
||||
// A linked list of ConnectivityStateWatchers that are monitoring the
|
||||
// subchannel's state.
|
||||
class ConnectivityStateWatcherList {
|
||||
public:
|
||||
~ConnectivityStateWatcherList() { Clear(); }
|
||||
|
||||
void AddWatcherLocked(UniquePtr<ConnectivityStateWatcher> watcher);
|
||||
void RemoveWatcherLocked(ConnectivityStateWatcher* watcher);
|
||||
|
||||
// Notifies all watchers in the list about a change to state.
|
||||
void NotifyLocked(Subchannel* subchannel, grpc_connectivity_state state);
|
||||
|
||||
void Clear();
|
||||
|
||||
bool empty() const { return head_ == nullptr; }
|
||||
|
||||
private:
|
||||
ConnectivityStateWatcher* head_ = nullptr;
|
||||
};
|
||||
|
||||
// A map that tracks ConnectivityStateWatchers using a particular health
|
||||
// check service name.
|
||||
//
|
||||
// There is one entry in the map for each health check service name.
|
||||
// Entries exist only as long as there are watchers using the
|
||||
// corresponding service name.
|
||||
//
|
||||
// A health check client is maintained only while the subchannel is in
|
||||
// state READY.
|
||||
class HealthWatcherMap {
|
||||
public:
|
||||
void AddWatcherLocked(Subchannel* subchannel,
|
||||
grpc_connectivity_state initial_state,
|
||||
UniquePtr<char> health_check_service_name,
|
||||
UniquePtr<ConnectivityStateWatcher> watcher);
|
||||
void RemoveWatcherLocked(const char* health_check_service_name,
|
||||
ConnectivityStateWatcher* watcher);
|
||||
|
||||
// Notifies the watcher when the subchannel's state changes.
|
||||
void NotifyLocked(grpc_connectivity_state state);
|
||||
|
||||
grpc_connectivity_state CheckConnectivityStateLocked(
|
||||
Subchannel* subchannel, const char* health_check_service_name);
|
||||
|
||||
void ShutdownLocked();
|
||||
|
||||
private:
|
||||
class HealthWatcher;
|
||||
|
||||
Map<const char*, OrphanablePtr<HealthWatcher>, StringLess> map_;
|
||||
};
|
||||
|
||||
class ConnectedSubchannelStateWatcher;
|
||||
|
||||
// Sets the subchannel's connectivity state to \a state.
|
||||
void SetConnectivityStateLocked(grpc_connectivity_state state,
|
||||
const char* reason);
|
||||
void SetConnectivityStateLocked(grpc_connectivity_state state);
|
||||
|
||||
// Methods for connection.
|
||||
void MaybeStartConnectingLocked();
|
||||
|
|
@ -279,15 +377,15 @@ class Subchannel {
|
|||
grpc_closure on_connecting_finished_;
|
||||
// Active connection, or null.
|
||||
RefCountedPtr<ConnectedSubchannel> connected_subchannel_;
|
||||
OrphanablePtr<ConnectedSubchannelStateWatcher> connected_subchannel_watcher_;
|
||||
bool connecting_ = false;
|
||||
bool disconnected_ = false;
|
||||
|
||||
// Connectivity state tracking.
|
||||
grpc_connectivity_state_tracker state_tracker_;
|
||||
grpc_connectivity_state_tracker state_and_health_tracker_;
|
||||
UniquePtr<char> health_check_service_name_;
|
||||
ExternalStateWatcher* external_state_watcher_list_ = nullptr;
|
||||
grpc_connectivity_state state_ = GRPC_CHANNEL_IDLE;
|
||||
// The list of watchers without a health check service name.
|
||||
ConnectivityStateWatcherList watcher_list_;
|
||||
// The map of watchers with health check service names.
|
||||
HealthWatcherMap health_watcher_map_;
|
||||
|
||||
// Backoff state.
|
||||
BackOff backoff_;
|
||||
|
|
|
|||
|
|
@ -23,11 +23,8 @@
|
|||
#include "src/core/lib/gprpp/global_config.h"
|
||||
#include "src/core/lib/transport/metadata.h"
|
||||
|
||||
GPR_GLOBAL_CONFIG_DEFINE_BOOL(
|
||||
grpc_experimental_disable_flow_control, false,
|
||||
"If set, flow control will be effectively disabled. Max out all values and "
|
||||
"assume the remote peer does the same. Thus we can ignore any flow control "
|
||||
"bookkeeping, error checking, and decision making");
|
||||
GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_experimental_disable_flow_control, false,
|
||||
"Disable flow control");
|
||||
|
||||
void grpc_chttp2_plugin_init(void) {
|
||||
g_flow_control_enabled =
|
||||
|
|
|
|||
|
|
@ -1720,7 +1720,7 @@ static void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
|
|||
}
|
||||
|
||||
static void cancel_pings(grpc_chttp2_transport* t, grpc_error* error) {
|
||||
/* callback remaining pings: they're not allowed to call into the transpot,
|
||||
/* callback remaining pings: they're not allowed to call into the transport,
|
||||
and maybe they hold resources that need to be freed */
|
||||
grpc_chttp2_ping_queue* pq = &t->ping_queue;
|
||||
GPR_ASSERT(error != GRPC_ERROR_NONE);
|
||||
|
|
|
|||
|
|
@ -104,23 +104,22 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
uint8_t* end = nullptr;
|
||||
uint8_t* cur = nullptr;
|
||||
|
||||
grpc_slice slice = grpc_slice_buffer_take_first(slices);
|
||||
|
||||
beg = GRPC_SLICE_START_PTR(slice);
|
||||
end = GRPC_SLICE_END_PTR(slice);
|
||||
grpc_slice* slice = grpc_slice_buffer_peek_first(slices);
|
||||
beg = GRPC_SLICE_START_PTR(*slice);
|
||||
end = GRPC_SLICE_END_PTR(*slice);
|
||||
cur = beg;
|
||||
uint32_t message_flags;
|
||||
char* msg;
|
||||
|
||||
if (cur == end) {
|
||||
grpc_slice_unref_internal(slice);
|
||||
grpc_slice_buffer_remove_first(slices);
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (p->state) {
|
||||
case GRPC_CHTTP2_DATA_ERROR:
|
||||
p->state = GRPC_CHTTP2_DATA_ERROR;
|
||||
grpc_slice_unref_internal(slice);
|
||||
grpc_slice_buffer_remove_first(slices);
|
||||
return GRPC_ERROR_REF(p->error);
|
||||
case GRPC_CHTTP2_DATA_FH_0:
|
||||
s->stats.incoming.framing_bytes++;
|
||||
|
|
@ -138,19 +137,19 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
p->error = grpc_error_set_int(p->error, GRPC_ERROR_INT_STREAM_ID,
|
||||
static_cast<intptr_t>(s->id));
|
||||
gpr_free(msg);
|
||||
msg = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
|
||||
msg = grpc_dump_slice(*slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
|
||||
p->error = grpc_error_set_str(p->error, GRPC_ERROR_STR_RAW_BYTES,
|
||||
grpc_slice_from_copied_string(msg));
|
||||
gpr_free(msg);
|
||||
p->error =
|
||||
grpc_error_set_int(p->error, GRPC_ERROR_INT_OFFSET, cur - beg);
|
||||
p->state = GRPC_CHTTP2_DATA_ERROR;
|
||||
grpc_slice_unref_internal(slice);
|
||||
grpc_slice_buffer_remove_first(slices);
|
||||
return GRPC_ERROR_REF(p->error);
|
||||
}
|
||||
if (++cur == end) {
|
||||
p->state = GRPC_CHTTP2_DATA_FH_1;
|
||||
grpc_slice_unref_internal(slice);
|
||||
grpc_slice_buffer_remove_first(slices);
|
||||
continue;
|
||||
}
|
||||
/* fallthrough */
|
||||
|
|
@ -159,7 +158,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
p->frame_size = (static_cast<uint32_t>(*cur)) << 24;
|
||||
if (++cur == end) {
|
||||
p->state = GRPC_CHTTP2_DATA_FH_2;
|
||||
grpc_slice_unref_internal(slice);
|
||||
grpc_slice_buffer_remove_first(slices);
|
||||
continue;
|
||||
}
|
||||
/* fallthrough */
|
||||
|
|
@ -168,7 +167,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
p->frame_size |= (static_cast<uint32_t>(*cur)) << 16;
|
||||
if (++cur == end) {
|
||||
p->state = GRPC_CHTTP2_DATA_FH_3;
|
||||
grpc_slice_unref_internal(slice);
|
||||
grpc_slice_buffer_remove_first(slices);
|
||||
continue;
|
||||
}
|
||||
/* fallthrough */
|
||||
|
|
@ -177,7 +176,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
p->frame_size |= (static_cast<uint32_t>(*cur)) << 8;
|
||||
if (++cur == end) {
|
||||
p->state = GRPC_CHTTP2_DATA_FH_4;
|
||||
grpc_slice_unref_internal(slice);
|
||||
grpc_slice_buffer_remove_first(slices);
|
||||
continue;
|
||||
}
|
||||
/* fallthrough */
|
||||
|
|
@ -204,19 +203,18 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
p->state = GRPC_CHTTP2_DATA_FH_0;
|
||||
}
|
||||
s->pending_byte_stream = true;
|
||||
|
||||
if (cur != end) {
|
||||
grpc_slice_buffer_undo_take_first(
|
||||
slices, grpc_slice_sub(slice, static_cast<size_t>(cur - beg),
|
||||
static_cast<size_t>(end - beg)));
|
||||
grpc_slice_buffer_sub_first(slices, static_cast<size_t>(cur - beg),
|
||||
static_cast<size_t>(end - beg));
|
||||
} else {
|
||||
grpc_slice_buffer_remove_first(slices);
|
||||
}
|
||||
grpc_slice_unref_internal(slice);
|
||||
return GRPC_ERROR_NONE;
|
||||
case GRPC_CHTTP2_DATA_FRAME: {
|
||||
GPR_ASSERT(p->parsing_frame != nullptr);
|
||||
GPR_ASSERT(slice_out != nullptr);
|
||||
if (cur == end) {
|
||||
grpc_slice_unref_internal(slice);
|
||||
grpc_slice_buffer_remove_first(slices);
|
||||
continue;
|
||||
}
|
||||
uint32_t remaining = static_cast<uint32_t>(end - cur);
|
||||
|
|
@ -224,32 +222,32 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
s->stats.incoming.data_bytes += remaining;
|
||||
if (GRPC_ERROR_NONE !=
|
||||
(error = p->parsing_frame->Push(
|
||||
grpc_slice_sub(slice, static_cast<size_t>(cur - beg),
|
||||
grpc_slice_sub(*slice, static_cast<size_t>(cur - beg),
|
||||
static_cast<size_t>(end - beg)),
|
||||
slice_out))) {
|
||||
grpc_slice_unref_internal(slice);
|
||||
grpc_slice_buffer_remove_first(slices);
|
||||
return error;
|
||||
}
|
||||
if (GRPC_ERROR_NONE !=
|
||||
(error = p->parsing_frame->Finished(GRPC_ERROR_NONE, true))) {
|
||||
grpc_slice_unref_internal(slice);
|
||||
grpc_slice_buffer_remove_first(slices);
|
||||
return error;
|
||||
}
|
||||
p->parsing_frame = nullptr;
|
||||
p->state = GRPC_CHTTP2_DATA_FH_0;
|
||||
grpc_slice_unref_internal(slice);
|
||||
grpc_slice_buffer_remove_first(slices);
|
||||
return GRPC_ERROR_NONE;
|
||||
} else if (remaining < p->frame_size) {
|
||||
s->stats.incoming.data_bytes += remaining;
|
||||
if (GRPC_ERROR_NONE !=
|
||||
(error = p->parsing_frame->Push(
|
||||
grpc_slice_sub(slice, static_cast<size_t>(cur - beg),
|
||||
grpc_slice_sub(*slice, static_cast<size_t>(cur - beg),
|
||||
static_cast<size_t>(end - beg)),
|
||||
slice_out))) {
|
||||
return error;
|
||||
}
|
||||
p->frame_size -= remaining;
|
||||
grpc_slice_unref_internal(slice);
|
||||
grpc_slice_buffer_remove_first(slices);
|
||||
return GRPC_ERROR_NONE;
|
||||
} else {
|
||||
GPR_ASSERT(remaining > p->frame_size);
|
||||
|
|
@ -257,30 +255,27 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
if (GRPC_ERROR_NONE !=
|
||||
p->parsing_frame->Push(
|
||||
grpc_slice_sub(
|
||||
slice, static_cast<size_t>(cur - beg),
|
||||
*slice, static_cast<size_t>(cur - beg),
|
||||
static_cast<size_t>(cur + p->frame_size - beg)),
|
||||
slice_out)) {
|
||||
grpc_slice_unref_internal(slice);
|
||||
grpc_slice_buffer_remove_first(slices);
|
||||
return error;
|
||||
}
|
||||
if (GRPC_ERROR_NONE !=
|
||||
(error = p->parsing_frame->Finished(GRPC_ERROR_NONE, true))) {
|
||||
grpc_slice_unref_internal(slice);
|
||||
grpc_slice_buffer_remove_first(slices);
|
||||
return error;
|
||||
}
|
||||
p->parsing_frame = nullptr;
|
||||
p->state = GRPC_CHTTP2_DATA_FH_0;
|
||||
cur += p->frame_size;
|
||||
grpc_slice_buffer_undo_take_first(
|
||||
slices, grpc_slice_sub(slice, static_cast<size_t>(cur - beg),
|
||||
static_cast<size_t>(end - beg)));
|
||||
grpc_slice_unref_internal(slice);
|
||||
grpc_slice_buffer_sub_first(slices, static_cast<size_t>(cur - beg),
|
||||
static_cast<size_t>(end - beg));
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -225,14 +225,14 @@ class Chttp2IncomingByteStream : public ByteStream {
|
|||
// TODO(roth): When I converted this class to C++, I wanted to make it
|
||||
// inherit from RefCounted or InternallyRefCounted instead of continuing
|
||||
// to use its own custom ref-counting code. However, that would require
|
||||
// using multiple inheritence, which sucks in general. And to make matters
|
||||
// using multiple inheritance, which sucks in general. And to make matters
|
||||
// worse, it causes problems with our New<> and Delete<> wrappers.
|
||||
// Specifically, unless RefCounted is first in the list of parent classes,
|
||||
// it will see a different value of the address of the object than the one
|
||||
// we actually allocated, in which case gpr_free() will be called on a
|
||||
// different address than the one we got from gpr_malloc(), thus causing a
|
||||
// crash. Given the fragility of depending on that, as well as a desire to
|
||||
// avoid multiple inheritence in general, I've decided to leave this
|
||||
// avoid multiple inheritance in general, I've decided to leave this
|
||||
// alone for now. We can revisit this once we're able to link against
|
||||
// libc++, at which point we can eliminate New<> and Delete<> and
|
||||
// switch to std::shared_ptr<>.
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "src/core/lib/profiling/timers.h"
|
||||
#include "src/core/lib/slice/slice_string_helpers.h"
|
||||
#include "src/core/lib/slice/slice_utils.h"
|
||||
#include "src/core/lib/transport/http2_errors.h"
|
||||
#include "src/core/lib/transport/static_metadata.h"
|
||||
#include "src/core/lib/transport/status_conversion.h"
|
||||
|
|
@ -410,53 +411,42 @@ static void on_initial_header(void* tp, grpc_mdelem md) {
|
|||
gpr_free(value);
|
||||
}
|
||||
|
||||
if (GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC) {
|
||||
// We don't use grpc_mdelem_eq here to avoid executing additional
|
||||
// instructions. The reasoning is if the payload is not equal, we already
|
||||
// know that the metadata elements are not equal because the md is
|
||||
// confirmed to be static. If we had used grpc_mdelem_eq here, then if the
|
||||
// payloads are not equal, grpc_mdelem_eq executes more instructions to
|
||||
// determine if they're equal or not.
|
||||
if (md.payload == GRPC_MDELEM_GRPC_STATUS_1.payload ||
|
||||
md.payload == GRPC_MDELEM_GRPC_STATUS_2.payload) {
|
||||
s->seen_error = true;
|
||||
}
|
||||
} else {
|
||||
if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_STATUS) &&
|
||||
!grpc_mdelem_eq(md, GRPC_MDELEM_GRPC_STATUS_0)) {
|
||||
/* TODO(ctiller): check for a status like " 0" */
|
||||
s->seen_error = true;
|
||||
}
|
||||
|
||||
if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_TIMEOUT)) {
|
||||
grpc_millis* cached_timeout = static_cast<grpc_millis*>(
|
||||
grpc_mdelem_get_user_data(md, free_timeout));
|
||||
grpc_millis timeout;
|
||||
if (cached_timeout != nullptr) {
|
||||
timeout = *cached_timeout;
|
||||
} else {
|
||||
if (GPR_UNLIKELY(
|
||||
!grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout))) {
|
||||
char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
|
||||
gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val);
|
||||
gpr_free(val);
|
||||
timeout = GRPC_MILLIS_INF_FUTURE;
|
||||
}
|
||||
if (GRPC_MDELEM_IS_INTERNED(md)) {
|
||||
/* store the result */
|
||||
cached_timeout =
|
||||
static_cast<grpc_millis*>(gpr_malloc(sizeof(grpc_millis)));
|
||||
*cached_timeout = timeout;
|
||||
grpc_mdelem_set_user_data(md, free_timeout, cached_timeout);
|
||||
}
|
||||
// If md.payload == GRPC_MDELEM_GRPC_STATUS_1 or GRPC_MDELEM_GRPC_STATUS_2,
|
||||
// then we have seen an error. In fact, if it is a GRPC_STATUS and it's
|
||||
// not equal to GRPC_MDELEM_GRPC_STATUS_0, then we have seen an error.
|
||||
if (grpc_slice_eq_static_interned(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_STATUS) &&
|
||||
!grpc_mdelem_static_value_eq(md, GRPC_MDELEM_GRPC_STATUS_0)) {
|
||||
/* TODO(ctiller): check for a status like " 0" */
|
||||
s->seen_error = true;
|
||||
} else if (grpc_slice_eq_static_interned(GRPC_MDKEY(md),
|
||||
GRPC_MDSTR_GRPC_TIMEOUT)) {
|
||||
grpc_millis* cached_timeout =
|
||||
static_cast<grpc_millis*>(grpc_mdelem_get_user_data(md, free_timeout));
|
||||
grpc_millis timeout;
|
||||
if (cached_timeout != nullptr) {
|
||||
timeout = *cached_timeout;
|
||||
} else {
|
||||
if (GPR_UNLIKELY(
|
||||
!grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout))) {
|
||||
char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
|
||||
gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val);
|
||||
gpr_free(val);
|
||||
timeout = GRPC_MILLIS_INF_FUTURE;
|
||||
}
|
||||
if (timeout != GRPC_MILLIS_INF_FUTURE) {
|
||||
grpc_chttp2_incoming_metadata_buffer_set_deadline(
|
||||
&s->metadata_buffer[0], grpc_core::ExecCtx::Get()->Now() + timeout);
|
||||
if (GRPC_MDELEM_IS_INTERNED(md)) {
|
||||
/* store the result */
|
||||
cached_timeout =
|
||||
static_cast<grpc_millis*>(gpr_malloc(sizeof(grpc_millis)));
|
||||
*cached_timeout = timeout;
|
||||
grpc_mdelem_set_user_data(md, free_timeout, cached_timeout);
|
||||
}
|
||||
GRPC_MDELEM_UNREF(md);
|
||||
return;
|
||||
}
|
||||
if (timeout != GRPC_MILLIS_INF_FUTURE) {
|
||||
grpc_chttp2_incoming_metadata_buffer_set_deadline(
|
||||
&s->metadata_buffer[0], grpc_core::ExecCtx::Get()->Now() + timeout);
|
||||
}
|
||||
GRPC_MDELEM_UNREF(md);
|
||||
return;
|
||||
}
|
||||
|
||||
const size_t new_size = s->metadata_buffer[0].size + GRPC_MDELEM_LENGTH(md);
|
||||
|
|
@ -506,19 +496,11 @@ static void on_trailing_header(void* tp, grpc_mdelem md) {
|
|||
gpr_free(value);
|
||||
}
|
||||
|
||||
if (GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC) {
|
||||
// We don't use grpc_mdelem_eq here to avoid executing additional
|
||||
// instructions. The reasoning is if the payload is not equal, we already
|
||||
// know that the metadata elements are not equal because the md is
|
||||
// confirmed to be static. If we had used grpc_mdelem_eq here, then if the
|
||||
// payloads are not equal, grpc_mdelem_eq executes more instructions to
|
||||
// determine if they're equal or not.
|
||||
if (md.payload == GRPC_MDELEM_GRPC_STATUS_1.payload ||
|
||||
md.payload == GRPC_MDELEM_GRPC_STATUS_2.payload) {
|
||||
s->seen_error = true;
|
||||
}
|
||||
} else if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_STATUS) &&
|
||||
!grpc_mdelem_eq(md, GRPC_MDELEM_GRPC_STATUS_0)) {
|
||||
// If md.payload == GRPC_MDELEM_GRPC_STATUS_1 or GRPC_MDELEM_GRPC_STATUS_2,
|
||||
// then we have seen an error. In fact, if it is a GRPC_STATUS and it's
|
||||
// not equal to GRPC_MDELEM_GRPC_STATUS_0, then we have seen an error.
|
||||
if (grpc_slice_eq_static_interned(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_STATUS) &&
|
||||
!grpc_mdelem_static_value_eq(md, GRPC_MDELEM_GRPC_STATUS_0)) {
|
||||
/* TODO(ctiller): check for a status like " 0" */
|
||||
s->seen_error = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -753,15 +753,16 @@ static void convert_metadata_to_cronet_headers(
|
|||
} else {
|
||||
value = grpc_slice_to_c_string(GRPC_MDVALUE(mdelem));
|
||||
}
|
||||
if (grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_SCHEME) ||
|
||||
grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_AUTHORITY)) {
|
||||
if (grpc_slice_eq_static_interned(GRPC_MDKEY(mdelem), GRPC_MDSTR_SCHEME) ||
|
||||
grpc_slice_eq_static_interned(GRPC_MDKEY(mdelem),
|
||||
GRPC_MDSTR_AUTHORITY)) {
|
||||
/* Cronet populates these fields on its own */
|
||||
gpr_free(key);
|
||||
gpr_free(value);
|
||||
continue;
|
||||
}
|
||||
if (grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_METHOD)) {
|
||||
if (grpc_slice_eq(GRPC_MDVALUE(mdelem), GRPC_MDSTR_PUT)) {
|
||||
if (grpc_slice_eq_static_interned(GRPC_MDKEY(mdelem), GRPC_MDSTR_METHOD)) {
|
||||
if (grpc_slice_eq_static_interned(GRPC_MDVALUE(mdelem), GRPC_MDSTR_PUT)) {
|
||||
*method = "PUT";
|
||||
} else {
|
||||
/* POST method in default*/
|
||||
|
|
@ -771,7 +772,7 @@ static void convert_metadata_to_cronet_headers(
|
|||
gpr_free(value);
|
||||
continue;
|
||||
}
|
||||
if (grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_PATH)) {
|
||||
if (grpc_slice_eq_static_interned(GRPC_MDKEY(mdelem), GRPC_MDSTR_PATH)) {
|
||||
/* Create URL by appending :path value to the hostname */
|
||||
gpr_asprintf(pp_url, "https://%s%s", host, value);
|
||||
gpr_free(key);
|
||||
|
|
@ -803,7 +804,8 @@ static void parse_grpc_header(const uint8_t* data, int* length,
|
|||
|
||||
static bool header_has_authority(grpc_linked_mdelem* head) {
|
||||
while (head != nullptr) {
|
||||
if (grpc_slice_eq(GRPC_MDKEY(head->md), GRPC_MDSTR_AUTHORITY)) {
|
||||
if (grpc_slice_eq_static_interned(GRPC_MDKEY(head->md),
|
||||
GRPC_MDSTR_AUTHORITY)) {
|
||||
return true;
|
||||
}
|
||||
head = head->next;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "src/core/lib/compression/algorithm_metadata.h"
|
||||
#include "src/core/lib/compression/compression_internal.h"
|
||||
#include "src/core/lib/gpr/useful.h"
|
||||
#include "src/core/lib/slice/slice_utils.h"
|
||||
#include "src/core/lib/surface/api_trace.h"
|
||||
#include "src/core/lib/transport/static_metadata.h"
|
||||
|
||||
|
|
@ -42,16 +43,17 @@ int grpc_compression_algorithm_is_stream(grpc_compression_algorithm algorithm) {
|
|||
|
||||
int grpc_compression_algorithm_parse(grpc_slice name,
|
||||
grpc_compression_algorithm* algorithm) {
|
||||
if (grpc_slice_eq(name, GRPC_MDSTR_IDENTITY)) {
|
||||
if (grpc_slice_eq_static_interned(name, GRPC_MDSTR_IDENTITY)) {
|
||||
*algorithm = GRPC_COMPRESS_NONE;
|
||||
return 1;
|
||||
} else if (grpc_slice_eq(name, GRPC_MDSTR_DEFLATE)) {
|
||||
} else if (grpc_slice_eq_static_interned(name, GRPC_MDSTR_DEFLATE)) {
|
||||
*algorithm = GRPC_COMPRESS_DEFLATE;
|
||||
return 1;
|
||||
} else if (grpc_slice_eq(name, GRPC_MDSTR_GZIP)) {
|
||||
} else if (grpc_slice_eq_static_interned(name, GRPC_MDSTR_GZIP)) {
|
||||
*algorithm = GRPC_COMPRESS_GZIP;
|
||||
return 1;
|
||||
} else if (grpc_slice_eq(name, GRPC_MDSTR_STREAM_SLASH_GZIP)) {
|
||||
} else if (grpc_slice_eq_static_interned(name,
|
||||
GRPC_MDSTR_STREAM_SLASH_GZIP)) {
|
||||
*algorithm = GRPC_COMPRESS_STREAM_GZIP;
|
||||
return 1;
|
||||
} else {
|
||||
|
|
@ -148,10 +150,13 @@ grpc_slice grpc_compression_algorithm_slice(
|
|||
|
||||
grpc_compression_algorithm grpc_compression_algorithm_from_slice(
|
||||
const grpc_slice& str) {
|
||||
if (grpc_slice_eq(str, GRPC_MDSTR_IDENTITY)) return GRPC_COMPRESS_NONE;
|
||||
if (grpc_slice_eq(str, GRPC_MDSTR_DEFLATE)) return GRPC_COMPRESS_DEFLATE;
|
||||
if (grpc_slice_eq(str, GRPC_MDSTR_GZIP)) return GRPC_COMPRESS_GZIP;
|
||||
if (grpc_slice_eq(str, GRPC_MDSTR_STREAM_SLASH_GZIP))
|
||||
if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_IDENTITY))
|
||||
return GRPC_COMPRESS_NONE;
|
||||
if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_DEFLATE))
|
||||
return GRPC_COMPRESS_DEFLATE;
|
||||
if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_GZIP))
|
||||
return GRPC_COMPRESS_GZIP;
|
||||
if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_STREAM_SLASH_GZIP))
|
||||
return GRPC_COMPRESS_STREAM_GZIP;
|
||||
return GRPC_COMPRESS_ALGORITHMS_COUNT;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "src/core/lib/compression/algorithm_metadata.h"
|
||||
#include "src/core/lib/compression/compression_internal.h"
|
||||
#include "src/core/lib/gpr/useful.h"
|
||||
#include "src/core/lib/slice/slice_utils.h"
|
||||
#include "src/core/lib/surface/api_trace.h"
|
||||
#include "src/core/lib/transport/static_metadata.h"
|
||||
|
||||
|
|
@ -33,18 +34,21 @@
|
|||
|
||||
grpc_message_compression_algorithm
|
||||
grpc_message_compression_algorithm_from_slice(const grpc_slice& str) {
|
||||
if (grpc_slice_eq(str, GRPC_MDSTR_IDENTITY))
|
||||
if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_IDENTITY))
|
||||
return GRPC_MESSAGE_COMPRESS_NONE;
|
||||
if (grpc_slice_eq(str, GRPC_MDSTR_DEFLATE))
|
||||
if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_DEFLATE))
|
||||
return GRPC_MESSAGE_COMPRESS_DEFLATE;
|
||||
if (grpc_slice_eq(str, GRPC_MDSTR_GZIP)) return GRPC_MESSAGE_COMPRESS_GZIP;
|
||||
if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_GZIP))
|
||||
return GRPC_MESSAGE_COMPRESS_GZIP;
|
||||
return GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT;
|
||||
}
|
||||
|
||||
grpc_stream_compression_algorithm grpc_stream_compression_algorithm_from_slice(
|
||||
const grpc_slice& str) {
|
||||
if (grpc_slice_eq(str, GRPC_MDSTR_IDENTITY)) return GRPC_STREAM_COMPRESS_NONE;
|
||||
if (grpc_slice_eq(str, GRPC_MDSTR_GZIP)) return GRPC_STREAM_COMPRESS_GZIP;
|
||||
if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_IDENTITY))
|
||||
return GRPC_STREAM_COMPRESS_NONE;
|
||||
if (grpc_slice_eq_static_interned(str, GRPC_MDSTR_GZIP))
|
||||
return GRPC_STREAM_COMPRESS_GZIP;
|
||||
return GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT;
|
||||
}
|
||||
|
||||
|
|
@ -244,13 +248,13 @@ grpc_message_compression_algorithm grpc_message_compression_algorithm_for_level(
|
|||
|
||||
int grpc_message_compression_algorithm_parse(
|
||||
grpc_slice value, grpc_message_compression_algorithm* algorithm) {
|
||||
if (grpc_slice_eq(value, GRPC_MDSTR_IDENTITY)) {
|
||||
if (grpc_slice_eq_static_interned(value, GRPC_MDSTR_IDENTITY)) {
|
||||
*algorithm = GRPC_MESSAGE_COMPRESS_NONE;
|
||||
return 1;
|
||||
} else if (grpc_slice_eq(value, GRPC_MDSTR_DEFLATE)) {
|
||||
} else if (grpc_slice_eq_static_interned(value, GRPC_MDSTR_DEFLATE)) {
|
||||
*algorithm = GRPC_MESSAGE_COMPRESS_DEFLATE;
|
||||
return 1;
|
||||
} else if (grpc_slice_eq(value, GRPC_MDSTR_GZIP)) {
|
||||
} else if (grpc_slice_eq_static_interned(value, GRPC_MDSTR_GZIP)) {
|
||||
*algorithm = GRPC_MESSAGE_COMPRESS_GZIP;
|
||||
return 1;
|
||||
} else {
|
||||
|
|
@ -263,10 +267,10 @@ int grpc_message_compression_algorithm_parse(
|
|||
|
||||
int grpc_stream_compression_algorithm_parse(
|
||||
grpc_slice value, grpc_stream_compression_algorithm* algorithm) {
|
||||
if (grpc_slice_eq(value, GRPC_MDSTR_IDENTITY)) {
|
||||
if (grpc_slice_eq_static_interned(value, GRPC_MDSTR_IDENTITY)) {
|
||||
*algorithm = GRPC_STREAM_COMPRESS_NONE;
|
||||
return 1;
|
||||
} else if (grpc_slice_eq(value, GRPC_MDSTR_GZIP)) {
|
||||
} else if (grpc_slice_eq_static_interned(value, GRPC_MDSTR_GZIP)) {
|
||||
*algorithm = GRPC_STREAM_COMPRESS_GZIP;
|
||||
return 1;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ typedef enum {
|
|||
GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT
|
||||
} grpc_message_compression_algorithm;
|
||||
|
||||
/** Stream compresssion algorithms supported by gRPC */
|
||||
/** Stream compression algorithms supported by gRPC */
|
||||
typedef enum {
|
||||
GRPC_STREAM_COMPRESS_NONE = 0,
|
||||
GRPC_STREAM_COMPRESS_GZIP,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "src/core/lib/compression/stream_compression.h"
|
||||
#include "src/core/lib/compression/stream_compression_gzip.h"
|
||||
#include "src/core/lib/slice/slice_utils.h"
|
||||
|
||||
extern const grpc_stream_compression_vtable
|
||||
grpc_stream_compression_identity_vtable;
|
||||
|
|
@ -65,11 +66,11 @@ void grpc_stream_compression_context_destroy(
|
|||
int grpc_stream_compression_method_parse(
|
||||
grpc_slice value, bool is_compress,
|
||||
grpc_stream_compression_method* method) {
|
||||
if (grpc_slice_eq(value, GRPC_MDSTR_IDENTITY)) {
|
||||
if (grpc_slice_eq_static_interned(value, GRPC_MDSTR_IDENTITY)) {
|
||||
*method = is_compress ? GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS
|
||||
: GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS;
|
||||
return 1;
|
||||
} else if (grpc_slice_eq(value, GRPC_MDSTR_GZIP)) {
|
||||
} else if (grpc_slice_eq_static_interned(value, GRPC_MDSTR_GZIP)) {
|
||||
*method = is_compress ? GRPC_STREAM_COMPRESSION_GZIP_COMPRESS
|
||||
: GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS;
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ struct grpc_stream_compression_vtable {
|
|||
* at the end of compression. Emits at most \a max_output_size compressed bytes
|
||||
* into \a out. If all the bytes in input buffer \a in are depleted and \a flush
|
||||
* is not GRPC_STREAM_COMPRESSION_FLUSH_NONE, the corresponding flush method is
|
||||
* executed. The total number of bytes emitted is outputed in \a output_size.
|
||||
* executed. The total number of bytes emitted is outputted in \a output_size.
|
||||
*
|
||||
* A SYNC flush indicates that the entire messages in \a in can be decompressed
|
||||
* from \a out. A FINISH flush implies a SYNC flush, and that any further
|
||||
|
|
@ -85,7 +85,7 @@ bool grpc_stream_compress(grpc_stream_compression_context* ctx,
|
|||
* Decompress bytes provided in \a in with a given context. Emits at most \a
|
||||
* max_output_size decompressed bytes into \a out. If decompression process
|
||||
* reached the end of a gzip stream, \a end_of_context is set to true; otherwise
|
||||
* it is set to false. The total number of bytes emitted is outputed in \a
|
||||
* it is set to false. The total number of bytes emitted is outputted in \a
|
||||
* output_size.
|
||||
*/
|
||||
bool grpc_stream_decompress(grpc_stream_compression_context* ctx,
|
||||
|
|
|
|||
|
|
@ -53,25 +53,25 @@ static bool gzip_flate(grpc_stream_compression_context_gzip* ctx,
|
|||
ctx->zs.avail_out = static_cast<uInt>(slice_size);
|
||||
ctx->zs.next_out = GRPC_SLICE_START_PTR(slice_out);
|
||||
while (ctx->zs.avail_out > 0 && in->length > 0 && !eoc) {
|
||||
grpc_slice slice = grpc_slice_buffer_take_first(in);
|
||||
ctx->zs.avail_in = static_cast<uInt> GRPC_SLICE_LENGTH(slice);
|
||||
ctx->zs.next_in = GRPC_SLICE_START_PTR(slice);
|
||||
grpc_slice* slice = grpc_slice_buffer_peek_first(in);
|
||||
ctx->zs.avail_in = static_cast<uInt> GRPC_SLICE_LENGTH(*slice);
|
||||
ctx->zs.next_in = GRPC_SLICE_START_PTR(*slice);
|
||||
r = ctx->flate(&ctx->zs, Z_NO_FLUSH);
|
||||
if (r < 0 && r != Z_BUF_ERROR) {
|
||||
gpr_log(GPR_ERROR, "zlib error (%d)", r);
|
||||
grpc_slice_unref_internal(slice_out);
|
||||
grpc_slice_unref_internal(slice);
|
||||
grpc_slice_buffer_remove_first(in);
|
||||
return false;
|
||||
} else if (r == Z_STREAM_END && ctx->flate == inflate) {
|
||||
eoc = true;
|
||||
}
|
||||
if (ctx->zs.avail_in > 0) {
|
||||
grpc_slice_buffer_undo_take_first(
|
||||
in,
|
||||
grpc_slice_sub(slice, GRPC_SLICE_LENGTH(slice) - ctx->zs.avail_in,
|
||||
GRPC_SLICE_LENGTH(slice)));
|
||||
grpc_slice_buffer_sub_first(
|
||||
in, GRPC_SLICE_LENGTH(*slice) - ctx->zs.avail_in,
|
||||
GRPC_SLICE_LENGTH(*slice));
|
||||
} else {
|
||||
grpc_slice_buffer_remove_first(in);
|
||||
}
|
||||
grpc_slice_unref_internal(slice);
|
||||
}
|
||||
if (flush != 0 && ctx->zs.avail_out > 0 && !eoc) {
|
||||
GPR_ASSERT(in->length == 0);
|
||||
|
|
|
|||
|
|
@ -26,11 +26,7 @@
|
|||
#include <grpc/grpc.h>
|
||||
#include <grpc/support/alloc.h>
|
||||
#include <grpc/support/log.h>
|
||||
|
||||
GPR_GLOBAL_CONFIG_DEFINE_STRING(
|
||||
grpc_trace, "",
|
||||
"A comma separated list of tracers that provide additional insight into "
|
||||
"how gRPC C core is processing requests via debug logs.");
|
||||
#include "src/core/lib/gpr/env.h"
|
||||
|
||||
int grpc_tracer_set_enabled(const char* name, int enabled);
|
||||
|
||||
|
|
@ -137,14 +133,12 @@ static void parse(const char* s) {
|
|||
gpr_free(strings);
|
||||
}
|
||||
|
||||
void grpc_tracer_init(const char* env_var_name) {
|
||||
(void)env_var_name; // suppress unused variable error
|
||||
grpc_tracer_init();
|
||||
}
|
||||
|
||||
void grpc_tracer_init() {
|
||||
grpc_core::UniquePtr<char> value = GPR_GLOBAL_CONFIG_GET(grpc_trace);
|
||||
parse(value.get());
|
||||
void grpc_tracer_init(const char* env_var) {
|
||||
char* e = gpr_getenv(env_var);
|
||||
if (e != nullptr) {
|
||||
parse(e);
|
||||
gpr_free(e);
|
||||
}
|
||||
}
|
||||
|
||||
void grpc_tracer_shutdown(void) {}
|
||||
|
|
|
|||
|
|
@ -24,15 +24,7 @@
|
|||
#include <grpc/support/atm.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "src/core/lib/gprpp/global_config.h"
|
||||
|
||||
GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_trace);
|
||||
|
||||
// TODO(veblush): Remove this deprecated function once codes depending on this
|
||||
// function are updated in the internal repo.
|
||||
void grpc_tracer_init(const char* env_var_name);
|
||||
|
||||
void grpc_tracer_init();
|
||||
void grpc_tracer_shutdown(void);
|
||||
|
||||
#if defined(__has_feature)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
/* Env utility functions */
|
||||
|
||||
/* Gets the environment variable value with the specified name.
|
||||
Returns a newly allocated string. It is the responsability of the caller to
|
||||
Returns a newly allocated string. It is the responsibility of the caller to
|
||||
gpr_free the return value if not NULL (which means that the environment
|
||||
variable exists). */
|
||||
char* gpr_getenv(const char* name);
|
||||
|
|
@ -34,6 +34,12 @@ char* gpr_getenv(const char* name);
|
|||
/* Sets the environment with the specified name to the specified value. */
|
||||
void gpr_setenv(const char* name, const char* value);
|
||||
|
||||
/* This is a version of gpr_getenv that does not produce any output if it has to
|
||||
use an insecure version of the function. It is ONLY to be used to solve the
|
||||
problem in which we need to check an env variable to configure the verbosity
|
||||
level of logging. So DO NOT USE THIS. */
|
||||
const char* gpr_getenv_silent(const char* name, char** dst);
|
||||
|
||||
/* Deletes the variable name from the environment. */
|
||||
void gpr_unsetenv(const char* name);
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
#include "src/core/lib/gpr/string.h"
|
||||
#include "src/core/lib/gpr/useful.h"
|
||||
|
||||
static const char* gpr_getenv_silent(const char* name, char** dst) {
|
||||
const char* gpr_getenv_silent(const char* name, char** dst) {
|
||||
const char* insecure_func_used = nullptr;
|
||||
char* result = nullptr;
|
||||
#if defined(GPR_BACKWARDS_COMPATIBILITY_MODE)
|
||||
|
|
|
|||
|
|
@ -30,6 +30,11 @@
|
|||
#include "src/core/lib/gpr/string.h"
|
||||
#include "src/core/lib/gpr/string_windows.h"
|
||||
|
||||
const char* gpr_getenv_silent(const char* name, char** dst) {
|
||||
*dst = gpr_getenv(name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* gpr_getenv(const char* name) {
|
||||
char* result = NULL;
|
||||
DWORD size;
|
||||
|
|
|
|||
|
|
@ -22,15 +22,12 @@
|
|||
#include <grpc/support/atm.h>
|
||||
#include <grpc/support/log.h>
|
||||
|
||||
#include "src/core/lib/gpr/env.h"
|
||||
#include "src/core/lib/gpr/string.h"
|
||||
#include "src/core/lib/gprpp/global_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_verbosity, "ERROR",
|
||||
"Default gRPC logging verbosity")
|
||||
|
||||
void gpr_default_log(gpr_log_func_args* args);
|
||||
static gpr_atm g_log_func = (gpr_atm)gpr_default_log;
|
||||
static gpr_atm g_min_severity_to_print = GPR_LOG_VERBOSITY_UNSET;
|
||||
|
|
@ -75,22 +72,29 @@ void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print) {
|
|||
}
|
||||
|
||||
void gpr_log_verbosity_init() {
|
||||
grpc_core::UniquePtr<char> verbosity = GPR_GLOBAL_CONFIG_GET(grpc_verbosity);
|
||||
char* verbosity = nullptr;
|
||||
const char* insecure_getenv = gpr_getenv_silent("GRPC_VERBOSITY", &verbosity);
|
||||
|
||||
gpr_atm min_severity_to_print = GPR_LOG_SEVERITY_ERROR;
|
||||
if (strlen(verbosity.get()) > 0) {
|
||||
if (gpr_stricmp(verbosity.get(), "DEBUG") == 0) {
|
||||
if (verbosity != nullptr) {
|
||||
if (gpr_stricmp(verbosity, "DEBUG") == 0) {
|
||||
min_severity_to_print = static_cast<gpr_atm>(GPR_LOG_SEVERITY_DEBUG);
|
||||
} else if (gpr_stricmp(verbosity.get(), "INFO") == 0) {
|
||||
} else if (gpr_stricmp(verbosity, "INFO") == 0) {
|
||||
min_severity_to_print = static_cast<gpr_atm>(GPR_LOG_SEVERITY_INFO);
|
||||
} else if (gpr_stricmp(verbosity.get(), "ERROR") == 0) {
|
||||
} else if (gpr_stricmp(verbosity, "ERROR") == 0) {
|
||||
min_severity_to_print = static_cast<gpr_atm>(GPR_LOG_SEVERITY_ERROR);
|
||||
}
|
||||
gpr_free(verbosity);
|
||||
}
|
||||
if ((gpr_atm_no_barrier_load(&g_min_severity_to_print)) ==
|
||||
GPR_LOG_VERBOSITY_UNSET) {
|
||||
gpr_atm_no_barrier_store(&g_min_severity_to_print, min_severity_to_print);
|
||||
}
|
||||
|
||||
if (insecure_getenv != nullptr) {
|
||||
gpr_log(GPR_DEBUG, "Warning: insecure environment read function '%s' used",
|
||||
insecure_getenv);
|
||||
}
|
||||
}
|
||||
|
||||
void gpr_set_log_function(gpr_log_func f) {
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@
|
|||
#include <grpc/support/sync.h>
|
||||
#include <grpc/support/time.h>
|
||||
|
||||
#include "src/core/lib/gpr/env.h"
|
||||
#include "src/core/lib/gpr/useful.h"
|
||||
#include "src/core/lib/gprpp/global_config.h"
|
||||
#include "src/core/lib/gprpp/memory.h"
|
||||
|
||||
/*
|
||||
|
|
@ -35,16 +35,6 @@
|
|||
* AROUND VERY SPECIFIC USE CASES.
|
||||
*/
|
||||
|
||||
#ifdef GRPC_ENABLE_FORK_SUPPORT
|
||||
#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT true
|
||||
#else
|
||||
#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT false
|
||||
#endif // GRPC_ENABLE_FORK_SUPPORT
|
||||
|
||||
GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_enable_fork_support,
|
||||
GRPC_ENABLE_FORK_SUPPORT_DEFAULT,
|
||||
"Enable folk support");
|
||||
|
||||
namespace grpc_core {
|
||||
namespace internal {
|
||||
// The exec_ctx_count has 2 modes, blocked and unblocked.
|
||||
|
|
@ -168,7 +158,34 @@ class ThreadState {
|
|||
|
||||
void Fork::GlobalInit() {
|
||||
if (!override_enabled_) {
|
||||
support_enabled_ = GPR_GLOBAL_CONFIG_GET(grpc_enable_fork_support);
|
||||
#ifdef GRPC_ENABLE_FORK_SUPPORT
|
||||
support_enabled_ = true;
|
||||
#endif
|
||||
bool env_var_set = false;
|
||||
char* env = gpr_getenv("GRPC_ENABLE_FORK_SUPPORT");
|
||||
if (env != nullptr) {
|
||||
static const char* truthy[] = {"yes", "Yes", "YES", "true",
|
||||
"True", "TRUE", "1"};
|
||||
static const char* falsey[] = {"no", "No", "NO", "false",
|
||||
"False", "FALSE", "0"};
|
||||
for (size_t i = 0; i < GPR_ARRAY_SIZE(truthy); i++) {
|
||||
if (0 == strcmp(env, truthy[i])) {
|
||||
support_enabled_ = true;
|
||||
env_var_set = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!env_var_set) {
|
||||
for (size_t i = 0; i < GPR_ARRAY_SIZE(falsey); i++) {
|
||||
if (0 == strcmp(env, falsey[i])) {
|
||||
support_enabled_ = false;
|
||||
env_var_set = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
gpr_free(env);
|
||||
}
|
||||
}
|
||||
if (support_enabled_) {
|
||||
exec_ctx_state_ = grpc_core::New<internal::ExecCtxState>();
|
||||
|
|
@ -243,7 +260,7 @@ void Fork::AwaitThreads() {
|
|||
|
||||
internal::ExecCtxState* Fork::exec_ctx_state_ = nullptr;
|
||||
internal::ThreadState* Fork::thread_state_ = nullptr;
|
||||
bool Fork::support_enabled_ = false;
|
||||
std::atomic<bool> Fork::support_enabled_;
|
||||
bool Fork::override_enabled_ = false;
|
||||
Fork::child_postfork_func Fork::reset_child_polling_engine_ = nullptr;
|
||||
} // namespace grpc_core
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@
|
|||
#ifndef GRPC_CORE_LIB_GPRPP_FORK_H
|
||||
#define GRPC_CORE_LIB_GPRPP_FORK_H
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
/*
|
||||
* NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK
|
||||
* AROUND VERY SPECIFIC USE CASES.
|
||||
|
|
@ -78,7 +82,7 @@ class Fork {
|
|||
private:
|
||||
static internal::ExecCtxState* exec_ctx_state_;
|
||||
static internal::ThreadState* thread_state_;
|
||||
static bool support_enabled_;
|
||||
static std::atomic<bool> support_enabled_;
|
||||
static bool override_enabled_;
|
||||
static child_postfork_func reset_child_polling_engine_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef GRPC_CORE_LIB_GPRPP_GLOBAL_CONFIG_CUSTOM_H
|
||||
#define GRPC_CORE_LIB_GPRPP_GLOBAL_CONFIG_CUSTOM_H
|
||||
|
||||
// This is a placeholder for custom global configuration implementaion.
|
||||
// This is a placeholder for custom global configuration implementation.
|
||||
// To use the custom one, please define following macros here.
|
||||
//
|
||||
// GPR_GLOBAL_CONFIG_DEFINE_BOOL
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ class RefCount {
|
|||
// So, use NonPolymorphicRefCount only when both of the following conditions
|
||||
// are guaranteed to hold:
|
||||
// (a) Child is a concrete leaf class in RefCounted<Child>, and
|
||||
// (b) you are gauranteed to call Unref only on concrete leaf classes and not
|
||||
// (b) you are guaranteed to call Unref only on concrete leaf classes and not
|
||||
// their parents.
|
||||
//
|
||||
// The following example is illegal, because calling Unref() will not call
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ struct grpc_error {
|
|||
uint8_t strs[GRPC_ERROR_STR_MAX];
|
||||
uint8_t times[GRPC_ERROR_TIME_MAX];
|
||||
// The child errors are stored in the arena, but are effectively a linked list
|
||||
// structure, since they are contained withing grpc_linked_error objects.
|
||||
// structure, since they are contained within grpc_linked_error objects.
|
||||
uint8_t first_err;
|
||||
uint8_t last_err;
|
||||
// The arena is dynamically reallocated with a grow factor of 1.5.
|
||||
|
|
|
|||
|
|
@ -1031,7 +1031,7 @@ static grpc_error* pollset_work(grpc_pollset* ps,
|
|||
process the pending epoll events.
|
||||
|
||||
The reason for decoupling do_epoll_wait and process_epoll_events is to
|
||||
better distrubute the work (i.e handling epoll events) across multiple
|
||||
better distribute the work (i.e handling epoll events) across multiple
|
||||
threads
|
||||
|
||||
process_epoll_events() returns very quickly: It just queues the work on
|
||||
|
|
|
|||
|
|
@ -31,19 +31,13 @@
|
|||
#include <grpc/support/string_util.h>
|
||||
|
||||
#include "src/core/lib/debug/trace.h"
|
||||
#include "src/core/lib/gpr/env.h"
|
||||
#include "src/core/lib/gpr/useful.h"
|
||||
#include "src/core/lib/gprpp/global_config.h"
|
||||
#include "src/core/lib/iomgr/ev_epoll1_linux.h"
|
||||
#include "src/core/lib/iomgr/ev_epollex_linux.h"
|
||||
#include "src/core/lib/iomgr/ev_poll_posix.h"
|
||||
#include "src/core/lib/iomgr/internal_errqueue.h"
|
||||
|
||||
GPR_GLOBAL_CONFIG_DEFINE_STRING(
|
||||
grpc_poll_strategy, "all",
|
||||
"Declares which polling engines to try when starting gRPC. "
|
||||
"This is a comma-separated list of engines, which are tried in priority "
|
||||
"order first -> last.")
|
||||
|
||||
grpc_core::TraceFlag grpc_polling_trace(false,
|
||||
"polling"); /* Disabled by default */
|
||||
|
||||
|
|
@ -52,15 +46,16 @@ grpc_core::TraceFlag grpc_fd_trace(false, "fd_trace");
|
|||
grpc_core::DebugOnlyTraceFlag grpc_trace_fd_refcount(false, "fd_refcount");
|
||||
grpc_core::DebugOnlyTraceFlag grpc_polling_api_trace(false, "polling_api");
|
||||
|
||||
// Polling API trace only enabled in debug builds
|
||||
#ifndef NDEBUG
|
||||
|
||||
// Polling API trace only enabled in debug builds
|
||||
#define GRPC_POLLING_API_TRACE(format, ...) \
|
||||
if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_api_trace)) { \
|
||||
gpr_log(GPR_INFO, "(polling-api) " format, __VA_ARGS__); \
|
||||
}
|
||||
#else
|
||||
#define GRPC_POLLING_API_TRACE(...)
|
||||
#endif // NDEBUG
|
||||
#endif
|
||||
|
||||
/** Default poll() function - a pointer so that it can be overridden by some
|
||||
* tests */
|
||||
|
|
@ -71,7 +66,7 @@ int aix_poll(struct pollfd fds[], nfds_t nfds, int timeout) {
|
|||
return poll(fds, nfds, timeout);
|
||||
}
|
||||
grpc_poll_function_type grpc_poll_function = aix_poll;
|
||||
#endif // GPR_AIX
|
||||
#endif
|
||||
|
||||
grpc_wakeup_fd grpc_global_wakeup_fd;
|
||||
|
||||
|
|
@ -210,11 +205,14 @@ void grpc_register_event_engine_factory(const char* name,
|
|||
const char* grpc_get_poll_strategy_name() { return g_poll_strategy_name; }
|
||||
|
||||
void grpc_event_engine_init(void) {
|
||||
grpc_core::UniquePtr<char> value = GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy);
|
||||
char* s = gpr_getenv("GRPC_POLL_STRATEGY");
|
||||
if (s == nullptr) {
|
||||
s = gpr_strdup("all");
|
||||
}
|
||||
|
||||
char** strings = nullptr;
|
||||
size_t nstrings = 0;
|
||||
split(value.get(), &strings, &nstrings);
|
||||
split(s, &strings, &nstrings);
|
||||
|
||||
for (size_t i = 0; g_event_engine == nullptr && i < nstrings; i++) {
|
||||
try_engine(strings[i]);
|
||||
|
|
@ -226,10 +224,10 @@ void grpc_event_engine_init(void) {
|
|||
gpr_free(strings);
|
||||
|
||||
if (g_event_engine == nullptr) {
|
||||
gpr_log(GPR_ERROR, "No event engine could be initialized from %s",
|
||||
value.get());
|
||||
gpr_log(GPR_ERROR, "No event engine could be initialized from %s", s);
|
||||
abort();
|
||||
}
|
||||
gpr_free(s);
|
||||
}
|
||||
|
||||
void grpc_event_engine_shutdown(void) {
|
||||
|
|
|
|||
|
|
@ -24,14 +24,11 @@
|
|||
#include <poll.h>
|
||||
|
||||
#include "src/core/lib/debug/trace.h"
|
||||
#include "src/core/lib/gprpp/global_config.h"
|
||||
#include "src/core/lib/iomgr/exec_ctx.h"
|
||||
#include "src/core/lib/iomgr/pollset.h"
|
||||
#include "src/core/lib/iomgr/pollset_set.h"
|
||||
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
|
||||
|
||||
GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_poll_strategy);
|
||||
|
||||
extern grpc_core::TraceFlag grpc_fd_trace; /* Disabled by default */
|
||||
extern grpc_core::TraceFlag grpc_polling_trace; /* Disabled by default */
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include <grpc/grpc.h>
|
||||
#include <grpc/support/log.h>
|
||||
|
||||
#include "src/core/lib/gpr/env.h"
|
||||
#include "src/core/lib/gprpp/fork.h"
|
||||
#include "src/core/lib/gprpp/thd.h"
|
||||
#include "src/core/lib/iomgr/ev_posix.h"
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@
|
|||
#include "src/core/lib/iomgr/timer_manager.h"
|
||||
|
||||
GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_abort_on_leaks, false,
|
||||
"A debugging aid to cause a call to abort() when "
|
||||
"gRPC objects are leaked past grpc_shutdown()");
|
||||
"Abort when leak is found");
|
||||
|
||||
static gpr_mu g_mu;
|
||||
static gpr_cv g_rcv;
|
||||
|
|
|
|||
|
|
@ -980,8 +980,7 @@ static bool tcp_flush(grpc_tcp* tcp, grpc_error** error) {
|
|||
// unref all and forget about all slices that have been written to this
|
||||
// point
|
||||
for (size_t idx = 0; idx < unwind_slice_idx; ++idx) {
|
||||
grpc_slice_unref_internal(
|
||||
grpc_slice_buffer_take_first(tcp->outgoing_buffer));
|
||||
grpc_slice_buffer_remove_first(tcp->outgoing_buffer);
|
||||
}
|
||||
return false;
|
||||
} else if (errno == EPIPE) {
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ void GrpcUdpListener::OnFdAboutToOrphan() {
|
|||
GRPC_CLOSURE_INIT(&destroyed_closure_, destroyed_port, server_,
|
||||
grpc_schedule_on_exec_ctx);
|
||||
if (!orphan_notified_ && udp_handler_ != nullptr) {
|
||||
/* Singals udp_handler that the FD is about to be closed and
|
||||
/* Signals udp_handler that the FD is about to be closed and
|
||||
* should no longer be used. */
|
||||
GRPC_CLOSURE_INIT(&orphan_fd_closure_, shutdown_fd, this,
|
||||
grpc_schedule_on_exec_ctx);
|
||||
|
|
@ -645,7 +645,7 @@ int grpc_udp_server_add_port(grpc_udp_server* s,
|
|||
grpc_sockaddr_set_port(addr, allocated_port1);
|
||||
port = allocated_port1;
|
||||
} else if (allocated_port1 >= 0) {
|
||||
/* The following sucessfully created socket should have same port as
|
||||
/* The following successfully created socket should have same port as
|
||||
* the first one. */
|
||||
GPR_ASSERT(port == allocated_port1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "src/core/lib/gprpp/global_config.h"
|
||||
#include "src/core/lib/profiling/timers.h"
|
||||
#include "src/core/lib/gpr/env.h"
|
||||
|
||||
typedef enum { BEGIN = '{', END = '}', MARK = '.' } marker_type;
|
||||
|
||||
|
|
@ -75,16 +74,11 @@ static __thread int g_thread_id;
|
|||
static int g_next_thread_id;
|
||||
static int g_writing_enabled = 1;
|
||||
|
||||
GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_latency_trace, "latency_trace.txt",
|
||||
"Output file name for latency trace")
|
||||
|
||||
static const char* output_filename() {
|
||||
if (output_filename_or_null == NULL) {
|
||||
grpc_core::UniquePtr<char> value =
|
||||
GPR_GLOBAL_CONFIG_GET(grpc_latency_trace);
|
||||
if (strlen(value.get()) > 0) {
|
||||
output_filename_or_null = value.release();
|
||||
} else {
|
||||
output_filename_or_null = gpr_getenv("LATENCY_TRACE");
|
||||
if (output_filename_or_null == NULL ||
|
||||
strlen(output_filename_or_null) == 0) {
|
||||
output_filename_or_null = "latency_trace.txt";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,15 +38,12 @@
|
|||
#include <grpc/support/log.h>
|
||||
#include <grpc/support/string_util.h>
|
||||
|
||||
#include "src/core/lib/gpr/env.h"
|
||||
#include "src/core/lib/gpr/string.h"
|
||||
#include "src/core/lib/gpr/useful.h"
|
||||
#include "src/core/lib/gprpp/global_config.h"
|
||||
#include "src/core/lib/gprpp/inlined_vector.h"
|
||||
#include "src/core/lib/iomgr/load_file.h"
|
||||
|
||||
GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_system_ssl_roots_dir, "",
|
||||
"Custom directory to SSL Roots");
|
||||
|
||||
namespace grpc_core {
|
||||
namespace {
|
||||
|
||||
|
|
@ -142,9 +139,10 @@ grpc_slice CreateRootCertsBundle(const char* certs_directory) {
|
|||
grpc_slice LoadSystemRootCerts() {
|
||||
grpc_slice result = grpc_empty_slice();
|
||||
// Prioritize user-specified custom directory if flag is set.
|
||||
UniquePtr<char> custom_dir = GPR_GLOBAL_CONFIG_GET(grpc_system_ssl_roots_dir);
|
||||
if (strlen(custom_dir.get()) > 0) {
|
||||
result = CreateRootCertsBundle(custom_dir.get());
|
||||
char* custom_dir = gpr_getenv("GRPC_SYSTEM_SSL_ROOTS_DIR");
|
||||
if (custom_dir != nullptr) {
|
||||
result = CreateRootCertsBundle(custom_dir);
|
||||
gpr_free(custom_dir);
|
||||
}
|
||||
// If the custom directory is empty/invalid/not specified, fallback to
|
||||
// distribution-specific directory.
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include "src/core/ext/transport/chttp2/alpn/alpn.h"
|
||||
#include "src/core/lib/channel/channel_args.h"
|
||||
#include "src/core/lib/channel/handshaker.h"
|
||||
#include "src/core/lib/gpr/env.h"
|
||||
#include "src/core/lib/gpr/host_port.h"
|
||||
#include "src/core/lib/gpr/string.h"
|
||||
#include "src/core/lib/iomgr/load_file.h"
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ class grpc_channel_security_connector : public grpc_security_connector {
|
|||
grpc_auth_context* auth_context,
|
||||
grpc_closure* on_call_host_checked,
|
||||
grpc_error** error) GRPC_ABSTRACT;
|
||||
/// Cancels a pending asychronous call to
|
||||
/// Cancels a pending asynchronous call to
|
||||
/// grpc_channel_security_connector_check_call_host() with
|
||||
/// \a on_call_host_checked as its callback.
|
||||
virtual void cancel_check_call_host(grpc_closure* on_call_host_checked,
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ class grpc_ssl_server_security_connector
|
|||
private:
|
||||
/* Attempts to fetch the server certificate config if a callback is available.
|
||||
* Current certificate config will continue to be used if the callback returns
|
||||
* an error. Returns true if new credentials were sucessfully loaded. */
|
||||
* an error. Returns true if new credentials were successfully loaded. */
|
||||
bool try_fetch_ssl_server_credentials() {
|
||||
grpc_ssl_server_certificate_config* certificate_config = nullptr;
|
||||
bool status;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "src/core/ext/transport/chttp2/alpn/alpn.h"
|
||||
#include "src/core/lib/channel/channel_args.h"
|
||||
#include "src/core/lib/gpr/env.h"
|
||||
#include "src/core/lib/gpr/host_port.h"
|
||||
#include "src/core/lib/gpr/string.h"
|
||||
#include "src/core/lib/gprpp/global_config.h"
|
||||
|
|
@ -45,13 +46,7 @@ static const char* installed_roots_path =
|
|||
INSTALL_PREFIX "/share/grpc/roots.pem";
|
||||
#endif
|
||||
|
||||
/** Config variable that points to the default SSL roots file. This file
|
||||
must be a PEM encoded file with all the roots such as the one that can be
|
||||
downloaded from https://pki.google.com/roots.pem. */
|
||||
GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_default_ssl_roots_file_path, "",
|
||||
"Path to the default SSL roots file.");
|
||||
|
||||
/** Config variable used as a flag to enable/disable loading system root
|
||||
/** Environment variable used as a flag to enable/disable loading system root
|
||||
certificates from the OS trust store. */
|
||||
GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_not_use_system_ssl_roots, false,
|
||||
"Disable loading system root certificates.");
|
||||
|
|
@ -70,22 +65,20 @@ void grpc_set_ssl_roots_override_callback(grpc_ssl_roots_override_callback cb) {
|
|||
|
||||
/* -- Cipher suites. -- */
|
||||
|
||||
/* Defines the cipher suites that we accept by default. All these cipher suites
|
||||
are compliant with HTTP2. */
|
||||
#define GRPC_SSL_CIPHER_SUITES \
|
||||
"ECDHE-ECDSA-AES128-GCM-SHA256:" \
|
||||
"ECDHE-ECDSA-AES256-GCM-SHA384:" \
|
||||
"ECDHE-RSA-AES128-GCM-SHA256:" \
|
||||
"ECDHE-RSA-AES256-GCM-SHA384"
|
||||
|
||||
static gpr_once cipher_suites_once = GPR_ONCE_INIT;
|
||||
static const char* cipher_suites = nullptr;
|
||||
|
||||
// All cipher suites for default are compliant with HTTP2.
|
||||
GPR_GLOBAL_CONFIG_DEFINE_STRING(
|
||||
grpc_ssl_cipher_suites,
|
||||
"ECDHE-ECDSA-AES128-GCM-SHA256:"
|
||||
"ECDHE-ECDSA-AES256-GCM-SHA384:"
|
||||
"ECDHE-RSA-AES128-GCM-SHA256:"
|
||||
"ECDHE-RSA-AES256-GCM-SHA384",
|
||||
"A colon separated list of cipher suites to use with OpenSSL")
|
||||
|
||||
static void init_cipher_suites(void) {
|
||||
grpc_core::UniquePtr<char> value =
|
||||
GPR_GLOBAL_CONFIG_GET(grpc_ssl_cipher_suites);
|
||||
cipher_suites = value.release();
|
||||
char* overridden = gpr_getenv("GRPC_SSL_CIPHER_SUITES");
|
||||
cipher_suites = overridden != nullptr ? overridden : GRPC_SSL_CIPHER_SUITES;
|
||||
}
|
||||
|
||||
/* --- Util --- */
|
||||
|
|
@ -437,12 +430,13 @@ grpc_slice DefaultSslRootStore::ComputePemRootCerts() {
|
|||
grpc_slice result = grpc_empty_slice();
|
||||
const bool not_use_system_roots =
|
||||
GPR_GLOBAL_CONFIG_GET(grpc_not_use_system_ssl_roots);
|
||||
// First try to load the roots from the configuration.
|
||||
UniquePtr<char> default_root_certs_path =
|
||||
GPR_GLOBAL_CONFIG_GET(grpc_default_ssl_roots_file_path);
|
||||
if (strlen(default_root_certs_path.get()) > 0) {
|
||||
GRPC_LOG_IF_ERROR(
|
||||
"load_file", grpc_load_file(default_root_certs_path.get(), 1, &result));
|
||||
// First try to load the roots from the environment.
|
||||
char* default_root_certs_path =
|
||||
gpr_getenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR);
|
||||
if (default_root_certs_path != nullptr) {
|
||||
GRPC_LOG_IF_ERROR("load_file",
|
||||
grpc_load_file(default_root_certs_path, 1, &result));
|
||||
gpr_free(default_root_certs_path);
|
||||
}
|
||||
// Try overridden roots if needed.
|
||||
grpc_ssl_roots_override_result ovrd_res = GRPC_SSL_ROOTS_OVERRIDE_FAIL;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include <grpc/grpc_security.h>
|
||||
#include <grpc/slice_buffer.h>
|
||||
|
||||
#include "src/core/lib/gprpp/global_config.h"
|
||||
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
||||
#include "src/core/lib/iomgr/error.h"
|
||||
#include "src/core/lib/security/security_connector/security_connector.h"
|
||||
|
|
@ -34,10 +33,7 @@
|
|||
#include "src/core/tsi/transport_security.h"
|
||||
#include "src/core/tsi/transport_security_interface.h"
|
||||
|
||||
GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_default_ssl_roots_file_path);
|
||||
GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_not_use_system_ssl_roots);
|
||||
|
||||
/* --- Util --- */
|
||||
/* --- Util. --- */
|
||||
|
||||
/* --- URL schemes. --- */
|
||||
#define GRPC_SSL_URL_SCHEME "https"
|
||||
|
|
|
|||
|
|
@ -144,11 +144,11 @@ size_t SecurityHandshaker::MoveReadBufferIntoHandshakeBuffer() {
|
|||
}
|
||||
size_t offset = 0;
|
||||
while (args_->read_buffer->count > 0) {
|
||||
grpc_slice next_slice = grpc_slice_buffer_take_first(args_->read_buffer);
|
||||
memcpy(handshake_buffer_ + offset, GRPC_SLICE_START_PTR(next_slice),
|
||||
GRPC_SLICE_LENGTH(next_slice));
|
||||
offset += GRPC_SLICE_LENGTH(next_slice);
|
||||
grpc_slice_unref_internal(next_slice);
|
||||
grpc_slice* next_slice = grpc_slice_buffer_peek_first(args_->read_buffer);
|
||||
memcpy(handshake_buffer_ + offset, GRPC_SLICE_START_PTR(*next_slice),
|
||||
GRPC_SLICE_LENGTH(*next_slice));
|
||||
offset += GRPC_SLICE_LENGTH(*next_slice);
|
||||
grpc_slice_buffer_remove_first(args_->read_buffer);
|
||||
}
|
||||
return bytes_in_read_buffer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include <grpc/slice.h>
|
||||
|
||||
/* Encodes data using base64. It is the caller's responsability to free
|
||||
/* Encodes data using base64. It is the caller's responsibility to free
|
||||
the returned char * using gpr_free. Returns NULL on NULL input.
|
||||
TODO(makdharma) : change the flags to bool from int */
|
||||
char* grpc_base64_encode(const void* data, size_t data_size, int url_safe,
|
||||
|
|
@ -35,7 +35,7 @@ size_t grpc_base64_estimate_encoded_size(size_t data_size, int url_safe,
|
|||
int multiline);
|
||||
|
||||
/* Encodes data using base64 and write it to memory pointed to by result. It is
|
||||
* the caller's responsiblity to allocate enough memory in |result| to fit the
|
||||
* the caller's responsibility to allocate enough memory in |result| to fit the
|
||||
* encoded data. */
|
||||
void grpc_base64_encode_core(char* result, const void* vdata, size_t data_size,
|
||||
int url_safe, int multiline);
|
||||
|
|
|
|||
|
|
@ -410,6 +410,31 @@ int grpc_slice_eq(grpc_slice a, grpc_slice b) {
|
|||
return grpc_slice_default_eq_impl(a, b);
|
||||
}
|
||||
|
||||
int grpc_slice_differs_refcounted(const grpc_slice& a,
|
||||
const grpc_slice& b_not_inline) {
|
||||
size_t a_len;
|
||||
const uint8_t* a_ptr;
|
||||
if (a.refcount) {
|
||||
a_len = a.data.refcounted.length;
|
||||
a_ptr = a.data.refcounted.bytes;
|
||||
} else {
|
||||
a_len = a.data.inlined.length;
|
||||
a_ptr = &a.data.inlined.bytes[0];
|
||||
}
|
||||
if (a_len != b_not_inline.data.refcounted.length) {
|
||||
return true;
|
||||
}
|
||||
if (a_len == 0) {
|
||||
return false;
|
||||
}
|
||||
// This check *must* occur after the a_len == 0 check
|
||||
// to retain compatibility with grpc_slice_eq.
|
||||
if (a_ptr == nullptr) {
|
||||
return true;
|
||||
}
|
||||
return memcmp(a_ptr, b_not_inline.data.refcounted.bytes, a_len);
|
||||
}
|
||||
|
||||
int grpc_slice_cmp(grpc_slice a, grpc_slice b) {
|
||||
int d = static_cast<int>(GRPC_SLICE_LENGTH(a) - GRPC_SLICE_LENGTH(b));
|
||||
if (d != 0) return d;
|
||||
|
|
|
|||
|
|
@ -375,6 +375,24 @@ grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer* sb) {
|
|||
return slice;
|
||||
}
|
||||
|
||||
void grpc_slice_buffer_remove_first(grpc_slice_buffer* sb) {
|
||||
GPR_DEBUG_ASSERT(sb->count > 0);
|
||||
sb->length -= GRPC_SLICE_LENGTH(sb->slices[0]);
|
||||
grpc_slice_unref_internal(sb->slices[0]);
|
||||
sb->slices++;
|
||||
if (--sb->count == 0) {
|
||||
sb->slices = sb->base_slices;
|
||||
}
|
||||
}
|
||||
|
||||
void grpc_slice_buffer_sub_first(grpc_slice_buffer* sb, size_t begin,
|
||||
size_t end) {
|
||||
// TODO(soheil): Introduce a ptr version for sub.
|
||||
sb->length -= GRPC_SLICE_LENGTH(sb->slices[0]);
|
||||
sb->slices[0] = grpc_slice_sub_no_ref(sb->slices[0], begin, end);
|
||||
sb->length += end - begin;
|
||||
}
|
||||
|
||||
void grpc_slice_buffer_undo_take_first(grpc_slice_buffer* sb,
|
||||
grpc_slice slice) {
|
||||
sb->slices--;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#include "src/core/lib/slice/slice_internal.h"
|
||||
#include "src/core/lib/slice/slice_utils.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
|
|
@ -143,7 +144,8 @@ grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice,
|
|||
static_metadata_hash_ent ent =
|
||||
static_metadata_hash[(hash + i) % GPR_ARRAY_SIZE(static_metadata_hash)];
|
||||
if (ent.hash == hash && ent.idx < GRPC_STATIC_MDSTR_COUNT &&
|
||||
grpc_slice_eq(grpc_static_slice_table[ent.idx], slice)) {
|
||||
grpc_slice_eq_static_interned(slice,
|
||||
grpc_static_slice_table[ent.idx])) {
|
||||
*returned_slice_is_different = true;
|
||||
return grpc_static_slice_table[ent.idx];
|
||||
}
|
||||
|
|
@ -170,7 +172,8 @@ grpc_slice grpc_slice_intern(grpc_slice slice) {
|
|||
static_metadata_hash_ent ent =
|
||||
static_metadata_hash[(hash + i) % GPR_ARRAY_SIZE(static_metadata_hash)];
|
||||
if (ent.hash == hash && ent.idx < GRPC_STATIC_MDSTR_COUNT &&
|
||||
grpc_slice_eq(grpc_static_slice_table[ent.idx], slice)) {
|
||||
grpc_slice_eq_static_interned(slice,
|
||||
grpc_static_slice_table[ent.idx])) {
|
||||
return grpc_static_slice_table[ent.idx];
|
||||
}
|
||||
}
|
||||
|
|
@ -183,7 +186,8 @@ grpc_slice grpc_slice_intern(grpc_slice slice) {
|
|||
/* search for an existing string */
|
||||
size_t idx = TABLE_IDX(hash, shard->capacity);
|
||||
for (s = shard->strs[idx]; s; s = s->bucket_next) {
|
||||
if (s->hash == hash && grpc_slice_eq(slice, materialize(s))) {
|
||||
if (s->hash == hash &&
|
||||
grpc_slice_eq_static_interned(slice, materialize(s))) {
|
||||
if (s->refcnt.RefIfNonZero()) {
|
||||
gpr_mu_unlock(&shard->mu);
|
||||
return materialize(s);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#include <grpc/support/log.h>
|
||||
|
||||
#include <grpc/slice.h>
|
||||
#include <grpc/slice_buffer.h>
|
||||
#include <string.h>
|
||||
|
|
@ -240,6 +242,20 @@ void grpc_slice_buffer_partial_unref_internal(grpc_slice_buffer* sb,
|
|||
size_t idx);
|
||||
void grpc_slice_buffer_destroy_internal(grpc_slice_buffer* sb);
|
||||
|
||||
// Returns a pointer to the first slice in the slice buffer without giving
|
||||
// ownership to or a reference count on that slice.
|
||||
inline grpc_slice* grpc_slice_buffer_peek_first(grpc_slice_buffer* sb) {
|
||||
GPR_DEBUG_ASSERT(sb->count > 0);
|
||||
return &sb->slices[0];
|
||||
}
|
||||
|
||||
// Removes the first slice from the slice buffer.
|
||||
void grpc_slice_buffer_remove_first(grpc_slice_buffer* sb);
|
||||
|
||||
// Calls grpc_slice_sub with the given parameters on the first slice.
|
||||
void grpc_slice_buffer_sub_first(grpc_slice_buffer* sb, size_t begin,
|
||||
size_t end);
|
||||
|
||||
/* Check if a slice is interned */
|
||||
bool grpc_slice_is_interned(const grpc_slice& slice);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2019 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GRPC_CORE_LIB_SLICE_SLICE_UTILS_H
|
||||
#define GRPC_CORE_LIB_SLICE_SLICE_UTILS_H
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#include <grpc/slice.h>
|
||||
|
||||
// When we compare two slices, and we know the latter is not inlined, we can
|
||||
// short circuit our comparison operator. We specifically use differs()
|
||||
// semantics instead of equals() semantics due to more favourable code
|
||||
// generation when using differs(). Specifically, we may use the output of
|
||||
// grpc_slice_differs_refcounted for control flow. If we use differs()
|
||||
// semantics, we end with a tailcall to memcmp(). If we use equals() semantics,
|
||||
// we need to invert the result that memcmp provides us, which costs several
|
||||
// instructions to do so. If we're using the result for control flow (i.e.
|
||||
// branching based on the output) then we're just performing the extra
|
||||
// operations to invert the result pointlessly. Concretely, we save 6 ops on
|
||||
// x86-64/clang with differs().
|
||||
int grpc_slice_differs_refcounted(const grpc_slice& a,
|
||||
const grpc_slice& b_not_inline);
|
||||
// When we compare two slices, and we *know* that one of them is static or
|
||||
// interned, we can short circuit our slice equality function. The second slice
|
||||
// here must be static or interned; slice a can be any slice, inlined or not.
|
||||
inline bool grpc_slice_eq_static_interned(const grpc_slice& a,
|
||||
const grpc_slice& b_static_interned) {
|
||||
if (a.refcount == b_static_interned.refcount) {
|
||||
return true;
|
||||
}
|
||||
return !grpc_slice_differs_refcounted(a, b_static_interned);
|
||||
}
|
||||
|
||||
#endif /* GRPC_CORE_LIB_SLICE_SLICE_UTILS_H */
|
||||
|
|
@ -42,8 +42,8 @@
|
|||
#include "src/core/lib/gprpp/ref_counted.h"
|
||||
#include "src/core/lib/iomgr/timer.h"
|
||||
#include "src/core/lib/profiling/timers.h"
|
||||
#include "src/core/lib/slice/slice_internal.h"
|
||||
#include "src/core/lib/slice/slice_string_helpers.h"
|
||||
#include "src/core/lib/slice/slice_utils.h"
|
||||
#include "src/core/lib/surface/api_trace.h"
|
||||
#include "src/core/lib/surface/call.h"
|
||||
#include "src/core/lib/surface/call_test_only.h"
|
||||
|
|
@ -349,8 +349,8 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args,
|
|||
MAX_SEND_EXTRA_METADATA_COUNT);
|
||||
for (size_t i = 0; i < args->add_initial_metadata_count; i++) {
|
||||
call->send_extra_metadata[i].md = args->add_initial_metadata[i];
|
||||
if (grpc_slice_eq(GRPC_MDKEY(args->add_initial_metadata[i]),
|
||||
GRPC_MDSTR_PATH)) {
|
||||
if (grpc_slice_eq_static_interned(
|
||||
GRPC_MDKEY(args->add_initial_metadata[i]), GRPC_MDSTR_PATH)) {
|
||||
path = grpc_slice_ref_internal(
|
||||
GRPC_MDVALUE(args->add_initial_metadata[i]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ void grpc_init(void) {
|
|||
* at the appropriate time */
|
||||
grpc_register_security_filters();
|
||||
register_builtin_channel_init();
|
||||
grpc_tracer_init();
|
||||
grpc_tracer_init("GRPC_TRACE");
|
||||
/* no more changes to channel init pipelines */
|
||||
grpc_channel_init_finalize();
|
||||
grpc_iomgr_start();
|
||||
|
|
|
|||
|
|
@ -25,4 +25,4 @@
|
|||
|
||||
const char* grpc_version_string(void) { return "7.0.0"; }
|
||||
|
||||
const char* grpc_g_stands_for(void) { return "gandalf"; }
|
||||
const char* grpc_g_stands_for(void) { return "gale"; }
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include "src/core/lib/gpr/useful.h"
|
||||
#include "src/core/lib/gprpp/atomic.h"
|
||||
#include "src/core/lib/gprpp/sync.h"
|
||||
#include "src/core/lib/slice/slice_utils.h"
|
||||
|
||||
extern grpc_core::DebugOnlyTraceFlag grpc_trace_metadata;
|
||||
|
||||
|
|
@ -138,7 +139,7 @@ bool grpc_mdelem_eq(grpc_mdelem a, grpc_mdelem b);
|
|||
* grpc_mdelem_eq and remove unnecessary checks. */
|
||||
inline bool grpc_mdelem_static_value_eq(grpc_mdelem a, grpc_mdelem b_static) {
|
||||
if (a.payload == b_static.payload) return true;
|
||||
return grpc_slice_eq(GRPC_MDVALUE(a), GRPC_MDVALUE(b_static));
|
||||
return grpc_slice_eq_static_interned(GRPC_MDVALUE(a), GRPC_MDVALUE(b_static));
|
||||
}
|
||||
|
||||
/* Mutator and accessor for grpc_mdelem user data. The destructor function
|
||||
|
|
|
|||
|
|
@ -384,9 +384,9 @@ static const uint8_t elem_idxs[] = {
|
|||
52, 53, 54, 76, 69, 55, 56, 70, 58, 78, 80, 81, 82, 83, 59, 64,
|
||||
60, 75, 72, 255, 85, 255, 255, 68, 255, 255, 0};
|
||||
|
||||
grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b) {
|
||||
grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b) {
|
||||
if (a == -1 || b == -1) return GRPC_MDNULL;
|
||||
uint32_t k = (uint32_t)(a * 107 + b);
|
||||
uint32_t k = static_cast<uint32_t>(a * 107 + b);
|
||||
uint32_t h = elems_phash(k);
|
||||
return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k &&
|
||||
elem_idxs[h] != 255
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
#include <grpc/support/port_platform.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "src/core/lib/transport/metadata.h"
|
||||
|
||||
#define GRPC_STATIC_MDSTR_COUNT 107
|
||||
|
|
@ -263,7 +265,8 @@ extern grpc_slice_refcount
|
|||
(slice).refcount->GetType() == grpc_slice_refcount::Type::STATIC)
|
||||
|
||||
#define GRPC_STATIC_METADATA_INDEX(static_slice) \
|
||||
((int)((static_slice).refcount - grpc_static_metadata_refcounts))
|
||||
(static_cast<intptr_t>( \
|
||||
((static_slice).refcount - grpc_static_metadata_refcounts)))
|
||||
|
||||
#define GRPC_STATIC_MDELEM_COUNT 86
|
||||
extern grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];
|
||||
|
|
@ -527,7 +530,7 @@ extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];
|
|||
#define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \
|
||||
(GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[85], GRPC_MDELEM_STORAGE_STATIC))
|
||||
|
||||
grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b);
|
||||
grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b);
|
||||
typedef enum {
|
||||
GRPC_BATCH_PATH,
|
||||
GRPC_BATCH_METHOD,
|
||||
|
|
@ -586,11 +589,11 @@ typedef union {
|
|||
} named;
|
||||
} grpc_metadata_batch_callouts;
|
||||
|
||||
#define GRPC_BATCH_INDEX_OF(slice) \
|
||||
(GRPC_IS_STATIC_METADATA_STRING((slice)) \
|
||||
? (grpc_metadata_batch_callouts_index)GPR_CLAMP( \
|
||||
GRPC_STATIC_METADATA_INDEX((slice)), 0, \
|
||||
GRPC_BATCH_CALLOUTS_COUNT) \
|
||||
#define GRPC_BATCH_INDEX_OF(slice) \
|
||||
(GRPC_IS_STATIC_METADATA_STRING((slice)) \
|
||||
? static_cast<grpc_metadata_batch_callouts_index>( \
|
||||
GPR_CLAMP(GRPC_STATIC_METADATA_INDEX((slice)), 0, \
|
||||
static_cast<intptr_t>(GRPC_BATCH_CALLOUTS_COUNT))) \
|
||||
: GRPC_BATCH_CALLOUTS_COUNT)
|
||||
|
||||
extern const uint8_t grpc_static_accept_encoding_metadata[8];
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ alts_shared_resource_dedicated* grpc_alts_get_shared_resource_dedicated(void);
|
|||
|
||||
/**
|
||||
* This method destroys the alts_shared_resource_dedicated object
|
||||
* shared by all TSI handshakes. The applicaiton is responsible for
|
||||
* shared by all TSI handshakes. The application is responsible for
|
||||
* invoking the API before calling grpc_shutdown().
|
||||
*/
|
||||
void grpc_alts_shared_resource_dedicated_shutdown();
|
||||
|
|
|
|||
|
|
@ -22,5 +22,5 @@
|
|||
#include <grpcpp/grpcpp.h>
|
||||
|
||||
namespace grpc {
|
||||
grpc::string Version() { return "1.21.0-dev"; }
|
||||
grpc::string Version() { return "1.22.0-dev"; }
|
||||
} // namespace grpc
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ namespace Grpc.Core
|
|||
/// <summary>
|
||||
/// Current <c>AssemblyFileVersion</c> of gRPC C# assemblies
|
||||
/// </summary>
|
||||
public const string CurrentAssemblyFileVersion = "1.21.0.0";
|
||||
public const string CurrentAssemblyFileVersion = "1.22.0.0";
|
||||
|
||||
/// <summary>
|
||||
/// Current version of gRPC C#
|
||||
/// </summary>
|
||||
public const string CurrentVersion = "1.21.0-dev";
|
||||
public const string CurrentVersion = "1.22.0-dev";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<!-- This file is generated -->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<GrpcCsharpVersion>1.21.0-dev</GrpcCsharpVersion>
|
||||
<GrpcCsharpVersion>1.22.0-dev</GrpcCsharpVersion>
|
||||
<GoogleProtobufVersion>3.7.0</GoogleProtobufVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
@rem limitations under the License.
|
||||
|
||||
@rem Current package versions
|
||||
set VERSION=1.21.0-dev
|
||||
set VERSION=1.22.0-dev
|
||||
|
||||
@rem Adjust the location of nuget.exe
|
||||
set NUGET=C:\nuget\nuget.exe
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ Pod::Spec.new do |s|
|
|||
# exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed
|
||||
# before them.
|
||||
s.name = '!ProtoCompiler-gRPCPlugin'
|
||||
v = '1.21.0-dev'
|
||||
v = '1.22.0-dev'
|
||||
s.version = v
|
||||
s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.'
|
||||
s.description = <<-DESC
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@
|
|||
NSBundle *resourceBundle = [NSBundle
|
||||
bundleWithURL:[[bundle resourceURL] URLByAppendingPathComponent:resourceBundlePath]];
|
||||
NSString *path = [resourceBundle pathForResource:rootsPEM ofType:@"pem"];
|
||||
setenv("GRPC_DEFAULT_SSL_ROOTS_FILE_PATH", [path cStringUsingEncoding:NSUTF8StringEncoding], 1);
|
||||
setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR,
|
||||
[path cStringUsingEncoding:NSUTF8StringEncoding], 1);
|
||||
});
|
||||
|
||||
NSData *rootsASCII = nil;
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@
|
|||
// instead. This file can be regenerated from the template by running
|
||||
// `tools/buildgen/generate_projects.sh`.
|
||||
|
||||
#define GRPC_OBJC_VERSION_STRING @"1.21.0-dev"
|
||||
#define GRPC_OBJC_VERSION_STRING @"1.22.0-dev"
|
||||
|
|
|
|||
|
|
@ -37,11 +37,11 @@
|
|||
#include <grpc/support/log.h>
|
||||
|
||||
#include "src/core/lib/channel/channel_args.h"
|
||||
#include "src/core/lib/gpr/env.h"
|
||||
#include "src/core/lib/gpr/host_port.h"
|
||||
#include "src/core/lib/gpr/string.h"
|
||||
#include "src/core/lib/gpr/tmpfile.h"
|
||||
#include "src/core/lib/security/credentials/credentials.h"
|
||||
#include "src/core/lib/security/security_connector/ssl_utils.h"
|
||||
#include "test/core/end2end/data/ssl_test_data.h"
|
||||
#include "test/core/util/port.h"
|
||||
#include "test/core/util/test_config.h"
|
||||
|
|
@ -172,7 +172,7 @@ static char *roots_filename;
|
|||
GPR_ASSERT(roots_file != NULL);
|
||||
GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size);
|
||||
fclose(roots_file);
|
||||
GPR_GLOBAL_CONFIG_SET(grpc_default_ssl_roots_file_path, roots_filename);
|
||||
gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename);
|
||||
|
||||
grpc_init();
|
||||
|
||||
|
|
|
|||
|
|
@ -22,5 +22,5 @@
|
|||
// instead. This file can be regenerated from the template by running
|
||||
// `tools/buildgen/generate_projects.sh`.
|
||||
|
||||
#define GRPC_OBJC_VERSION_STRING @"1.21.0-dev"
|
||||
#define GRPC_OBJC_VERSION_STRING @"1.22.0-dev"
|
||||
#define GRPC_C_VERSION_STRING @"7.0.0"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "grpc/grpc-dev",
|
||||
"description": "gRPC library for PHP - for Developement use only",
|
||||
"license": "Apache-2.0",
|
||||
"version": "1.21.0",
|
||||
"version": "1.22.0",
|
||||
"require": {
|
||||
"php": ">=5.5.0",
|
||||
"google/protobuf": "^v3.3.0"
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@
|
|||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
#define PHP_GRPC_VERSION "1.21.0dev"
|
||||
#define PHP_GRPC_VERSION "1.22.0dev"
|
||||
|
||||
#endif /* VERSION_H */
|
||||
|
|
|
|||
|
|
@ -14,4 +14,4 @@
|
|||
|
||||
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!!
|
||||
|
||||
__version__ = """1.21.0.dev0"""
|
||||
__version__ = """1.22.0.dev0"""
|
||||
|
|
|
|||
|
|
@ -385,7 +385,6 @@ CORE_SOURCE_FILES = [
|
|||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc',
|
||||
'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc',
|
||||
'src/core/ext/filters/census/grpc_context.cc',
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue