grpc 1.49.1-x86_64-linux → 1.50.0.pre1-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (275) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +54 -153
  3. data/include/grpc/event_engine/endpoint_config.h +11 -5
  4. data/include/grpc/event_engine/event_engine.h +1 -1
  5. data/include/grpc/impl/codegen/atm_gcc_atomic.h +19 -28
  6. data/include/grpc/impl/codegen/atm_gcc_sync.h +0 -2
  7. data/include/grpc/impl/codegen/atm_windows.h +0 -2
  8. data/include/grpc/impl/codegen/grpc_types.h +6 -0
  9. data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +3 -3
  10. data/src/core/ext/filters/client_channel/backup_poller.cc +4 -6
  11. data/src/core/ext/filters/client_channel/client_channel.cc +33 -22
  12. data/src/core/ext/filters/client_channel/client_channel.h +1 -1
  13. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +0 -16
  14. data/src/core/ext/filters/client_channel/http_proxy.cc +12 -19
  15. data/src/core/ext/filters/client_channel/http_proxy.h +3 -2
  16. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +6 -4
  17. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +5 -4
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +0 -2
  19. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +112 -96
  20. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +20 -11
  21. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +106 -108
  22. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +16 -0
  23. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +20 -13
  24. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +165 -257
  25. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +218 -231
  26. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -6
  27. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +389 -444
  28. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +16 -16
  29. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +8 -13
  30. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +84 -96
  31. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +38 -37
  32. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +106 -186
  33. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +106 -93
  34. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +170 -218
  35. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +2 -2
  36. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -1
  37. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +13 -15
  38. data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +84 -37
  39. data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +11 -0
  40. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -0
  41. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +5 -3
  42. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +5 -4
  43. data/src/core/ext/filters/client_channel/retry_filter.cc +25 -29
  44. data/src/core/ext/filters/client_channel/subchannel.cc +38 -33
  45. data/src/core/ext/filters/client_channel/subchannel.h +12 -3
  46. data/src/core/ext/filters/client_channel/subchannel_stream_client.cc +1 -2
  47. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +23 -16
  48. data/src/core/ext/filters/fault_injection/fault_injection_filter.h +8 -0
  49. data/src/core/ext/filters/http/client/http_client_filter.cc +1 -2
  50. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +2 -4
  51. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +0 -2
  52. data/src/core/ext/filters/http/server/http_server_filter.cc +1 -2
  53. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +12 -8
  54. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +32 -26
  55. data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +1 -1
  56. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +25 -130
  57. data/src/core/ext/transport/chttp2/transport/decode_huff.cc +287 -0
  58. data/src/core/ext/transport/chttp2/transport/decode_huff.h +1018 -0
  59. data/src/core/ext/transport/chttp2/transport/flow_control.cc +83 -51
  60. data/src/core/ext/transport/chttp2/transport/flow_control.h +11 -6
  61. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -2
  62. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +2 -20
  63. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +28 -28
  64. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +1 -10
  65. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +11 -6
  66. data/src/core/ext/transport/chttp2/transport/internal.h +2 -0
  67. data/src/core/ext/transport/chttp2/transport/parsing.cc +44 -0
  68. data/src/core/ext/transport/chttp2/transport/writing.cc +3 -14
  69. data/src/core/ext/transport/inproc/inproc_transport.cc +1 -3
  70. data/src/core/ext/xds/certificate_provider_store.cc +63 -3
  71. data/src/core/ext/xds/certificate_provider_store.h +9 -1
  72. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +5 -5
  73. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +1 -1
  74. data/src/core/ext/xds/xds_api.cc +21 -17
  75. data/src/core/ext/xds/xds_api.h +7 -0
  76. data/src/core/ext/xds/xds_bootstrap.cc +5 -537
  77. data/src/core/ext/xds/xds_bootstrap.h +39 -111
  78. data/src/core/ext/xds/xds_bootstrap_grpc.cc +370 -0
  79. data/src/core/ext/xds/xds_bootstrap_grpc.h +169 -0
  80. data/src/core/ext/xds/xds_client.cc +219 -145
  81. data/src/core/ext/xds/xds_client.h +19 -17
  82. data/src/core/ext/xds/xds_client_grpc.cc +18 -80
  83. data/src/core/ext/xds/xds_client_grpc.h +2 -25
  84. data/src/core/ext/xds/xds_client_stats.cc +4 -4
  85. data/src/core/ext/xds/xds_cluster.cc +87 -79
  86. data/src/core/ext/xds/xds_cluster.h +5 -5
  87. data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +3 -1
  88. data/src/core/ext/xds/xds_common_types.cc +13 -5
  89. data/src/core/ext/xds/xds_endpoint.cc +8 -6
  90. data/src/core/ext/xds/xds_endpoint.h +3 -4
  91. data/src/core/ext/xds/xds_lb_policy_registry.cc +4 -2
  92. data/src/core/ext/xds/xds_listener.cc +25 -20
  93. data/src/core/ext/xds/xds_listener.h +3 -4
  94. data/src/core/ext/xds/xds_resource_type.h +11 -8
  95. data/src/core/ext/xds/xds_route_config.cc +15 -16
  96. data/src/core/ext/xds/xds_route_config.h +3 -3
  97. data/src/core/ext/xds/xds_server_config_fetcher.cc +7 -5
  98. data/src/core/ext/xds/xds_transport_grpc.cc +15 -7
  99. data/src/core/lib/backoff/backoff.cc +2 -4
  100. data/src/core/lib/channel/call_finalization.h +1 -3
  101. data/src/core/lib/channel/channel_args.h +114 -14
  102. data/src/core/lib/channel/channel_trace.cc +3 -4
  103. data/src/core/lib/channel/promise_based_filter.cc +18 -19
  104. data/src/core/lib/channel/status_util.cc +27 -0
  105. data/src/core/lib/channel/status_util.h +10 -0
  106. data/src/core/lib/config/core_configuration.cc +5 -1
  107. data/src/core/lib/config/core_configuration.h +33 -0
  108. data/src/core/lib/debug/stats.cc +26 -30
  109. data/src/core/lib/debug/stats.h +2 -12
  110. data/src/core/lib/debug/stats_data.cc +118 -614
  111. data/src/core/lib/debug/stats_data.h +67 -465
  112. data/src/core/lib/debug/trace.cc +0 -2
  113. data/src/core/lib/event_engine/channel_args_endpoint_config.cc +12 -20
  114. data/src/core/lib/event_engine/channel_args_endpoint_config.h +13 -7
  115. data/src/core/lib/event_engine/forkable.cc +1 -1
  116. data/src/core/lib/event_engine/poller.h +14 -12
  117. data/src/core/lib/event_engine/posix_engine/timer_manager.cc +53 -32
  118. data/src/core/lib/event_engine/posix_engine/timer_manager.h +23 -1
  119. data/src/core/lib/event_engine/thread_pool.cc +131 -94
  120. data/src/core/lib/event_engine/thread_pool.h +56 -23
  121. data/src/core/lib/event_engine/time_util.cc +30 -0
  122. data/src/core/lib/event_engine/time_util.h +32 -0
  123. data/src/core/lib/event_engine/utils.cc +0 -5
  124. data/src/core/lib/event_engine/utils.h +0 -4
  125. data/src/core/lib/event_engine/windows/iocp.cc +13 -7
  126. data/src/core/lib/event_engine/windows/iocp.h +2 -1
  127. data/src/core/lib/event_engine/windows/win_socket.cc +1 -1
  128. data/src/core/lib/experiments/config.cc +146 -0
  129. data/src/core/lib/experiments/config.h +43 -0
  130. data/src/core/lib/experiments/experiments.cc +75 -0
  131. data/src/core/lib/experiments/experiments.h +56 -0
  132. data/src/core/lib/gpr/alloc.cc +1 -9
  133. data/src/core/lib/gpr/log_windows.cc +0 -1
  134. data/src/core/lib/gpr/string_util_windows.cc +3 -30
  135. data/src/core/lib/gpr/sync_abseil.cc +0 -14
  136. data/src/core/lib/gpr/sync_posix.cc +0 -14
  137. data/src/core/lib/gpr/time_posix.cc +0 -6
  138. data/src/core/lib/gpr/time_precise.h +1 -1
  139. data/src/core/lib/gpr/tmpfile_windows.cc +5 -7
  140. data/src/core/lib/gpr/useful.h +11 -0
  141. data/src/core/lib/{gpr → gprpp}/env.h +25 -12
  142. data/src/core/lib/{gpr → gprpp}/env_linux.cc +20 -15
  143. data/src/core/lib/{gpr → gprpp}/env_posix.cc +11 -10
  144. data/src/core/lib/gprpp/env_windows.cc +56 -0
  145. data/src/core/lib/gprpp/fork.cc +14 -22
  146. data/src/core/lib/gprpp/fork.h +0 -8
  147. data/src/core/lib/gprpp/global_config_env.cc +7 -6
  148. data/src/core/lib/gprpp/notification.h +67 -0
  149. data/src/core/lib/gprpp/packed_table.h +40 -0
  150. data/src/core/lib/gprpp/ref_counted_ptr.h +20 -33
  151. data/src/core/lib/gprpp/sorted_pack.h +98 -0
  152. data/src/core/lib/gprpp/status_helper.h +6 -0
  153. data/src/core/lib/gprpp/table.h +9 -1
  154. data/src/core/lib/gprpp/tchar.cc +49 -0
  155. data/src/core/lib/gprpp/tchar.h +33 -0
  156. data/src/core/lib/gprpp/time.cc +21 -0
  157. data/src/core/lib/gprpp/time.h +55 -0
  158. data/src/core/lib/gprpp/validation_errors.cc +61 -0
  159. data/src/core/lib/gprpp/validation_errors.h +110 -0
  160. data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper.h +3 -3
  161. data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper_registry.cc +14 -36
  162. data/src/core/lib/handshaker/proxy_mapper_registry.h +75 -0
  163. data/src/core/lib/iomgr/call_combiner.cc +0 -8
  164. data/src/core/lib/iomgr/closure.h +0 -1
  165. data/src/core/lib/iomgr/endpoint_pair_posix.cc +14 -10
  166. data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
  167. data/src/core/lib/iomgr/ev_epoll1_linux.cc +1 -38
  168. data/src/core/lib/iomgr/ev_poll_posix.cc +2 -17
  169. data/src/core/lib/iomgr/exec_ctx.cc +0 -10
  170. data/src/core/lib/iomgr/exec_ctx.h +7 -31
  171. data/src/core/lib/iomgr/iocp_windows.cc +1 -2
  172. data/src/core/lib/iomgr/iomgr.cc +6 -8
  173. data/src/core/lib/iomgr/iomgr_fwd.h +1 -0
  174. data/src/core/lib/iomgr/pollset.h +1 -1
  175. data/src/core/lib/iomgr/pollset_set.h +0 -1
  176. data/src/core/lib/iomgr/resolve_address.h +1 -0
  177. data/src/core/lib/iomgr/resolve_address_impl.h +1 -0
  178. data/src/core/lib/iomgr/resolve_address_posix.cc +1 -0
  179. data/src/core/lib/iomgr/resolve_address_windows.cc +1 -0
  180. data/src/core/lib/iomgr/sockaddr_utils_posix.cc +2 -1
  181. data/src/core/lib/iomgr/socket_utils_common_posix.cc +12 -34
  182. data/src/core/lib/iomgr/socket_utils_posix.cc +83 -1
  183. data/src/core/lib/iomgr/socket_utils_posix.h +98 -6
  184. data/src/core/lib/iomgr/tcp_client.cc +6 -7
  185. data/src/core/lib/iomgr/tcp_client.h +11 -11
  186. data/src/core/lib/iomgr/tcp_client_cfstream.cc +6 -6
  187. data/src/core/lib/iomgr/tcp_client_posix.cc +33 -29
  188. data/src/core/lib/iomgr/tcp_client_posix.h +12 -9
  189. data/src/core/lib/iomgr/tcp_client_windows.cc +6 -6
  190. data/src/core/lib/iomgr/tcp_posix.cc +131 -114
  191. data/src/core/lib/iomgr/tcp_posix.h +3 -1
  192. data/src/core/lib/iomgr/tcp_server.cc +5 -4
  193. data/src/core/lib/iomgr/tcp_server.h +9 -6
  194. data/src/core/lib/iomgr/tcp_server_posix.cc +17 -28
  195. data/src/core/lib/iomgr/tcp_server_utils_posix.h +2 -2
  196. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +3 -3
  197. data/src/core/lib/iomgr/tcp_server_windows.cc +6 -7
  198. data/src/core/lib/iomgr/tcp_windows.cc +0 -1
  199. data/src/core/lib/iomgr/tcp_windows.h +0 -1
  200. data/src/core/lib/iomgr/timer_generic.cc +4 -4
  201. data/src/core/lib/iomgr/timer_manager.cc +1 -2
  202. data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +0 -2
  203. data/src/core/lib/json/json_object_loader.cc +21 -52
  204. data/src/core/lib/json/json_object_loader.h +56 -76
  205. data/src/core/lib/json/json_util.cc +2 -1
  206. data/src/core/lib/load_balancing/lb_policy.h +5 -5
  207. data/src/core/lib/load_balancing/lb_policy_registry.cc +29 -55
  208. data/src/core/lib/load_balancing/lb_policy_registry.h +23 -11
  209. data/src/core/lib/promise/activity.h +2 -3
  210. data/src/core/lib/promise/context.h +1 -1
  211. data/src/core/lib/promise/sleep.cc +16 -4
  212. data/src/core/lib/promise/sleep.h +8 -2
  213. data/src/core/lib/resolver/resolver.h +13 -3
  214. data/src/core/lib/resource_quota/api.cc +9 -0
  215. data/src/core/lib/resource_quota/api.h +6 -0
  216. data/src/core/lib/resource_quota/arena.cc +1 -3
  217. data/src/core/lib/resource_quota/memory_quota.cc +8 -24
  218. data/src/core/lib/resource_quota/memory_quota.h +6 -19
  219. data/src/core/lib/resource_quota/periodic_update.cc +2 -3
  220. data/src/core/{ext/xds → lib/security/certificate_provider}/certificate_provider_factory.h +3 -3
  221. data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +60 -0
  222. data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +70 -0
  223. data/src/core/lib/security/credentials/channel_creds_registry_init.cc +1 -0
  224. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +15 -16
  225. data/src/core/lib/security/credentials/external/external_account_credentials.cc +2 -1
  226. data/src/core/lib/security/credentials/google_default/credentials_generic.cc +5 -8
  227. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +6 -6
  228. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +3 -2
  229. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +1 -1
  230. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -2
  231. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +4 -3
  232. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +4 -2
  233. data/src/core/lib/security/credentials/tls/tls_utils.cc +3 -1
  234. data/src/core/lib/security/transport/client_auth_filter.cc +12 -1
  235. data/src/core/lib/security/transport/secure_endpoint.cc +0 -4
  236. data/src/core/lib/surface/call.cc +1 -11
  237. data/src/core/lib/surface/channel.cc +3 -2
  238. data/src/core/lib/surface/completion_queue.cc +16 -28
  239. data/src/core/lib/surface/completion_queue.h +1 -1
  240. data/src/core/lib/surface/completion_queue_factory.cc +5 -0
  241. data/src/core/lib/surface/init.cc +16 -11
  242. data/src/core/lib/surface/init_internally.cc +24 -0
  243. data/src/core/lib/surface/init_internally.h +28 -0
  244. data/src/core/lib/surface/server.cc +1 -7
  245. data/src/core/lib/surface/server.h +4 -6
  246. data/src/core/lib/surface/version.cc +2 -2
  247. data/src/core/lib/transport/bdp_estimator.cc +1 -3
  248. data/src/core/lib/transport/metadata_batch.cc +2 -3
  249. data/src/core/lib/transport/metadata_batch.h +9 -7
  250. data/src/core/lib/transport/parsed_metadata.h +4 -2
  251. data/src/core/lib/transport/status_conversion.cc +1 -3
  252. data/src/core/lib/transport/tcp_connect_handshaker.cc +9 -5
  253. data/src/core/lib/transport/transport.h +0 -1
  254. data/src/core/lib/transport/transport_impl.h +0 -1
  255. data/src/core/plugin_registry/grpc_plugin_registry.cc +23 -46
  256. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +13 -25
  257. data/src/ruby/lib/grpc/2.6/grpc_c.so +0 -0
  258. data/src/ruby/lib/grpc/2.7/grpc_c.so +0 -0
  259. data/src/ruby/lib/grpc/3.0/grpc_c.so +0 -0
  260. data/src/ruby/lib/grpc/3.1/grpc_c.so +0 -0
  261. data/src/ruby/lib/grpc/grpc_c.so +0 -0
  262. data/src/ruby/lib/grpc/version.rb +1 -1
  263. data/src/ruby/spec/channel_spec.rb +5 -0
  264. data/src/ruby/spec/generic/server_interceptors_spec.rb +1 -1
  265. data/src/ruby/spec/user_agent_spec.rb +1 -1
  266. metadata +33 -19
  267. data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +0 -56
  268. data/src/core/ext/xds/certificate_provider_registry.cc +0 -103
  269. data/src/core/ext/xds/certificate_provider_registry.h +0 -59
  270. data/src/core/lib/event_engine/promise.h +0 -78
  271. data/src/core/lib/gpr/env_windows.cc +0 -74
  272. data/src/core/lib/gpr/string_windows.h +0 -32
  273. data/src/core/lib/profiling/basic_timers.cc +0 -295
  274. data/src/core/lib/profiling/stap_timers.cc +0 -50
  275. data/src/core/lib/profiling/timers.h +0 -94
@@ -20,6 +20,7 @@
20
20
 
21
21
  #include <grpc/impl/codegen/grpc_types.h>
22
22
 
23
+ #include "src/core/lib/gprpp/global_config_generic.h"
23
24
  #include "src/core/lib/iomgr/port.h"
24
25
 
25
26
  #ifdef GRPC_POSIX_SOCKET_TCP
@@ -47,9 +48,9 @@
47
48
  #include <grpc/support/time.h>
48
49
 
49
50
  #include "src/core/lib/address_utils/sockaddr_utils.h"
50
- #include "src/core/lib/channel/channel_args.h"
51
51
  #include "src/core/lib/debug/stats.h"
52
52
  #include "src/core/lib/debug/trace.h"
53
+ #include "src/core/lib/experiments/experiments.h"
53
54
  #include "src/core/lib/gpr/string.h"
54
55
  #include "src/core/lib/gpr/useful.h"
55
56
  #include "src/core/lib/gprpp/sync.h"
@@ -58,7 +59,6 @@
58
59
  #include "src/core/lib/iomgr/executor.h"
59
60
  #include "src/core/lib/iomgr/socket_utils_posix.h"
60
61
  #include "src/core/lib/iomgr/tcp_posix.h"
61
- #include "src/core/lib/profiling/timers.h"
62
62
  #include "src/core/lib/resource_quota/api.h"
63
63
  #include "src/core/lib/resource_quota/memory_quota.h"
64
64
  #include "src/core/lib/resource_quota/trace.h"
@@ -97,8 +97,6 @@ typedef size_t msg_iovlen_type;
97
97
 
98
98
  extern grpc_core::TraceFlag grpc_tcp_trace;
99
99
 
100
- GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_experimental_enable_tcp_frame_size_tuning);
101
-
102
100
  namespace grpc_core {
103
101
 
104
102
  class TcpZerocopySendRecord {
@@ -466,22 +464,20 @@ using grpc_core::TcpZerocopySendRecord;
466
464
 
467
465
  namespace {
468
466
 
469
- bool ExperimentalTcpFrameSizeTuningEnabled() {
470
- static const bool kEnableTcpFrameSizeTuning =
471
- GPR_GLOBAL_CONFIG_GET(grpc_experimental_enable_tcp_frame_size_tuning);
472
- return kEnableTcpFrameSizeTuning;
473
- }
474
-
475
467
  struct grpc_tcp {
476
- grpc_tcp(int max_sends, size_t send_bytes_threshold)
477
- : tcp_zerocopy_send_ctx(max_sends, send_bytes_threshold) {}
468
+ explicit grpc_tcp(const grpc_core::PosixTcpOptions& tcp_options)
469
+ : min_read_chunk_size(tcp_options.tcp_min_read_chunk_size),
470
+ max_read_chunk_size(tcp_options.tcp_max_read_chunk_size),
471
+ tcp_zerocopy_send_ctx(
472
+ tcp_options.tcp_tx_zerocopy_max_simultaneous_sends,
473
+ tcp_options.tcp_tx_zerocopy_send_bytes_threshold) {}
478
474
  grpc_endpoint base;
479
475
  grpc_fd* em_fd;
480
476
  int fd;
481
477
  /* Used by the endpoint read function to distinguish the very first read call
482
478
  * from the rest */
483
479
  bool is_first_read;
484
- bool has_posted_reclaimer;
480
+ bool has_posted_reclaimer ABSL_GUARDED_BY(read_mu) = false;
485
481
  double target_length;
486
482
  double bytes_read_this_round;
487
483
  grpc_core::RefCount refcount;
@@ -489,6 +485,7 @@ struct grpc_tcp {
489
485
 
490
486
  int min_read_chunk_size;
491
487
  int max_read_chunk_size;
488
+ int set_rcvlowat = 0;
492
489
 
493
490
  /* garbage after the last read */
494
491
  grpc_slice_buffer last_read_buffer;
@@ -585,8 +582,7 @@ static void run_poller(void* bp, grpc_error_handle /*error_ignored*/) {
585
582
  }
586
583
  gpr_mu_lock(p->pollset_mu);
587
584
  grpc_core::Timestamp deadline =
588
- grpc_core::ExecCtx::Get()->Now() + grpc_core::Duration::Seconds(10);
589
- GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS();
585
+ grpc_core::Timestamp::Now() + grpc_core::Duration::Seconds(10);
590
586
  GRPC_LOG_IF_ERROR(
591
587
  "backup_poller:pollset_work",
592
588
  grpc_pollset_work(BACKUP_POLLER_POLLSET(p), nullptr, deadline));
@@ -647,7 +643,6 @@ static void cover_self(grpc_tcp* tcp) {
647
643
  g_backup_poller = p;
648
644
  grpc_pollset_init(BACKUP_POLLER_POLLSET(p), &p->pollset_mu);
649
645
  g_backup_poller_mu->Unlock();
650
- GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED();
651
646
  if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
652
647
  gpr_log(GPR_INFO, "BACKUP_POLLER:%p create", p);
653
648
  }
@@ -793,8 +788,8 @@ static void perform_reclamation(grpc_tcp* tcp)
793
788
  if (tcp->incoming_buffer != nullptr) {
794
789
  grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
795
790
  }
796
- tcp->read_mu.Unlock();
797
791
  tcp->has_posted_reclaimer = false;
792
+ tcp->read_mu.Unlock();
798
793
  }
799
794
 
800
795
  static void maybe_post_reclaimer(grpc_tcp* tcp)
@@ -829,11 +824,54 @@ static void tcp_trace_read(grpc_tcp* tcp, grpc_error_handle error)
829
824
  }
830
825
  }
831
826
 
827
+ static void update_rcvlowat(grpc_tcp* tcp)
828
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(tcp->read_mu) {
829
+ if (!grpc_core::IsTcpRcvLowatEnabled()) return;
830
+
831
+ // TODO(ctiller): Check if supported by OS.
832
+ // TODO(ctiller): Allow some adjustments instead of hardcoding things.
833
+
834
+ static constexpr int kRcvLowatMax = 16 * 1024 * 1024;
835
+ static constexpr int kRcvLowatThreshold = 16 * 1024;
836
+
837
+ int remaining = std::min(static_cast<int>(tcp->incoming_buffer->length),
838
+ tcp->min_progress_size);
839
+ remaining = std::min(remaining, kRcvLowatMax);
840
+
841
+ // Setting SO_RCVLOWAT for small quantities does not save on CPU.
842
+ if (remaining < kRcvLowatThreshold) {
843
+ remaining = 0;
844
+ }
845
+
846
+ // If zerocopy is off, wake shortly before the full RPC is here. More can
847
+ // show up partway through recvmsg() since it takes a while to copy data.
848
+ // So an early wakeup aids latency.
849
+ if (!tcp->tcp_zerocopy_send_ctx.enabled() && remaining > 0) {
850
+ remaining -= kRcvLowatThreshold;
851
+ }
852
+
853
+ // We still do not know the RPC size. Do not set SO_RCVLOWAT.
854
+ if (tcp->set_rcvlowat <= 1 && remaining <= 1) return;
855
+
856
+ // Previous value is still valid. No change needed in SO_RCVLOWAT.
857
+ if (tcp->set_rcvlowat == remaining) {
858
+ return;
859
+ }
860
+ if (setsockopt(tcp->fd, SOL_SOCKET, SO_RCVLOWAT, &remaining,
861
+ sizeof(remaining)) != 0) {
862
+ gpr_log(GPR_ERROR, "%s",
863
+ absl::StrCat("Cannot set SO_RCVLOWAT on fd=", tcp->fd,
864
+ " err=", strerror(errno))
865
+ .c_str());
866
+ return;
867
+ }
868
+ tcp->set_rcvlowat = remaining;
869
+ }
870
+
832
871
  /* Returns true if data available to read or error other than EAGAIN. */
833
- #define MAX_READ_IOVEC 4
872
+ #define MAX_READ_IOVEC 64
834
873
  static bool tcp_do_read(grpc_tcp* tcp, grpc_error_handle* error)
835
874
  ABSL_EXCLUSIVE_LOCKS_REQUIRED(tcp->read_mu) {
836
- GPR_TIMER_SCOPE("tcp_do_read", 0);
837
875
  if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
838
876
  gpr_log(GPR_INFO, "TCP:%p do_read", tcp);
839
877
  }
@@ -881,7 +919,6 @@ static bool tcp_do_read(grpc_tcp* tcp, grpc_error_handle* error)
881
919
  GRPC_STATS_INC_TCP_READ_OFFER_IOV_SIZE(tcp->incoming_buffer->count);
882
920
 
883
921
  do {
884
- GPR_TIMER_SCOPE("recvmsg", 0);
885
922
  GRPC_STATS_INC_SYSCALL_READ();
886
923
  read_bytes = recvmsg(tcp->fd, &msg, 0);
887
924
  } while (read_bytes < 0 && errno == EINTR);
@@ -1010,31 +1047,66 @@ static bool tcp_do_read(grpc_tcp* tcp, grpc_error_handle* error)
1010
1047
 
1011
1048
  static void maybe_make_read_slices(grpc_tcp* tcp)
1012
1049
  ABSL_EXCLUSIVE_LOCKS_REQUIRED(tcp->read_mu) {
1013
- if (tcp->incoming_buffer->length <
1014
- static_cast<size_t>(tcp->min_progress_size) &&
1015
- tcp->incoming_buffer->count < MAX_READ_IOVEC) {
1016
- if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
1017
- gpr_log(GPR_INFO,
1018
- "TCP:%p alloc_slices; min_chunk=%d max_chunk=%d target=%lf "
1019
- "buf_len=%" PRIdPTR,
1020
- tcp, tcp->min_read_chunk_size, tcp->max_read_chunk_size,
1021
- tcp->target_length, tcp->incoming_buffer->length);
1050
+ if (grpc_core::IsTcpReadChunksEnabled()) {
1051
+ static const int kBigAlloc = 64 * 1024;
1052
+ static const int kSmallAlloc = 8 * 1024;
1053
+ if (tcp->incoming_buffer->length <
1054
+ static_cast<size_t>(tcp->min_progress_size)) {
1055
+ size_t allocate_length = tcp->min_progress_size;
1056
+ const size_t target_length = static_cast<size_t>(tcp->target_length);
1057
+ // If memory pressure is low and we think there will be more than
1058
+ // min_progress_size bytes to read, allocate a bit more.
1059
+ const bool low_memory_pressure =
1060
+ tcp->memory_owner.GetPressureInfo().pressure_control_value < 0.8;
1061
+ if (low_memory_pressure && target_length > allocate_length) {
1062
+ allocate_length = target_length;
1063
+ }
1064
+ int extra_wanted =
1065
+ allocate_length - static_cast<int>(tcp->incoming_buffer->length);
1066
+ if (extra_wanted >=
1067
+ (low_memory_pressure ? kSmallAlloc * 3 / 2 : kBigAlloc)) {
1068
+ while (extra_wanted > 0) {
1069
+ extra_wanted -= kBigAlloc;
1070
+ grpc_slice_buffer_add_indexed(tcp->incoming_buffer,
1071
+ tcp->memory_owner.MakeSlice(kBigAlloc));
1072
+ GRPC_STATS_INC_TCP_READ_ALLOC_64K();
1073
+ }
1074
+ } else {
1075
+ while (extra_wanted > 0) {
1076
+ extra_wanted -= kSmallAlloc;
1077
+ grpc_slice_buffer_add_indexed(
1078
+ tcp->incoming_buffer, tcp->memory_owner.MakeSlice(kSmallAlloc));
1079
+ GRPC_STATS_INC_TCP_READ_ALLOC_8K();
1080
+ }
1081
+ }
1082
+ maybe_post_reclaimer(tcp);
1083
+ }
1084
+ } else {
1085
+ if (tcp->incoming_buffer->length <
1086
+ static_cast<size_t>(tcp->min_progress_size) &&
1087
+ tcp->incoming_buffer->count < MAX_READ_IOVEC) {
1088
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
1089
+ gpr_log(GPR_INFO,
1090
+ "TCP:%p alloc_slices; min_chunk=%d max_chunk=%d target=%lf "
1091
+ "buf_len=%" PRIdPTR,
1092
+ tcp, tcp->min_read_chunk_size, tcp->max_read_chunk_size,
1093
+ tcp->target_length, tcp->incoming_buffer->length);
1094
+ }
1095
+ int target_length = std::max(static_cast<int>(tcp->target_length),
1096
+ tcp->min_progress_size);
1097
+ int extra_wanted =
1098
+ target_length - static_cast<int>(tcp->incoming_buffer->length);
1099
+ int min_read_chunk_size =
1100
+ std::max(tcp->min_read_chunk_size, tcp->min_progress_size);
1101
+ int max_read_chunk_size =
1102
+ std::max(tcp->max_read_chunk_size, tcp->min_progress_size);
1103
+ grpc_slice slice = tcp->memory_owner.MakeSlice(grpc_core::MemoryRequest(
1104
+ min_read_chunk_size,
1105
+ grpc_core::Clamp(extra_wanted, min_read_chunk_size,
1106
+ max_read_chunk_size)));
1107
+ grpc_slice_buffer_add_indexed(tcp->incoming_buffer, slice);
1108
+ maybe_post_reclaimer(tcp);
1022
1109
  }
1023
- int target_length =
1024
- std::max(static_cast<int>(tcp->target_length), tcp->min_progress_size);
1025
- int extra_wanted =
1026
- target_length - static_cast<int>(tcp->incoming_buffer->length);
1027
- int min_read_chunk_size =
1028
- std::max(tcp->min_read_chunk_size, tcp->min_progress_size);
1029
- int max_read_chunk_size =
1030
- std::max(tcp->max_read_chunk_size, tcp->min_progress_size);
1031
- grpc_slice_buffer_add_indexed(
1032
- tcp->incoming_buffer,
1033
- tcp->memory_owner.MakeSlice(grpc_core::MemoryRequest(
1034
- min_read_chunk_size,
1035
- grpc_core::Clamp(extra_wanted, min_read_chunk_size,
1036
- max_read_chunk_size))));
1037
- maybe_post_reclaimer(tcp);
1038
1110
  }
1039
1111
  }
1040
1112
 
@@ -1050,6 +1122,7 @@ static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error_handle error) {
1050
1122
  maybe_make_read_slices(tcp);
1051
1123
  if (!tcp_do_read(tcp, &tcp_read_error)) {
1052
1124
  /* We've consumed the edge, request a new one */
1125
+ update_rcvlowat(tcp);
1053
1126
  tcp->read_mu.Unlock();
1054
1127
  notify_on_read(tcp);
1055
1128
  return;
@@ -1079,19 +1152,23 @@ static void tcp_read(grpc_endpoint* ep, grpc_slice_buffer* incoming_buffer,
1079
1152
  tcp->frame_size_tuning_enabled ? min_progress_size : 1;
1080
1153
  grpc_slice_buffer_reset_and_unref_internal(incoming_buffer);
1081
1154
  grpc_slice_buffer_swap(incoming_buffer, &tcp->last_read_buffer);
1082
- tcp->read_mu.Unlock();
1083
1155
  TCP_REF(tcp, "read");
1084
1156
  if (tcp->is_first_read) {
1157
+ update_rcvlowat(tcp);
1158
+ tcp->read_mu.Unlock();
1085
1159
  /* Endpoint read called for the very first time. Register read callback with
1086
1160
  * the polling engine */
1087
1161
  tcp->is_first_read = false;
1088
1162
  notify_on_read(tcp);
1089
1163
  } else if (!urgent && tcp->inq == 0) {
1164
+ update_rcvlowat(tcp);
1165
+ tcp->read_mu.Unlock();
1090
1166
  /* Upper layer asked to read more but we know there is no pending data
1091
1167
  * to read from previous reads. So, wait for POLLIN.
1092
1168
  */
1093
1169
  notify_on_read(tcp);
1094
1170
  } else {
1171
+ tcp->read_mu.Unlock();
1095
1172
  /* Not the first time. We may or may not have more bytes available. In any
1096
1173
  * case call tcp->read_done_closure (i.e tcp_handle_read()) which does the
1097
1174
  * right thing (i.e calls tcp_do_read() which either reads the available
@@ -1106,7 +1183,6 @@ static void tcp_read(grpc_endpoint* ep, grpc_slice_buffer* incoming_buffer,
1106
1183
  * of bytes sent. */
1107
1184
  ssize_t tcp_send(int fd, const struct msghdr* msg, int* saved_errno,
1108
1185
  int additional_flags = 0) {
1109
- GPR_TIMER_SCOPE("sendmsg", 1);
1110
1186
  ssize_t sent_length;
1111
1187
  do {
1112
1188
  /* TODO(klempner): Cork if this is a partial write */
@@ -1748,7 +1824,6 @@ static void tcp_handle_write(void* arg /* grpc_tcp */,
1748
1824
 
1749
1825
  static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
1750
1826
  grpc_closure* cb, void* arg, int /*max_frame_size*/) {
1751
- GPR_TIMER_SCOPE("tcp_write", 0);
1752
1827
  grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep);
1753
1828
  grpc_error_handle error = GRPC_ERROR_NONE;
1754
1829
  TcpZerocopySendRecord* zerocopy_send_record = nullptr;
@@ -1869,72 +1944,16 @@ static const grpc_endpoint_vtable vtable = {tcp_read,
1869
1944
  tcp_get_fd,
1870
1945
  tcp_can_track_err};
1871
1946
 
1872
- #define MAX_CHUNK_SIZE (32 * 1024 * 1024)
1873
-
1874
1947
  grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd,
1875
- const grpc_channel_args* channel_args,
1948
+ const grpc_core::PosixTcpOptions& options,
1876
1949
  absl::string_view peer_string) {
1877
- static constexpr bool kZerocpTxEnabledDefault = false;
1878
- int tcp_read_chunk_size = GRPC_TCP_DEFAULT_READ_SLICE_SIZE;
1879
- int tcp_max_read_chunk_size = 4 * 1024 * 1024;
1880
- int tcp_min_read_chunk_size = 256;
1881
- bool tcp_tx_zerocopy_enabled = kZerocpTxEnabledDefault;
1882
- int tcp_tx_zerocopy_send_bytes_thresh =
1883
- grpc_core::TcpZerocopySendCtx::kDefaultSendBytesThreshold;
1884
- int tcp_tx_zerocopy_max_simult_sends =
1885
- grpc_core::TcpZerocopySendCtx::kDefaultMaxSends;
1886
- if (channel_args != nullptr) {
1887
- for (size_t i = 0; i < channel_args->num_args; i++) {
1888
- if (0 ==
1889
- strcmp(channel_args->args[i].key, GRPC_ARG_TCP_READ_CHUNK_SIZE)) {
1890
- grpc_integer_options options = {tcp_read_chunk_size, 1, MAX_CHUNK_SIZE};
1891
- tcp_read_chunk_size =
1892
- grpc_channel_arg_get_integer(&channel_args->args[i], options);
1893
- } else if (0 == strcmp(channel_args->args[i].key,
1894
- GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE)) {
1895
- grpc_integer_options options = {tcp_read_chunk_size, 1, MAX_CHUNK_SIZE};
1896
- tcp_min_read_chunk_size =
1897
- grpc_channel_arg_get_integer(&channel_args->args[i], options);
1898
- } else if (0 == strcmp(channel_args->args[i].key,
1899
- GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE)) {
1900
- grpc_integer_options options = {tcp_read_chunk_size, 1, MAX_CHUNK_SIZE};
1901
- tcp_max_read_chunk_size =
1902
- grpc_channel_arg_get_integer(&channel_args->args[i], options);
1903
- } else if (0 == strcmp(channel_args->args[i].key,
1904
- GRPC_ARG_TCP_TX_ZEROCOPY_ENABLED)) {
1905
- tcp_tx_zerocopy_enabled = grpc_channel_arg_get_bool(
1906
- &channel_args->args[i], kZerocpTxEnabledDefault);
1907
- } else if (0 == strcmp(channel_args->args[i].key,
1908
- GRPC_ARG_TCP_TX_ZEROCOPY_SEND_BYTES_THRESHOLD)) {
1909
- grpc_integer_options options = {
1910
- grpc_core::TcpZerocopySendCtx::kDefaultSendBytesThreshold, 0,
1911
- INT_MAX};
1912
- tcp_tx_zerocopy_send_bytes_thresh =
1913
- grpc_channel_arg_get_integer(&channel_args->args[i], options);
1914
- } else if (0 == strcmp(channel_args->args[i].key,
1915
- GRPC_ARG_TCP_TX_ZEROCOPY_MAX_SIMULT_SENDS)) {
1916
- grpc_integer_options options = {
1917
- grpc_core::TcpZerocopySendCtx::kDefaultMaxSends, 0, INT_MAX};
1918
- tcp_tx_zerocopy_max_simult_sends =
1919
- grpc_channel_arg_get_integer(&channel_args->args[i], options);
1920
- }
1921
- }
1922
- }
1923
-
1924
- if (tcp_min_read_chunk_size > tcp_max_read_chunk_size) {
1925
- tcp_min_read_chunk_size = tcp_max_read_chunk_size;
1926
- }
1927
- tcp_read_chunk_size = grpc_core::Clamp(
1928
- tcp_read_chunk_size, tcp_min_read_chunk_size, tcp_max_read_chunk_size);
1929
-
1930
- grpc_tcp* tcp = new grpc_tcp(tcp_tx_zerocopy_max_simult_sends,
1931
- tcp_tx_zerocopy_send_bytes_thresh);
1950
+ grpc_tcp* tcp = new grpc_tcp(options);
1932
1951
  tcp->base.vtable = &vtable;
1933
1952
  tcp->peer_string = std::string(peer_string);
1934
1953
  tcp->fd = grpc_fd_wrapped_fd(em_fd);
1935
- tcp->memory_owner = grpc_core::ResourceQuotaFromChannelArgs(channel_args)
1936
- ->memory_quota()
1937
- ->CreateMemoryOwner(peer_string);
1954
+ GPR_ASSERT(options.resource_quota != nullptr);
1955
+ tcp->memory_owner =
1956
+ options.resource_quota->memory_quota()->CreateMemoryOwner(peer_string);
1938
1957
  tcp->self_reservation = tcp->memory_owner.MakeReservation(sizeof(grpc_tcp));
1939
1958
  grpc_resolved_address resolved_local_addr;
1940
1959
  memset(&resolved_local_addr, 0, sizeof(resolved_local_addr));
@@ -1953,20 +1972,18 @@ grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd,
1953
1972
  tcp->current_zerocopy_send = nullptr;
1954
1973
  tcp->release_fd_cb = nullptr;
1955
1974
  tcp->release_fd = nullptr;
1956
- tcp->target_length = static_cast<double>(tcp_read_chunk_size);
1957
- tcp->min_read_chunk_size = tcp_min_read_chunk_size;
1958
- tcp->max_read_chunk_size = tcp_max_read_chunk_size;
1975
+ tcp->target_length = static_cast<double>(options.tcp_read_chunk_size);
1959
1976
  tcp->bytes_read_this_round = 0;
1960
1977
  /* Will be set to false by the very first endpoint read function */
1961
1978
  tcp->is_first_read = true;
1962
- tcp->has_posted_reclaimer = false;
1963
1979
  tcp->bytes_counter = -1;
1964
1980
  tcp->socket_ts_enabled = false;
1965
1981
  tcp->ts_capable = true;
1966
1982
  tcp->outgoing_buffer_arg = nullptr;
1967
- tcp->frame_size_tuning_enabled = ExperimentalTcpFrameSizeTuningEnabled();
1983
+ tcp->frame_size_tuning_enabled = grpc_core::IsTcpFrameSizeTuningEnabled();
1968
1984
  tcp->min_progress_size = 1;
1969
- if (tcp_tx_zerocopy_enabled && !tcp->tcp_zerocopy_send_ctx.memory_limited()) {
1985
+ if (options.tcp_tx_zero_copy_enabled &&
1986
+ !tcp->tcp_zerocopy_send_ctx.memory_limited()) {
1970
1987
  #ifdef GRPC_LINUX_ERRQUEUE
1971
1988
  const int enable = 1;
1972
1989
  auto err =
@@ -36,12 +36,14 @@
36
36
  #include "src/core/lib/iomgr/endpoint.h"
37
37
  #include "src/core/lib/iomgr/ev_posix.h"
38
38
  #include "src/core/lib/iomgr/port.h"
39
+ #include "src/core/lib/iomgr/socket_utils_posix.h"
39
40
 
40
41
  extern grpc_core::TraceFlag grpc_tcp_trace;
41
42
 
42
43
  /// Create a tcp endpoint given a file desciptor and a read slice size.
43
44
  /// Takes ownership of \a fd. Takes ownership of the \a slice_allocator.
44
- grpc_endpoint* grpc_tcp_create(grpc_fd* fd, const grpc_channel_args* args,
45
+ grpc_endpoint* grpc_tcp_create(grpc_fd* fd,
46
+ const grpc_core::PosixTcpOptions& options,
45
47
  absl::string_view peer_string);
46
48
 
47
49
  /// Return the tcp endpoint's fd, or -1 if this is not available. Does not
@@ -22,10 +22,11 @@
22
22
 
23
23
  grpc_tcp_server_vtable* grpc_tcp_server_impl;
24
24
 
25
- grpc_error_handle grpc_tcp_server_create(grpc_closure* shutdown_complete,
26
- const grpc_channel_args* args,
27
- grpc_tcp_server** server) {
28
- return grpc_tcp_server_impl->create(shutdown_complete, args, server);
25
+ grpc_error_handle grpc_tcp_server_create(
26
+ grpc_closure* shutdown_complete,
27
+ const grpc_event_engine::experimental::EndpointConfig& config,
28
+ grpc_tcp_server** server) {
29
+ return grpc_tcp_server_impl->create(shutdown_complete, config, server);
29
30
  }
30
31
 
31
32
  void grpc_tcp_server_start(grpc_tcp_server* server,
@@ -23,6 +23,7 @@
23
23
 
24
24
  #include <vector>
25
25
 
26
+ #include <grpc/event_engine/endpoint_config.h>
26
27
  #include <grpc/grpc.h>
27
28
  #include <grpc/impl/codegen/grpc_types.h>
28
29
 
@@ -63,9 +64,10 @@ class TcpServerFdHandler {
63
64
  } // namespace grpc_core
64
65
 
65
66
  typedef struct grpc_tcp_server_vtable {
66
- grpc_error_handle (*create)(grpc_closure* shutdown_complete,
67
- const grpc_channel_args* args,
68
- grpc_tcp_server** server);
67
+ grpc_error_handle (*create)(
68
+ grpc_closure* shutdown_complete,
69
+ const grpc_event_engine::experimental::EndpointConfig& config,
70
+ grpc_tcp_server** server);
69
71
  void (*start)(grpc_tcp_server* server,
70
72
  const std::vector<grpc_pollset*>* pollsets,
71
73
  grpc_tcp_server_cb on_accept_cb, void* cb_arg);
@@ -86,9 +88,10 @@ typedef struct grpc_tcp_server_vtable {
86
88
  If shutdown_complete is not NULL, it will be used by
87
89
  grpc_tcp_server_unref() when the ref count reaches zero.
88
90
  Takes ownership of the slice_allocator_factory. */
89
- grpc_error_handle grpc_tcp_server_create(grpc_closure* shutdown_complete,
90
- const grpc_channel_args* args,
91
- grpc_tcp_server** server);
91
+ grpc_error_handle grpc_tcp_server_create(
92
+ grpc_closure* shutdown_complete,
93
+ const grpc_event_engine::experimental::EndpointConfig& config,
94
+ grpc_tcp_server** server);
92
95
 
93
96
  /* Start listening to bound ports */
94
97
  void grpc_tcp_server_start(grpc_tcp_server* server,
@@ -43,13 +43,13 @@
43
43
  #include "absl/strings/str_cat.h"
44
44
  #include "absl/strings/str_format.h"
45
45
 
46
+ #include <grpc/event_engine/endpoint_config.h>
46
47
  #include <grpc/support/alloc.h>
47
48
  #include <grpc/support/log.h>
48
49
  #include <grpc/support/sync.h>
49
50
  #include <grpc/support/time.h>
50
51
 
51
52
  #include "src/core/lib/address_utils/sockaddr_utils.h"
52
- #include "src/core/lib/channel/channel_args.h"
53
53
  #include "src/core/lib/gpr/string.h"
54
54
  #include "src/core/lib/gprpp/memory.h"
55
55
  #include "src/core/lib/iomgr/exec_ctx.h"
@@ -64,31 +64,21 @@
64
64
 
65
65
  static std::atomic<int64_t> num_dropped_connections{0};
66
66
 
67
+ using ::grpc_event_engine::experimental::EndpointConfig;
68
+
67
69
  static grpc_error_handle tcp_server_create(grpc_closure* shutdown_complete,
68
- const grpc_channel_args* args,
70
+ const EndpointConfig& config,
69
71
  grpc_tcp_server** server) {
70
72
  grpc_tcp_server* s = new grpc_tcp_server;
71
73
  s->so_reuseport = grpc_is_socket_reuse_port_supported();
72
74
  s->expand_wildcard_addrs = false;
73
- for (size_t i = 0; i < (args == nullptr ? 0 : args->num_args); i++) {
74
- if (0 == strcmp(GRPC_ARG_ALLOW_REUSEPORT, args->args[i].key)) {
75
- if (args->args[i].type == GRPC_ARG_INTEGER) {
76
- s->so_reuseport = grpc_is_socket_reuse_port_supported() &&
77
- (args->args[i].value.integer != 0);
78
- } else {
79
- gpr_free(s);
80
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(GRPC_ARG_ALLOW_REUSEPORT
81
- " must be an integer");
82
- }
83
- } else if (0 == strcmp(GRPC_ARG_EXPAND_WILDCARD_ADDRS, args->args[i].key)) {
84
- if (args->args[i].type == GRPC_ARG_INTEGER) {
85
- s->expand_wildcard_addrs = (args->args[i].value.integer != 0);
86
- } else {
87
- gpr_free(s);
88
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
89
- GRPC_ARG_EXPAND_WILDCARD_ADDRS " must be an integer");
90
- }
91
- }
75
+ auto value = config.GetInt(GRPC_ARG_ALLOW_REUSEPORT);
76
+ if (value.has_value()) {
77
+ s->so_reuseport = (grpc_is_socket_reuse_port_supported() && *value != 0);
78
+ }
79
+ value = config.GetInt(GRPC_ARG_EXPAND_WILDCARD_ADDRS);
80
+ if (value.has_value()) {
81
+ s->expand_wildcard_addrs = (*value != 0);
92
82
  }
93
83
  gpr_ref_init(&s->refs, 1);
94
84
  gpr_mu_init(&s->mu);
@@ -103,10 +93,10 @@ static grpc_error_handle tcp_server_create(grpc_closure* shutdown_complete,
103
93
  s->head = nullptr;
104
94
  s->tail = nullptr;
105
95
  s->nports = 0;
106
- s->channel_args = grpc_channel_args_copy(args);
96
+ s->options = TcpOptionsFromEndpointConfig(config);
107
97
  s->fd_handler = nullptr;
108
- s->memory_quota =
109
- grpc_core::ResourceQuotaFromChannelArgs(args)->memory_quota();
98
+ GPR_ASSERT(s->options.resource_quota != nullptr);
99
+ s->memory_quota = s->options.resource_quota->memory_quota();
110
100
  gpr_atm_no_barrier_store(&s->next_pollset_to_assign, 0);
111
101
  *server = s;
112
102
  return GRPC_ERROR_NONE;
@@ -126,7 +116,6 @@ static void finish_shutdown(grpc_tcp_server* s) {
126
116
  s->head = sp->next;
127
117
  gpr_free(sp);
128
118
  }
129
- grpc_channel_args_destroy(s->channel_args);
130
119
  delete s->fd_handler;
131
120
  delete s;
132
121
  }
@@ -252,7 +241,7 @@ static void on_read(void* arg, grpc_error_handle err) {
252
241
  (void)grpc_set_socket_no_sigpipe_if_possible(fd);
253
242
 
254
243
  err = grpc_apply_socket_mutator_in_args(fd, GRPC_FD_SERVER_CONNECTION_USAGE,
255
- sp->server->channel_args);
244
+ sp->server->options);
256
245
  if (!GRPC_ERROR_IS_NONE(err)) {
257
246
  goto error;
258
247
  }
@@ -287,7 +276,7 @@ static void on_read(void* arg, grpc_error_handle err) {
287
276
  acceptor->external_connection = false;
288
277
  sp->server->on_accept_cb(
289
278
  sp->server->on_accept_cb_arg,
290
- grpc_tcp_create(fdobj, sp->server->channel_args, addr_uri.value()),
279
+ grpc_tcp_create(fdobj, sp->server->options, addr_uri.value()),
291
280
  read_notifier_pollset, acceptor);
292
281
  }
293
282
 
@@ -639,7 +628,7 @@ class ExternalConnectionHandler : public grpc_core::TcpServerFdHandler {
639
628
  acceptor->listener_fd = listener_fd;
640
629
  acceptor->pending_data = buf;
641
630
  s_->on_accept_cb(s_->on_accept_cb_arg,
642
- grpc_tcp_create(fdobj, s_->channel_args, addr_uri.value()),
631
+ grpc_tcp_create(fdobj, s_->options, addr_uri.value()),
643
632
  read_notifier_pollset, acceptor);
644
633
  }
645
634
 
@@ -90,8 +90,8 @@ struct grpc_tcp_server {
90
90
  /* next pollset to assign a channel to */
91
91
  gpr_atm next_pollset_to_assign = 0;
92
92
 
93
- /* channel args for this server */
94
- grpc_channel_args* channel_args = nullptr;
93
+ /* Contains config extracted from channel args for this server */
94
+ grpc_core::PosixTcpOptions options;
95
95
 
96
96
  /* a handler for external connections, owned */
97
97
  grpc_core::TcpServerFdHandler* fd_handler = nullptr;
@@ -178,15 +178,15 @@ grpc_error_handle grpc_tcp_server_prepare_socket(
178
178
  if (!GRPC_ERROR_IS_NONE(err)) goto error;
179
179
  err = grpc_set_socket_reuse_addr(fd, 1);
180
180
  if (!GRPC_ERROR_IS_NONE(err)) goto error;
181
- err = grpc_set_socket_tcp_user_timeout(fd, s->channel_args,
182
- false /* is_client */);
181
+ err =
182
+ grpc_set_socket_tcp_user_timeout(fd, s->options, false /* is_client */);
183
183
  if (!GRPC_ERROR_IS_NONE(err)) goto error;
184
184
  }
185
185
  err = grpc_set_socket_no_sigpipe_if_possible(fd);
186
186
  if (!GRPC_ERROR_IS_NONE(err)) goto error;
187
187
 
188
188
  err = grpc_apply_socket_mutator_in_args(fd, GRPC_FD_SERVER_LISTENER_USAGE,
189
- s->channel_args);
189
+ s->options);
190
190
  if (!GRPC_ERROR_IS_NONE(err)) goto error;
191
191
 
192
192
  if (bind(fd, reinterpret_cast<grpc_sockaddr*>(const_cast<char*>(addr->addr)),