Reland max_age filter -> promises (#29127)

* TrySeq fix

* Revert "Revert "Revert "Revert "Convert max_age filter to promises (#28904)" (#28957)" (#28958)" (#29105)"

This reverts commit ff14d1d7f3.

* Single set pointer

* Update single_set_ptr.h

* fix

* fix

* build

* fix race

* fix race

* Automated change: Fix sanity tests

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
pull/29147/head^2
Craig Tiller 3 years ago committed by GitHub
parent a87173e87e
commit ba41407ea6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      BUILD
  2. 12
      CMakeLists.txt
  3. 10
      Makefile
  4. 22
      build_autogenerated.yaml
  5. 8
      config.m4
  6. 8
      config.w32
  7. 12
      gRPC-C++.podspec
  8. 15
      gRPC-Core.podspec
  9. 9
      grpc.gemspec
  10. 10
      grpc.gyp
  11. 9
      package.xml
  12. 406
      src/core/ext/filters/channel_idle/channel_idle_filter.cc
  13. 2
      src/core/ext/filters/channel_idle/idle_filter_state.cc
  14. 6
      src/core/ext/filters/channel_idle/idle_filter_state.h
  15. 199
      src/core/ext/filters/client_idle/client_idle_filter.cc
  16. 566
      src/core/ext/filters/max_age/max_age_filter.cc
  17. 26
      src/core/ext/filters/max_age/max_age_filter.h
  18. 22
      src/core/lib/gprpp/single_set_ptr.h
  19. 6
      src/core/plugin_registry/grpc_plugin_registry.cc
  20. 5
      src/python/grpcio/grpc_core_dependencies.py
  21. 2
      test/core/client_idle/idle_filter_state_test.cc
  22. 9
      tools/doxygen/Doxyfile.c++.internal
  23. 9
      tools/doxygen/Doxyfile.core.internal

28
BUILD

@ -2285,8 +2285,7 @@ grpc_cc_library(
"grpc_lb_policy_ring_hash",
"grpc_lb_policy_round_robin",
"grpc_lb_policy_weighted_target",
"grpc_client_idle_filter",
"grpc_max_age_filter",
"grpc_channel_idle_filter",
"grpc_message_size_filter",
"grpc_resolver_binder",
"grpc_resolver_dns_ares",
@ -2582,10 +2581,10 @@ grpc_cc_library(
grpc_cc_library(
name = "idle_filter_state",
srcs = [
"src/core/ext/filters/client_idle/idle_filter_state.cc",
"src/core/ext/filters/channel_idle/idle_filter_state.cc",
],
hdrs = [
"src/core/ext/filters/client_idle/idle_filter_state.h",
"src/core/ext/filters/channel_idle/idle_filter_state.h",
],
language = "c++",
deps = [
@ -2594,9 +2593,9 @@ grpc_cc_library(
)
grpc_cc_library(
name = "grpc_client_idle_filter",
name = "grpc_channel_idle_filter",
srcs = [
"src/core/ext/filters/client_idle/client_idle_filter.cc",
"src/core/ext/filters/channel_idle/channel_idle_filter.cc",
],
deps = [
"capture",
@ -2606,27 +2605,12 @@ grpc_cc_library(
"grpc_base",
"idle_filter_state",
"loop",
"single_set_ptr",
"sleep",
"try_seq",
],
)
grpc_cc_library(
name = "grpc_max_age_filter",
srcs = [
"src/core/ext/filters/max_age/max_age_filter.cc",
],
hdrs = [
"src/core/ext/filters/max_age/max_age_filter.h",
],
language = "c++",
deps = [
"config",
"gpr_base",
"grpc_base",
],
)
grpc_cc_library(
name = "grpc_deadline_filter",
srcs = [

12
CMakeLists.txt generated

@ -1438,6 +1438,8 @@ endif()
add_library(grpc
src/core/ext/filters/census/grpc_context.cc
src/core/ext/filters/channel_idle/channel_idle_filter.cc
src/core/ext/filters/channel_idle/idle_filter_state.cc
src/core/ext/filters/client_channel/backend_metric.cc
src/core/ext/filters/client_channel/backup_poller.cc
src/core/ext/filters/client_channel/channel_connectivity.cc
@ -1496,8 +1498,6 @@ add_library(grpc
src/core/ext/filters/client_channel/subchannel.cc
src/core/ext/filters/client_channel/subchannel_pool_interface.cc
src/core/ext/filters/client_channel/subchannel_stream_client.cc
src/core/ext/filters/client_idle/client_idle_filter.cc
src/core/ext/filters/client_idle/idle_filter_state.cc
src/core/ext/filters/deadline/deadline_filter.cc
src/core/ext/filters/fault_injection/fault_injection_filter.cc
src/core/ext/filters/fault_injection/service_config_parser.cc
@ -1507,7 +1507,6 @@ add_library(grpc
src/core/ext/filters/http/message_compress/message_compress_filter.cc
src/core/ext/filters/http/message_compress/message_decompress_filter.cc
src/core/ext/filters/http/server/http_server_filter.cc
src/core/ext/filters/max_age/max_age_filter.cc
src/core/ext/filters/message_size/message_size_filter.cc
src/core/ext/filters/rbac/rbac_filter.cc
src/core/ext/filters/rbac/rbac_service_config_parser.cc
@ -2374,6 +2373,8 @@ endif()
add_library(grpc_unsecure
src/core/ext/filters/census/grpc_context.cc
src/core/ext/filters/channel_idle/channel_idle_filter.cc
src/core/ext/filters/channel_idle/idle_filter_state.cc
src/core/ext/filters/client_channel/backend_metric.cc
src/core/ext/filters/client_channel/backup_poller.cc
src/core/ext/filters/client_channel/channel_connectivity.cc
@ -2426,8 +2427,6 @@ add_library(grpc_unsecure
src/core/ext/filters/client_channel/subchannel.cc
src/core/ext/filters/client_channel/subchannel_pool_interface.cc
src/core/ext/filters/client_channel/subchannel_stream_client.cc
src/core/ext/filters/client_idle/client_idle_filter.cc
src/core/ext/filters/client_idle/idle_filter_state.cc
src/core/ext/filters/deadline/deadline_filter.cc
src/core/ext/filters/fault_injection/fault_injection_filter.cc
src/core/ext/filters/fault_injection/service_config_parser.cc
@ -2437,7 +2436,6 @@ add_library(grpc_unsecure
src/core/ext/filters/http/message_compress/message_compress_filter.cc
src/core/ext/filters/http/message_compress/message_decompress_filter.cc
src/core/ext/filters/http/server/http_server_filter.cc
src/core/ext/filters/max_age/max_age_filter.cc
src/core/ext/filters/message_size/message_size_filter.cc
src/core/ext/transport/chttp2/alpn/alpn.cc
src/core/ext/transport/chttp2/client/chttp2_connector.cc
@ -11932,7 +11930,7 @@ endif()
if(gRPC_BUILD_TESTS)
add_executable(idle_filter_state_test
src/core/ext/filters/client_idle/idle_filter_state.cc
src/core/ext/filters/channel_idle/idle_filter_state.cc
test/core/client_idle/idle_filter_state_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc

10
Makefile generated

@ -1023,6 +1023,8 @@ endif
# start of build recipe for library "grpc" (generated by makelib(lib) template function)
LIBGRPC_SRC = \
src/core/ext/filters/census/grpc_context.cc \
src/core/ext/filters/channel_idle/channel_idle_filter.cc \
src/core/ext/filters/channel_idle/idle_filter_state.cc \
src/core/ext/filters/client_channel/backend_metric.cc \
src/core/ext/filters/client_channel/backup_poller.cc \
src/core/ext/filters/client_channel/channel_connectivity.cc \
@ -1081,8 +1083,6 @@ LIBGRPC_SRC = \
src/core/ext/filters/client_channel/subchannel.cc \
src/core/ext/filters/client_channel/subchannel_pool_interface.cc \
src/core/ext/filters/client_channel/subchannel_stream_client.cc \
src/core/ext/filters/client_idle/client_idle_filter.cc \
src/core/ext/filters/client_idle/idle_filter_state.cc \
src/core/ext/filters/deadline/deadline_filter.cc \
src/core/ext/filters/fault_injection/fault_injection_filter.cc \
src/core/ext/filters/fault_injection/service_config_parser.cc \
@ -1092,7 +1092,6 @@ LIBGRPC_SRC = \
src/core/ext/filters/http/message_compress/message_compress_filter.cc \
src/core/ext/filters/http/message_compress/message_decompress_filter.cc \
src/core/ext/filters/http/server/http_server_filter.cc \
src/core/ext/filters/max_age/max_age_filter.cc \
src/core/ext/filters/message_size/message_size_filter.cc \
src/core/ext/filters/rbac/rbac_filter.cc \
src/core/ext/filters/rbac/rbac_service_config_parser.cc \
@ -1808,6 +1807,8 @@ endif
# start of build recipe for library "grpc_unsecure" (generated by makelib(lib) template function)
LIBGRPC_UNSECURE_SRC = \
src/core/ext/filters/census/grpc_context.cc \
src/core/ext/filters/channel_idle/channel_idle_filter.cc \
src/core/ext/filters/channel_idle/idle_filter_state.cc \
src/core/ext/filters/client_channel/backend_metric.cc \
src/core/ext/filters/client_channel/backup_poller.cc \
src/core/ext/filters/client_channel/channel_connectivity.cc \
@ -1860,8 +1861,6 @@ LIBGRPC_UNSECURE_SRC = \
src/core/ext/filters/client_channel/subchannel.cc \
src/core/ext/filters/client_channel/subchannel_pool_interface.cc \
src/core/ext/filters/client_channel/subchannel_stream_client.cc \
src/core/ext/filters/client_idle/client_idle_filter.cc \
src/core/ext/filters/client_idle/idle_filter_state.cc \
src/core/ext/filters/deadline/deadline_filter.cc \
src/core/ext/filters/fault_injection/fault_injection_filter.cc \
src/core/ext/filters/fault_injection/service_config_parser.cc \
@ -1871,7 +1870,6 @@ LIBGRPC_UNSECURE_SRC = \
src/core/ext/filters/http/message_compress/message_compress_filter.cc \
src/core/ext/filters/http/message_compress/message_decompress_filter.cc \
src/core/ext/filters/http/server/http_server_filter.cc \
src/core/ext/filters/max_age/max_age_filter.cc \
src/core/ext/filters/message_size/message_size_filter.cc \
src/core/ext/transport/chttp2/alpn/alpn.cc \
src/core/ext/transport/chttp2/client/chttp2_connector.cc \

@ -312,6 +312,7 @@ libs:
- include/grpc/status.h
- include/grpc/support/workaround_list.h
headers:
- src/core/ext/filters/channel_idle/idle_filter_state.h
- src/core/ext/filters/client_channel/backend_metric.h
- src/core/ext/filters/client_channel/backup_poller.h
- src/core/ext/filters/client_channel/client_channel.h
@ -355,7 +356,6 @@ libs:
- src/core/ext/filters/client_channel/subchannel_interface.h
- src/core/ext/filters/client_channel/subchannel_pool_interface.h
- src/core/ext/filters/client_channel/subchannel_stream_client.h
- src/core/ext/filters/client_idle/idle_filter_state.h
- src/core/ext/filters/deadline/deadline_filter.h
- src/core/ext/filters/fault_injection/fault_injection_filter.h
- src/core/ext/filters/fault_injection/service_config_parser.h
@ -364,7 +364,6 @@ libs:
- src/core/ext/filters/http/message_compress/message_compress_filter.h
- src/core/ext/filters/http/message_compress/message_decompress_filter.h
- src/core/ext/filters/http/server/http_server_filter.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/rbac/rbac_filter.h
- src/core/ext/filters/rbac/rbac_service_config_parser.h
@ -736,6 +735,7 @@ libs:
- src/core/lib/gprpp/overload.h
- src/core/lib/gprpp/ref_counted.h
- src/core/lib/gprpp/ref_counted_ptr.h
- src/core/lib/gprpp/single_set_ptr.h
- src/core/lib/gprpp/table.h
- src/core/lib/gprpp/time.h
- src/core/lib/http/format_request.h
@ -969,6 +969,8 @@ libs:
- third_party/xxhash/xxhash.h
src:
- src/core/ext/filters/census/grpc_context.cc
- src/core/ext/filters/channel_idle/channel_idle_filter.cc
- src/core/ext/filters/channel_idle/idle_filter_state.cc
- src/core/ext/filters/client_channel/backend_metric.cc
- src/core/ext/filters/client_channel/backup_poller.cc
- src/core/ext/filters/client_channel/channel_connectivity.cc
@ -1027,8 +1029,6 @@ libs:
- src/core/ext/filters/client_channel/subchannel.cc
- src/core/ext/filters/client_channel/subchannel_pool_interface.cc
- src/core/ext/filters/client_channel/subchannel_stream_client.cc
- src/core/ext/filters/client_idle/client_idle_filter.cc
- src/core/ext/filters/client_idle/idle_filter_state.cc
- src/core/ext/filters/deadline/deadline_filter.cc
- src/core/ext/filters/fault_injection/fault_injection_filter.cc
- src/core/ext/filters/fault_injection/service_config_parser.cc
@ -1038,7 +1038,6 @@ libs:
- src/core/ext/filters/http/message_compress/message_compress_filter.cc
- src/core/ext/filters/http/message_compress/message_decompress_filter.cc
- src/core/ext/filters/http/server/http_server_filter.cc
- src/core/ext/filters/max_age/max_age_filter.cc
- src/core/ext/filters/message_size/message_size_filter.cc
- src/core/ext/filters/rbac/rbac_filter.cc
- src/core/ext/filters/rbac/rbac_service_config_parser.cc
@ -1783,6 +1782,7 @@ libs:
- include/grpc/status.h
- include/grpc/support/workaround_list.h
headers:
- src/core/ext/filters/channel_idle/idle_filter_state.h
- src/core/ext/filters/client_channel/backend_metric.h
- src/core/ext/filters/client_channel/backup_poller.h
- src/core/ext/filters/client_channel/client_channel.h
@ -1823,7 +1823,6 @@ libs:
- src/core/ext/filters/client_channel/subchannel_interface.h
- src/core/ext/filters/client_channel/subchannel_pool_interface.h
- src/core/ext/filters/client_channel/subchannel_stream_client.h
- src/core/ext/filters/client_idle/idle_filter_state.h
- src/core/ext/filters/deadline/deadline_filter.h
- src/core/ext/filters/fault_injection/fault_injection_filter.h
- src/core/ext/filters/fault_injection/service_config_parser.h
@ -1832,7 +1831,6 @@ libs:
- src/core/ext/filters/http/message_compress/message_compress_filter.h
- src/core/ext/filters/http/message_compress/message_decompress_filter.h
- src/core/ext/filters/http/server/http_server_filter.h
- src/core/ext/filters/max_age/max_age_filter.h
- src/core/ext/filters/message_size/message_size_filter.h
- src/core/ext/transport/chttp2/alpn/alpn.h
- src/core/ext/transport/chttp2/client/chttp2_connector.h
@ -1916,6 +1914,7 @@ libs:
- src/core/lib/gprpp/overload.h
- src/core/lib/gprpp/ref_counted.h
- src/core/lib/gprpp/ref_counted_ptr.h
- src/core/lib/gprpp/single_set_ptr.h
- src/core/lib/gprpp/table.h
- src/core/lib/gprpp/time.h
- src/core/lib/http/format_request.h
@ -2093,6 +2092,8 @@ libs:
- third_party/xxhash/xxhash.h
src:
- src/core/ext/filters/census/grpc_context.cc
- src/core/ext/filters/channel_idle/channel_idle_filter.cc
- src/core/ext/filters/channel_idle/idle_filter_state.cc
- src/core/ext/filters/client_channel/backend_metric.cc
- src/core/ext/filters/client_channel/backup_poller.cc
- src/core/ext/filters/client_channel/channel_connectivity.cc
@ -2145,8 +2146,6 @@ libs:
- src/core/ext/filters/client_channel/subchannel.cc
- src/core/ext/filters/client_channel/subchannel_pool_interface.cc
- src/core/ext/filters/client_channel/subchannel_stream_client.cc
- src/core/ext/filters/client_idle/client_idle_filter.cc
- src/core/ext/filters/client_idle/idle_filter_state.cc
- src/core/ext/filters/deadline/deadline_filter.cc
- src/core/ext/filters/fault_injection/fault_injection_filter.cc
- src/core/ext/filters/fault_injection/service_config_parser.cc
@ -2156,7 +2155,6 @@ libs:
- src/core/ext/filters/http/message_compress/message_compress_filter.cc
- src/core/ext/filters/http/message_compress/message_decompress_filter.cc
- src/core/ext/filters/http/server/http_server_filter.cc
- src/core/ext/filters/max_age/max_age_filter.cc
- src/core/ext/filters/message_size/message_size_filter.cc
- src/core/ext/transport/chttp2/alpn/alpn.cc
- src/core/ext/transport/chttp2/client/chttp2_connector.cc
@ -6213,9 +6211,9 @@ targets:
build: test
language: c++
headers:
- src/core/ext/filters/client_idle/idle_filter_state.h
- src/core/ext/filters/channel_idle/idle_filter_state.h
src:
- src/core/ext/filters/client_idle/idle_filter_state.cc
- src/core/ext/filters/channel_idle/idle_filter_state.cc
- test/core/client_idle/idle_filter_state_test.cc
deps: []
uses_polling: false

8
config.m4 generated

@ -41,6 +41,8 @@ if test "$PHP_GRPC" != "no"; then
PHP_NEW_EXTENSION(grpc,
src/core/ext/filters/census/grpc_context.cc \
src/core/ext/filters/channel_idle/channel_idle_filter.cc \
src/core/ext/filters/channel_idle/idle_filter_state.cc \
src/core/ext/filters/client_channel/backend_metric.cc \
src/core/ext/filters/client_channel/backup_poller.cc \
src/core/ext/filters/client_channel/channel_connectivity.cc \
@ -99,8 +101,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/filters/client_channel/subchannel.cc \
src/core/ext/filters/client_channel/subchannel_pool_interface.cc \
src/core/ext/filters/client_channel/subchannel_stream_client.cc \
src/core/ext/filters/client_idle/client_idle_filter.cc \
src/core/ext/filters/client_idle/idle_filter_state.cc \
src/core/ext/filters/deadline/deadline_filter.cc \
src/core/ext/filters/fault_injection/fault_injection_filter.cc \
src/core/ext/filters/fault_injection/service_config_parser.cc \
@ -110,7 +110,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/filters/http/message_compress/message_compress_filter.cc \
src/core/ext/filters/http/message_compress/message_decompress_filter.cc \
src/core/ext/filters/http/server/http_server_filter.cc \
src/core/ext/filters/max_age/max_age_filter.cc \
src/core/ext/filters/message_size/message_size_filter.cc \
src/core/ext/filters/rbac/rbac_filter.cc \
src/core/ext/filters/rbac/rbac_service_config_parser.cc \
@ -1167,6 +1166,7 @@ if test "$PHP_GRPC" != "no"; then
-DGRPC_XDS_USER_AGENT_VERSION_SUFFIX='"\"1.46.0dev\""')
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/census)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/channel_idle)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/health)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/lb_policy)
@ -1187,14 +1187,12 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/google_c2p)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/sockaddr)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/xds)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_idle)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/deadline)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/fault_injection)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http/client)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http/message_compress)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http/server)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/max_age)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/message_size)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/rbac)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/server_config_selector)

8
config.w32 generated

@ -7,6 +7,8 @@ if (PHP_GRPC != "no") {
EXTENSION("grpc",
"src\\core\\ext\\filters\\census\\grpc_context.cc " +
"src\\core\\ext\\filters\\channel_idle\\channel_idle_filter.cc " +
"src\\core\\ext\\filters\\channel_idle\\idle_filter_state.cc " +
"src\\core\\ext\\filters\\client_channel\\backend_metric.cc " +
"src\\core\\ext\\filters\\client_channel\\backup_poller.cc " +
"src\\core\\ext\\filters\\client_channel\\channel_connectivity.cc " +
@ -65,8 +67,6 @@ if (PHP_GRPC != "no") {
"src\\core\\ext\\filters\\client_channel\\subchannel.cc " +
"src\\core\\ext\\filters\\client_channel\\subchannel_pool_interface.cc " +
"src\\core\\ext\\filters\\client_channel\\subchannel_stream_client.cc " +
"src\\core\\ext\\filters\\client_idle\\client_idle_filter.cc " +
"src\\core\\ext\\filters\\client_idle\\idle_filter_state.cc " +
"src\\core\\ext\\filters\\deadline\\deadline_filter.cc " +
"src\\core\\ext\\filters\\fault_injection\\fault_injection_filter.cc " +
"src\\core\\ext\\filters\\fault_injection\\service_config_parser.cc " +
@ -76,7 +76,6 @@ if (PHP_GRPC != "no") {
"src\\core\\ext\\filters\\http\\message_compress\\message_compress_filter.cc " +
"src\\core\\ext\\filters\\http\\message_compress\\message_decompress_filter.cc " +
"src\\core\\ext\\filters\\http\\server\\http_server_filter.cc " +
"src\\core\\ext\\filters\\max_age\\max_age_filter.cc " +
"src\\core\\ext\\filters\\message_size\\message_size_filter.cc " +
"src\\core\\ext\\filters\\rbac\\rbac_filter.cc " +
"src\\core\\ext\\filters\\rbac\\rbac_service_config_parser.cc " +
@ -1165,6 +1164,7 @@ if (PHP_GRPC != "no") {
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\census");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\channel_idle");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\health");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\lb_policy");
@ -1185,14 +1185,12 @@ if (PHP_GRPC != "no") {
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\resolver\\google_c2p");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_channel\\resolver\\xds");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\client_idle");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\deadline");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\fault_injection");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\http");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\http\\client");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\http\\message_compress");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\http\\server");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\max_age");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\message_size");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\rbac");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\server_config_selector");

12
gRPC-C++.podspec generated

@ -214,7 +214,8 @@ Pod::Spec.new do |s|
ss.dependency 'abseil/types/variant', abseil_version
ss.dependency 'abseil/utility/utility', abseil_version
ss.source_files = 'src/core/ext/filters/client_channel/backend_metric.h',
ss.source_files = 'src/core/ext/filters/channel_idle/idle_filter_state.h',
'src/core/ext/filters/client_channel/backend_metric.h',
'src/core/ext/filters/client_channel/backup_poller.h',
'src/core/ext/filters/client_channel/client_channel.h',
'src/core/ext/filters/client_channel/client_channel_channelz.h',
@ -257,7 +258,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/subchannel_interface.h',
'src/core/ext/filters/client_channel/subchannel_pool_interface.h',
'src/core/ext/filters/client_channel/subchannel_stream_client.h',
'src/core/ext/filters/client_idle/idle_filter_state.h',
'src/core/ext/filters/deadline/deadline_filter.h',
'src/core/ext/filters/fault_injection/fault_injection_filter.h',
'src/core/ext/filters/fault_injection/service_config_parser.h',
@ -266,7 +266,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/http/message_compress/message_compress_filter.h',
'src/core/ext/filters/http/message_compress/message_decompress_filter.h',
'src/core/ext/filters/http/server/http_server_filter.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/rbac/rbac_filter.h',
'src/core/ext/filters/rbac/rbac_service_config_parser.h',
@ -698,6 +697,7 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/overload.h',
'src/core/lib/gprpp/ref_counted.h',
'src/core/lib/gprpp/ref_counted_ptr.h',
'src/core/lib/gprpp/single_set_ptr.h',
'src/core/lib/gprpp/stat.h',
'src/core/lib/gprpp/status_helper.h',
'src/core/lib/gprpp/sync.h',
@ -1041,7 +1041,8 @@ Pod::Spec.new do |s|
'third_party/upb/upb/upb_internal.h',
'third_party/xxhash/xxhash.h'
ss.private_header_files = 'src/core/ext/filters/client_channel/backend_metric.h',
ss.private_header_files = 'src/core/ext/filters/channel_idle/idle_filter_state.h',
'src/core/ext/filters/client_channel/backend_metric.h',
'src/core/ext/filters/client_channel/backup_poller.h',
'src/core/ext/filters/client_channel/client_channel.h',
'src/core/ext/filters/client_channel/client_channel_channelz.h',
@ -1084,7 +1085,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/subchannel_interface.h',
'src/core/ext/filters/client_channel/subchannel_pool_interface.h',
'src/core/ext/filters/client_channel/subchannel_stream_client.h',
'src/core/ext/filters/client_idle/idle_filter_state.h',
'src/core/ext/filters/deadline/deadline_filter.h',
'src/core/ext/filters/fault_injection/fault_injection_filter.h',
'src/core/ext/filters/fault_injection/service_config_parser.h',
@ -1093,7 +1093,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/http/message_compress/message_compress_filter.h',
'src/core/ext/filters/http/message_compress/message_decompress_filter.h',
'src/core/ext/filters/http/server/http_server_filter.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/rbac/rbac_filter.h',
'src/core/ext/filters/rbac/rbac_service_config_parser.h',
@ -1507,6 +1506,7 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/overload.h',
'src/core/lib/gprpp/ref_counted.h',
'src/core/lib/gprpp/ref_counted_ptr.h',
'src/core/lib/gprpp/single_set_ptr.h',
'src/core/lib/gprpp/stat.h',
'src/core/lib/gprpp/status_helper.h',
'src/core/lib/gprpp/sync.h',

15
gRPC-Core.podspec generated

@ -192,6 +192,9 @@ Pod::Spec.new do |s|
ss.compiler_flags = '-DBORINGSSL_PREFIX=GRPC -Wno-unreachable-code -Wno-shorten-64-to-32'
ss.source_files = 'src/core/ext/filters/census/grpc_context.cc',
'src/core/ext/filters/channel_idle/channel_idle_filter.cc',
'src/core/ext/filters/channel_idle/idle_filter_state.cc',
'src/core/ext/filters/channel_idle/idle_filter_state.h',
'src/core/ext/filters/client_channel/backend_metric.cc',
'src/core/ext/filters/client_channel/backend_metric.h',
'src/core/ext/filters/client_channel/backup_poller.cc',
@ -293,9 +296,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/subchannel_pool_interface.h',
'src/core/ext/filters/client_channel/subchannel_stream_client.cc',
'src/core/ext/filters/client_channel/subchannel_stream_client.h',
'src/core/ext/filters/client_idle/client_idle_filter.cc',
'src/core/ext/filters/client_idle/idle_filter_state.cc',
'src/core/ext/filters/client_idle/idle_filter_state.h',
'src/core/ext/filters/deadline/deadline_filter.cc',
'src/core/ext/filters/deadline/deadline_filter.h',
'src/core/ext/filters/fault_injection/fault_injection_filter.cc',
@ -313,8 +313,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/http/message_compress/message_decompress_filter.h',
'src/core/ext/filters/http/server/http_server_filter.cc',
'src/core/ext/filters/http/server/http_server_filter.h',
'src/core/ext/filters/max_age/max_age_filter.cc',
'src/core/ext/filters/max_age/max_age_filter.h',
'src/core/ext/filters/message_size/message_size_filter.cc',
'src/core/ext/filters/message_size/message_size_filter.h',
'src/core/ext/filters/rbac/rbac_filter.cc',
@ -1101,6 +1099,7 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/overload.h',
'src/core/lib/gprpp/ref_counted.h',
'src/core/lib/gprpp/ref_counted_ptr.h',
'src/core/lib/gprpp/single_set_ptr.h',
'src/core/lib/gprpp/stat.h',
'src/core/lib/gprpp/stat_posix.cc',
'src/core/lib/gprpp/stat_windows.cc',
@ -1663,7 +1662,8 @@ Pod::Spec.new do |s|
'third_party/upb/upb/upb.hpp',
'third_party/upb/upb/upb_internal.h',
'third_party/xxhash/xxhash.h'
ss.private_header_files = 'src/core/ext/filters/client_channel/backend_metric.h',
ss.private_header_files = 'src/core/ext/filters/channel_idle/idle_filter_state.h',
'src/core/ext/filters/client_channel/backend_metric.h',
'src/core/ext/filters/client_channel/backup_poller.h',
'src/core/ext/filters/client_channel/client_channel.h',
'src/core/ext/filters/client_channel/client_channel_channelz.h',
@ -1706,7 +1706,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/subchannel_interface.h',
'src/core/ext/filters/client_channel/subchannel_pool_interface.h',
'src/core/ext/filters/client_channel/subchannel_stream_client.h',
'src/core/ext/filters/client_idle/idle_filter_state.h',
'src/core/ext/filters/deadline/deadline_filter.h',
'src/core/ext/filters/fault_injection/fault_injection_filter.h',
'src/core/ext/filters/fault_injection/service_config_parser.h',
@ -1715,7 +1714,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/http/message_compress/message_compress_filter.h',
'src/core/ext/filters/http/message_compress/message_decompress_filter.h',
'src/core/ext/filters/http/server/http_server_filter.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/rbac/rbac_filter.h',
'src/core/ext/filters/rbac/rbac_service_config_parser.h',
@ -2109,6 +2107,7 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/overload.h',
'src/core/lib/gprpp/ref_counted.h',
'src/core/lib/gprpp/ref_counted_ptr.h',
'src/core/lib/gprpp/single_set_ptr.h',
'src/core/lib/gprpp/stat.h',
'src/core/lib/gprpp/status_helper.h',
'src/core/lib/gprpp/sync.h',

9
grpc.gemspec generated

@ -111,6 +111,9 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/support/time.h )
s.files += %w( include/grpc/support/workaround_list.h )
s.files += %w( src/core/ext/filters/census/grpc_context.cc )
s.files += %w( src/core/ext/filters/channel_idle/channel_idle_filter.cc )
s.files += %w( src/core/ext/filters/channel_idle/idle_filter_state.cc )
s.files += %w( src/core/ext/filters/channel_idle/idle_filter_state.h )
s.files += %w( src/core/ext/filters/client_channel/backend_metric.cc )
s.files += %w( src/core/ext/filters/client_channel/backend_metric.h )
s.files += %w( src/core/ext/filters/client_channel/backup_poller.cc )
@ -212,9 +215,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/filters/client_channel/subchannel_pool_interface.h )
s.files += %w( src/core/ext/filters/client_channel/subchannel_stream_client.cc )
s.files += %w( src/core/ext/filters/client_channel/subchannel_stream_client.h )
s.files += %w( src/core/ext/filters/client_idle/client_idle_filter.cc )
s.files += %w( src/core/ext/filters/client_idle/idle_filter_state.cc )
s.files += %w( src/core/ext/filters/client_idle/idle_filter_state.h )
s.files += %w( src/core/ext/filters/deadline/deadline_filter.cc )
s.files += %w( src/core/ext/filters/deadline/deadline_filter.h )
s.files += %w( src/core/ext/filters/fault_injection/fault_injection_filter.cc )
@ -232,8 +232,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/filters/http/message_compress/message_decompress_filter.h )
s.files += %w( src/core/ext/filters/http/server/http_server_filter.cc )
s.files += %w( src/core/ext/filters/http/server/http_server_filter.h )
s.files += %w( src/core/ext/filters/max_age/max_age_filter.cc )
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.cc )
s.files += %w( src/core/ext/filters/message_size/message_size_filter.h )
s.files += %w( src/core/ext/filters/rbac/rbac_filter.cc )
@ -1020,6 +1018,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/gprpp/overload.h )
s.files += %w( src/core/lib/gprpp/ref_counted.h )
s.files += %w( src/core/lib/gprpp/ref_counted_ptr.h )
s.files += %w( src/core/lib/gprpp/single_set_ptr.h )
s.files += %w( src/core/lib/gprpp/stat.h )
s.files += %w( src/core/lib/gprpp/stat_posix.cc )
s.files += %w( src/core/lib/gprpp/stat_windows.cc )

10
grpc.gyp generated

@ -371,6 +371,8 @@
],
'sources': [
'src/core/ext/filters/census/grpc_context.cc',
'src/core/ext/filters/channel_idle/channel_idle_filter.cc',
'src/core/ext/filters/channel_idle/idle_filter_state.cc',
'src/core/ext/filters/client_channel/backend_metric.cc',
'src/core/ext/filters/client_channel/backup_poller.cc',
'src/core/ext/filters/client_channel/channel_connectivity.cc',
@ -429,8 +431,6 @@
'src/core/ext/filters/client_channel/subchannel.cc',
'src/core/ext/filters/client_channel/subchannel_pool_interface.cc',
'src/core/ext/filters/client_channel/subchannel_stream_client.cc',
'src/core/ext/filters/client_idle/client_idle_filter.cc',
'src/core/ext/filters/client_idle/idle_filter_state.cc',
'src/core/ext/filters/deadline/deadline_filter.cc',
'src/core/ext/filters/fault_injection/fault_injection_filter.cc',
'src/core/ext/filters/fault_injection/service_config_parser.cc',
@ -440,7 +440,6 @@
'src/core/ext/filters/http/message_compress/message_compress_filter.cc',
'src/core/ext/filters/http/message_compress/message_decompress_filter.cc',
'src/core/ext/filters/http/server/http_server_filter.cc',
'src/core/ext/filters/max_age/max_age_filter.cc',
'src/core/ext/filters/message_size/message_size_filter.cc',
'src/core/ext/filters/rbac/rbac_filter.cc',
'src/core/ext/filters/rbac/rbac_service_config_parser.cc',
@ -1127,6 +1126,8 @@
],
'sources': [
'src/core/ext/filters/census/grpc_context.cc',
'src/core/ext/filters/channel_idle/channel_idle_filter.cc',
'src/core/ext/filters/channel_idle/idle_filter_state.cc',
'src/core/ext/filters/client_channel/backend_metric.cc',
'src/core/ext/filters/client_channel/backup_poller.cc',
'src/core/ext/filters/client_channel/channel_connectivity.cc',
@ -1179,8 +1180,6 @@
'src/core/ext/filters/client_channel/subchannel.cc',
'src/core/ext/filters/client_channel/subchannel_pool_interface.cc',
'src/core/ext/filters/client_channel/subchannel_stream_client.cc',
'src/core/ext/filters/client_idle/client_idle_filter.cc',
'src/core/ext/filters/client_idle/idle_filter_state.cc',
'src/core/ext/filters/deadline/deadline_filter.cc',
'src/core/ext/filters/fault_injection/fault_injection_filter.cc',
'src/core/ext/filters/fault_injection/service_config_parser.cc',
@ -1190,7 +1189,6 @@
'src/core/ext/filters/http/message_compress/message_compress_filter.cc',
'src/core/ext/filters/http/message_compress/message_decompress_filter.cc',
'src/core/ext/filters/http/server/http_server_filter.cc',
'src/core/ext/filters/max_age/max_age_filter.cc',
'src/core/ext/filters/message_size/message_size_filter.cc',
'src/core/ext/transport/chttp2/alpn/alpn.cc',
'src/core/ext/transport/chttp2/client/chttp2_connector.cc',

9
package.xml generated

@ -91,6 +91,9 @@
<file baseinstalldir="/" name="include/grpc/support/time.h" role="src" />
<file baseinstalldir="/" name="include/grpc/support/workaround_list.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/census/grpc_context.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/channel_idle/channel_idle_filter.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/channel_idle/idle_filter_state.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/channel_idle/idle_filter_state.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/backend_metric.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/backend_metric.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/backup_poller.cc" role="src" />
@ -192,9 +195,6 @@
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/subchannel_pool_interface.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/subchannel_stream_client.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/subchannel_stream_client.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_idle/client_idle_filter.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_idle/idle_filter_state.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_idle/idle_filter_state.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/deadline/deadline_filter.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/deadline/deadline_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/fault_injection/fault_injection_filter.cc" role="src" />
@ -212,8 +212,6 @@
<file baseinstalldir="/" name="src/core/ext/filters/http/message_compress/message_decompress_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/http/server/http_server_filter.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/http/server/http_server_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/max_age/max_age_filter.cc" 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.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/message_size/message_size_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/rbac/rbac_filter.cc" role="src" />
@ -1000,6 +998,7 @@
<file baseinstalldir="/" name="src/core/lib/gprpp/overload.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/ref_counted.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/ref_counted_ptr.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/single_set_ptr.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/stat.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/stat_posix.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/stat_windows.cc" role="src" />

@ -0,0 +1,406 @@
// Copyright 2022 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.
// TODO(ctiller): Add a unit test suite for these filters once it's practical to
// mock transport operations.
#include <grpc/support/port_platform.h>
#include <limits.h>
#include <stdlib.h>
#include <atomic>
#include <limits>
#include "src/core/ext/filters/channel_idle/idle_filter_state.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/channel/promise_based_filter.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gprpp/capture.h"
#include "src/core/lib/gprpp/single_set_ptr.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/promise/exec_ctx_wakeup_scheduler.h"
#include "src/core/lib/promise/loop.h"
#include "src/core/lib/promise/sleep.h"
#include "src/core/lib/promise/try_seq.h"
#include "src/core/lib/transport/http2_errors.h"
// TODO(juanlishen): The idle filter was disabled in client channel by default
// due to b/143502997. Now the bug is fixed enable the filter by default.
#define DEFAULT_IDLE_TIMEOUT_MS INT_MAX
// The user input idle timeout smaller than this would be capped to it.
#define MIN_IDLE_TIMEOUT_MS (1 /*second*/ * 1000)
// If these settings change, make sure that we are not sending a GOAWAY for
// inproc transport, since a GOAWAY to inproc ends up destroying the transport.
#define DEFAULT_MAX_CONNECTION_AGE_MS INT_MAX
#define DEFAULT_MAX_CONNECTION_AGE_GRACE_MS INT_MAX
#define DEFAULT_MAX_CONNECTION_IDLE_MS INT_MAX
#define MAX_CONNECTION_AGE_JITTER 0.1
#define MAX_CONNECTION_AGE_INTEGER_OPTIONS \
{ DEFAULT_MAX_CONNECTION_AGE_MS, 1, INT_MAX }
#define MAX_CONNECTION_IDLE_INTEGER_OPTIONS \
{ DEFAULT_MAX_CONNECTION_IDLE_MS, 1, INT_MAX }
namespace grpc_core {
TraceFlag grpc_trace_client_idle_filter(false, "client_idle_filter");
#define GRPC_IDLE_FILTER_LOG(format, ...) \
do { \
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_client_idle_filter)) { \
gpr_log(GPR_INFO, "(client idle filter) " format, ##__VA_ARGS__); \
} \
} while (0)
namespace {
using SingleSetActivityPtr =
SingleSetPtr<Activity, typename ActivityPtr::deleter_type>;
Duration GetClientIdleTimeout(const grpc_channel_args* args) {
int ms = std::max(
grpc_channel_arg_get_integer(
grpc_channel_args_find(args, GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS),
{DEFAULT_IDLE_TIMEOUT_MS, 0, INT_MAX}),
MIN_IDLE_TIMEOUT_MS);
return ms == INT_MAX ? Duration::Infinity() : Duration::Milliseconds(ms);
}
struct MaxAgeConfig {
Duration max_connection_age;
Duration max_connection_idle;
Duration max_connection_age_grace;
bool enable() const {
return max_connection_age != Duration::Infinity() ||
max_connection_idle != Duration::Infinity();
}
};
/* A random jitter of +/-10% will be added to MAX_CONNECTION_AGE to spread out
connection storms. Note that the MAX_CONNECTION_AGE option without jitter
would not create connection storms by itself, but if there happened to be a
connection storm it could cause it to repeat at a fixed period. */
MaxAgeConfig GetMaxAgeConfig(const grpc_channel_args* args) {
const int args_max_age = grpc_channel_arg_get_integer(
grpc_channel_args_find(args, GRPC_ARG_MAX_CONNECTION_AGE_MS),
MAX_CONNECTION_AGE_INTEGER_OPTIONS);
const int args_max_idle = grpc_channel_arg_get_integer(
grpc_channel_args_find(args, GRPC_ARG_MAX_CONNECTION_IDLE_MS),
MAX_CONNECTION_IDLE_INTEGER_OPTIONS);
const int args_max_age_grace = grpc_channel_arg_get_integer(
grpc_channel_args_find(args, GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS),
{DEFAULT_MAX_CONNECTION_AGE_GRACE_MS, 0, INT_MAX});
/* generate a random number between 1 - MAX_CONNECTION_AGE_JITTER and
1 + MAX_CONNECTION_AGE_JITTER */
const double multiplier =
rand() * MAX_CONNECTION_AGE_JITTER * 2.0 / RAND_MAX + 1.0 -
MAX_CONNECTION_AGE_JITTER;
/* GRPC_MILLIS_INF_FUTURE - 0.5 converts the value to float, so that result
will not be cast to int implicitly before the comparison. */
return MaxAgeConfig{
args_max_age == INT_MAX
? Duration::Infinity()
: Duration::FromSecondsAsDouble(multiplier * args_max_age / 1000.0),
args_max_idle == INT_MAX ? Duration::Infinity()
: Duration::Milliseconds(args_max_idle),
Duration::Milliseconds(args_max_age_grace)};
}
class ChannelIdleFilter : public ChannelFilter {
public:
~ChannelIdleFilter() override = default;
ChannelIdleFilter(const ChannelIdleFilter&) = delete;
ChannelIdleFilter& operator=(const ChannelIdleFilter&) = delete;
ChannelIdleFilter(ChannelIdleFilter&&) = default;
ChannelIdleFilter& operator=(ChannelIdleFilter&&) = default;
// Construct a promise for one call.
ArenaPromise<ServerMetadataHandle> MakeCallPromise(
CallArgs call_args, NextPromiseFactory next_promise_factory) override;
bool StartTransportOp(grpc_transport_op* op) override;
protected:
ChannelIdleFilter(grpc_channel_stack* channel_stack,
Duration client_idle_timeout)
: channel_stack_(channel_stack),
client_idle_timeout_(client_idle_timeout) {}
grpc_channel_stack* channel_stack() { return channel_stack_; };
virtual void Shutdown();
void CloseChannel();
void IncreaseCallCount();
void DecreaseCallCount();
private:
void StartIdleTimer();
struct CallCountDecreaser {
void operator()(ChannelIdleFilter* filter) const {
filter->DecreaseCallCount();
}
};
// The channel stack to which we take refs for pending callbacks.
grpc_channel_stack* channel_stack_;
Duration client_idle_timeout_;
std::shared_ptr<IdleFilterState> idle_filter_state_{
std::make_shared<IdleFilterState>(false)};
SingleSetActivityPtr activity_;
};
class ClientIdleFilter final : public ChannelIdleFilter {
public:
static absl::StatusOr<ClientIdleFilter> Create(
const grpc_channel_args* args, ChannelFilter::Args filter_args);
private:
using ChannelIdleFilter::ChannelIdleFilter;
};
class MaxAgeFilter final : public ChannelIdleFilter {
public:
static absl::StatusOr<MaxAgeFilter> Create(const grpc_channel_args* args,
ChannelFilter::Args filter_args);
void Start();
private:
class ConnectivityWatcher : public AsyncConnectivityStateWatcherInterface {
public:
explicit ConnectivityWatcher(MaxAgeFilter* filter)
: channel_stack_(filter->channel_stack()->Ref()), filter_(filter) {}
~ConnectivityWatcher() override = default;
void OnConnectivityStateChange(grpc_connectivity_state new_state,
const absl::Status&) override {
if (new_state == GRPC_CHANNEL_SHUTDOWN) filter_->Shutdown();
}
private:
RefCountedPtr<grpc_channel_stack> channel_stack_;
MaxAgeFilter* filter_;
};
MaxAgeFilter(grpc_channel_stack* channel_stack,
const MaxAgeConfig& max_age_config)
: ChannelIdleFilter(channel_stack, max_age_config.max_connection_idle),
max_connection_age_(max_age_config.max_connection_age),
max_connection_age_grace_(max_age_config.max_connection_age_grace) {}
void Shutdown() override;
SingleSetActivityPtr max_age_activity_;
Duration max_connection_age_;
Duration max_connection_age_grace_;
};
absl::StatusOr<ClientIdleFilter> ClientIdleFilter::Create(
const grpc_channel_args* args, ChannelFilter::Args filter_args) {
ClientIdleFilter filter(filter_args.channel_stack(),
GetClientIdleTimeout(args));
return absl::StatusOr<ClientIdleFilter>(std::move(filter));
}
absl::StatusOr<MaxAgeFilter> MaxAgeFilter::Create(
const grpc_channel_args* args, ChannelFilter::Args filter_args) {
const auto config = GetMaxAgeConfig(args);
MaxAgeFilter filter(filter_args.channel_stack(), config);
return absl::StatusOr<MaxAgeFilter>(std::move(filter));
}
void MaxAgeFilter::Shutdown() {
max_age_activity_.Reset();
ChannelIdleFilter::Shutdown();
}
void MaxAgeFilter::Start() {
// Trigger idle timer immediately
IncreaseCallCount();
DecreaseCallCount();
struct StartupClosure {
RefCountedPtr<grpc_channel_stack> channel_stack;
MaxAgeFilter* filter;
grpc_closure closure;
};
auto run_startup = [](void* p, grpc_error_handle) {
auto* startup = static_cast<StartupClosure*>(p);
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->start_connectivity_watch.reset(
new ConnectivityWatcher(startup->filter));
op->start_connectivity_watch_state = GRPC_CHANNEL_IDLE;
grpc_channel_next_op(
grpc_channel_stack_element(startup->channel_stack.get(), 0), op);
delete startup;
};
auto* startup =
new StartupClosure{this->channel_stack()->Ref(), this, grpc_closure{}};
GRPC_CLOSURE_INIT(&startup->closure, run_startup, startup, nullptr);
ExecCtx::Run(DEBUG_LOCATION, &startup->closure, GRPC_ERROR_NONE);
auto channel_stack = this->channel_stack()->Ref();
// Start the max age timer
if (max_connection_age_ != Duration::Infinity()) {
max_age_activity_.Set(MakeActivity(
TrySeq(
// First sleep until the max connection age
Sleep(ExecCtx::Get()->Now() + max_connection_age_),
// Then send a goaway.
[this] {
GRPC_CHANNEL_STACK_REF(this->channel_stack(),
"max_age send_goaway");
// Jump out of the activity to send the goaway.
auto fn = [](void* arg, grpc_error_handle) {
auto* channel_stack = static_cast<grpc_channel_stack*>(arg);
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->goaway_error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("max_age"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_NO_ERROR);
grpc_channel_element* elem =
grpc_channel_stack_element(channel_stack, 0);
elem->filter->start_transport_op(elem, op);
GRPC_CHANNEL_STACK_UNREF(channel_stack, "max_age send_goaway");
};
ExecCtx::Run(
DEBUG_LOCATION,
GRPC_CLOSURE_CREATE(fn, this->channel_stack(), nullptr),
GRPC_ERROR_NONE);
return Immediate(absl::OkStatus());
},
// Sleep for the grace period
[this] {
return Sleep(ExecCtx::Get()->Now() + max_connection_age_grace_);
}),
ExecCtxWakeupScheduler(), [channel_stack, this](absl::Status status) {
// OnDone -- close the connection if the promise completed
// successfully.
// (if it did not, it was cancelled)
if (status.ok()) CloseChannel();
}));
}
}
// Construct a promise for one call.
ArenaPromise<ServerMetadataHandle> ChannelIdleFilter::MakeCallPromise(
CallArgs call_args, NextPromiseFactory next_promise_factory) {
using Decrementer = std::unique_ptr<ChannelIdleFilter, CallCountDecreaser>;
IncreaseCallCount();
return ArenaPromise<ServerMetadataHandle>(
Capture([](Decrementer*, ArenaPromise<ServerMetadataHandle>* next)
-> Poll<ServerMetadataHandle> { return (*next)(); },
Decrementer(this), next_promise_factory(std::move(call_args))));
}
bool ChannelIdleFilter::StartTransportOp(grpc_transport_op* op) {
// Catch the disconnect_with_error transport op.
if (op->disconnect_with_error != GRPC_ERROR_NONE) Shutdown();
// Pass the op to the next filter.
return false;
}
void ChannelIdleFilter::Shutdown() {
// IncreaseCallCount() introduces a phony call and prevent the timer from
// being reset by other threads.
IncreaseCallCount();
activity_.Reset();
}
void ChannelIdleFilter::IncreaseCallCount() {
idle_filter_state_->IncreaseCallCount();
}
void ChannelIdleFilter::DecreaseCallCount() {
if (idle_filter_state_->DecreaseCallCount()) {
// If there are no more calls in progress, start the idle timer.
StartIdleTimer();
}
}
void ChannelIdleFilter::StartIdleTimer() {
GRPC_IDLE_FILTER_LOG("timer has started");
auto idle_filter_state = idle_filter_state_;
// Hold a ref to the channel stack for the timer callback.
auto channel_stack = channel_stack_->Ref();
auto timeout = client_idle_timeout_;
auto promise = Loop([timeout, idle_filter_state]() {
return TrySeq(Sleep(ExecCtx::Get()->Now() + timeout),
[idle_filter_state]() -> Poll<LoopCtl<absl::Status>> {
if (idle_filter_state->CheckTimer()) {
return Continue{};
} else {
return absl::OkStatus();
}
});
});
activity_.Set(MakeActivity(std::move(promise), ExecCtxWakeupScheduler{},
[channel_stack, this](absl::Status status) {
if (status.ok()) CloseChannel();
}));
}
void ChannelIdleFilter::CloseChannel() {
auto* op = grpc_make_transport_op(nullptr);
op->disconnect_with_error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("enter idle"),
GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE, GRPC_CHANNEL_IDLE);
// Pass the transport op down to the channel stack.
auto* elem = grpc_channel_stack_element(channel_stack_, 0);
elem->filter->start_transport_op(elem, op);
}
const grpc_channel_filter grpc_client_idle_filter =
MakePromiseBasedFilter<ClientIdleFilter, FilterEndpoint::kClient>(
"client_idle");
const grpc_channel_filter grpc_max_age_filter =
MakePromiseBasedFilter<MaxAgeFilter, FilterEndpoint::kServer>("max_age");
} // namespace
void RegisterChannelIdleFilters(CoreConfiguration::Builder* builder) {
builder->channel_init()->RegisterStage(
GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
[](ChannelStackBuilder* builder) {
const grpc_channel_args* channel_args = builder->channel_args();
if (!grpc_channel_args_want_minimal_stack(channel_args) &&
GetClientIdleTimeout(channel_args) != Duration::Infinity()) {
builder->PrependFilter(&grpc_client_idle_filter, nullptr);
}
return true;
});
builder->channel_init()->RegisterStage(
GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
[](ChannelStackBuilder* builder) {
const grpc_channel_args* channel_args = builder->channel_args();
if (!grpc_channel_args_want_minimal_stack(channel_args) &&
GetMaxAgeConfig(channel_args).enable()) {
builder->PrependFilter(
&grpc_max_age_filter,
[](grpc_channel_stack*, grpc_channel_element* elem) {
static_cast<MaxAgeFilter*>(elem->channel_data)->Start();
});
}
return true;
});
}
} // namespace grpc_core

@ -14,7 +14,7 @@
#include <grpc/support/port_platform.h>
#include "src/core/ext/filters/client_idle/idle_filter_state.h"
#include "src/core/ext/filters/channel_idle/idle_filter_state.h"
#include <assert.h>

@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_IDLE_IDLE_FILTER_STATE_H
#define GRPC_CORE_EXT_FILTERS_CLIENT_IDLE_IDLE_FILTER_STATE_H
#ifndef GRPC_CORE_EXT_FILTERS_CHANNEL_IDLE_IDLE_FILTER_STATE_H
#define GRPC_CORE_EXT_FILTERS_CHANNEL_IDLE_IDLE_FILTER_STATE_H
#include <grpc/support/port_platform.h>
@ -63,4 +63,4 @@ class IdleFilterState {
} // namespace grpc_core
#endif // GRPC_CORE_EXT_FILTERS_CLIENT_IDLE_IDLE_FILTER_STATE_H
#endif // GRPC_CORE_EXT_FILTERS_CHANNEL_IDLE_IDLE_FILTER_STATE_H

@ -1,199 +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.
*
*/
#include <grpc/support/port_platform.h>
#include <limits.h>
#include <atomic>
#include "src/core/ext/filters/client_idle/idle_filter_state.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/channel/promise_based_filter.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gprpp/capture.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/promise/exec_ctx_wakeup_scheduler.h"
#include "src/core/lib/promise/loop.h"
#include "src/core/lib/promise/sleep.h"
#include "src/core/lib/promise/try_seq.h"
#include "src/core/lib/transport/http2_errors.h"
// TODO(juanlishen): The idle filter is disabled in client channel by default
// due to b/143502997. Try to fix the bug and enable the filter by default.
#define DEFAULT_IDLE_TIMEOUT_MS INT_MAX
// The user input idle timeout smaller than this would be capped to it.
#define MIN_IDLE_TIMEOUT_MS (1 /*second*/ * 1000)
namespace grpc_core {
TraceFlag grpc_trace_client_idle_filter(false, "client_idle_filter");
#define GRPC_IDLE_FILTER_LOG(format, ...) \
do { \
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_client_idle_filter)) { \
gpr_log(GPR_INFO, "(client idle filter) " format, ##__VA_ARGS__); \
} \
} while (0)
namespace {
Duration GetClientIdleTimeout(const grpc_channel_args* args) {
auto millis = std::max(
grpc_channel_arg_get_integer(
grpc_channel_args_find(args, GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS),
{DEFAULT_IDLE_TIMEOUT_MS, 0, INT_MAX}),
MIN_IDLE_TIMEOUT_MS);
if (millis == INT_MAX) return Duration::Infinity();
return Duration::Milliseconds(millis);
}
class ClientIdleFilter : public ChannelFilter {
public:
static absl::StatusOr<ClientIdleFilter> Create(
const grpc_channel_args* args, ChannelFilter::Args filter_args);
~ClientIdleFilter() override = default;
ClientIdleFilter(const ClientIdleFilter&) = delete;
ClientIdleFilter& operator=(const ClientIdleFilter&) = delete;
ClientIdleFilter(ClientIdleFilter&&) = default;
ClientIdleFilter& operator=(ClientIdleFilter&&) = default;
// Construct a promise for one call.
ArenaPromise<ServerMetadataHandle> MakeCallPromise(
CallArgs call_args, NextPromiseFactory next_promise_factory) override;
bool StartTransportOp(grpc_transport_op* op) override;
private:
ClientIdleFilter(grpc_channel_stack* channel_stack,
Duration client_idle_timeout)
: channel_stack_(channel_stack),
client_idle_timeout_(client_idle_timeout) {}
void StartIdleTimer();
void IncreaseCallCount();
void DecreaseCallCount();
struct CallCountDecreaser {
void operator()(ClientIdleFilter* filter) const {
filter->DecreaseCallCount();
}
};
// The channel stack to which we take refs for pending callbacks.
grpc_channel_stack* channel_stack_;
Duration client_idle_timeout_;
std::shared_ptr<IdleFilterState> idle_filter_state_{
std::make_shared<IdleFilterState>(false)};
ActivityPtr activity_;
};
absl::StatusOr<ClientIdleFilter> ClientIdleFilter::Create(
const grpc_channel_args* args, ChannelFilter::Args filter_args) {
ClientIdleFilter filter(filter_args.channel_stack(),
GetClientIdleTimeout(args));
return absl::StatusOr<ClientIdleFilter>(std::move(filter));
}
// Construct a promise for one call.
ArenaPromise<ServerMetadataHandle> ClientIdleFilter::MakeCallPromise(
CallArgs call_args, NextPromiseFactory next_promise_factory) {
using Decrementer = std::unique_ptr<ClientIdleFilter, CallCountDecreaser>;
IncreaseCallCount();
return ArenaPromise<ServerMetadataHandle>(
Capture([](Decrementer*, ArenaPromise<ServerMetadataHandle>* next)
-> Poll<ServerMetadataHandle> { return (*next)(); },
Decrementer(this), next_promise_factory(std::move(call_args))));
}
bool ClientIdleFilter::StartTransportOp(grpc_transport_op* op) {
// Catch the disconnect_with_error transport op.
if (op->disconnect_with_error != GRPC_ERROR_NONE) {
// IncreaseCallCount() introduces a phony call and prevent the timer from
// being reset by other threads.
IncreaseCallCount();
activity_.reset();
}
// Pass the op to the next filter.
return false;
}
void ClientIdleFilter::IncreaseCallCount() {
idle_filter_state_->IncreaseCallCount();
}
void ClientIdleFilter::DecreaseCallCount() {
if (idle_filter_state_->DecreaseCallCount()) {
// If there are no more calls in progress, start the idle timer.
StartIdleTimer();
}
}
void ClientIdleFilter::StartIdleTimer() {
GRPC_IDLE_FILTER_LOG("timer has started");
auto idle_filter_state = idle_filter_state_;
// Hold a ref to the channel stack for the timer callback.
auto channel_stack = channel_stack_->Ref();
auto timeout = client_idle_timeout_;
auto promise = Loop([timeout, idle_filter_state]() {
return TrySeq(Sleep(ExecCtx::Get()->Now() + timeout),
[idle_filter_state]() -> Poll<LoopCtl<absl::Status>> {
if (idle_filter_state->CheckTimer()) {
return Continue{};
} else {
return absl::OkStatus();
}
});
});
activity_ = MakeActivity(
std::move(promise), ExecCtxWakeupScheduler{},
[channel_stack](absl::Status status) {
if (!status.ok()) return;
auto* op = grpc_make_transport_op(nullptr);
op->disconnect_with_error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("enter idle"),
GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE, GRPC_CHANNEL_IDLE);
// Pass the transport op down to the channel stack.
auto* elem = grpc_channel_stack_element(channel_stack.get(), 0);
elem->filter->start_transport_op(elem, op);
});
}
const grpc_channel_filter grpc_client_idle_filter =
MakePromiseBasedFilter<ClientIdleFilter, FilterEndpoint::kClient>(
"client_idle");
} // namespace
void RegisterClientIdleFilter(CoreConfiguration::Builder* builder) {
builder->channel_init()->RegisterStage(
GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
[](ChannelStackBuilder* builder) {
const grpc_channel_args* channel_args = builder->channel_args();
if (!grpc_channel_args_want_minimal_stack(channel_args) &&
GetClientIdleTimeout(channel_args) != Duration::Infinity()) {
builder->PrependFilter(&grpc_client_idle_filter, nullptr);
}
return true;
});
}
} // namespace grpc_core

@ -1,566 +0,0 @@
/*
*
* Copyright 2017 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <grpc/support/port_platform.h>
#include "src/core/ext/filters/max_age/max_age_filter.h"
#include <limits.h>
#include <string.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/transport/http2_errors.h"
/* If these settings change, make sure that we are not sending a GOAWAY for
* inproc transport, since a GOAWAY to inproc ends up destroying the transport.
*/
#define DEFAULT_MAX_CONNECTION_AGE_MS INT_MAX
#define DEFAULT_MAX_CONNECTION_AGE_GRACE_MS INT_MAX
#define DEFAULT_MAX_CONNECTION_IDLE_MS INT_MAX
#define MAX_CONNECTION_AGE_JITTER 0.1
#define MAX_CONNECTION_AGE_INTEGER_OPTIONS \
{ DEFAULT_MAX_CONNECTION_AGE_MS, 1, INT_MAX }
#define MAX_CONNECTION_IDLE_INTEGER_OPTIONS \
{ DEFAULT_MAX_CONNECTION_IDLE_MS, 1, INT_MAX }
/* States for idle_state in channel_data */
#define MAX_IDLE_STATE_INIT ((gpr_atm)0)
#define MAX_IDLE_STATE_SEEN_EXIT_IDLE ((gpr_atm)1)
#define MAX_IDLE_STATE_SEEN_ENTER_IDLE ((gpr_atm)2)
#define MAX_IDLE_STATE_TIMER_SET ((gpr_atm)3)
namespace {
struct channel_data {
/* The channel stack to which we take refs for pending callbacks. */
grpc_channel_stack* channel_stack;
/* Guards access to max_age_timer, max_age_timer_pending, max_age_grace_timer
and max_age_grace_timer_pending */
grpc_core::Mutex max_age_timer_mu;
/* True if the max_age timer callback is currently pending */
bool max_age_timer_pending ABSL_GUARDED_BY(max_age_timer_mu) = false;
/* True if the max_age_grace timer callback is currently pending */
bool max_age_grace_timer_pending ABSL_GUARDED_BY(max_age_timer_mu) = false;
/* The timer for checking if the channel has reached its max age */
grpc_timer max_age_timer ABSL_GUARDED_BY(max_age_timer_mu);
/* The timer for checking if the max-aged channel has uesed up the grace
period */
grpc_timer max_age_grace_timer ABSL_GUARDED_BY(max_age_timer_mu);
/* The timer for checking if the channel's idle duration reaches
max_connection_idle */
grpc_timer max_idle_timer;
/* Allowed max time a channel may have no outstanding rpcs */
grpc_core::Duration max_connection_idle;
/* Allowed max time a channel may exist */
grpc_core::Duration max_connection_age;
/* Allowed grace period after the channel reaches its max age */
grpc_core::Duration max_connection_age_grace;
/* Closure to run when the channel's idle duration reaches max_connection_idle
and should be closed gracefully */
grpc_closure max_idle_timer_cb;
/* Closure to run when the channel reaches its max age and should be closed
gracefully */
grpc_closure close_max_age_channel;
/* Closure to run the channel uses up its max age grace time and should be
closed forcibly */
grpc_closure force_close_max_age_channel;
/* Closure to run when the init fo channel stack is done and the max_idle
timer should be started */
grpc_closure start_max_idle_timer_after_init;
/* Closure to run when the init fo channel stack is done and the max_age timer
should be started */
grpc_closure start_max_age_timer_after_init;
/* Closure to run when the goaway op is finished and the max_age_timer */
grpc_closure start_max_age_grace_timer_after_goaway_op;
/* Number of active calls */
gpr_atm call_count;
/* TODO(zyc): C++lize this state machine */
/* 'idle_state' holds the states of max_idle_timer and channel idleness.
It can contain one of the following values:
+--------------------------------+----------------+---------+
| idle_state | max_idle_timer | channel |
+--------------------------------+----------------+---------+
| MAX_IDLE_STATE_INIT | unset | busy |
| MAX_IDLE_STATE_TIMER_SET | set, valid | idle |
| MAX_IDLE_STATE_SEEN_EXIT_IDLE | set, invalid | busy |
| MAX_IDLE_STATE_SEEN_ENTER_IDLE | set, invalid | idle |
+--------------------------------+----------------+---------+
MAX_IDLE_STATE_INIT: The initial and final state of 'idle_state'. The
channel has 1 or 1+ active calls, and the timer is not set. Note that
we may put a virtual call to hold this state at channel initialization or
shutdown, so that the channel won't enter other states.
MAX_IDLE_STATE_TIMER_SET: The state after the timer is set and no calls
have arrived after the timer is set. The channel must have 0 active call in
this state. If the timer is fired in this state, we will close the channel
due to idleness.
MAX_IDLE_STATE_SEEN_EXIT_IDLE: The state after the timer is set and at
least one call has arrived after the timer is set. The channel must have 1
or 1+ active calls in this state. If the timer is fired in this state, we
won't reschudle it.
MAX_IDLE_STATE_SEEN_ENTER_IDLE: The state after the timer is set and the at
least one call has arrived after the timer is set, BUT the channel
currently has 0 active calls. If the timer is fired in this state, we will
reschudle it.
max_idle_timer will not be cancelled (unless the channel is shutting down).
If the timer callback is called when the max_idle_timer is valid (i.e.
idle_state is MAX_IDLE_STATE_TIMER_SET), the channel will be closed due to
idleness, otherwise the channel won't be changed.
State transitions:
MAX_IDLE_STATE_INIT <-------3------ MAX_IDLE_STATE_SEEN_EXIT_IDLE
^ | ^ ^ |
| | | | |
1 2 +-----------4------------+ 6 7
| | | | |
| v | | v
MAX_IDLE_STATE_TIMER_SET <----5------ MAX_IDLE_STATE_SEEN_ENTER_IDLE
For 1, 3, 5 : See max_idle_timer_cb() function
For 2, 7 : See decrease_call_count() function
For 4, 6 : See increase_call_count() function */
gpr_atm idle_state;
/* Time when the channel finished its last outstanding call, in
* grpc_core::Timestamp */
gpr_atm last_enter_idle_time_millis;
};
} // namespace
/* Increase the nubmer of active calls. Before the increasement, if there are no
calls, the max_idle_timer should be cancelled. */
static void increase_call_count(channel_data* chand) {
/* Exit idle */
if (gpr_atm_full_fetch_add(&chand->call_count, 1) == 0) {
while (true) {
gpr_atm idle_state = gpr_atm_acq_load(&chand->idle_state);
switch (idle_state) {
case MAX_IDLE_STATE_TIMER_SET:
/* max_idle_timer_cb may have already set idle_state to
MAX_IDLE_STATE_INIT, in this case, we don't need to set it to
MAX_IDLE_STATE_SEEN_EXIT_IDLE */
gpr_atm_rel_cas(&chand->idle_state, MAX_IDLE_STATE_TIMER_SET,
MAX_IDLE_STATE_SEEN_EXIT_IDLE);
return;
case MAX_IDLE_STATE_SEEN_ENTER_IDLE:
gpr_atm_rel_store(&chand->idle_state, MAX_IDLE_STATE_SEEN_EXIT_IDLE);
return;
default:
/* try again */
break;
}
}
}
}
/* Decrease the nubmer of active calls. After the decrement, if there are no
calls, the max_idle_timer should be started. */
static void decrease_call_count(channel_data* chand) {
/* Enter idle */
if (gpr_atm_full_fetch_add(&chand->call_count, -1) == 1) {
gpr_atm_no_barrier_store(&chand->last_enter_idle_time_millis,
(gpr_atm)grpc_core::ExecCtx::Get()
->Now()
.milliseconds_after_process_epoch());
while (true) {
gpr_atm idle_state = gpr_atm_acq_load(&chand->idle_state);
switch (idle_state) {
case MAX_IDLE_STATE_INIT:
GRPC_CHANNEL_STACK_REF(chand->channel_stack,
"max_age max_idle_timer");
grpc_timer_init(
&chand->max_idle_timer,
grpc_core::ExecCtx::Get()->Now() + chand->max_connection_idle,
&chand->max_idle_timer_cb);
gpr_atm_rel_store(&chand->idle_state, MAX_IDLE_STATE_TIMER_SET);
return;
case MAX_IDLE_STATE_SEEN_EXIT_IDLE:
if (gpr_atm_rel_cas(&chand->idle_state, MAX_IDLE_STATE_SEEN_EXIT_IDLE,
MAX_IDLE_STATE_SEEN_ENTER_IDLE)) {
return;
}
break;
default:
/* try again */
break;
}
}
}
}
static void start_max_idle_timer_after_init(void* arg,
grpc_error_handle /*error*/) {
channel_data* chand = static_cast<channel_data*>(arg);
/* Decrease call_count. If there are no active calls at this time,
max_idle_timer will start here. If the number of active calls is not 0,
max_idle_timer will start after all the active calls end. */
decrease_call_count(chand);
GRPC_CHANNEL_STACK_UNREF(chand->channel_stack,
"max_age start_max_idle_timer_after_init");
}
namespace grpc_core {
class ConnectivityWatcher : public AsyncConnectivityStateWatcherInterface {
public:
explicit ConnectivityWatcher(channel_data* chand) : chand_(chand) {
GRPC_CHANNEL_STACK_REF(chand_->channel_stack, "max_age conn_watch");
}
~ConnectivityWatcher() override {
GRPC_CHANNEL_STACK_UNREF(chand_->channel_stack, "max_age conn_watch");
}
private:
void OnConnectivityStateChange(grpc_connectivity_state new_state,
const absl::Status& /* status */) override {
if (new_state != GRPC_CHANNEL_SHUTDOWN) return;
{
MutexLock lock(&chand_->max_age_timer_mu);
if (chand_->max_age_timer_pending) {
grpc_timer_cancel(&chand_->max_age_timer);
chand_->max_age_timer_pending = false;
}
if (chand_->max_age_grace_timer_pending) {
grpc_timer_cancel(&chand_->max_age_grace_timer);
chand_->max_age_grace_timer_pending = false;
}
}
/* If there are no active calls, this increasement will cancel
max_idle_timer, and prevent max_idle_timer from being started in the
future. */
increase_call_count(chand_);
if (gpr_atm_acq_load(&chand_->idle_state) ==
MAX_IDLE_STATE_SEEN_EXIT_IDLE) {
grpc_timer_cancel(&chand_->max_idle_timer);
}
}
channel_data* chand_;
};
} // namespace grpc_core
static void start_max_age_timer_after_init(void* arg,
grpc_error_handle /*error*/) {
channel_data* chand = static_cast<channel_data*>(arg);
{
grpc_core::MutexLock lock(&chand->max_age_timer_mu);
chand->max_age_timer_pending = true;
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_age_timer");
grpc_timer_init(
&chand->max_age_timer,
grpc_core::ExecCtx::Get()->Now() + chand->max_connection_age,
&chand->close_max_age_channel);
}
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->start_connectivity_watch.reset(new grpc_core::ConnectivityWatcher(chand));
op->start_connectivity_watch_state = GRPC_CHANNEL_IDLE;
grpc_channel_next_op(grpc_channel_stack_element(chand->channel_stack, 0), op);
GRPC_CHANNEL_STACK_UNREF(chand->channel_stack,
"max_age start_max_age_timer_after_init");
}
static void start_max_age_grace_timer_after_goaway_op(
void* arg, grpc_error_handle /*error*/) {
channel_data* chand = static_cast<channel_data*>(arg);
{
grpc_core::MutexLock lock(&chand->max_age_timer_mu);
chand->max_age_grace_timer_pending = true;
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_age_grace_timer");
grpc_timer_init(
&chand->max_age_grace_timer,
grpc_core::ExecCtx::Get()->Now() + chand->max_connection_age_grace,
&chand->force_close_max_age_channel);
}
GRPC_CHANNEL_STACK_UNREF(chand->channel_stack,
"max_age start_max_age_grace_timer_after_goaway_op");
}
static void close_max_idle_channel(channel_data* chand) {
/* Prevent the max idle timer from being set again */
gpr_atm_no_barrier_fetch_add(&chand->call_count, 1);
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->goaway_error =
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("max_idle"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_NO_ERROR);
grpc_channel_element* elem =
grpc_channel_stack_element(chand->channel_stack, 0);
elem->filter->start_transport_op(elem, op);
}
static void max_idle_timer_cb(void* arg, grpc_error_handle error) {
channel_data* chand = static_cast<channel_data*>(arg);
if (error == GRPC_ERROR_NONE) {
bool try_again = true;
while (try_again) {
gpr_atm idle_state = gpr_atm_acq_load(&chand->idle_state);
switch (idle_state) {
case MAX_IDLE_STATE_TIMER_SET:
close_max_idle_channel(chand);
/* This MAX_IDLE_STATE_INIT is a final state, we don't have to check
* if idle_state has been changed */
gpr_atm_rel_store(&chand->idle_state, MAX_IDLE_STATE_INIT);
try_again = false;
break;
case MAX_IDLE_STATE_SEEN_EXIT_IDLE:
if (gpr_atm_rel_cas(&chand->idle_state, MAX_IDLE_STATE_SEEN_EXIT_IDLE,
MAX_IDLE_STATE_INIT)) {
try_again = false;
}
break;
case MAX_IDLE_STATE_SEEN_ENTER_IDLE:
GRPC_CHANNEL_STACK_REF(chand->channel_stack,
"max_age max_idle_timer");
grpc_timer_init(
&chand->max_idle_timer,
grpc_core::Timestamp::FromMillisecondsAfterProcessEpoch(
gpr_atm_no_barrier_load(
&chand->last_enter_idle_time_millis)) +
chand->max_connection_idle,
&chand->max_idle_timer_cb);
/* idle_state may have already been set to
MAX_IDLE_STATE_SEEN_EXIT_IDLE by increase_call_count(), in this
case, we don't need to set it to MAX_IDLE_STATE_TIMER_SET */
gpr_atm_rel_cas(&chand->idle_state, MAX_IDLE_STATE_SEEN_ENTER_IDLE,
MAX_IDLE_STATE_TIMER_SET);
try_again = false;
break;
default:
/* try again */
break;
}
}
}
GRPC_CHANNEL_STACK_UNREF(chand->channel_stack, "max_age max_idle_timer");
}
static void close_max_age_channel(void* arg, grpc_error_handle error) {
channel_data* chand = static_cast<channel_data*>(arg);
{
grpc_core::MutexLock lock(&chand->max_age_timer_mu);
chand->max_age_timer_pending = false;
}
if (error == GRPC_ERROR_NONE) {
GRPC_CHANNEL_STACK_REF(chand->channel_stack,
"max_age start_max_age_grace_timer_after_goaway_op");
grpc_transport_op* op = grpc_make_transport_op(
&chand->start_max_age_grace_timer_after_goaway_op);
op->goaway_error =
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("max_age"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_NO_ERROR);
grpc_channel_element* elem =
grpc_channel_stack_element(chand->channel_stack, 0);
elem->filter->start_transport_op(elem, op);
} else if (error != GRPC_ERROR_CANCELLED) {
GRPC_LOG_IF_ERROR("close_max_age_channel", error);
}
GRPC_CHANNEL_STACK_UNREF(chand->channel_stack, "max_age max_age_timer");
}
static void force_close_max_age_channel(void* arg, grpc_error_handle error) {
channel_data* chand = static_cast<channel_data*>(arg);
{
grpc_core::MutexLock lock(&chand->max_age_timer_mu);
chand->max_age_grace_timer_pending = false;
}
if (error == GRPC_ERROR_NONE) {
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->disconnect_with_error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel reaches max age");
grpc_channel_element* elem =
grpc_channel_stack_element(chand->channel_stack, 0);
elem->filter->start_transport_op(elem, op);
} else if (error != GRPC_ERROR_CANCELLED) {
GRPC_LOG_IF_ERROR("force_close_max_age_channel", error);
}
GRPC_CHANNEL_STACK_UNREF(chand->channel_stack, "max_age max_age_grace_timer");
}
/* A random jitter of +/-10% will be added to MAX_CONNECTION_AGE to spread out
connection storms. Note that the MAX_CONNECTION_AGE option without jitter
would not create connection storms by itself, but if there happened to be a
connection storm it could cause it to repeat at a fixed period. */
static grpc_core::Duration
add_random_max_connection_age_jitter_and_convert_to_duration(int value) {
/* generate a random number between 1 - MAX_CONNECTION_AGE_JITTER and
1 + MAX_CONNECTION_AGE_JITTER */
double multiplier = rand() * MAX_CONNECTION_AGE_JITTER * 2.0 / RAND_MAX +
1.0 - MAX_CONNECTION_AGE_JITTER;
double result = multiplier * value;
/* INT_MAX - 0.5 converts the value to float, so that result will not be
cast to int implicitly before the comparison. */
return result > (static_cast<double>(
grpc_core::Duration::Infinity().millis())) -
0.5
? grpc_core::Duration::Infinity()
: grpc_core::Duration::Milliseconds(result);
}
/* Constructor for call_data. */
static grpc_error_handle max_age_init_call_elem(
grpc_call_element* elem, const grpc_call_element_args* /*args*/) {
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
increase_call_count(chand);
return GRPC_ERROR_NONE;
}
/* Destructor for call_data. */
static void max_age_destroy_call_elem(
grpc_call_element* elem, const grpc_call_final_info* /*final_info*/,
grpc_closure* /*ignored*/) {
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
decrease_call_count(chand);
}
/* Constructor for channel_data. */
static grpc_error_handle max_age_init_channel_elem(
grpc_channel_element* elem, grpc_channel_element_args* args) {
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
new (chand) channel_data();
chand->channel_stack = args->channel_stack;
chand->max_connection_age =
add_random_max_connection_age_jitter_and_convert_to_duration(
DEFAULT_MAX_CONNECTION_AGE_MS);
chand->max_connection_age_grace =
DEFAULT_MAX_CONNECTION_AGE_GRACE_MS == INT_MAX
? grpc_core::Duration::Infinity()
: grpc_core::Duration::Milliseconds(
DEFAULT_MAX_CONNECTION_AGE_GRACE_MS);
chand->max_connection_idle =
DEFAULT_MAX_CONNECTION_IDLE_MS == INT_MAX
? grpc_core::Duration::Infinity()
: grpc_core::Duration::Milliseconds(DEFAULT_MAX_CONNECTION_IDLE_MS);
chand->idle_state = MAX_IDLE_STATE_INIT;
gpr_atm_no_barrier_store(&chand->last_enter_idle_time_millis, GPR_ATM_MIN);
for (size_t i = 0; i < args->channel_args->num_args; ++i) {
if (0 == strcmp(args->channel_args->args[i].key,
GRPC_ARG_MAX_CONNECTION_AGE_MS)) {
const int value = grpc_channel_arg_get_integer(
&args->channel_args->args[i], MAX_CONNECTION_AGE_INTEGER_OPTIONS);
chand->max_connection_age =
add_random_max_connection_age_jitter_and_convert_to_duration(value);
} else if (0 == strcmp(args->channel_args->args[i].key,
GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS)) {
const int value = grpc_channel_arg_get_integer(
&args->channel_args->args[i],
{DEFAULT_MAX_CONNECTION_AGE_GRACE_MS, 0, INT_MAX});
chand->max_connection_age_grace =
value == INT_MAX ? grpc_core::Duration::Infinity()
: grpc_core::Duration::Milliseconds(value);
} else if (0 == strcmp(args->channel_args->args[i].key,
GRPC_ARG_MAX_CONNECTION_IDLE_MS)) {
const int value = grpc_channel_arg_get_integer(
&args->channel_args->args[i], MAX_CONNECTION_IDLE_INTEGER_OPTIONS);
chand->max_connection_idle =
value == INT_MAX ? grpc_core::Duration::Infinity()
: grpc_core::Duration::Milliseconds(value);
}
}
GRPC_CLOSURE_INIT(&chand->max_idle_timer_cb, max_idle_timer_cb, chand,
grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&chand->close_max_age_channel, close_max_age_channel, chand,
grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&chand->force_close_max_age_channel,
force_close_max_age_channel, chand,
grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&chand->start_max_idle_timer_after_init,
start_max_idle_timer_after_init, chand,
grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&chand->start_max_age_timer_after_init,
start_max_age_timer_after_init, chand,
grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&chand->start_max_age_grace_timer_after_goaway_op,
start_max_age_grace_timer_after_goaway_op, chand,
grpc_schedule_on_exec_ctx);
if (chand->max_connection_age != grpc_core::Duration::Infinity()) {
/* When the channel reaches its max age, we send down an op with
goaway_error set. However, we can't send down any ops until after the
channel stack is fully initialized. If we start the timer here, we have
no guarantee that the timer won't pop before channel stack initialization
is finished. To avoid that problem, we create a closure to start the
timer, and we schedule that closure to be run after call stack
initialization is done. */
GRPC_CHANNEL_STACK_REF(chand->channel_stack,
"max_age start_max_age_timer_after_init");
grpc_core::ExecCtx::Run(DEBUG_LOCATION,
&chand->start_max_age_timer_after_init,
GRPC_ERROR_NONE);
}
/* Initialize the number of calls as 1, so that the max_idle_timer will not
start until start_max_idle_timer_after_init is invoked. */
gpr_atm_rel_store(&chand->call_count, 1);
if (chand->max_connection_idle != grpc_core::Duration::Infinity()) {
GRPC_CHANNEL_STACK_REF(chand->channel_stack,
"max_age start_max_idle_timer_after_init");
grpc_core::ExecCtx::Run(DEBUG_LOCATION,
&chand->start_max_idle_timer_after_init,
GRPC_ERROR_NONE);
}
return GRPC_ERROR_NONE;
}
/* Destructor for channel_data. */
static void max_age_destroy_channel_elem(grpc_channel_element* elem) {
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
chand->~channel_data();
}
const grpc_channel_filter grpc_max_age_filter = {
grpc_call_next_op,
nullptr,
grpc_channel_next_op,
0, /* sizeof_call_data */
max_age_init_call_elem,
grpc_call_stack_ignore_set_pollset_or_pollset_set,
max_age_destroy_call_elem,
sizeof(channel_data),
max_age_init_channel_elem,
max_age_destroy_channel_elem,
grpc_channel_next_get_info,
"max_age"};
namespace grpc_core {
void RegisterMaxAgeFilter(CoreConfiguration::Builder* builder) {
builder->channel_init()->RegisterStage(
GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
[](ChannelStackBuilder* builder) {
const grpc_channel_args* channel_args = builder->channel_args();
bool enable = grpc_channel_arg_get_integer(
grpc_channel_args_find(
channel_args, GRPC_ARG_MAX_CONNECTION_AGE_MS),
MAX_CONNECTION_AGE_INTEGER_OPTIONS) != INT_MAX ||
grpc_channel_arg_get_integer(
grpc_channel_args_find(
channel_args, GRPC_ARG_MAX_CONNECTION_IDLE_MS),
MAX_CONNECTION_IDLE_INTEGER_OPTIONS) != INT_MAX;
if (enable) {
builder->PrependFilter(&grpc_max_age_filter, nullptr);
}
return true;
});
}
} // namespace grpc_core

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

@ -28,14 +28,16 @@ template <class T, class Deleter = std::default_delete<T>>
class SingleSetPtr {
public:
SingleSetPtr() = default;
explicit SingleSetPtr(T* p) : p_{p} {}
explicit SingleSetPtr(std::unique_ptr<T, Deleter> p) : p_{p.release()} {}
~SingleSetPtr() { Delete(p_.load(std::memory_order_relaxed)); }
SingleSetPtr(const SingleSetPtr&) = delete;
SingleSetPtr& operator=(const SingleSetPtr&) = delete;
SingleSetPtr(SingleSetPtr&& other) noexcept
: p_(other.p_.exchange(sentinel())) {}
: p_(other.p_.exchange(nullptr)) {}
SingleSetPtr& operator=(SingleSetPtr&& other) noexcept {
Set(other.p_.exchange(sentinel(), std::memory_order_acq_rel));
Set(other.p_.exchange(nullptr, std::memory_order_acq_rel));
return *this;
}
@ -47,22 +49,25 @@ class SingleSetPtr {
if (!p_.compare_exchange_strong(expected, ptr, std::memory_order_acq_rel,
std::memory_order_acquire)) {
Delete(ptr);
return expected == sentinel() ? nullptr : expected;
return expected;
}
return ptr;
}
// Clear the pointer. Cannot be set again.
void Reset() { Delete(p_.exchange(sentinel(), std::memory_order_acq_rel)); }
// Set the pointer from a compatible unique_ptr - with the same caveats as
// above.
T* Set(std::unique_ptr<T, Deleter> ptr) { return Set(ptr.release()); }
// Clear the pointer.
void Reset() { Delete(p_.exchange(nullptr, std::memory_order_acq_rel)); }
bool is_set() const {
T* p = p_.load(std::memory_order_acquire);
return p != nullptr && p != sentinel();
return p != nullptr;
}
T* operator->() const {
T* p = p_.load(std::memory_order_acquire);
GPR_DEBUG_ASSERT(p != sentinel());
GPR_DEBUG_ASSERT(p != nullptr);
return p;
}
@ -70,9 +75,8 @@ class SingleSetPtr {
T& operator*() const { return *operator->(); }
private:
static T* sentinel() { return reinterpret_cast<T*>(1); }
static void Delete(T* p) {
if (p == sentinel() || p == nullptr) return;
if (p == nullptr) return;
Deleter()(p);
}
std::atomic<T*> p_{nullptr};

@ -80,12 +80,11 @@ extern void BuildClientChannelConfiguration(
extern void SecurityRegisterHandshakerFactories(
CoreConfiguration::Builder* builder);
extern void RegisterClientAuthorityFilter(CoreConfiguration::Builder* builder);
extern void RegisterClientIdleFilter(CoreConfiguration::Builder* builder);
extern void RegisterChannelIdleFilters(CoreConfiguration::Builder* builder);
extern void RegisterDeadlineFilter(CoreConfiguration::Builder* builder);
extern void RegisterGrpcLbLoadReportingFilter(
CoreConfiguration::Builder* builder);
extern void RegisterHttpFilters(CoreConfiguration::Builder* builder);
extern void RegisterMaxAgeFilter(CoreConfiguration::Builder* builder);
extern void RegisterMessageSizeFilter(CoreConfiguration::Builder* builder);
extern void RegisterSecurityFilters(CoreConfiguration::Builder* builder);
extern void RegisterServiceConfigChannelArgFilter(
@ -105,10 +104,9 @@ void BuildCoreConfiguration(CoreConfiguration::Builder* builder) {
BuildClientChannelConfiguration(builder);
SecurityRegisterHandshakerFactories(builder);
RegisterClientAuthorityFilter(builder);
RegisterClientIdleFilter(builder);
RegisterChannelIdleFilters(builder);
RegisterGrpcLbLoadReportingFilter(builder);
RegisterHttpFilters(builder);
RegisterMaxAgeFilter(builder);
RegisterDeadlineFilter(builder);
RegisterMessageSizeFilter(builder);
RegisterServiceConfigChannelArgFilter(builder);

@ -16,6 +16,8 @@
CORE_SOURCE_FILES = [
'src/core/ext/filters/census/grpc_context.cc',
'src/core/ext/filters/channel_idle/channel_idle_filter.cc',
'src/core/ext/filters/channel_idle/idle_filter_state.cc',
'src/core/ext/filters/client_channel/backend_metric.cc',
'src/core/ext/filters/client_channel/backup_poller.cc',
'src/core/ext/filters/client_channel/channel_connectivity.cc',
@ -74,8 +76,6 @@ CORE_SOURCE_FILES = [
'src/core/ext/filters/client_channel/subchannel.cc',
'src/core/ext/filters/client_channel/subchannel_pool_interface.cc',
'src/core/ext/filters/client_channel/subchannel_stream_client.cc',
'src/core/ext/filters/client_idle/client_idle_filter.cc',
'src/core/ext/filters/client_idle/idle_filter_state.cc',
'src/core/ext/filters/deadline/deadline_filter.cc',
'src/core/ext/filters/fault_injection/fault_injection_filter.cc',
'src/core/ext/filters/fault_injection/service_config_parser.cc',
@ -85,7 +85,6 @@ CORE_SOURCE_FILES = [
'src/core/ext/filters/http/message_compress/message_compress_filter.cc',
'src/core/ext/filters/http/message_compress/message_decompress_filter.cc',
'src/core/ext/filters/http/server/http_server_filter.cc',
'src/core/ext/filters/max_age/max_age_filter.cc',
'src/core/ext/filters/message_size/message_size_filter.cc',
'src/core/ext/filters/rbac/rbac_filter.cc',
'src/core/ext/filters/rbac/rbac_service_config_parser.cc',

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/core/ext/filters/client_idle/idle_filter_state.h"
#include "src/core/ext/filters/channel_idle/idle_filter_state.h"
#include <stdio.h>

@ -1053,6 +1053,9 @@ include/grpcpp/support/time.h \
include/grpcpp/support/validate_service_config.h \
include/grpcpp/xds_server_builder.h \
src/core/ext/filters/census/grpc_context.cc \
src/core/ext/filters/channel_idle/channel_idle_filter.cc \
src/core/ext/filters/channel_idle/idle_filter_state.cc \
src/core/ext/filters/channel_idle/idle_filter_state.h \
src/core/ext/filters/client_channel/backend_metric.cc \
src/core/ext/filters/client_channel/backend_metric.h \
src/core/ext/filters/client_channel/backup_poller.cc \
@ -1154,9 +1157,6 @@ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \
src/core/ext/filters/client_channel/subchannel_pool_interface.h \
src/core/ext/filters/client_channel/subchannel_stream_client.cc \
src/core/ext/filters/client_channel/subchannel_stream_client.h \
src/core/ext/filters/client_idle/client_idle_filter.cc \
src/core/ext/filters/client_idle/idle_filter_state.cc \
src/core/ext/filters/client_idle/idle_filter_state.h \
src/core/ext/filters/deadline/deadline_filter.cc \
src/core/ext/filters/deadline/deadline_filter.h \
src/core/ext/filters/fault_injection/fault_injection_filter.cc \
@ -1174,8 +1174,6 @@ src/core/ext/filters/http/message_compress/message_decompress_filter.cc \
src/core/ext/filters/http/message_compress/message_decompress_filter.h \
src/core/ext/filters/http/server/http_server_filter.cc \
src/core/ext/filters/http/server/http_server_filter.h \
src/core/ext/filters/max_age/max_age_filter.cc \
src/core/ext/filters/max_age/max_age_filter.h \
src/core/ext/filters/message_size/message_size_filter.cc \
src/core/ext/filters/message_size/message_size_filter.h \
src/core/ext/filters/rbac/rbac_filter.cc \
@ -2000,6 +1998,7 @@ src/core/lib/gprpp/orphanable.h \
src/core/lib/gprpp/overload.h \
src/core/lib/gprpp/ref_counted.h \
src/core/lib/gprpp/ref_counted_ptr.h \
src/core/lib/gprpp/single_set_ptr.h \
src/core/lib/gprpp/stat.h \
src/core/lib/gprpp/stat_posix.cc \
src/core/lib/gprpp/stat_windows.cc \

@ -872,6 +872,9 @@ include/grpc/support/workaround_list.h \
src/core/README.md \
src/core/ext/README.md \
src/core/ext/filters/census/grpc_context.cc \
src/core/ext/filters/channel_idle/channel_idle_filter.cc \
src/core/ext/filters/channel_idle/idle_filter_state.cc \
src/core/ext/filters/channel_idle/idle_filter_state.h \
src/core/ext/filters/client_channel/README.md \
src/core/ext/filters/client_channel/backend_metric.cc \
src/core/ext/filters/client_channel/backend_metric.h \
@ -978,9 +981,6 @@ src/core/ext/filters/client_channel/subchannel_pool_interface.cc \
src/core/ext/filters/client_channel/subchannel_pool_interface.h \
src/core/ext/filters/client_channel/subchannel_stream_client.cc \
src/core/ext/filters/client_channel/subchannel_stream_client.h \
src/core/ext/filters/client_idle/client_idle_filter.cc \
src/core/ext/filters/client_idle/idle_filter_state.cc \
src/core/ext/filters/client_idle/idle_filter_state.h \
src/core/ext/filters/deadline/deadline_filter.cc \
src/core/ext/filters/deadline/deadline_filter.h \
src/core/ext/filters/fault_injection/fault_injection_filter.cc \
@ -998,8 +998,6 @@ src/core/ext/filters/http/message_compress/message_decompress_filter.cc \
src/core/ext/filters/http/message_compress/message_decompress_filter.h \
src/core/ext/filters/http/server/http_server_filter.cc \
src/core/ext/filters/http/server/http_server_filter.h \
src/core/ext/filters/max_age/max_age_filter.cc \
src/core/ext/filters/max_age/max_age_filter.h \
src/core/ext/filters/message_size/message_size_filter.cc \
src/core/ext/filters/message_size/message_size_filter.h \
src/core/ext/filters/rbac/rbac_filter.cc \
@ -1794,6 +1792,7 @@ src/core/lib/gprpp/orphanable.h \
src/core/lib/gprpp/overload.h \
src/core/lib/gprpp/ref_counted.h \
src/core/lib/gprpp/ref_counted_ptr.h \
src/core/lib/gprpp/single_set_ptr.h \
src/core/lib/gprpp/stat.h \
src/core/lib/gprpp/stat_posix.cc \
src/core/lib/gprpp/stat_windows.cc \

Loading…
Cancel
Save