grpc 1.8.7 → 1.9.0.pre1

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 (488) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +549 -325
  3. data/include/grpc/impl/codegen/grpc_types.h +1 -2
  4. data/include/grpc/impl/codegen/port_platform.h +46 -5
  5. data/include/grpc/impl/codegen/slice.h +1 -2
  6. data/include/grpc/module.modulemap +0 -2
  7. data/include/grpc/slice_buffer.h +1 -2
  8. data/include/grpc/support/log.h +4 -2
  9. data/include/grpc/support/thd.h +4 -1
  10. data/include/grpc/support/tls.h +6 -0
  11. data/include/grpc/support/tls_gcc.h +5 -40
  12. data/include/grpc/support/tls_msvc.h +9 -0
  13. data/include/grpc/support/tls_pthread.h +9 -0
  14. data/src/core/ext/filters/client_channel/backup_poller.cc +32 -29
  15. data/src/core/ext/filters/client_channel/backup_poller.h +2 -2
  16. data/src/core/ext/filters/client_channel/channel_connectivity.cc +26 -32
  17. data/src/core/ext/filters/client_channel/client_channel.cc +325 -356
  18. data/src/core/ext/filters/client_channel/client_channel.h +4 -12
  19. data/src/core/ext/filters/client_channel/client_channel_factory.cc +9 -14
  20. data/src/core/ext/filters/client_channel/client_channel_factory.h +7 -20
  21. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +7 -10
  22. data/src/core/ext/filters/client_channel/connector.cc +6 -7
  23. data/src/core/ext/filters/client_channel/connector.h +6 -16
  24. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +38 -50
  25. data/src/core/ext/filters/client_channel/http_connect_handshaker.h +0 -8
  26. data/src/core/ext/filters/client_channel/http_proxy.cc +9 -13
  27. data/src/core/ext/filters/client_channel/http_proxy.h +0 -8
  28. data/src/core/ext/filters/client_channel/lb_policy.cc +72 -94
  29. data/src/core/ext/filters/client_channel/lb_policy.h +83 -92
  30. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +14 -19
  31. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +0 -8
  32. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +474 -591
  33. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +0 -8
  34. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +2 -10
  35. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +6 -6
  36. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +0 -8
  37. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +0 -9
  38. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +0 -9
  39. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +3 -4
  40. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +9 -12
  41. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +160 -182
  42. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +182 -221
  43. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +24 -35
  44. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +9 -20
  45. data/src/core/ext/filters/client_channel/lb_policy_factory.cc +6 -9
  46. data/src/core/ext/filters/client_channel/lb_policy_factory.h +4 -15
  47. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +3 -3
  48. data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -9
  49. data/src/core/ext/filters/client_channel/parse_address.cc +1 -1
  50. data/src/core/ext/filters/client_channel/parse_address.h +0 -8
  51. data/src/core/ext/filters/client_channel/proxy_mapper.cc +6 -8
  52. data/src/core/ext/filters/client_channel/proxy_mapper.h +6 -16
  53. data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +13 -17
  54. data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +2 -12
  55. data/src/core/ext/filters/client_channel/resolver.cc +11 -13
  56. data/src/core/ext/filters/client_channel/resolver.h +14 -25
  57. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +57 -70
  58. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +2 -12
  59. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +23 -31
  60. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +27 -45
  61. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +5 -15
  62. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +9 -11
  63. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +53 -66
  64. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +25 -33
  65. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +1 -9
  66. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +26 -35
  67. data/src/core/ext/filters/client_channel/resolver_factory.cc +2 -3
  68. data/src/core/ext/filters/client_channel/resolver_factory.h +2 -12
  69. data/src/core/ext/filters/client_channel/resolver_registry.cc +12 -15
  70. data/src/core/ext/filters/client_channel/resolver_registry.h +3 -12
  71. data/src/core/ext/filters/client_channel/retry_throttle.h +0 -8
  72. data/src/core/ext/filters/client_channel/subchannel.cc +289 -301
  73. data/src/core/ext/filters/client_channel/subchannel.h +57 -84
  74. data/src/core/ext/filters/client_channel/subchannel_index.cc +30 -33
  75. data/src/core/ext/filters/client_channel/subchannel_index.h +4 -16
  76. data/src/core/ext/filters/client_channel/uri_parser.cc +13 -17
  77. data/src/core/ext/filters/client_channel/uri_parser.h +1 -10
  78. data/src/core/ext/filters/deadline/deadline_filter.cc +49 -67
  79. data/src/core/ext/filters/deadline/deadline_filter.h +4 -14
  80. data/src/core/ext/filters/http/client/http_client_filter.cc +60 -77
  81. data/src/core/ext/filters/http/client/http_client_filter.h +0 -8
  82. data/src/core/ext/filters/http/http_filters_plugin.cc +4 -6
  83. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +63 -79
  84. data/src/core/ext/filters/http/message_compress/message_compress_filter.h +0 -8
  85. data/src/core/ext/filters/http/server/http_server_filter.cc +57 -71
  86. data/src/core/ext/filters/http/server/http_server_filter.h +0 -8
  87. data/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +19 -24
  88. data/src/core/ext/filters/load_reporting/server_load_reporting_filter.h +0 -8
  89. data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc +3 -3
  90. data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h +0 -8
  91. data/src/core/ext/filters/max_age/max_age_filter.cc +49 -62
  92. data/src/core/ext/filters/max_age/max_age_filter.h +0 -8
  93. data/src/core/ext/filters/message_size/message_size_filter.cc +23 -29
  94. data/src/core/ext/filters/message_size/message_size_filter.h +0 -8
  95. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +15 -18
  96. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +0 -8
  97. data/src/core/ext/filters/workarounds/workaround_utils.h +0 -8
  98. data/src/core/ext/transport/chttp2/alpn/alpn.h +0 -8
  99. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +33 -40
  100. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +0 -8
  101. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +15 -17
  102. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +8 -8
  103. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +23 -28
  104. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +50 -57
  105. data/src/core/ext/transport/chttp2/server/chttp2_server.h +1 -10
  106. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +3 -3
  107. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +7 -10
  108. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +5 -6
  109. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +7 -9
  110. data/src/core/ext/transport/chttp2/transport/bin_decoder.h +2 -11
  111. data/src/core/ext/transport/chttp2/transport/bin_encoder.h +1 -9
  112. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +10 -2
  113. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +516 -636
  114. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +4 -11
  115. data/src/core/ext/transport/chttp2/transport/flow_control.cc +29 -13
  116. data/src/core/ext/transport/chttp2/transport/flow_control.h +196 -53
  117. data/src/core/ext/transport/chttp2/transport/frame.h +0 -8
  118. data/src/core/ext/transport/chttp2/transport/frame_data.cc +31 -33
  119. data/src/core/ext/transport/chttp2/transport/frame_data.h +3 -12
  120. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -3
  121. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +1 -10
  122. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -6
  123. data/src/core/ext/transport/chttp2/transport/frame_ping.h +1 -9
  124. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +2 -3
  125. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +1 -10
  126. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +8 -3
  127. data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -10
  128. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +8 -8
  129. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +5 -11
  130. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +63 -81
  131. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -12
  132. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +230 -318
  133. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +6 -19
  134. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +14 -20
  135. data/src/core/ext/transport/chttp2/transport/hpack_table.h +5 -16
  136. data/src/core/ext/transport/chttp2/transport/http2_settings.h +0 -7
  137. data/src/core/ext/transport/chttp2/transport/huffsyms.h +0 -8
  138. data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +8 -11
  139. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +4 -13
  140. data/src/core/ext/transport/chttp2/transport/internal.h +51 -75
  141. data/src/core/ext/transport/chttp2/transport/parsing.cc +83 -109
  142. data/src/core/ext/transport/chttp2/transport/stream_lists.cc +2 -0
  143. data/src/core/ext/transport/chttp2/transport/stream_map.h +0 -8
  144. data/src/core/ext/transport/chttp2/transport/varint.h +0 -8
  145. data/src/core/ext/transport/chttp2/transport/writing.cc +61 -65
  146. data/src/core/ext/transport/inproc/inproc_plugin.cc +2 -4
  147. data/src/core/ext/transport/inproc/inproc_transport.cc +177 -188
  148. data/src/core/ext/transport/inproc/inproc_transport.h +0 -8
  149. data/src/core/lib/backoff/backoff.cc +39 -44
  150. data/src/core/lib/backoff/backoff.h +61 -57
  151. data/src/core/lib/channel/channel_args.cc +8 -10
  152. data/src/core/lib/channel/channel_args.h +4 -13
  153. data/src/core/lib/channel/channel_stack.cc +19 -27
  154. data/src/core/lib/channel/channel_stack.h +27 -47
  155. data/src/core/lib/channel/channel_stack_builder.cc +11 -14
  156. data/src/core/lib/channel/channel_stack_builder.h +4 -15
  157. data/src/core/lib/channel/connected_channel.cc +23 -36
  158. data/src/core/lib/channel/connected_channel.h +1 -10
  159. data/src/core/lib/channel/handshaker.cc +31 -40
  160. data/src/core/lib/channel/handshaker.h +14 -25
  161. data/src/core/lib/channel/handshaker_factory.cc +6 -6
  162. data/src/core/lib/channel/handshaker_factory.h +5 -15
  163. data/src/core/lib/channel/handshaker_registry.cc +9 -13
  164. data/src/core/lib/channel/handshaker_registry.h +2 -11
  165. data/src/core/lib/compression/algorithm_metadata.h +0 -8
  166. data/src/core/lib/compression/message_compress.cc +19 -23
  167. data/src/core/lib/compression/message_compress.h +2 -12
  168. data/src/core/lib/compression/stream_compression.cc +1 -1
  169. data/src/core/lib/compression/stream_compression.h +0 -8
  170. data/src/core/lib/compression/stream_compression_gzip.cc +12 -11
  171. data/src/core/lib/compression/stream_compression_gzip.h +0 -8
  172. data/src/core/lib/compression/stream_compression_identity.h +0 -8
  173. data/src/core/lib/debug/stats.cc +4 -4
  174. data/src/core/lib/debug/stats.h +9 -19
  175. data/src/core/lib/debug/stats_data.cc +85 -116
  176. data/src/core/lib/debug/stats_data.h +236 -312
  177. data/src/core/lib/debug/trace.cc +1 -1
  178. data/src/core/lib/debug/trace.h +0 -12
  179. data/src/core/lib/{support → gpr++}/abstract.h +8 -3
  180. data/src/core/lib/{support → gpr++}/atomic.h +5 -5
  181. data/src/core/lib/{support → gpr++}/atomic_with_atm.h +3 -3
  182. data/src/core/lib/{support → gpr++}/atomic_with_std.h +3 -3
  183. data/src/core/lib/gpr++/debug_location.h +52 -0
  184. data/src/core/lib/gpr++/inlined_vector.h +112 -0
  185. data/src/core/lib/{support → gpr++}/manual_constructor.h +2 -2
  186. data/src/core/lib/{support → gpr++}/memory.h +3 -3
  187. data/src/core/lib/gpr++/orphanable.h +171 -0
  188. data/src/core/lib/gpr++/ref_counted.h +133 -0
  189. data/src/core/lib/gpr++/ref_counted_ptr.h +99 -0
  190. data/src/core/lib/{support → gpr}/alloc.cc +0 -0
  191. data/src/core/lib/{support → gpr}/arena.cc +1 -1
  192. data/src/core/lib/{support → gpr}/arena.h +3 -11
  193. data/src/core/lib/{support → gpr}/atm.cc +0 -0
  194. data/src/core/lib/{support → gpr}/avl.cc +0 -0
  195. data/src/core/lib/{support → gpr}/cmdline.cc +1 -1
  196. data/src/core/lib/{support → gpr}/cpu_iphone.cc +0 -0
  197. data/src/core/lib/{support → gpr}/cpu_linux.cc +0 -0
  198. data/src/core/lib/{support → gpr}/cpu_posix.cc +0 -0
  199. data/src/core/lib/{support → gpr}/cpu_windows.cc +0 -0
  200. data/src/core/lib/{support → gpr}/env.h +3 -11
  201. data/src/core/lib/{support → gpr}/env_linux.cc +2 -2
  202. data/src/core/lib/{support → gpr}/env_posix.cc +4 -4
  203. data/src/core/lib/{support → gpr}/env_windows.cc +3 -3
  204. data/src/core/lib/{support → gpr}/fork.cc +3 -3
  205. data/src/core/lib/{support → gpr}/fork.h +3 -3
  206. data/src/core/lib/{support → gpr}/host_port.cc +1 -1
  207. data/src/core/lib/{support → gpr}/log.cc +3 -3
  208. data/src/core/lib/{support → gpr}/log_android.cc +3 -3
  209. data/src/core/lib/{support → gpr}/log_linux.cc +1 -1
  210. data/src/core/lib/{support → gpr}/log_posix.cc +5 -5
  211. data/src/core/lib/{support → gpr}/log_windows.cc +3 -3
  212. data/src/core/lib/{support → gpr}/mpscq.cc +1 -1
  213. data/src/core/lib/{support → gpr}/mpscq.h +3 -10
  214. data/src/core/lib/{support → gpr}/murmur_hash.cc +1 -1
  215. data/src/core/lib/{support → gpr}/murmur_hash.h +3 -11
  216. data/src/core/lib/{support → gpr}/spinlock.h +3 -3
  217. data/src/core/lib/{support → gpr}/string.cc +1 -1
  218. data/src/core/lib/{support → gpr}/string.h +3 -10
  219. data/src/core/lib/{support → gpr}/string_posix.cc +0 -0
  220. data/src/core/lib/{support → gpr}/string_util_windows.cc +2 -2
  221. data/src/core/lib/{support → gpr}/string_windows.cc +1 -1
  222. data/src/core/lib/{support → gpr}/string_windows.h +3 -11
  223. data/src/core/lib/{support → gpr}/subprocess_posix.cc +0 -0
  224. data/src/core/lib/{support → gpr}/subprocess_windows.cc +2 -2
  225. data/src/core/lib/{support → gpr}/sync.cc +0 -0
  226. data/src/core/lib/{support → gpr}/sync_posix.cc +10 -1
  227. data/src/core/lib/{support → gpr}/sync_windows.cc +0 -0
  228. data/src/core/lib/{support → gpr}/thd.cc +0 -0
  229. data/src/core/lib/{support → gpr}/thd_internal.h +3 -3
  230. data/src/core/lib/{support → gpr}/thd_posix.cc +18 -2
  231. data/src/core/lib/{support → gpr}/thd_windows.cc +2 -1
  232. data/src/core/lib/{support → gpr}/time.cc +0 -0
  233. data/src/core/lib/{support → gpr}/time_posix.cc +2 -4
  234. data/src/core/lib/{support → gpr}/time_precise.cc +1 -1
  235. data/src/core/lib/{support → gpr}/time_precise.h +3 -11
  236. data/src/core/lib/{support → gpr}/time_windows.cc +1 -3
  237. data/src/core/lib/{support → gpr}/tls_pthread.cc +0 -0
  238. data/src/core/lib/{support → gpr}/tmpfile.h +3 -11
  239. data/src/core/lib/{support → gpr}/tmpfile_msys.cc +2 -2
  240. data/src/core/lib/{support → gpr}/tmpfile_posix.cc +2 -2
  241. data/src/core/lib/{support → gpr}/tmpfile_windows.cc +2 -2
  242. data/src/core/lib/{support → gpr}/wrap_memcpy.cc +0 -0
  243. data/src/core/lib/http/format_request.cc +1 -1
  244. data/src/core/lib/http/format_request.h +0 -8
  245. data/src/core/lib/http/httpcli.cc +55 -74
  246. data/src/core/lib/http/httpcli.h +13 -22
  247. data/src/core/lib/http/httpcli_security_connector.cc +27 -33
  248. data/src/core/lib/http/parser.h +0 -8
  249. data/src/core/lib/iomgr/block_annotate.h +10 -17
  250. data/src/core/lib/iomgr/call_combiner.cc +14 -17
  251. data/src/core/lib/iomgr/call_combiner.h +16 -34
  252. data/src/core/lib/iomgr/closure.h +24 -37
  253. data/src/core/lib/iomgr/combiner.cc +62 -66
  254. data/src/core/lib/iomgr/combiner.h +6 -16
  255. data/src/core/lib/iomgr/endpoint.cc +15 -21
  256. data/src/core/lib/iomgr/endpoint.h +16 -33
  257. data/src/core/lib/iomgr/endpoint_pair.h +0 -8
  258. data/src/core/lib/iomgr/endpoint_pair_posix.cc +4 -5
  259. data/src/core/lib/iomgr/endpoint_pair_windows.cc +4 -6
  260. data/src/core/lib/iomgr/error.cc +2 -6
  261. data/src/core/lib/iomgr/error.h +4 -9
  262. data/src/core/lib/iomgr/error_internal.h +0 -8
  263. data/src/core/lib/iomgr/ev_epoll1_linux.cc +110 -117
  264. data/src/core/lib/iomgr/ev_epoll1_linux.h +0 -8
  265. data/src/core/lib/iomgr/ev_epollex_linux.cc +111 -141
  266. data/src/core/lib/iomgr/ev_epollex_linux.h +0 -8
  267. data/src/core/lib/iomgr/ev_epollsig_linux.cc +83 -109
  268. data/src/core/lib/iomgr/ev_epollsig_linux.h +2 -10
  269. data/src/core/lib/iomgr/ev_poll_posix.cc +103 -125
  270. data/src/core/lib/iomgr/ev_poll_posix.h +0 -8
  271. data/src/core/lib/iomgr/ev_posix.cc +35 -50
  272. data/src/core/lib/iomgr/ev_posix.h +27 -53
  273. data/src/core/lib/iomgr/exec_ctx.cc +46 -78
  274. data/src/core/lib/iomgr/exec_ctx.h +127 -60
  275. data/src/core/lib/iomgr/executor.cc +34 -38
  276. data/src/core/lib/iomgr/executor.h +3 -11
  277. data/src/core/lib/iomgr/fork_posix.cc +13 -12
  278. data/src/core/lib/iomgr/gethostname.h +0 -8
  279. data/src/core/lib/iomgr/gethostname_sysconf.cc +1 -1
  280. data/src/core/lib/iomgr/iocp_windows.cc +14 -16
  281. data/src/core/lib/iomgr/iocp_windows.h +1 -10
  282. data/src/core/lib/iomgr/iomgr.cc +60 -59
  283. data/src/core/lib/iomgr/iomgr.h +3 -12
  284. data/src/core/lib/iomgr/iomgr_internal.h +0 -8
  285. data/src/core/lib/iomgr/iomgr_uv.cc +2 -3
  286. data/src/core/lib/iomgr/iomgr_uv.h +0 -8
  287. data/src/core/lib/iomgr/is_epollexclusive_available.cc +1 -1
  288. data/src/core/lib/iomgr/load_file.cc +1 -1
  289. data/src/core/lib/iomgr/load_file.h +0 -8
  290. data/src/core/lib/iomgr/lockfree_event.cc +7 -8
  291. data/src/core/lib/iomgr/lockfree_event.h +3 -3
  292. data/src/core/lib/iomgr/polling_entity.cc +6 -10
  293. data/src/core/lib/iomgr/polling_entity.h +2 -11
  294. data/src/core/lib/iomgr/pollset.h +4 -13
  295. data/src/core/lib/iomgr/pollset_set.h +5 -18
  296. data/src/core/lib/iomgr/pollset_set_uv.cc +5 -10
  297. data/src/core/lib/iomgr/pollset_set_windows.cc +5 -10
  298. data/src/core/lib/iomgr/pollset_uv.cc +8 -9
  299. data/src/core/lib/iomgr/pollset_uv.h +0 -8
  300. data/src/core/lib/iomgr/pollset_windows.cc +14 -15
  301. data/src/core/lib/iomgr/pollset_windows.h +0 -8
  302. data/src/core/lib/iomgr/port.h +6 -1
  303. data/src/core/lib/iomgr/resolve_address.h +1 -10
  304. data/src/core/lib/iomgr/resolve_address_posix.cc +10 -12
  305. data/src/core/lib/iomgr/resolve_address_uv.cc +7 -8
  306. data/src/core/lib/iomgr/resolve_address_windows.cc +8 -9
  307. data/src/core/lib/iomgr/resource_quota.cc +77 -107
  308. data/src/core/lib/iomgr/resource_quota.h +8 -25
  309. data/src/core/lib/iomgr/sockaddr_utils.cc +1 -1
  310. data/src/core/lib/iomgr/sockaddr_utils.h +0 -8
  311. data/src/core/lib/iomgr/socket_factory_posix.cc +1 -1
  312. data/src/core/lib/iomgr/socket_factory_posix.h +0 -8
  313. data/src/core/lib/iomgr/socket_mutator.cc +1 -1
  314. data/src/core/lib/iomgr/socket_mutator.h +1 -9
  315. data/src/core/lib/iomgr/socket_utils.h +0 -8
  316. data/src/core/lib/iomgr/socket_utils_common_posix.cc +1 -1
  317. data/src/core/lib/iomgr/socket_utils_posix.h +0 -8
  318. data/src/core/lib/iomgr/socket_windows.cc +8 -11
  319. data/src/core/lib/iomgr/socket_windows.h +3 -14
  320. data/src/core/lib/iomgr/tcp_client.h +1 -10
  321. data/src/core/lib/iomgr/tcp_client_posix.cc +94 -78
  322. data/src/core/lib/iomgr/tcp_client_posix.h +36 -8
  323. data/src/core/lib/iomgr/tcp_client_uv.cc +16 -23
  324. data/src/core/lib/iomgr/tcp_client_windows.cc +22 -25
  325. data/src/core/lib/iomgr/tcp_posix.cc +131 -153
  326. data/src/core/lib/iomgr/tcp_posix.h +3 -12
  327. data/src/core/lib/iomgr/tcp_server.h +6 -17
  328. data/src/core/lib/iomgr/tcp_server_posix.cc +31 -35
  329. data/src/core/lib/iomgr/tcp_server_utils_posix.h +0 -8
  330. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -1
  331. data/src/core/lib/iomgr/tcp_server_uv.cc +23 -34
  332. data/src/core/lib/iomgr/tcp_server_windows.cc +24 -34
  333. data/src/core/lib/iomgr/tcp_uv.cc +42 -56
  334. data/src/core/lib/iomgr/tcp_uv.h +0 -8
  335. data/src/core/lib/iomgr/tcp_windows.cc +43 -50
  336. data/src/core/lib/iomgr/tcp_windows.h +1 -9
  337. data/src/core/lib/iomgr/time_averaged_stats.h +0 -8
  338. data/src/core/lib/iomgr/timer.h +6 -15
  339. data/src/core/lib/iomgr/timer_generic.cc +22 -27
  340. data/src/core/lib/iomgr/timer_heap.h +0 -8
  341. data/src/core/lib/iomgr/timer_manager.cc +17 -19
  342. data/src/core/lib/iomgr/timer_manager.h +0 -8
  343. data/src/core/lib/iomgr/timer_uv.cc +12 -14
  344. data/src/core/lib/iomgr/udp_server.cc +148 -54
  345. data/src/core/lib/iomgr/udp_server.h +16 -21
  346. data/src/core/lib/iomgr/unix_sockets_posix.h +0 -8
  347. data/src/core/lib/iomgr/wakeup_fd_cv.cc +4 -4
  348. data/src/core/lib/iomgr/wakeup_fd_cv.h +12 -20
  349. data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +1 -1
  350. data/src/core/lib/iomgr/wakeup_fd_pipe.h +0 -8
  351. data/src/core/lib/iomgr/wakeup_fd_posix.h +0 -8
  352. data/src/core/lib/json/json.h +0 -8
  353. data/src/core/lib/json/json_reader.h +0 -8
  354. data/src/core/lib/json/json_writer.h +0 -8
  355. data/src/core/lib/profiling/basic_timers.cc +3 -2
  356. data/src/core/lib/profiling/timers.h +0 -8
  357. data/src/core/lib/security/context/security_context.cc +9 -10
  358. data/src/core/lib/security/context/security_context.h +0 -8
  359. data/src/core/lib/security/credentials/composite/composite_credentials.cc +23 -28
  360. data/src/core/lib/security/credentials/composite/composite_credentials.h +0 -8
  361. data/src/core/lib/security/credentials/credentials.cc +33 -42
  362. data/src/core/lib/security/credentials/credentials.h +24 -43
  363. data/src/core/lib/security/credentials/credentials_metadata.cc +2 -2
  364. data/src/core/lib/security/credentials/fake/fake_credentials.cc +16 -22
  365. data/src/core/lib/security/credentials/fake/fake_credentials.h +0 -8
  366. data/src/core/lib/security/credentials/google_default/credentials_generic.cc +3 -3
  367. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +28 -34
  368. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +0 -8
  369. data/src/core/lib/security/credentials/iam/iam_credentials.cc +9 -13
  370. data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
  371. data/src/core/lib/security/credentials/jwt/json_token.h +0 -8
  372. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +14 -20
  373. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +1 -10
  374. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +56 -72
  375. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +5 -17
  376. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +47 -55
  377. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +3 -12
  378. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +23 -28
  379. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +8 -13
  380. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +0 -8
  381. data/src/core/lib/security/transport/auth_filters.h +0 -8
  382. data/src/core/lib/security/transport/client_auth_filter.cc +45 -54
  383. data/src/core/lib/security/transport/lb_targets_info.cc +2 -2
  384. data/src/core/lib/security/transport/lb_targets_info.h +0 -8
  385. data/src/core/lib/security/transport/secure_endpoint.cc +54 -68
  386. data/src/core/lib/security/transport/secure_endpoint.h +0 -8
  387. data/src/core/lib/security/transport/security_connector.cc +62 -86
  388. data/src/core/lib/security/transport/security_connector.h +22 -39
  389. data/src/core/lib/security/transport/security_handshaker.cc +83 -106
  390. data/src/core/lib/security/transport/security_handshaker.h +1 -10
  391. data/src/core/lib/security/transport/server_auth_filter.cc +31 -38
  392. data/src/core/lib/security/transport/tsi_error.h +0 -8
  393. data/src/core/lib/security/util/json_util.h +0 -8
  394. data/src/core/lib/slice/b64.cc +5 -6
  395. data/src/core/lib/slice/b64.h +3 -12
  396. data/src/core/lib/slice/percent_encoding.h +0 -8
  397. data/src/core/lib/slice/slice.cc +8 -9
  398. data/src/core/lib/slice/slice_buffer.cc +11 -16
  399. data/src/core/lib/slice/slice_hash_table.cc +5 -7
  400. data/src/core/lib/slice/slice_hash_table.h +2 -12
  401. data/src/core/lib/slice/slice_intern.cc +4 -5
  402. data/src/core/lib/slice/slice_internal.h +4 -15
  403. data/src/core/lib/slice/slice_string_helpers.cc +1 -1
  404. data/src/core/lib/slice/slice_string_helpers.h +1 -9
  405. data/src/core/lib/surface/alarm.cc +11 -14
  406. data/src/core/lib/surface/alarm_internal.h +0 -8
  407. data/src/core/lib/surface/byte_buffer.cc +2 -3
  408. data/src/core/lib/surface/byte_buffer_reader.cc +7 -9
  409. data/src/core/lib/surface/call.cc +198 -241
  410. data/src/core/lib/surface/call.h +9 -23
  411. data/src/core/lib/surface/call_details.cc +3 -4
  412. data/src/core/lib/surface/call_log_batch.cc +1 -1
  413. data/src/core/lib/surface/call_test_only.h +0 -8
  414. data/src/core/lib/surface/channel.cc +53 -64
  415. data/src/core/lib/surface/channel.h +12 -23
  416. data/src/core/lib/surface/channel_init.cc +2 -3
  417. data/src/core/lib/surface/channel_init.h +2 -12
  418. data/src/core/lib/surface/channel_ping.cc +7 -9
  419. data/src/core/lib/surface/channel_stack_type.h +0 -8
  420. data/src/core/lib/surface/completion_queue.cc +158 -176
  421. data/src/core/lib/surface/completion_queue.h +9 -20
  422. data/src/core/lib/surface/completion_queue_factory.h +0 -8
  423. data/src/core/lib/surface/event_string.cc +1 -1
  424. data/src/core/lib/surface/event_string.h +0 -8
  425. data/src/core/lib/surface/init.cc +27 -25
  426. data/src/core/lib/surface/init.h +0 -8
  427. data/src/core/lib/surface/init_secure.cc +2 -2
  428. data/src/core/lib/surface/lame_client.cc +30 -33
  429. data/src/core/lib/surface/lame_client.h +0 -8
  430. data/src/core/lib/surface/server.cc +151 -203
  431. data/src/core/lib/surface/server.h +7 -16
  432. data/src/core/lib/surface/validate_metadata.h +0 -8
  433. data/src/core/lib/surface/version.cc +2 -2
  434. data/src/core/lib/transport/bdp_estimator.cc +2 -2
  435. data/src/core/lib/transport/bdp_estimator.h +1 -1
  436. data/src/core/lib/transport/byte_stream.cc +24 -38
  437. data/src/core/lib/transport/byte_stream.h +10 -25
  438. data/src/core/lib/transport/connectivity_state.cc +9 -13
  439. data/src/core/lib/transport/connectivity_state.h +4 -14
  440. data/src/core/lib/transport/error_utils.cc +6 -6
  441. data/src/core/lib/transport/error_utils.h +2 -11
  442. data/src/core/lib/transport/metadata.cc +21 -23
  443. data/src/core/lib/transport/metadata.h +8 -20
  444. data/src/core/lib/transport/metadata_batch.cc +34 -45
  445. data/src/core/lib/transport/metadata_batch.h +18 -32
  446. data/src/core/lib/transport/service_config.cc +11 -15
  447. data/src/core/lib/transport/service_config.h +3 -13
  448. data/src/core/lib/transport/static_metadata.cc +1 -1
  449. data/src/core/lib/transport/static_metadata.h +1 -7
  450. data/src/core/lib/transport/status_conversion.cc +2 -3
  451. data/src/core/lib/transport/status_conversion.h +1 -10
  452. data/src/core/lib/transport/timeout_encoding.cc +1 -1
  453. data/src/core/lib/transport/timeout_encoding.h +1 -9
  454. data/src/core/lib/transport/transport.cc +36 -50
  455. data/src/core/lib/transport/transport.h +28 -30
  456. data/src/core/lib/transport/transport_impl.h +12 -23
  457. data/src/core/lib/transport/transport_op_string.cc +2 -2
  458. data/src/core/plugin_registry/grpc_plugin_registry.cc +34 -34
  459. data/src/core/tsi/fake_transport_security.cc +7 -10
  460. data/src/core/tsi/fake_transport_security.h +0 -8
  461. data/src/core/tsi/gts_transport_security.cc +2 -2
  462. data/src/core/tsi/gts_transport_security.h +0 -8
  463. data/src/core/tsi/ssl_transport_security.cc +3 -0
  464. data/src/core/tsi/ssl_transport_security.h +0 -8
  465. data/src/core/tsi/ssl_types.h +0 -8
  466. data/src/core/tsi/transport_security.h +1 -9
  467. data/src/core/tsi/transport_security_adapter.h +0 -8
  468. data/src/core/tsi/transport_security_grpc.cc +11 -18
  469. data/src/core/tsi/transport_security_grpc.h +9 -21
  470. data/src/core/tsi/transport_security_interface.h +0 -8
  471. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +0 -30
  472. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +2 -48
  473. data/src/ruby/lib/grpc/version.rb +1 -1
  474. data/src/ruby/spec/channel_connection_spec.rb +2 -1
  475. data/src/ruby/spec/client_auth_spec.rb +1 -1
  476. data/src/ruby/spec/client_server_spec.rb +2 -2
  477. data/src/ruby/spec/generic/active_call_spec.rb +1 -1
  478. data/src/ruby/spec/generic/client_stub_spec.rb +4 -4
  479. data/src/ruby/spec/generic/interceptor_registry_spec.rb +1 -1
  480. data/src/ruby/spec/generic/rpc_server_spec.rb +12 -12
  481. data/src/ruby/spec/google_rpc_status_utils_spec.rb +3 -2
  482. data/src/ruby/spec/pb/health/checker_spec.rb +1 -1
  483. data/src/ruby/spec/server_spec.rb +9 -9
  484. data/src/ruby/spec/support/helpers.rb +35 -1
  485. metadata +68 -66
  486. data/include/grpc/impl/codegen/exec_ctx_fwd.h +0 -26
  487. data/include/grpc/support/histogram.h +0 -64
  488. data/src/core/lib/support/histogram.cc +0 -227
@@ -25,10 +25,10 @@
25
25
 
26
26
  /* Start polling \a interested_parties periodically in the timer thread */
27
27
  void grpc_client_channel_start_backup_polling(
28
- grpc_exec_ctx* exec_ctx, grpc_pollset_set* interested_parties);
28
+ grpc_pollset_set* interested_parties);
29
29
 
30
30
  /* Stop polling \a interested_parties */
31
31
  void grpc_client_channel_stop_backup_polling(
32
- grpc_exec_ctx* exec_ctx, grpc_pollset_set* interested_parties);
32
+ grpc_pollset_set* interested_parties);
33
33
 
34
34
  #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_BACKUP_POLLER_H */
@@ -33,22 +33,22 @@ grpc_connectivity_state grpc_channel_check_connectivity_state(
33
33
  /* forward through to the underlying client channel */
34
34
  grpc_channel_element* client_channel_elem =
35
35
  grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
36
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
36
+ grpc_core::ExecCtx exec_ctx;
37
37
  grpc_connectivity_state state;
38
38
  GRPC_API_TRACE(
39
39
  "grpc_channel_check_connectivity_state(channel=%p, try_to_connect=%d)", 2,
40
40
  (channel, try_to_connect));
41
41
  if (client_channel_elem->filter == &grpc_client_channel_filter) {
42
- state = grpc_client_channel_check_connectivity_state(
43
- &exec_ctx, client_channel_elem, try_to_connect);
44
- grpc_exec_ctx_finish(&exec_ctx);
42
+ state = grpc_client_channel_check_connectivity_state(client_channel_elem,
43
+ try_to_connect);
44
+
45
45
  return state;
46
46
  }
47
47
  gpr_log(GPR_ERROR,
48
48
  "grpc_channel_check_connectivity_state called on something that is "
49
49
  "not a client channel, but '%s'",
50
50
  client_channel_elem->filter->name);
51
- grpc_exec_ctx_finish(&exec_ctx);
51
+
52
52
  return GRPC_CHANNEL_SHUTDOWN;
53
53
  }
54
54
 
@@ -58,7 +58,8 @@ typedef enum {
58
58
  CALLING_BACK_AND_FINISHED,
59
59
  } callback_phase;
60
60
 
61
- typedef struct {
61
+ namespace {
62
+ struct state_watcher {
62
63
  gpr_mu mu;
63
64
  callback_phase phase;
64
65
  grpc_closure on_complete;
@@ -71,14 +72,14 @@ typedef struct {
71
72
  grpc_channel* channel;
72
73
  grpc_error* error;
73
74
  void* tag;
74
- } state_watcher;
75
+ };
76
+ } // namespace
75
77
 
76
- static void delete_state_watcher(grpc_exec_ctx* exec_ctx, state_watcher* w) {
78
+ static void delete_state_watcher(state_watcher* w) {
77
79
  grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element(
78
80
  grpc_channel_get_channel_stack(w->channel));
79
81
  if (client_channel_elem->filter == &grpc_client_channel_filter) {
80
- GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, w->channel,
81
- "watch_channel_connectivity");
82
+ GRPC_CHANNEL_INTERNAL_UNREF(w->channel, "watch_channel_connectivity");
82
83
  } else {
83
84
  abort();
84
85
  }
@@ -86,8 +87,7 @@ static void delete_state_watcher(grpc_exec_ctx* exec_ctx, state_watcher* w) {
86
87
  gpr_free(w);
87
88
  }
88
89
 
89
- static void finished_completion(grpc_exec_ctx* exec_ctx, void* pw,
90
- grpc_cq_completion* ignored) {
90
+ static void finished_completion(void* pw, grpc_cq_completion* ignored) {
91
91
  bool should_delete = false;
92
92
  state_watcher* w = (state_watcher*)pw;
93
93
  gpr_mu_lock(&w->mu);
@@ -102,19 +102,19 @@ static void finished_completion(grpc_exec_ctx* exec_ctx, void* pw,
102
102
  gpr_mu_unlock(&w->mu);
103
103
 
104
104
  if (should_delete) {
105
- delete_state_watcher(exec_ctx, w);
105
+ delete_state_watcher(w);
106
106
  }
107
107
  }
108
108
 
109
- static void partly_done(grpc_exec_ctx* exec_ctx, state_watcher* w,
110
- bool due_to_completion, grpc_error* error) {
109
+ static void partly_done(state_watcher* w, bool due_to_completion,
110
+ grpc_error* error) {
111
111
  if (due_to_completion) {
112
- grpc_timer_cancel(exec_ctx, &w->alarm);
112
+ grpc_timer_cancel(&w->alarm);
113
113
  } else {
114
114
  grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element(
115
115
  grpc_channel_get_channel_stack(w->channel));
116
116
  grpc_client_channel_watch_connectivity_state(
117
- exec_ctx, client_channel_elem,
117
+ client_channel_elem,
118
118
  grpc_polling_entity_create_from_pollset(grpc_cq_pollset(w->cq)),
119
119
  nullptr, &w->on_complete, nullptr);
120
120
  }
@@ -149,7 +149,7 @@ static void partly_done(grpc_exec_ctx* exec_ctx, state_watcher* w,
149
149
  w->error = error;
150
150
  }
151
151
  w->phase = CALLING_BACK_AND_FINISHED;
152
- grpc_cq_end_op(exec_ctx, w->cq, w->tag, w->error, finished_completion, w,
152
+ grpc_cq_end_op(w->cq, w->tag, w->error, finished_completion, w,
153
153
  &w->completion_storage);
154
154
  break;
155
155
  case CALLING_BACK_AND_FINISHED:
@@ -161,14 +161,12 @@ static void partly_done(grpc_exec_ctx* exec_ctx, state_watcher* w,
161
161
  GRPC_ERROR_UNREF(error);
162
162
  }
163
163
 
164
- static void watch_complete(grpc_exec_ctx* exec_ctx, void* pw,
165
- grpc_error* error) {
166
- partly_done(exec_ctx, (state_watcher*)pw, true, GRPC_ERROR_REF(error));
164
+ static void watch_complete(void* pw, grpc_error* error) {
165
+ partly_done((state_watcher*)pw, true, GRPC_ERROR_REF(error));
167
166
  }
168
167
 
169
- static void timeout_complete(grpc_exec_ctx* exec_ctx, void* pw,
170
- grpc_error* error) {
171
- partly_done(exec_ctx, (state_watcher*)pw, false, GRPC_ERROR_REF(error));
168
+ static void timeout_complete(void* pw, grpc_error* error) {
169
+ partly_done((state_watcher*)pw, false, GRPC_ERROR_REF(error));
172
170
  }
173
171
 
174
172
  int grpc_channel_num_external_connectivity_watchers(grpc_channel* channel) {
@@ -183,12 +181,10 @@ typedef struct watcher_timer_init_arg {
183
181
  gpr_timespec deadline;
184
182
  } watcher_timer_init_arg;
185
183
 
186
- static void watcher_timer_init(grpc_exec_ctx* exec_ctx, void* arg,
187
- grpc_error* error_ignored) {
184
+ static void watcher_timer_init(void* arg, grpc_error* error_ignored) {
188
185
  watcher_timer_init_arg* wa = (watcher_timer_init_arg*)arg;
189
186
 
190
- grpc_timer_init(exec_ctx, &wa->w->alarm,
191
- grpc_timespec_to_millis_round_up(wa->deadline),
187
+ grpc_timer_init(&wa->w->alarm, grpc_timespec_to_millis_round_up(wa->deadline),
192
188
  &wa->w->on_timeout);
193
189
  gpr_free(wa);
194
190
  }
@@ -204,7 +200,7 @@ void grpc_channel_watch_connectivity_state(
204
200
  gpr_timespec deadline, grpc_completion_queue* cq, void* tag) {
205
201
  grpc_channel_element* client_channel_elem =
206
202
  grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
207
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
203
+ grpc_core::ExecCtx exec_ctx;
208
204
  state_watcher* w = (state_watcher*)gpr_malloc(sizeof(*w));
209
205
 
210
206
  GRPC_API_TRACE(
@@ -241,12 +237,10 @@ void grpc_channel_watch_connectivity_state(
241
237
  if (client_channel_elem->filter == &grpc_client_channel_filter) {
242
238
  GRPC_CHANNEL_INTERNAL_REF(channel, "watch_channel_connectivity");
243
239
  grpc_client_channel_watch_connectivity_state(
244
- &exec_ctx, client_channel_elem,
240
+ client_channel_elem,
245
241
  grpc_polling_entity_create_from_pollset(grpc_cq_pollset(cq)), &w->state,
246
242
  &w->on_complete, &w->watcher_timer_init);
247
243
  } else {
248
244
  abort();
249
245
  }
250
-
251
- grpc_exec_ctx_finish(&exec_ctx);
252
246
  }
@@ -41,12 +41,12 @@
41
41
  #include "src/core/ext/filters/deadline/deadline_filter.h"
42
42
  #include "src/core/lib/channel/channel_args.h"
43
43
  #include "src/core/lib/channel/connected_channel.h"
44
+ #include "src/core/lib/gpr/string.h"
44
45
  #include "src/core/lib/iomgr/combiner.h"
45
46
  #include "src/core/lib/iomgr/iomgr.h"
46
47
  #include "src/core/lib/iomgr/polling_entity.h"
47
48
  #include "src/core/lib/profiling/timers.h"
48
49
  #include "src/core/lib/slice/slice_internal.h"
49
- #include "src/core/lib/support/string.h"
50
50
  #include "src/core/lib/surface/channel.h"
51
51
  #include "src/core/lib/transport/connectivity_state.h"
52
52
  #include "src/core/lib/transport/metadata.h"
@@ -91,8 +91,7 @@ static void method_parameters_unref(method_parameters* method_params) {
91
91
  static void* method_parameters_ref_wrapper(void* value) {
92
92
  return method_parameters_ref((method_parameters*)value);
93
93
  }
94
- static void method_parameters_unref_wrapper(grpc_exec_ctx* exec_ctx,
95
- void* value) {
94
+ static void method_parameters_unref_wrapper(void* value) {
96
95
  method_parameters_unref((method_parameters*)value);
97
96
  }
98
97
 
@@ -210,6 +209,14 @@ typedef struct client_channel_channel_data {
210
209
  char* info_service_config_json;
211
210
  } channel_data;
212
211
 
212
+ typedef struct {
213
+ channel_data* chand;
214
+ /** used as an identifier, don't dereference it because the LB policy may be
215
+ * non-existing when the callback is run */
216
+ grpc_lb_policy* lb_policy;
217
+ grpc_closure closure;
218
+ } reresolution_request_args;
219
+
213
220
  /** We create one watcher for each new lb_policy that is returned from a
214
221
  resolver, to watch for state changes from the lb_policy. When a state
215
222
  change is seen, we update the channel, and create a new watcher. */
@@ -220,12 +227,11 @@ typedef struct {
220
227
  grpc_lb_policy* lb_policy;
221
228
  } lb_policy_connectivity_watcher;
222
229
 
223
- static void watch_lb_policy_locked(grpc_exec_ctx* exec_ctx, channel_data* chand,
230
+ static void watch_lb_policy_locked(channel_data* chand,
224
231
  grpc_lb_policy* lb_policy,
225
232
  grpc_connectivity_state current_state);
226
233
 
227
- static void set_channel_connectivity_state_locked(grpc_exec_ctx* exec_ctx,
228
- channel_data* chand,
234
+ static void set_channel_connectivity_state_locked(channel_data* chand,
229
235
  grpc_connectivity_state state,
230
236
  grpc_error* error,
231
237
  const char* reason) {
@@ -237,12 +243,12 @@ static void set_channel_connectivity_state_locked(grpc_exec_ctx* exec_ctx,
237
243
  if (state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
238
244
  /* cancel picks with wait_for_ready=false */
239
245
  grpc_lb_policy_cancel_picks_locked(
240
- exec_ctx, chand->lb_policy,
246
+ chand->lb_policy,
241
247
  /* mask= */ GRPC_INITIAL_METADATA_WAIT_FOR_READY,
242
248
  /* check= */ 0, GRPC_ERROR_REF(error));
243
249
  } else if (state == GRPC_CHANNEL_SHUTDOWN) {
244
250
  /* cancel all picks */
245
- grpc_lb_policy_cancel_picks_locked(exec_ctx, chand->lb_policy,
251
+ grpc_lb_policy_cancel_picks_locked(chand->lb_policy,
246
252
  /* mask= */ 0, /* check= */ 0,
247
253
  GRPC_ERROR_REF(error));
248
254
  }
@@ -251,38 +257,28 @@ static void set_channel_connectivity_state_locked(grpc_exec_ctx* exec_ctx,
251
257
  gpr_log(GPR_DEBUG, "chand=%p: setting connectivity state to %s", chand,
252
258
  grpc_connectivity_state_name(state));
253
259
  }
254
- grpc_connectivity_state_set(exec_ctx, &chand->state_tracker, state, error,
255
- reason);
260
+ grpc_connectivity_state_set(&chand->state_tracker, state, error, reason);
256
261
  }
257
262
 
258
- static void on_lb_policy_state_changed_locked(grpc_exec_ctx* exec_ctx,
259
- void* arg, grpc_error* error) {
263
+ static void on_lb_policy_state_changed_locked(void* arg, grpc_error* error) {
260
264
  lb_policy_connectivity_watcher* w = (lb_policy_connectivity_watcher*)arg;
261
- grpc_connectivity_state publish_state = w->state;
262
265
  /* check if the notification is for the latest policy */
263
266
  if (w->lb_policy == w->chand->lb_policy) {
264
267
  if (grpc_client_channel_trace.enabled()) {
265
268
  gpr_log(GPR_DEBUG, "chand=%p: lb_policy=%p state changed to %s", w->chand,
266
269
  w->lb_policy, grpc_connectivity_state_name(w->state));
267
270
  }
268
- if (publish_state == GRPC_CHANNEL_SHUTDOWN &&
269
- w->chand->resolver != nullptr) {
270
- publish_state = GRPC_CHANNEL_TRANSIENT_FAILURE;
271
- grpc_resolver_channel_saw_error_locked(exec_ctx, w->chand->resolver);
272
- GRPC_LB_POLICY_UNREF(exec_ctx, w->chand->lb_policy, "channel");
273
- w->chand->lb_policy = nullptr;
274
- }
275
- set_channel_connectivity_state_locked(exec_ctx, w->chand, publish_state,
271
+ set_channel_connectivity_state_locked(w->chand, w->state,
276
272
  GRPC_ERROR_REF(error), "lb_changed");
277
273
  if (w->state != GRPC_CHANNEL_SHUTDOWN) {
278
- watch_lb_policy_locked(exec_ctx, w->chand, w->lb_policy, w->state);
274
+ watch_lb_policy_locked(w->chand, w->lb_policy, w->state);
279
275
  }
280
276
  }
281
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, w->chand->owning_stack, "watch_lb_policy");
277
+ GRPC_CHANNEL_STACK_UNREF(w->chand->owning_stack, "watch_lb_policy");
282
278
  gpr_free(w);
283
279
  }
284
280
 
285
- static void watch_lb_policy_locked(grpc_exec_ctx* exec_ctx, channel_data* chand,
281
+ static void watch_lb_policy_locked(channel_data* chand,
286
282
  grpc_lb_policy* lb_policy,
287
283
  grpc_connectivity_state current_state) {
288
284
  lb_policy_connectivity_watcher* w =
@@ -293,19 +289,18 @@ static void watch_lb_policy_locked(grpc_exec_ctx* exec_ctx, channel_data* chand,
293
289
  grpc_combiner_scheduler(chand->combiner));
294
290
  w->state = current_state;
295
291
  w->lb_policy = lb_policy;
296
- grpc_lb_policy_notify_on_state_change_locked(exec_ctx, lb_policy, &w->state,
292
+ grpc_lb_policy_notify_on_state_change_locked(lb_policy, &w->state,
297
293
  &w->on_changed);
298
294
  }
299
295
 
300
- static void start_resolving_locked(grpc_exec_ctx* exec_ctx,
301
- channel_data* chand) {
296
+ static void start_resolving_locked(channel_data* chand) {
302
297
  if (grpc_client_channel_trace.enabled()) {
303
298
  gpr_log(GPR_DEBUG, "chand=%p: starting name resolution", chand);
304
299
  }
305
300
  GPR_ASSERT(!chand->started_resolving);
306
301
  chand->started_resolving = true;
307
302
  GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver");
308
- grpc_resolver_next_locked(exec_ctx, chand->resolver, &chand->resolver_result,
303
+ grpc_resolver_next_locked(chand->resolver, &chand->resolver_result,
309
304
  &chand->on_resolver_result_changed);
310
305
  }
311
306
 
@@ -369,8 +364,26 @@ static void parse_retry_throttle_params(const grpc_json* field, void* arg) {
369
364
  }
370
365
  }
371
366
 
372
- static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
373
- void* arg, grpc_error* error) {
367
+ static void request_reresolution_locked(void* arg, grpc_error* error) {
368
+ reresolution_request_args* args = (reresolution_request_args*)arg;
369
+ channel_data* chand = args->chand;
370
+ // If this invocation is for a stale LB policy, treat it as an LB shutdown
371
+ // signal.
372
+ if (args->lb_policy != chand->lb_policy || error != GRPC_ERROR_NONE ||
373
+ chand->resolver == nullptr) {
374
+ GRPC_CHANNEL_STACK_UNREF(chand->owning_stack, "re-resolution");
375
+ gpr_free(args);
376
+ return;
377
+ }
378
+ if (grpc_client_channel_trace.enabled()) {
379
+ gpr_log(GPR_DEBUG, "chand=%p: started name re-resolving", chand);
380
+ }
381
+ grpc_resolver_channel_saw_error_locked(chand->resolver);
382
+ // Give back the closure to the LB policy.
383
+ grpc_lb_policy_set_reresolve_closure_locked(chand->lb_policy, &args->closure);
384
+ }
385
+
386
+ static void on_resolver_result_changed_locked(void* arg, grpc_error* error) {
374
387
  channel_data* chand = (channel_data*)arg;
375
388
  if (grpc_client_channel_trace.enabled()) {
376
389
  gpr_log(GPR_DEBUG, "chand=%p: got resolver result: error=%s", chand,
@@ -385,101 +398,112 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
385
398
  grpc_server_retry_throttle_data* retry_throttle_data = nullptr;
386
399
  grpc_slice_hash_table* method_params_table = nullptr;
387
400
  if (chand->resolver_result != nullptr) {
388
- // Find LB policy name.
389
- const char* lb_policy_name = nullptr;
390
- const grpc_arg* channel_arg =
391
- grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_POLICY_NAME);
392
- if (channel_arg != nullptr) {
393
- GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
394
- lb_policy_name = channel_arg->value.string;
395
- }
396
- // Special case: If at least one balancer address is present, we use
397
- // the grpclb policy, regardless of what the resolver actually specified.
398
- channel_arg =
399
- grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_ADDRESSES);
400
- if (channel_arg != nullptr && channel_arg->type == GRPC_ARG_POINTER) {
401
- grpc_lb_addresses* addresses =
402
- (grpc_lb_addresses*)channel_arg->value.pointer.p;
403
- bool found_balancer_address = false;
404
- for (size_t i = 0; i < addresses->num_addresses; ++i) {
405
- if (addresses->addresses[i].is_balancer) {
406
- found_balancer_address = true;
407
- break;
401
+ if (chand->resolver != nullptr) {
402
+ // Find LB policy name.
403
+ const char* lb_policy_name = nullptr;
404
+ const grpc_arg* channel_arg = grpc_channel_args_find(
405
+ chand->resolver_result, GRPC_ARG_LB_POLICY_NAME);
406
+ if (channel_arg != nullptr) {
407
+ GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
408
+ lb_policy_name = channel_arg->value.string;
409
+ }
410
+ // Special case: If at least one balancer address is present, we use
411
+ // the grpclb policy, regardless of what the resolver actually specified.
412
+ channel_arg =
413
+ grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_ADDRESSES);
414
+ if (channel_arg != nullptr && channel_arg->type == GRPC_ARG_POINTER) {
415
+ grpc_lb_addresses* addresses =
416
+ (grpc_lb_addresses*)channel_arg->value.pointer.p;
417
+ bool found_balancer_address = false;
418
+ for (size_t i = 0; i < addresses->num_addresses; ++i) {
419
+ if (addresses->addresses[i].is_balancer) {
420
+ found_balancer_address = true;
421
+ break;
422
+ }
423
+ }
424
+ if (found_balancer_address) {
425
+ if (lb_policy_name != nullptr &&
426
+ strcmp(lb_policy_name, "grpclb") != 0) {
427
+ gpr_log(GPR_INFO,
428
+ "resolver requested LB policy %s but provided at least one "
429
+ "balancer address -- forcing use of grpclb LB policy",
430
+ lb_policy_name);
431
+ }
432
+ lb_policy_name = "grpclb";
408
433
  }
409
434
  }
410
- if (found_balancer_address) {
411
- if (lb_policy_name != nullptr &&
412
- strcmp(lb_policy_name, "grpclb") != 0) {
413
- gpr_log(GPR_INFO,
414
- "resolver requested LB policy %s but provided at least one "
415
- "balancer address -- forcing use of grpclb LB policy",
435
+ // Use pick_first if nothing was specified and we didn't select grpclb
436
+ // above.
437
+ if (lb_policy_name == nullptr) lb_policy_name = "pick_first";
438
+ grpc_lb_policy_args lb_policy_args;
439
+ lb_policy_args.args = chand->resolver_result;
440
+ lb_policy_args.client_channel_factory = chand->client_channel_factory;
441
+ lb_policy_args.combiner = chand->combiner;
442
+ // Check to see if we're already using the right LB policy.
443
+ // Note: It's safe to use chand->info_lb_policy_name here without
444
+ // taking a lock on chand->info_mu, because this function is the
445
+ // only thing that modifies its value, and it can only be invoked
446
+ // once at any given time.
447
+ lb_policy_name_changed =
448
+ chand->info_lb_policy_name == nullptr ||
449
+ gpr_stricmp(chand->info_lb_policy_name, lb_policy_name) != 0;
450
+ if (chand->lb_policy != nullptr && !lb_policy_name_changed) {
451
+ // Continue using the same LB policy. Update with new addresses.
452
+ lb_policy_updated = true;
453
+ grpc_lb_policy_update_locked(chand->lb_policy, &lb_policy_args);
454
+ } else {
455
+ // Instantiate new LB policy.
456
+ new_lb_policy = grpc_lb_policy_create(lb_policy_name, &lb_policy_args);
457
+ if (new_lb_policy == nullptr) {
458
+ gpr_log(GPR_ERROR, "could not create LB policy \"%s\"",
416
459
  lb_policy_name);
460
+ } else {
461
+ reresolution_request_args* args =
462
+ (reresolution_request_args*)gpr_zalloc(sizeof(*args));
463
+ args->chand = chand;
464
+ args->lb_policy = new_lb_policy;
465
+ GRPC_CLOSURE_INIT(&args->closure, request_reresolution_locked, args,
466
+ grpc_combiner_scheduler(chand->combiner));
467
+ GRPC_CHANNEL_STACK_REF(chand->owning_stack, "re-resolution");
468
+ grpc_lb_policy_set_reresolve_closure_locked(new_lb_policy,
469
+ &args->closure);
417
470
  }
418
- lb_policy_name = "grpclb";
419
- }
420
- }
421
- // Use pick_first if nothing was specified and we didn't select grpclb
422
- // above.
423
- if (lb_policy_name == nullptr) lb_policy_name = "pick_first";
424
- grpc_lb_policy_args lb_policy_args;
425
- lb_policy_args.args = chand->resolver_result;
426
- lb_policy_args.client_channel_factory = chand->client_channel_factory;
427
- lb_policy_args.combiner = chand->combiner;
428
- // Check to see if we're already using the right LB policy.
429
- // Note: It's safe to use chand->info_lb_policy_name here without
430
- // taking a lock on chand->info_mu, because this function is the
431
- // only thing that modifies its value, and it can only be invoked
432
- // once at any given time.
433
- lb_policy_name_changed =
434
- chand->info_lb_policy_name == nullptr ||
435
- strcmp(chand->info_lb_policy_name, lb_policy_name) != 0;
436
- if (chand->lb_policy != nullptr && !lb_policy_name_changed) {
437
- // Continue using the same LB policy. Update with new addresses.
438
- lb_policy_updated = true;
439
- grpc_lb_policy_update_locked(exec_ctx, chand->lb_policy, &lb_policy_args);
440
- } else {
441
- // Instantiate new LB policy.
442
- new_lb_policy =
443
- grpc_lb_policy_create(exec_ctx, lb_policy_name, &lb_policy_args);
444
- if (new_lb_policy == nullptr) {
445
- gpr_log(GPR_ERROR, "could not create LB policy \"%s\"", lb_policy_name);
446
471
  }
447
- }
448
- // Find service config.
449
- channel_arg =
450
- grpc_channel_args_find(chand->resolver_result, GRPC_ARG_SERVICE_CONFIG);
451
- if (channel_arg != nullptr) {
452
- GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
453
- service_config_json = gpr_strdup(channel_arg->value.string);
454
- grpc_service_config* service_config =
455
- grpc_service_config_create(service_config_json);
456
- if (service_config != nullptr) {
457
- channel_arg =
458
- grpc_channel_args_find(chand->resolver_result, GRPC_ARG_SERVER_URI);
459
- GPR_ASSERT(channel_arg != nullptr);
472
+ // Find service config.
473
+ channel_arg = grpc_channel_args_find(chand->resolver_result,
474
+ GRPC_ARG_SERVICE_CONFIG);
475
+ if (channel_arg != nullptr) {
460
476
  GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
461
- grpc_uri* uri =
462
- grpc_uri_parse(exec_ctx, channel_arg->value.string, true);
463
- GPR_ASSERT(uri->path[0] != '\0');
464
- service_config_parsing_state parsing_state;
465
- memset(&parsing_state, 0, sizeof(parsing_state));
466
- parsing_state.server_name =
467
- uri->path[0] == '/' ? uri->path + 1 : uri->path;
468
- grpc_service_config_parse_global_params(
469
- service_config, parse_retry_throttle_params, &parsing_state);
470
- grpc_uri_destroy(uri);
471
- retry_throttle_data = parsing_state.retry_throttle_data;
472
- method_params_table = grpc_service_config_create_method_config_table(
473
- exec_ctx, service_config, method_parameters_create_from_json,
474
- method_parameters_ref_wrapper, method_parameters_unref_wrapper);
475
- grpc_service_config_destroy(service_config);
477
+ service_config_json = gpr_strdup(channel_arg->value.string);
478
+ grpc_service_config* service_config =
479
+ grpc_service_config_create(service_config_json);
480
+ if (service_config != nullptr) {
481
+ channel_arg = grpc_channel_args_find(chand->resolver_result,
482
+ GRPC_ARG_SERVER_URI);
483
+ GPR_ASSERT(channel_arg != nullptr);
484
+ GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
485
+ grpc_uri* uri = grpc_uri_parse(channel_arg->value.string, true);
486
+ GPR_ASSERT(uri->path[0] != '\0');
487
+ service_config_parsing_state parsing_state;
488
+ memset(&parsing_state, 0, sizeof(parsing_state));
489
+ parsing_state.server_name =
490
+ uri->path[0] == '/' ? uri->path + 1 : uri->path;
491
+ grpc_service_config_parse_global_params(
492
+ service_config, parse_retry_throttle_params, &parsing_state);
493
+ grpc_uri_destroy(uri);
494
+ retry_throttle_data = parsing_state.retry_throttle_data;
495
+ method_params_table = grpc_service_config_create_method_config_table(
496
+ service_config, method_parameters_create_from_json,
497
+ method_parameters_ref_wrapper, method_parameters_unref_wrapper);
498
+ grpc_service_config_destroy(service_config);
499
+ }
476
500
  }
501
+ // Before we clean up, save a copy of lb_policy_name, since it might
502
+ // be pointing to data inside chand->resolver_result.
503
+ // The copy will be saved in chand->lb_policy_name below.
504
+ lb_policy_name_dup = gpr_strdup(lb_policy_name);
477
505
  }
478
- // Before we clean up, save a copy of lb_policy_name, since it might
479
- // be pointing to data inside chand->resolver_result.
480
- // The copy will be saved in chand->lb_policy_name below.
481
- lb_policy_name_dup = gpr_strdup(lb_policy_name);
482
- grpc_channel_args_destroy(exec_ctx, chand->resolver_result);
506
+ grpc_channel_args_destroy(chand->resolver_result);
483
507
  chand->resolver_result = nullptr;
484
508
  }
485
509
  if (grpc_client_channel_trace.enabled()) {
@@ -511,15 +535,15 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
511
535
  chand->retry_throttle_data = retry_throttle_data;
512
536
  // Swap out the method params table.
513
537
  if (chand->method_params_table != nullptr) {
514
- grpc_slice_hash_table_unref(exec_ctx, chand->method_params_table);
538
+ grpc_slice_hash_table_unref(chand->method_params_table);
515
539
  }
516
540
  chand->method_params_table = method_params_table;
517
541
  // If we have a new LB policy or are shutting down (in which case
518
- // new_lb_policy will be NULL), swap out the LB policy, unreffing the
519
- // old one and removing its fds from chand->interested_parties.
520
- // Note that we do NOT do this if either (a) we updated the existing
521
- // LB policy above or (b) we failed to create the new LB policy (in
522
- // which case we want to continue using the most recent one we had).
542
+ // new_lb_policy will be NULL), swap out the LB policy, unreffing the old one
543
+ // and removing its fds from chand->interested_parties. Note that we do NOT do
544
+ // this if either (a) we updated the existing LB policy above or (b) we failed
545
+ // to create the new LB policy (in which case we want to continue using the
546
+ // most recent one we had).
523
547
  if (new_lb_policy != nullptr || error != GRPC_ERROR_NONE ||
524
548
  chand->resolver == nullptr) {
525
549
  if (chand->lb_policy != nullptr) {
@@ -527,10 +551,10 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
527
551
  gpr_log(GPR_DEBUG, "chand=%p: unreffing lb_policy=%p", chand,
528
552
  chand->lb_policy);
529
553
  }
530
- grpc_pollset_set_del_pollset_set(exec_ctx,
531
- chand->lb_policy->interested_parties,
554
+ grpc_pollset_set_del_pollset_set(chand->lb_policy->interested_parties,
532
555
  chand->interested_parties);
533
- GRPC_LB_POLICY_UNREF(exec_ctx, chand->lb_policy, "channel");
556
+ grpc_lb_policy_shutdown_locked(chand->lb_policy, new_lb_policy);
557
+ GRPC_LB_POLICY_UNREF(chand->lb_policy, "channel");
534
558
  }
535
559
  chand->lb_policy = new_lb_policy;
536
560
  }
@@ -544,21 +568,20 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
544
568
  if (grpc_client_channel_trace.enabled()) {
545
569
  gpr_log(GPR_DEBUG, "chand=%p: shutting down resolver", chand);
546
570
  }
547
- grpc_resolver_shutdown_locked(exec_ctx, chand->resolver);
548
- GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel");
571
+ grpc_resolver_shutdown_locked(chand->resolver);
572
+ GRPC_RESOLVER_UNREF(chand->resolver, "channel");
549
573
  chand->resolver = nullptr;
550
574
  }
551
575
  set_channel_connectivity_state_locked(
552
- exec_ctx, chand, GRPC_CHANNEL_SHUTDOWN,
576
+ chand, GRPC_CHANNEL_SHUTDOWN,
553
577
  GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
554
578
  "Got resolver result after disconnection", &error, 1),
555
579
  "resolver_gone");
556
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->owning_stack, "resolver");
580
+ GRPC_CHANNEL_STACK_UNREF(chand->owning_stack, "resolver");
557
581
  grpc_closure_list_fail_all(&chand->waiting_for_resolver_result_closures,
558
582
  GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
559
583
  "Channel disconnected", &error, 1));
560
- GRPC_CLOSURE_LIST_SCHED(exec_ctx,
561
- &chand->waiting_for_resolver_result_closures);
584
+ GRPC_CLOSURE_LIST_SCHED(&chand->waiting_for_resolver_result_closures);
562
585
  } else { // Not shutting down.
563
586
  grpc_connectivity_state state = GRPC_CHANNEL_TRANSIENT_FAILURE;
564
587
  grpc_error* state_error =
@@ -568,33 +591,28 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
568
591
  gpr_log(GPR_DEBUG, "chand=%p: initializing new LB policy", chand);
569
592
  }
570
593
  GRPC_ERROR_UNREF(state_error);
571
- state = grpc_lb_policy_check_connectivity_locked(exec_ctx, new_lb_policy,
572
- &state_error);
573
- grpc_pollset_set_add_pollset_set(exec_ctx,
574
- new_lb_policy->interested_parties,
594
+ state =
595
+ grpc_lb_policy_check_connectivity_locked(new_lb_policy, &state_error);
596
+ grpc_pollset_set_add_pollset_set(new_lb_policy->interested_parties,
575
597
  chand->interested_parties);
576
- GRPC_CLOSURE_LIST_SCHED(exec_ctx,
577
- &chand->waiting_for_resolver_result_closures);
598
+ GRPC_CLOSURE_LIST_SCHED(&chand->waiting_for_resolver_result_closures);
578
599
  if (chand->exit_idle_when_lb_policy_arrives) {
579
- grpc_lb_policy_exit_idle_locked(exec_ctx, new_lb_policy);
600
+ grpc_lb_policy_exit_idle_locked(new_lb_policy);
580
601
  chand->exit_idle_when_lb_policy_arrives = false;
581
602
  }
582
- watch_lb_policy_locked(exec_ctx, chand, new_lb_policy, state);
603
+ watch_lb_policy_locked(chand, new_lb_policy, state);
583
604
  }
584
605
  if (!lb_policy_updated) {
585
- set_channel_connectivity_state_locked(exec_ctx, chand, state,
586
- GRPC_ERROR_REF(state_error),
587
- "new_lb+resolver");
606
+ set_channel_connectivity_state_locked(
607
+ chand, state, GRPC_ERROR_REF(state_error), "new_lb+resolver");
588
608
  }
589
- grpc_resolver_next_locked(exec_ctx, chand->resolver,
590
- &chand->resolver_result,
609
+ grpc_resolver_next_locked(chand->resolver, &chand->resolver_result,
591
610
  &chand->on_resolver_result_changed);
592
611
  GRPC_ERROR_UNREF(state_error);
593
612
  }
594
613
  }
595
614
 
596
- static void start_transport_op_locked(grpc_exec_ctx* exec_ctx, void* arg,
597
- grpc_error* error_ignored) {
615
+ static void start_transport_op_locked(void* arg, grpc_error* error_ignored) {
598
616
  grpc_transport_op* op = (grpc_transport_op*)arg;
599
617
  grpc_channel_element* elem =
600
618
  (grpc_channel_element*)op->handler_private.extra_arg;
@@ -602,75 +620,75 @@ static void start_transport_op_locked(grpc_exec_ctx* exec_ctx, void* arg,
602
620
 
603
621
  if (op->on_connectivity_state_change != nullptr) {
604
622
  grpc_connectivity_state_notify_on_state_change(
605
- exec_ctx, &chand->state_tracker, op->connectivity_state,
623
+ &chand->state_tracker, op->connectivity_state,
606
624
  op->on_connectivity_state_change);
607
625
  op->on_connectivity_state_change = nullptr;
608
626
  op->connectivity_state = nullptr;
609
627
  }
610
628
 
611
- if (op->send_ping != nullptr) {
629
+ if (op->send_ping.on_initiate != nullptr || op->send_ping.on_ack != nullptr) {
612
630
  if (chand->lb_policy == nullptr) {
613
631
  GRPC_CLOSURE_SCHED(
614
- exec_ctx, op->send_ping,
632
+ op->send_ping.on_initiate,
633
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Ping with no load balancing"));
634
+ GRPC_CLOSURE_SCHED(
635
+ op->send_ping.on_ack,
615
636
  GRPC_ERROR_CREATE_FROM_STATIC_STRING("Ping with no load balancing"));
616
637
  } else {
617
- grpc_lb_policy_ping_one_locked(exec_ctx, chand->lb_policy, op->send_ping);
638
+ grpc_lb_policy_ping_one_locked(
639
+ chand->lb_policy, op->send_ping.on_initiate, op->send_ping.on_ack);
618
640
  op->bind_pollset = nullptr;
619
641
  }
620
- op->send_ping = nullptr;
642
+ op->send_ping.on_initiate = nullptr;
643
+ op->send_ping.on_ack = nullptr;
621
644
  }
622
645
 
623
646
  if (op->disconnect_with_error != GRPC_ERROR_NONE) {
624
647
  if (chand->resolver != nullptr) {
625
648
  set_channel_connectivity_state_locked(
626
- exec_ctx, chand, GRPC_CHANNEL_SHUTDOWN,
649
+ chand, GRPC_CHANNEL_SHUTDOWN,
627
650
  GRPC_ERROR_REF(op->disconnect_with_error), "disconnect");
628
- grpc_resolver_shutdown_locked(exec_ctx, chand->resolver);
629
- GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel");
651
+ grpc_resolver_shutdown_locked(chand->resolver);
652
+ GRPC_RESOLVER_UNREF(chand->resolver, "channel");
630
653
  chand->resolver = nullptr;
631
654
  if (!chand->started_resolving) {
632
655
  grpc_closure_list_fail_all(&chand->waiting_for_resolver_result_closures,
633
656
  GRPC_ERROR_REF(op->disconnect_with_error));
634
- GRPC_CLOSURE_LIST_SCHED(exec_ctx,
635
- &chand->waiting_for_resolver_result_closures);
657
+ GRPC_CLOSURE_LIST_SCHED(&chand->waiting_for_resolver_result_closures);
636
658
  }
637
659
  if (chand->lb_policy != nullptr) {
638
- grpc_pollset_set_del_pollset_set(exec_ctx,
639
- chand->lb_policy->interested_parties,
660
+ grpc_pollset_set_del_pollset_set(chand->lb_policy->interested_parties,
640
661
  chand->interested_parties);
641
- GRPC_LB_POLICY_UNREF(exec_ctx, chand->lb_policy, "channel");
662
+ grpc_lb_policy_shutdown_locked(chand->lb_policy, nullptr);
663
+ GRPC_LB_POLICY_UNREF(chand->lb_policy, "channel");
642
664
  chand->lb_policy = nullptr;
643
665
  }
644
666
  }
645
667
  GRPC_ERROR_UNREF(op->disconnect_with_error);
646
668
  }
647
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->owning_stack, "start_transport_op");
669
+ GRPC_CHANNEL_STACK_UNREF(chand->owning_stack, "start_transport_op");
648
670
 
649
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
671
+ GRPC_CLOSURE_SCHED(op->on_consumed, GRPC_ERROR_NONE);
650
672
  }
651
673
 
652
- static void cc_start_transport_op(grpc_exec_ctx* exec_ctx,
653
- grpc_channel_element* elem,
674
+ static void cc_start_transport_op(grpc_channel_element* elem,
654
675
  grpc_transport_op* op) {
655
676
  channel_data* chand = (channel_data*)elem->channel_data;
656
677
 
657
678
  GPR_ASSERT(op->set_accept_stream == false);
658
679
  if (op->bind_pollset != nullptr) {
659
- grpc_pollset_set_add_pollset(exec_ctx, chand->interested_parties,
660
- op->bind_pollset);
680
+ grpc_pollset_set_add_pollset(chand->interested_parties, op->bind_pollset);
661
681
  }
662
682
 
663
683
  op->handler_private.extra_arg = elem;
664
684
  GRPC_CHANNEL_STACK_REF(chand->owning_stack, "start_transport_op");
665
685
  GRPC_CLOSURE_SCHED(
666
- exec_ctx,
667
686
  GRPC_CLOSURE_INIT(&op->handler_private.closure, start_transport_op_locked,
668
687
  op, grpc_combiner_scheduler(chand->combiner)),
669
688
  GRPC_ERROR_NONE);
670
689
  }
671
690
 
672
- static void cc_get_channel_info(grpc_exec_ctx* exec_ctx,
673
- grpc_channel_element* elem,
691
+ static void cc_get_channel_info(grpc_channel_element* elem,
674
692
  const grpc_channel_info* info) {
675
693
  channel_data* chand = (channel_data*)elem->channel_data;
676
694
  gpr_mu_lock(&chand->info_mu);
@@ -689,8 +707,7 @@ static void cc_get_channel_info(grpc_exec_ctx* exec_ctx,
689
707
  }
690
708
 
691
709
  /* Constructor for channel_data */
692
- static grpc_error* cc_init_channel_elem(grpc_exec_ctx* exec_ctx,
693
- grpc_channel_element* elem,
710
+ static grpc_error* cc_init_channel_elem(grpc_channel_element* elem,
694
711
  grpc_channel_element_args* args) {
695
712
  channel_data* chand = (channel_data*)elem->channel_data;
696
713
  GPR_ASSERT(args->is_last);
@@ -711,7 +728,7 @@ static grpc_error* cc_init_channel_elem(grpc_exec_ctx* exec_ctx,
711
728
  chand->interested_parties = grpc_pollset_set_create();
712
729
  grpc_connectivity_state_init(&chand->state_tracker, GRPC_CHANNEL_IDLE,
713
730
  "client_channel");
714
- grpc_client_channel_start_backup_polling(exec_ctx, chand->interested_parties);
731
+ grpc_client_channel_start_backup_polling(chand->interested_parties);
715
732
  // Record client channel factory.
716
733
  const grpc_arg* arg = grpc_channel_args_find(args->channel_args,
717
734
  GRPC_ARG_CLIENT_CHANNEL_FACTORY);
@@ -739,15 +756,15 @@ static grpc_error* cc_init_channel_elem(grpc_exec_ctx* exec_ctx,
739
756
  }
740
757
  char* proxy_name = nullptr;
741
758
  grpc_channel_args* new_args = nullptr;
742
- grpc_proxy_mappers_map_name(exec_ctx, arg->value.string, args->channel_args,
759
+ grpc_proxy_mappers_map_name(arg->value.string, args->channel_args,
743
760
  &proxy_name, &new_args);
744
761
  // Instantiate resolver.
745
762
  chand->resolver = grpc_resolver_create(
746
- exec_ctx, proxy_name != nullptr ? proxy_name : arg->value.string,
763
+ proxy_name != nullptr ? proxy_name : arg->value.string,
747
764
  new_args != nullptr ? new_args : args->channel_args,
748
765
  chand->interested_parties, chand->combiner);
749
766
  if (proxy_name != nullptr) gpr_free(proxy_name);
750
- if (new_args != nullptr) grpc_channel_args_destroy(exec_ctx, new_args);
767
+ if (new_args != nullptr) grpc_channel_args_destroy(new_args);
751
768
  if (chand->resolver == nullptr) {
752
769
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("resolver creation failed");
753
770
  }
@@ -756,32 +773,29 @@ static grpc_error* cc_init_channel_elem(grpc_exec_ctx* exec_ctx,
756
773
  return GRPC_ERROR_NONE;
757
774
  }
758
775
 
759
- static void shutdown_resolver_locked(grpc_exec_ctx* exec_ctx, void* arg,
760
- grpc_error* error) {
776
+ static void shutdown_resolver_locked(void* arg, grpc_error* error) {
761
777
  grpc_resolver* resolver = (grpc_resolver*)arg;
762
- grpc_resolver_shutdown_locked(exec_ctx, resolver);
763
- GRPC_RESOLVER_UNREF(exec_ctx, resolver, "channel");
778
+ grpc_resolver_shutdown_locked(resolver);
779
+ GRPC_RESOLVER_UNREF(resolver, "channel");
764
780
  }
765
781
 
766
782
  /* Destructor for channel_data */
767
- static void cc_destroy_channel_elem(grpc_exec_ctx* exec_ctx,
768
- grpc_channel_element* elem) {
783
+ static void cc_destroy_channel_elem(grpc_channel_element* elem) {
769
784
  channel_data* chand = (channel_data*)elem->channel_data;
770
785
  if (chand->resolver != nullptr) {
771
786
  GRPC_CLOSURE_SCHED(
772
- exec_ctx,
773
787
  GRPC_CLOSURE_CREATE(shutdown_resolver_locked, chand->resolver,
774
788
  grpc_combiner_scheduler(chand->combiner)),
775
789
  GRPC_ERROR_NONE);
776
790
  }
777
791
  if (chand->client_channel_factory != nullptr) {
778
- grpc_client_channel_factory_unref(exec_ctx, chand->client_channel_factory);
792
+ grpc_client_channel_factory_unref(chand->client_channel_factory);
779
793
  }
780
794
  if (chand->lb_policy != nullptr) {
781
- grpc_pollset_set_del_pollset_set(exec_ctx,
782
- chand->lb_policy->interested_parties,
795
+ grpc_pollset_set_del_pollset_set(chand->lb_policy->interested_parties,
783
796
  chand->interested_parties);
784
- GRPC_LB_POLICY_UNREF(exec_ctx, chand->lb_policy, "channel");
797
+ grpc_lb_policy_shutdown_locked(chand->lb_policy, nullptr);
798
+ GRPC_LB_POLICY_UNREF(chand->lb_policy, "channel");
785
799
  }
786
800
  gpr_free(chand->info_lb_policy_name);
787
801
  gpr_free(chand->info_service_config_json);
@@ -789,12 +803,12 @@ static void cc_destroy_channel_elem(grpc_exec_ctx* exec_ctx,
789
803
  grpc_server_retry_throttle_data_unref(chand->retry_throttle_data);
790
804
  }
791
805
  if (chand->method_params_table != nullptr) {
792
- grpc_slice_hash_table_unref(exec_ctx, chand->method_params_table);
806
+ grpc_slice_hash_table_unref(chand->method_params_table);
793
807
  }
794
- grpc_client_channel_stop_backup_polling(exec_ctx, chand->interested_parties);
795
- grpc_connectivity_state_destroy(exec_ctx, &chand->state_tracker);
796
- grpc_pollset_set_destroy(exec_ctx, chand->interested_parties);
797
- GRPC_COMBINER_UNREF(exec_ctx, chand->combiner, "client_channel");
808
+ grpc_client_channel_stop_backup_polling(chand->interested_parties);
809
+ grpc_connectivity_state_destroy(&chand->state_tracker);
810
+ grpc_pollset_set_destroy(chand->interested_parties);
811
+ GRPC_COMBINER_UNREF(chand->combiner, "client_channel");
798
812
  gpr_mu_destroy(&chand->info_mu);
799
813
  gpr_mu_destroy(&chand->external_connectivity_watcher_list_mu);
800
814
  }
@@ -841,12 +855,10 @@ typedef struct client_channel_call_data {
841
855
  grpc_subchannel_call* subchannel_call;
842
856
  grpc_error* error;
843
857
 
844
- grpc_lb_policy* lb_policy; // Holds ref while LB pick is pending.
858
+ grpc_lb_policy_pick_state pick;
845
859
  grpc_closure lb_pick_closure;
846
860
  grpc_closure lb_pick_cancel_closure;
847
861
 
848
- grpc_connected_subchannel* connected_subchannel;
849
- grpc_call_context_element subchannel_call_context[GRPC_CONTEXT_COUNT];
850
862
  grpc_polling_entity* pollent;
851
863
 
852
864
  grpc_transport_stream_op_batch* waiting_for_pick_batches[MAX_WAITING_BATCHES];
@@ -855,8 +867,6 @@ typedef struct client_channel_call_data {
855
867
 
856
868
  grpc_transport_stream_op_batch* initial_metadata_batch;
857
869
 
858
- grpc_linked_mdelem lb_token_mdelem;
859
-
860
870
  grpc_closure on_complete;
861
871
  grpc_closure* original_on_complete;
862
872
  } call_data;
@@ -881,21 +891,18 @@ static void waiting_for_pick_batches_add(
881
891
  }
882
892
 
883
893
  // This is called via the call combiner, so access to calld is synchronized.
884
- static void fail_pending_batch_in_call_combiner(grpc_exec_ctx* exec_ctx,
885
- void* arg, grpc_error* error) {
894
+ static void fail_pending_batch_in_call_combiner(void* arg, grpc_error* error) {
886
895
  call_data* calld = (call_data*)arg;
887
896
  if (calld->waiting_for_pick_batches_count > 0) {
888
897
  --calld->waiting_for_pick_batches_count;
889
898
  grpc_transport_stream_op_batch_finish_with_failure(
890
- exec_ctx,
891
899
  calld->waiting_for_pick_batches[calld->waiting_for_pick_batches_count],
892
900
  GRPC_ERROR_REF(error), calld->call_combiner);
893
901
  }
894
902
  }
895
903
 
896
904
  // This is called via the call combiner, so access to calld is synchronized.
897
- static void waiting_for_pick_batches_fail(grpc_exec_ctx* exec_ctx,
898
- grpc_call_element* elem,
905
+ static void waiting_for_pick_batches_fail(grpc_call_element* elem,
899
906
  grpc_error* error) {
900
907
  call_data* calld = (call_data*)elem->call_data;
901
908
  if (grpc_client_channel_trace.enabled()) {
@@ -908,37 +915,34 @@ static void waiting_for_pick_batches_fail(grpc_exec_ctx* exec_ctx,
908
915
  GRPC_CLOSURE_INIT(&calld->handle_pending_batch_in_call_combiner[i],
909
916
  fail_pending_batch_in_call_combiner, calld,
910
917
  grpc_schedule_on_exec_ctx);
911
- GRPC_CALL_COMBINER_START(exec_ctx, calld->call_combiner,
912
- &calld->handle_pending_batch_in_call_combiner[i],
913
- GRPC_ERROR_REF(error),
914
- "waiting_for_pick_batches_fail");
918
+ GRPC_CALL_COMBINER_START(
919
+ calld->call_combiner, &calld->handle_pending_batch_in_call_combiner[i],
920
+ GRPC_ERROR_REF(error), "waiting_for_pick_batches_fail");
915
921
  }
916
922
  if (calld->initial_metadata_batch != nullptr) {
917
923
  grpc_transport_stream_op_batch_finish_with_failure(
918
- exec_ctx, calld->initial_metadata_batch, GRPC_ERROR_REF(error),
924
+ calld->initial_metadata_batch, GRPC_ERROR_REF(error),
919
925
  calld->call_combiner);
920
926
  } else {
921
- GRPC_CALL_COMBINER_STOP(exec_ctx, calld->call_combiner,
927
+ GRPC_CALL_COMBINER_STOP(calld->call_combiner,
922
928
  "waiting_for_pick_batches_fail");
923
929
  }
924
930
  GRPC_ERROR_UNREF(error);
925
931
  }
926
932
 
927
933
  // This is called via the call combiner, so access to calld is synchronized.
928
- static void run_pending_batch_in_call_combiner(grpc_exec_ctx* exec_ctx,
929
- void* arg, grpc_error* ignored) {
934
+ static void run_pending_batch_in_call_combiner(void* arg, grpc_error* ignored) {
930
935
  call_data* calld = (call_data*)arg;
931
936
  if (calld->waiting_for_pick_batches_count > 0) {
932
937
  --calld->waiting_for_pick_batches_count;
933
938
  grpc_subchannel_call_process_op(
934
- exec_ctx, calld->subchannel_call,
939
+ calld->subchannel_call,
935
940
  calld->waiting_for_pick_batches[calld->waiting_for_pick_batches_count]);
936
941
  }
937
942
  }
938
943
 
939
944
  // This is called via the call combiner, so access to calld is synchronized.
940
- static void waiting_for_pick_batches_resume(grpc_exec_ctx* exec_ctx,
941
- grpc_call_element* elem) {
945
+ static void waiting_for_pick_batches_resume(grpc_call_element* elem) {
942
946
  channel_data* chand = (channel_data*)elem->channel_data;
943
947
  call_data* calld = (call_data*)elem->call_data;
944
948
  if (grpc_client_channel_trace.enabled()) {
@@ -952,20 +956,18 @@ static void waiting_for_pick_batches_resume(grpc_exec_ctx* exec_ctx,
952
956
  GRPC_CLOSURE_INIT(&calld->handle_pending_batch_in_call_combiner[i],
953
957
  run_pending_batch_in_call_combiner, calld,
954
958
  grpc_schedule_on_exec_ctx);
955
- GRPC_CALL_COMBINER_START(exec_ctx, calld->call_combiner,
956
- &calld->handle_pending_batch_in_call_combiner[i],
957
- GRPC_ERROR_NONE,
958
- "waiting_for_pick_batches_resume");
959
+ GRPC_CALL_COMBINER_START(
960
+ calld->call_combiner, &calld->handle_pending_batch_in_call_combiner[i],
961
+ GRPC_ERROR_NONE, "waiting_for_pick_batches_resume");
959
962
  }
960
963
  GPR_ASSERT(calld->initial_metadata_batch != nullptr);
961
- grpc_subchannel_call_process_op(exec_ctx, calld->subchannel_call,
964
+ grpc_subchannel_call_process_op(calld->subchannel_call,
962
965
  calld->initial_metadata_batch);
963
966
  }
964
967
 
965
968
  // Applies service config to the call. Must be invoked once we know
966
969
  // that the resolver has returned results to the channel.
967
- static void apply_service_config_to_call_locked(grpc_exec_ctx* exec_ctx,
968
- grpc_call_element* elem) {
970
+ static void apply_service_config_to_call_locked(grpc_call_element* elem) {
969
971
  channel_data* chand = (channel_data*)elem->channel_data;
970
972
  call_data* calld = (call_data*)elem->call_data;
971
973
  if (grpc_client_channel_trace.enabled()) {
@@ -978,7 +980,7 @@ static void apply_service_config_to_call_locked(grpc_exec_ctx* exec_ctx,
978
980
  }
979
981
  if (chand->method_params_table != nullptr) {
980
982
  calld->method_params = (method_parameters*)grpc_method_config_table_get(
981
- exec_ctx, chand->method_params_table, calld->path);
983
+ chand->method_params_table, calld->path);
982
984
  if (calld->method_params != nullptr) {
983
985
  method_parameters_ref(calld->method_params);
984
986
  // If the deadline from the service config is shorter than the one
@@ -990,49 +992,46 @@ static void apply_service_config_to_call_locked(grpc_exec_ctx* exec_ctx,
990
992
  calld->method_params->timeout;
991
993
  if (per_method_deadline < calld->deadline) {
992
994
  calld->deadline = per_method_deadline;
993
- grpc_deadline_state_reset(exec_ctx, elem, calld->deadline);
995
+ grpc_deadline_state_reset(elem, calld->deadline);
994
996
  }
995
997
  }
996
998
  }
997
999
  }
998
1000
  }
999
1001
 
1000
- static void create_subchannel_call_locked(grpc_exec_ctx* exec_ctx,
1001
- grpc_call_element* elem,
1002
+ static void create_subchannel_call_locked(grpc_call_element* elem,
1002
1003
  grpc_error* error) {
1003
1004
  channel_data* chand = (channel_data*)elem->channel_data;
1004
1005
  call_data* calld = (call_data*)elem->call_data;
1005
- const grpc_connected_subchannel_call_args call_args = {
1006
- calld->pollent, // pollent
1007
- calld->path, // path
1008
- calld->call_start_time, // start_time
1009
- calld->deadline, // deadline
1010
- calld->arena, // arena
1011
- calld->subchannel_call_context, // context
1012
- calld->call_combiner // call_combiner
1006
+ const grpc_core::ConnectedSubchannel::CallArgs call_args = {
1007
+ calld->pollent, // pollent
1008
+ calld->path, // path
1009
+ calld->call_start_time, // start_time
1010
+ calld->deadline, // deadline
1011
+ calld->arena, // arena
1012
+ calld->pick.subchannel_call_context, // context
1013
+ calld->call_combiner // call_combiner
1013
1014
  };
1014
- grpc_error* new_error = grpc_connected_subchannel_create_call(
1015
- exec_ctx, calld->connected_subchannel, &call_args,
1016
- &calld->subchannel_call);
1015
+ grpc_error* new_error = calld->pick.connected_subchannel->CreateCall(
1016
+ call_args, &calld->subchannel_call);
1017
1017
  if (grpc_client_channel_trace.enabled()) {
1018
1018
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: create subchannel_call=%p: error=%s",
1019
1019
  chand, calld, calld->subchannel_call, grpc_error_string(new_error));
1020
1020
  }
1021
1021
  if (new_error != GRPC_ERROR_NONE) {
1022
1022
  new_error = grpc_error_add_child(new_error, error);
1023
- waiting_for_pick_batches_fail(exec_ctx, elem, new_error);
1023
+ waiting_for_pick_batches_fail(elem, new_error);
1024
1024
  } else {
1025
- waiting_for_pick_batches_resume(exec_ctx, elem);
1025
+ waiting_for_pick_batches_resume(elem);
1026
1026
  }
1027
1027
  GRPC_ERROR_UNREF(error);
1028
1028
  }
1029
1029
 
1030
1030
  // Invoked when a pick is completed, on both success or failure.
1031
- static void pick_done_locked(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
1032
- grpc_error* error) {
1031
+ static void pick_done_locked(grpc_call_element* elem, grpc_error* error) {
1033
1032
  call_data* calld = (call_data*)elem->call_data;
1034
1033
  channel_data* chand = (channel_data*)elem->channel_data;
1035
- if (calld->connected_subchannel == nullptr) {
1034
+ if (calld->pick.connected_subchannel == nullptr) {
1036
1035
  // Failed to create subchannel.
1037
1036
  GRPC_ERROR_UNREF(calld->error);
1038
1037
  calld->error = error == GRPC_ERROR_NONE
@@ -1045,10 +1044,10 @@ static void pick_done_locked(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
1045
1044
  "chand=%p calld=%p: failed to create subchannel: error=%s", chand,
1046
1045
  calld, grpc_error_string(calld->error));
1047
1046
  }
1048
- waiting_for_pick_batches_fail(exec_ctx, elem, GRPC_ERROR_REF(calld->error));
1047
+ waiting_for_pick_batches_fail(elem, GRPC_ERROR_REF(calld->error));
1049
1048
  } else {
1050
1049
  /* Create call on subchannel. */
1051
- create_subchannel_call_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
1050
+ create_subchannel_call_locked(elem, GRPC_ERROR_REF(error));
1052
1051
  }
1053
1052
  GRPC_ERROR_UNREF(error);
1054
1053
  }
@@ -1057,38 +1056,37 @@ static void pick_done_locked(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
1057
1056
  // either (a) the pick was deferred pending a resolver result or (b) the
1058
1057
  // pick was done asynchronously. Removes the call's polling entity from
1059
1058
  // chand->interested_parties before invoking pick_done_locked().
1060
- static void async_pick_done_locked(grpc_exec_ctx* exec_ctx,
1061
- grpc_call_element* elem, grpc_error* error) {
1059
+ static void async_pick_done_locked(grpc_call_element* elem, grpc_error* error) {
1062
1060
  channel_data* chand = (channel_data*)elem->channel_data;
1063
1061
  call_data* calld = (call_data*)elem->call_data;
1064
- grpc_polling_entity_del_from_pollset_set(exec_ctx, calld->pollent,
1062
+ grpc_polling_entity_del_from_pollset_set(calld->pollent,
1065
1063
  chand->interested_parties);
1066
- pick_done_locked(exec_ctx, elem, error);
1064
+ pick_done_locked(elem, error);
1067
1065
  }
1068
1066
 
1069
1067
  // Note: This runs under the client_channel combiner, but will NOT be
1070
1068
  // holding the call combiner.
1071
- static void pick_callback_cancel_locked(grpc_exec_ctx* exec_ctx, void* arg,
1072
- grpc_error* error) {
1069
+ static void pick_callback_cancel_locked(void* arg, grpc_error* error) {
1073
1070
  grpc_call_element* elem = (grpc_call_element*)arg;
1074
1071
  channel_data* chand = (channel_data*)elem->channel_data;
1075
1072
  call_data* calld = (call_data*)elem->call_data;
1076
- if (calld->lb_policy != nullptr) {
1073
+ // Note: chand->lb_policy may have changed since we started our pick,
1074
+ // in which case we will be cancelling the pick on a policy other than
1075
+ // the one we started it on. However, this will just be a no-op.
1076
+ if (error != GRPC_ERROR_NONE && chand->lb_policy != nullptr) {
1077
1077
  if (grpc_client_channel_trace.enabled()) {
1078
1078
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: cancelling pick from LB policy %p",
1079
- chand, calld, calld->lb_policy);
1079
+ chand, calld, chand->lb_policy);
1080
1080
  }
1081
- grpc_lb_policy_cancel_pick_locked(exec_ctx, calld->lb_policy,
1082
- &calld->connected_subchannel,
1081
+ grpc_lb_policy_cancel_pick_locked(chand->lb_policy, &calld->pick,
1083
1082
  GRPC_ERROR_REF(error));
1084
1083
  }
1085
- GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "pick_callback_cancel");
1084
+ GRPC_CALL_STACK_UNREF(calld->owning_call, "pick_callback_cancel");
1086
1085
  }
1087
1086
 
1088
1087
  // Callback invoked by grpc_lb_policy_pick_locked() for async picks.
1089
1088
  // Unrefs the LB policy and invokes async_pick_done_locked().
1090
- static void pick_callback_done_locked(grpc_exec_ctx* exec_ctx, void* arg,
1091
- grpc_error* error) {
1089
+ static void pick_callback_done_locked(void* arg, grpc_error* error) {
1092
1090
  grpc_call_element* elem = (grpc_call_element*)arg;
1093
1091
  channel_data* chand = (channel_data*)elem->channel_data;
1094
1092
  call_data* calld = (call_data*)elem->call_data;
@@ -1096,24 +1094,20 @@ static void pick_callback_done_locked(grpc_exec_ctx* exec_ctx, void* arg,
1096
1094
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: pick completed asynchronously",
1097
1095
  chand, calld);
1098
1096
  }
1099
- GPR_ASSERT(calld->lb_policy != nullptr);
1100
- GRPC_LB_POLICY_UNREF(exec_ctx, calld->lb_policy, "pick_subchannel");
1101
- calld->lb_policy = nullptr;
1102
- async_pick_done_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
1097
+ async_pick_done_locked(elem, GRPC_ERROR_REF(error));
1103
1098
  }
1104
1099
 
1105
1100
  // Takes a ref to chand->lb_policy and calls grpc_lb_policy_pick_locked().
1106
1101
  // If the pick was completed synchronously, unrefs the LB policy and
1107
1102
  // returns true.
1108
- static bool pick_callback_start_locked(grpc_exec_ctx* exec_ctx,
1109
- grpc_call_element* elem) {
1103
+ static bool pick_callback_start_locked(grpc_call_element* elem) {
1110
1104
  channel_data* chand = (channel_data*)elem->channel_data;
1111
1105
  call_data* calld = (call_data*)elem->call_data;
1112
1106
  if (grpc_client_channel_trace.enabled()) {
1113
1107
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: starting pick on lb_policy=%p",
1114
1108
  chand, calld, chand->lb_policy);
1115
1109
  }
1116
- apply_service_config_to_call_locked(exec_ctx, elem);
1110
+ apply_service_config_to_call_locked(elem);
1117
1111
  // If the application explicitly set wait_for_ready, use that.
1118
1112
  // Otherwise, if the service config specified a value for this
1119
1113
  // method, use that.
@@ -1133,30 +1127,25 @@ static bool pick_callback_start_locked(grpc_exec_ctx* exec_ctx,
1133
1127
  initial_metadata_flags &= ~GRPC_INITIAL_METADATA_WAIT_FOR_READY;
1134
1128
  }
1135
1129
  }
1136
- const grpc_lb_policy_pick_args inputs = {
1130
+ calld->pick.initial_metadata =
1137
1131
  calld->initial_metadata_batch->payload->send_initial_metadata
1138
- .send_initial_metadata,
1139
- initial_metadata_flags, &calld->lb_token_mdelem};
1140
- // Keep a ref to the LB policy in calld while the pick is pending.
1141
- GRPC_LB_POLICY_REF(chand->lb_policy, "pick_subchannel");
1142
- calld->lb_policy = chand->lb_policy;
1132
+ .send_initial_metadata;
1133
+ calld->pick.initial_metadata_flags = initial_metadata_flags;
1143
1134
  GRPC_CLOSURE_INIT(&calld->lb_pick_closure, pick_callback_done_locked, elem,
1144
1135
  grpc_combiner_scheduler(chand->combiner));
1145
- const bool pick_done = grpc_lb_policy_pick_locked(
1146
- exec_ctx, chand->lb_policy, &inputs, &calld->connected_subchannel,
1147
- calld->subchannel_call_context, nullptr, &calld->lb_pick_closure);
1136
+ calld->pick.on_complete = &calld->lb_pick_closure;
1137
+ const bool pick_done =
1138
+ grpc_lb_policy_pick_locked(chand->lb_policy, &calld->pick);
1148
1139
  if (pick_done) {
1149
1140
  /* synchronous grpc_lb_policy_pick call. Unref the LB policy. */
1150
1141
  if (grpc_client_channel_trace.enabled()) {
1151
1142
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: pick completed synchronously",
1152
1143
  chand, calld);
1153
1144
  }
1154
- GRPC_LB_POLICY_UNREF(exec_ctx, calld->lb_policy, "pick_subchannel");
1155
- calld->lb_policy = nullptr;
1156
1145
  } else {
1157
1146
  GRPC_CALL_STACK_REF(calld->owning_call, "pick_callback_cancel");
1158
1147
  grpc_call_combiner_set_notify_on_cancel(
1159
- exec_ctx, calld->call_combiner,
1148
+ calld->call_combiner,
1160
1149
  GRPC_CLOSURE_INIT(&calld->lb_pick_cancel_closure,
1161
1150
  pick_callback_cancel_locked, elem,
1162
1151
  grpc_combiner_scheduler(chand->combiner)));
@@ -1173,8 +1162,7 @@ typedef struct {
1173
1162
 
1174
1163
  // Note: This runs under the client_channel combiner, but will NOT be
1175
1164
  // holding the call combiner.
1176
- static void pick_after_resolver_result_cancel_locked(grpc_exec_ctx* exec_ctx,
1177
- void* arg,
1165
+ static void pick_after_resolver_result_cancel_locked(void* arg,
1178
1166
  grpc_error* error) {
1179
1167
  pick_after_resolver_result_args* args = (pick_after_resolver_result_args*)arg;
1180
1168
  if (args->finished) {
@@ -1202,16 +1190,13 @@ static void pick_after_resolver_result_cancel_locked(grpc_exec_ctx* exec_ctx,
1202
1190
  // it's safe to call async_pick_done_locked() here -- we are
1203
1191
  // essentially calling it here instead of calling it in
1204
1192
  // pick_after_resolver_result_done_locked().
1205
- async_pick_done_locked(exec_ctx, elem,
1206
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
1207
- "Pick cancelled", &error, 1));
1193
+ async_pick_done_locked(elem, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
1194
+ "Pick cancelled", &error, 1));
1208
1195
  }
1209
1196
 
1210
- static void pick_after_resolver_result_start_locked(grpc_exec_ctx* exec_ctx,
1211
- grpc_call_element* elem);
1197
+ static void pick_after_resolver_result_start_locked(grpc_call_element* elem);
1212
1198
 
1213
- static void pick_after_resolver_result_done_locked(grpc_exec_ctx* exec_ctx,
1214
- void* arg,
1199
+ static void pick_after_resolver_result_done_locked(void* arg,
1215
1200
  grpc_error* error) {
1216
1201
  pick_after_resolver_result_args* args = (pick_after_resolver_result_args*)arg;
1217
1202
  if (args->finished) {
@@ -1231,19 +1216,19 @@ static void pick_after_resolver_result_done_locked(grpc_exec_ctx* exec_ctx,
1231
1216
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver failed to return data",
1232
1217
  chand, calld);
1233
1218
  }
1234
- async_pick_done_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
1219
+ async_pick_done_locked(elem, GRPC_ERROR_REF(error));
1235
1220
  } else if (chand->lb_policy != nullptr) {
1236
1221
  if (grpc_client_channel_trace.enabled()) {
1237
1222
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver returned, doing pick",
1238
1223
  chand, calld);
1239
1224
  }
1240
- if (pick_callback_start_locked(exec_ctx, elem)) {
1225
+ if (pick_callback_start_locked(elem)) {
1241
1226
  // Even if the LB policy returns a result synchronously, we have
1242
1227
  // already added our polling entity to chand->interested_parties
1243
1228
  // in order to wait for the resolver result, so we need to
1244
1229
  // remove it here. Therefore, we call async_pick_done_locked()
1245
1230
  // instead of pick_done_locked().
1246
- async_pick_done_locked(exec_ctx, elem, GRPC_ERROR_NONE);
1231
+ async_pick_done_locked(elem, GRPC_ERROR_NONE);
1247
1232
  }
1248
1233
  }
1249
1234
  // TODO(roth): It should be impossible for chand->lb_policy to be NULL
@@ -1261,19 +1246,18 @@ static void pick_after_resolver_result_done_locked(grpc_exec_ctx* exec_ctx,
1261
1246
  "trying again",
1262
1247
  chand, calld);
1263
1248
  }
1264
- pick_after_resolver_result_start_locked(exec_ctx, elem);
1249
+ pick_after_resolver_result_start_locked(elem);
1265
1250
  } else {
1266
1251
  if (grpc_client_channel_trace.enabled()) {
1267
1252
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver disconnected", chand,
1268
1253
  calld);
1269
1254
  }
1270
1255
  async_pick_done_locked(
1271
- exec_ctx, elem, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Disconnected"));
1256
+ elem, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Disconnected"));
1272
1257
  }
1273
1258
  }
1274
1259
 
1275
- static void pick_after_resolver_result_start_locked(grpc_exec_ctx* exec_ctx,
1276
- grpc_call_element* elem) {
1260
+ static void pick_after_resolver_result_start_locked(grpc_call_element* elem) {
1277
1261
  channel_data* chand = (channel_data*)elem->channel_data;
1278
1262
  call_data* calld = (call_data*)elem->call_data;
1279
1263
  if (grpc_client_channel_trace.enabled()) {
@@ -1289,47 +1273,46 @@ static void pick_after_resolver_result_start_locked(grpc_exec_ctx* exec_ctx,
1289
1273
  grpc_closure_list_append(&chand->waiting_for_resolver_result_closures,
1290
1274
  &args->closure, GRPC_ERROR_NONE);
1291
1275
  grpc_call_combiner_set_notify_on_cancel(
1292
- exec_ctx, calld->call_combiner,
1276
+ calld->call_combiner,
1293
1277
  GRPC_CLOSURE_INIT(&args->cancel_closure,
1294
1278
  pick_after_resolver_result_cancel_locked, args,
1295
1279
  grpc_combiner_scheduler(chand->combiner)));
1296
1280
  }
1297
1281
 
1298
- static void start_pick_locked(grpc_exec_ctx* exec_ctx, void* arg,
1299
- grpc_error* ignored) {
1282
+ static void start_pick_locked(void* arg, grpc_error* ignored) {
1300
1283
  grpc_call_element* elem = (grpc_call_element*)arg;
1301
1284
  call_data* calld = (call_data*)elem->call_data;
1302
1285
  channel_data* chand = (channel_data*)elem->channel_data;
1303
- GPR_ASSERT(calld->connected_subchannel == nullptr);
1286
+ GPR_ASSERT(calld->pick.connected_subchannel == nullptr);
1304
1287
  if (chand->lb_policy != nullptr) {
1305
1288
  // We already have an LB policy, so ask it for a pick.
1306
- if (pick_callback_start_locked(exec_ctx, elem)) {
1289
+ if (pick_callback_start_locked(elem)) {
1307
1290
  // Pick completed synchronously.
1308
- pick_done_locked(exec_ctx, elem, GRPC_ERROR_NONE);
1291
+ pick_done_locked(elem, GRPC_ERROR_NONE);
1309
1292
  return;
1310
1293
  }
1311
1294
  } else {
1312
1295
  // We do not yet have an LB policy, so wait for a resolver result.
1313
1296
  if (chand->resolver == nullptr) {
1314
- pick_done_locked(exec_ctx, elem,
1297
+ pick_done_locked(elem,
1315
1298
  GRPC_ERROR_CREATE_FROM_STATIC_STRING("Disconnected"));
1316
1299
  return;
1317
1300
  }
1318
1301
  if (!chand->started_resolving) {
1319
- start_resolving_locked(exec_ctx, chand);
1302
+ start_resolving_locked(chand);
1320
1303
  }
1321
- pick_after_resolver_result_start_locked(exec_ctx, elem);
1304
+ pick_after_resolver_result_start_locked(elem);
1322
1305
  }
1323
1306
  // We need to wait for either a resolver result or for an async result
1324
1307
  // from the LB policy. Add the polling entity from call_data to the
1325
1308
  // channel_data's interested_parties, so that the I/O of the LB policy
1326
1309
  // and resolver can be done under it. The polling entity will be
1327
1310
  // removed in async_pick_done_locked().
1328
- grpc_polling_entity_add_to_pollset_set(exec_ctx, calld->pollent,
1311
+ grpc_polling_entity_add_to_pollset_set(calld->pollent,
1329
1312
  chand->interested_parties);
1330
1313
  }
1331
1314
 
1332
- static void on_complete(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
1315
+ static void on_complete(void* arg, grpc_error* error) {
1333
1316
  grpc_call_element* elem = (grpc_call_element*)arg;
1334
1317
  call_data* calld = (call_data*)elem->call_data;
1335
1318
  if (calld->retry_throttle_data != nullptr) {
@@ -1345,18 +1328,15 @@ static void on_complete(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
1345
1328
  calld->retry_throttle_data);
1346
1329
  }
1347
1330
  }
1348
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_on_complete,
1349
- GRPC_ERROR_REF(error));
1331
+ GRPC_CLOSURE_RUN(calld->original_on_complete, GRPC_ERROR_REF(error));
1350
1332
  }
1351
1333
 
1352
1334
  static void cc_start_transport_stream_op_batch(
1353
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
1354
- grpc_transport_stream_op_batch* batch) {
1335
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
1355
1336
  call_data* calld = (call_data*)elem->call_data;
1356
1337
  channel_data* chand = (channel_data*)elem->channel_data;
1357
1338
  if (chand->deadline_checking_enabled) {
1358
- grpc_deadline_state_client_start_transport_stream_op_batch(exec_ctx, elem,
1359
- batch);
1339
+ grpc_deadline_state_client_start_transport_stream_op_batch(elem, batch);
1360
1340
  }
1361
1341
  GPR_TIMER_BEGIN("cc_start_transport_stream_op_batch", 0);
1362
1342
  // If we've previously been cancelled, immediately fail any new batches.
@@ -1366,7 +1346,7 @@ static void cc_start_transport_stream_op_batch(
1366
1346
  chand, calld, grpc_error_string(calld->error));
1367
1347
  }
1368
1348
  grpc_transport_stream_op_batch_finish_with_failure(
1369
- exec_ctx, batch, GRPC_ERROR_REF(calld->error), calld->call_combiner);
1349
+ batch, GRPC_ERROR_REF(calld->error), calld->call_combiner);
1370
1350
  goto done;
1371
1351
  }
1372
1352
  if (batch->cancel_stream) {
@@ -1384,11 +1364,10 @@ static void cc_start_transport_stream_op_batch(
1384
1364
  // If we have a subchannel call, send the cancellation batch down.
1385
1365
  // Otherwise, fail all pending batches.
1386
1366
  if (calld->subchannel_call != nullptr) {
1387
- grpc_subchannel_call_process_op(exec_ctx, calld->subchannel_call, batch);
1367
+ grpc_subchannel_call_process_op(calld->subchannel_call, batch);
1388
1368
  } else {
1389
1369
  waiting_for_pick_batches_add(calld, batch);
1390
- waiting_for_pick_batches_fail(exec_ctx, elem,
1391
- GRPC_ERROR_REF(calld->error));
1370
+ waiting_for_pick_batches_fail(elem, GRPC_ERROR_REF(calld->error));
1392
1371
  }
1393
1372
  goto done;
1394
1373
  }
@@ -1411,7 +1390,7 @@ static void cc_start_transport_stream_op_batch(
1411
1390
  "chand=%p calld=%p: sending batch to subchannel_call=%p", chand,
1412
1391
  calld, calld->subchannel_call);
1413
1392
  }
1414
- grpc_subchannel_call_process_op(exec_ctx, calld->subchannel_call, batch);
1393
+ grpc_subchannel_call_process_op(calld->subchannel_call, batch);
1415
1394
  goto done;
1416
1395
  }
1417
1396
  // We do not yet have a subchannel call.
@@ -1425,7 +1404,6 @@ static void cc_start_transport_stream_op_batch(
1425
1404
  chand, calld);
1426
1405
  }
1427
1406
  GRPC_CLOSURE_SCHED(
1428
- exec_ctx,
1429
1407
  GRPC_CLOSURE_INIT(&batch->handler_private.closure, start_pick_locked,
1430
1408
  elem, grpc_combiner_scheduler(chand->combiner)),
1431
1409
  GRPC_ERROR_NONE);
@@ -1436,7 +1414,7 @@ static void cc_start_transport_stream_op_batch(
1436
1414
  "chand=%p calld=%p: saved batch, yeilding call combiner", chand,
1437
1415
  calld);
1438
1416
  }
1439
- GRPC_CALL_COMBINER_STOP(exec_ctx, calld->call_combiner,
1417
+ GRPC_CALL_COMBINER_STOP(calld->call_combiner,
1440
1418
  "batch does not include send_initial_metadata");
1441
1419
  }
1442
1420
  done:
@@ -1444,8 +1422,7 @@ done:
1444
1422
  }
1445
1423
 
1446
1424
  /* Constructor for call_data */
1447
- static grpc_error* cc_init_call_elem(grpc_exec_ctx* exec_ctx,
1448
- grpc_call_element* elem,
1425
+ static grpc_error* cc_init_call_elem(grpc_call_element* elem,
1449
1426
  const grpc_call_element_args* args) {
1450
1427
  call_data* calld = (call_data*)elem->call_data;
1451
1428
  channel_data* chand = (channel_data*)elem->channel_data;
@@ -1457,23 +1434,22 @@ static grpc_error* cc_init_call_elem(grpc_exec_ctx* exec_ctx,
1457
1434
  calld->owning_call = args->call_stack;
1458
1435
  calld->call_combiner = args->call_combiner;
1459
1436
  if (chand->deadline_checking_enabled) {
1460
- grpc_deadline_state_init(exec_ctx, elem, args->call_stack,
1461
- args->call_combiner, calld->deadline);
1437
+ grpc_deadline_state_init(elem, args->call_stack, args->call_combiner,
1438
+ calld->deadline);
1462
1439
  }
1463
1440
  return GRPC_ERROR_NONE;
1464
1441
  }
1465
1442
 
1466
1443
  /* Destructor for call_data */
1467
- static void cc_destroy_call_elem(grpc_exec_ctx* exec_ctx,
1468
- grpc_call_element* elem,
1444
+ static void cc_destroy_call_elem(grpc_call_element* elem,
1469
1445
  const grpc_call_final_info* final_info,
1470
1446
  grpc_closure* then_schedule_closure) {
1471
1447
  call_data* calld = (call_data*)elem->call_data;
1472
1448
  channel_data* chand = (channel_data*)elem->channel_data;
1473
1449
  if (chand->deadline_checking_enabled) {
1474
- grpc_deadline_state_destroy(exec_ctx, elem);
1450
+ grpc_deadline_state_destroy(elem);
1475
1451
  }
1476
- grpc_slice_unref_internal(exec_ctx, calld->path);
1452
+ grpc_slice_unref_internal(calld->path);
1477
1453
  if (calld->method_params != nullptr) {
1478
1454
  method_parameters_unref(calld->method_params);
1479
1455
  }
@@ -1482,26 +1458,23 @@ static void cc_destroy_call_elem(grpc_exec_ctx* exec_ctx,
1482
1458
  grpc_subchannel_call_set_cleanup_closure(calld->subchannel_call,
1483
1459
  then_schedule_closure);
1484
1460
  then_schedule_closure = nullptr;
1485
- GRPC_SUBCHANNEL_CALL_UNREF(exec_ctx, calld->subchannel_call,
1461
+ GRPC_SUBCHANNEL_CALL_UNREF(calld->subchannel_call,
1486
1462
  "client_channel_destroy_call");
1487
1463
  }
1488
- GPR_ASSERT(calld->lb_policy == nullptr);
1489
1464
  GPR_ASSERT(calld->waiting_for_pick_batches_count == 0);
1490
- if (calld->connected_subchannel != nullptr) {
1491
- GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, calld->connected_subchannel,
1492
- "picked");
1465
+ if (calld->pick.connected_subchannel != nullptr) {
1466
+ calld->pick.connected_subchannel.reset();
1493
1467
  }
1494
1468
  for (size_t i = 0; i < GRPC_CONTEXT_COUNT; ++i) {
1495
- if (calld->subchannel_call_context[i].value != nullptr) {
1496
- calld->subchannel_call_context[i].destroy(
1497
- calld->subchannel_call_context[i].value);
1469
+ if (calld->pick.subchannel_call_context[i].value != nullptr) {
1470
+ calld->pick.subchannel_call_context[i].destroy(
1471
+ calld->pick.subchannel_call_context[i].value);
1498
1472
  }
1499
1473
  }
1500
- GRPC_CLOSURE_SCHED(exec_ctx, then_schedule_closure, GRPC_ERROR_NONE);
1474
+ GRPC_CLOSURE_SCHED(then_schedule_closure, GRPC_ERROR_NONE);
1501
1475
  }
1502
1476
 
1503
- static void cc_set_pollset_or_pollset_set(grpc_exec_ctx* exec_ctx,
1504
- grpc_call_element* elem,
1477
+ static void cc_set_pollset_or_pollset_set(grpc_call_element* elem,
1505
1478
  grpc_polling_entity* pollent) {
1506
1479
  call_data* calld = (call_data*)elem->call_data;
1507
1480
  calld->pollent = pollent;
@@ -1525,29 +1498,27 @@ const grpc_channel_filter grpc_client_channel_filter = {
1525
1498
  "client-channel",
1526
1499
  };
1527
1500
 
1528
- static void try_to_connect_locked(grpc_exec_ctx* exec_ctx, void* arg,
1529
- grpc_error* error_ignored) {
1501
+ static void try_to_connect_locked(void* arg, grpc_error* error_ignored) {
1530
1502
  channel_data* chand = (channel_data*)arg;
1531
1503
  if (chand->lb_policy != nullptr) {
1532
- grpc_lb_policy_exit_idle_locked(exec_ctx, chand->lb_policy);
1504
+ grpc_lb_policy_exit_idle_locked(chand->lb_policy);
1533
1505
  } else {
1534
1506
  chand->exit_idle_when_lb_policy_arrives = true;
1535
1507
  if (!chand->started_resolving && chand->resolver != nullptr) {
1536
- start_resolving_locked(exec_ctx, chand);
1508
+ start_resolving_locked(chand);
1537
1509
  }
1538
1510
  }
1539
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->owning_stack, "try_to_connect");
1511
+ GRPC_CHANNEL_STACK_UNREF(chand->owning_stack, "try_to_connect");
1540
1512
  }
1541
1513
 
1542
1514
  grpc_connectivity_state grpc_client_channel_check_connectivity_state(
1543
- grpc_exec_ctx* exec_ctx, grpc_channel_element* elem, int try_to_connect) {
1515
+ grpc_channel_element* elem, int try_to_connect) {
1544
1516
  channel_data* chand = (channel_data*)elem->channel_data;
1545
1517
  grpc_connectivity_state out =
1546
1518
  grpc_connectivity_state_check(&chand->state_tracker);
1547
1519
  if (out == GRPC_CHANNEL_IDLE && try_to_connect) {
1548
1520
  GRPC_CHANNEL_STACK_REF(chand->owning_stack, "try_to_connect");
1549
1521
  GRPC_CLOSURE_SCHED(
1550
- exec_ctx,
1551
1522
  GRPC_CLOSURE_CREATE(try_to_connect_locked, chand,
1552
1523
  grpc_combiner_scheduler(chand->combiner)),
1553
1524
  GRPC_ERROR_NONE);
@@ -1628,50 +1599,49 @@ int grpc_client_channel_num_external_connectivity_watchers(
1628
1599
  return count;
1629
1600
  }
1630
1601
 
1631
- static void on_external_watch_complete_locked(grpc_exec_ctx* exec_ctx,
1632
- void* arg, grpc_error* error) {
1602
+ static void on_external_watch_complete_locked(void* arg, grpc_error* error) {
1633
1603
  external_connectivity_watcher* w = (external_connectivity_watcher*)arg;
1634
1604
  grpc_closure* follow_up = w->on_complete;
1635
- grpc_polling_entity_del_from_pollset_set(exec_ctx, &w->pollent,
1605
+ grpc_polling_entity_del_from_pollset_set(&w->pollent,
1636
1606
  w->chand->interested_parties);
1637
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, w->chand->owning_stack,
1607
+ GRPC_CHANNEL_STACK_UNREF(w->chand->owning_stack,
1638
1608
  "external_connectivity_watcher");
1639
1609
  external_connectivity_watcher_list_remove(w->chand, w);
1640
1610
  gpr_free(w);
1641
- GRPC_CLOSURE_RUN(exec_ctx, follow_up, GRPC_ERROR_REF(error));
1611
+ GRPC_CLOSURE_RUN(follow_up, GRPC_ERROR_REF(error));
1642
1612
  }
1643
1613
 
1644
- static void watch_connectivity_state_locked(grpc_exec_ctx* exec_ctx, void* arg,
1614
+ static void watch_connectivity_state_locked(void* arg,
1645
1615
  grpc_error* error_ignored) {
1646
1616
  external_connectivity_watcher* w = (external_connectivity_watcher*)arg;
1647
1617
  external_connectivity_watcher* found = nullptr;
1648
1618
  if (w->state != nullptr) {
1649
1619
  external_connectivity_watcher_list_append(w->chand, w);
1650
- GRPC_CLOSURE_RUN(exec_ctx, w->watcher_timer_init, GRPC_ERROR_NONE);
1620
+ GRPC_CLOSURE_RUN(w->watcher_timer_init, GRPC_ERROR_NONE);
1651
1621
  GRPC_CLOSURE_INIT(&w->my_closure, on_external_watch_complete_locked, w,
1652
1622
  grpc_combiner_scheduler(w->chand->combiner));
1653
- grpc_connectivity_state_notify_on_state_change(
1654
- exec_ctx, &w->chand->state_tracker, w->state, &w->my_closure);
1623
+ grpc_connectivity_state_notify_on_state_change(&w->chand->state_tracker,
1624
+ w->state, &w->my_closure);
1655
1625
  } else {
1656
1626
  GPR_ASSERT(w->watcher_timer_init == nullptr);
1657
1627
  found = lookup_external_connectivity_watcher(w->chand, w->on_complete);
1658
1628
  if (found) {
1659
1629
  GPR_ASSERT(found->on_complete == w->on_complete);
1660
1630
  grpc_connectivity_state_notify_on_state_change(
1661
- exec_ctx, &found->chand->state_tracker, nullptr, &found->my_closure);
1631
+ &found->chand->state_tracker, nullptr, &found->my_closure);
1662
1632
  }
1663
- grpc_polling_entity_del_from_pollset_set(exec_ctx, &w->pollent,
1633
+ grpc_polling_entity_del_from_pollset_set(&w->pollent,
1664
1634
  w->chand->interested_parties);
1665
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, w->chand->owning_stack,
1635
+ GRPC_CHANNEL_STACK_UNREF(w->chand->owning_stack,
1666
1636
  "external_connectivity_watcher");
1667
1637
  gpr_free(w);
1668
1638
  }
1669
1639
  }
1670
1640
 
1671
1641
  void grpc_client_channel_watch_connectivity_state(
1672
- grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
1673
- grpc_polling_entity pollent, grpc_connectivity_state* state,
1674
- grpc_closure* closure, grpc_closure* watcher_timer_init) {
1642
+ grpc_channel_element* elem, grpc_polling_entity pollent,
1643
+ grpc_connectivity_state* state, grpc_closure* closure,
1644
+ grpc_closure* watcher_timer_init) {
1675
1645
  channel_data* chand = (channel_data*)elem->channel_data;
1676
1646
  external_connectivity_watcher* w =
1677
1647
  (external_connectivity_watcher*)gpr_zalloc(sizeof(*w));
@@ -1680,12 +1650,11 @@ void grpc_client_channel_watch_connectivity_state(
1680
1650
  w->on_complete = closure;
1681
1651
  w->state = state;
1682
1652
  w->watcher_timer_init = watcher_timer_init;
1683
- grpc_polling_entity_add_to_pollset_set(exec_ctx, &w->pollent,
1653
+ grpc_polling_entity_add_to_pollset_set(&w->pollent,
1684
1654
  chand->interested_parties);
1685
1655
  GRPC_CHANNEL_STACK_REF(w->chand->owning_stack,
1686
1656
  "external_connectivity_watcher");
1687
1657
  GRPC_CLOSURE_SCHED(
1688
- exec_ctx,
1689
1658
  GRPC_CLOSURE_INIT(&w->my_closure, watch_connectivity_state_locked, w,
1690
1659
  grpc_combiner_scheduler(chand->combiner)),
1691
1660
  GRPC_ERROR_NONE);