grpc 1.4.5 → 1.6.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 (928) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1235 -1100
  3. data/etc/roots.pem +0 -412
  4. data/include/grpc/byte_buffer.h +10 -25
  5. data/include/grpc/byte_buffer_reader.h +10 -25
  6. data/include/grpc/census.h +10 -25
  7. data/include/grpc/compression.h +10 -25
  8. data/include/grpc/grpc.h +15 -26
  9. data/include/grpc/grpc_cronet.h +10 -25
  10. data/include/grpc/grpc_posix.h +10 -25
  11. data/include/grpc/grpc_security.h +10 -25
  12. data/include/grpc/grpc_security_constants.h +10 -25
  13. data/include/grpc/impl/codegen/atm.h +11 -25
  14. data/include/grpc/impl/codegen/atm_gcc_atomic.h +10 -25
  15. data/include/grpc/impl/codegen/atm_gcc_sync.h +10 -25
  16. data/include/grpc/impl/codegen/atm_windows.h +10 -25
  17. data/include/grpc/impl/codegen/byte_buffer_reader.h +11 -26
  18. data/include/grpc/impl/codegen/compression_types.h +12 -27
  19. data/include/grpc/impl/codegen/connectivity_state.h +10 -25
  20. data/include/grpc/impl/codegen/exec_ctx_fwd.h +10 -25
  21. data/include/grpc/impl/codegen/gpr_slice.h +10 -25
  22. data/include/grpc/impl/codegen/gpr_types.h +10 -25
  23. data/include/grpc/impl/codegen/grpc_types.h +42 -43
  24. data/include/grpc/impl/codegen/port_platform.h +10 -25
  25. data/include/grpc/impl/codegen/propagation_bits.h +10 -25
  26. data/include/grpc/impl/codegen/slice.h +13 -28
  27. data/include/grpc/impl/codegen/status.h +10 -25
  28. data/include/grpc/impl/codegen/sync.h +10 -25
  29. data/include/grpc/impl/codegen/sync_generic.h +10 -25
  30. data/include/grpc/impl/codegen/sync_posix.h +10 -25
  31. data/include/grpc/impl/codegen/sync_windows.h +10 -25
  32. data/include/grpc/load_reporting.h +10 -25
  33. data/include/grpc/slice.h +10 -25
  34. data/include/grpc/slice_buffer.h +10 -25
  35. data/include/grpc/status.h +10 -25
  36. data/include/grpc/support/alloc.h +10 -25
  37. data/include/grpc/support/atm.h +10 -25
  38. data/include/grpc/support/atm_gcc_atomic.h +10 -25
  39. data/include/grpc/support/atm_gcc_sync.h +10 -25
  40. data/include/grpc/support/atm_windows.h +10 -25
  41. data/include/grpc/support/avl.h +46 -49
  42. data/include/grpc/support/cmdline.h +10 -25
  43. data/include/grpc/support/cpu.h +10 -25
  44. data/include/grpc/support/histogram.h +10 -25
  45. data/include/grpc/support/host_port.h +10 -25
  46. data/include/grpc/support/log.h +10 -25
  47. data/include/grpc/support/log_windows.h +10 -25
  48. data/include/grpc/support/port_platform.h +10 -25
  49. data/include/grpc/support/string_util.h +10 -25
  50. data/include/grpc/support/subprocess.h +10 -25
  51. data/include/grpc/support/sync.h +10 -25
  52. data/include/grpc/support/sync_generic.h +10 -25
  53. data/include/grpc/support/sync_posix.h +10 -25
  54. data/include/grpc/support/sync_windows.h +10 -25
  55. data/include/grpc/support/thd.h +10 -25
  56. data/include/grpc/support/time.h +10 -25
  57. data/include/grpc/support/tls.h +10 -25
  58. data/include/grpc/support/tls_gcc.h +10 -25
  59. data/include/grpc/support/tls_msvc.h +10 -25
  60. data/include/grpc/support/tls_pthread.h +10 -25
  61. data/include/grpc/support/useful.h +10 -25
  62. data/include/grpc/support/workaround_list.h +11 -26
  63. data/src/boringssl/err_data.c +277 -259
  64. data/src/core/ext/census/aggregation.h +10 -25
  65. data/src/core/ext/census/base_resources.c +10 -25
  66. data/src/core/ext/census/base_resources.h +10 -25
  67. data/src/core/ext/census/census_interface.h +10 -25
  68. data/src/core/ext/census/census_rpc_stats.h +10 -25
  69. data/src/core/ext/census/context.c +10 -25
  70. data/src/core/ext/census/gen/census.pb.c +10 -25
  71. data/src/core/ext/census/gen/census.pb.h +10 -25
  72. data/src/core/ext/census/gen/trace_context.pb.c +10 -25
  73. data/src/core/ext/census/gen/trace_context.pb.h +10 -25
  74. data/src/core/ext/census/grpc_context.c +10 -25
  75. data/src/core/ext/census/grpc_filter.c +11 -26
  76. data/src/core/ext/census/grpc_filter.h +10 -25
  77. data/src/core/ext/census/grpc_plugin.c +10 -25
  78. data/src/core/ext/census/initialize.c +10 -25
  79. data/src/core/ext/census/intrusive_hash_map.c +10 -25
  80. data/src/core/ext/census/intrusive_hash_map.h +10 -25
  81. data/src/core/ext/census/intrusive_hash_map_internal.h +10 -25
  82. data/src/core/ext/census/mlog.c +10 -25
  83. data/src/core/ext/census/mlog.h +10 -25
  84. data/src/core/ext/census/operation.c +10 -25
  85. data/src/core/ext/census/placeholders.c +10 -25
  86. data/src/core/ext/census/resource.c +10 -25
  87. data/src/core/ext/census/resource.h +10 -25
  88. data/src/core/ext/census/rpc_metric_id.h +10 -25
  89. data/src/core/ext/census/trace_context.c +10 -25
  90. data/src/core/ext/census/trace_context.h +10 -25
  91. data/src/core/ext/census/trace_label.h +10 -25
  92. data/src/core/ext/census/trace_propagation.h +10 -25
  93. data/src/core/ext/census/trace_status.h +10 -25
  94. data/src/core/ext/census/trace_string.h +10 -25
  95. data/src/core/ext/census/tracing.c +10 -26
  96. data/src/core/ext/census/tracing.h +10 -25
  97. data/src/core/ext/filters/client_channel/channel_connectivity.c +20 -33
  98. data/src/core/ext/filters/client_channel/client_channel.c +617 -520
  99. data/src/core/ext/filters/client_channel/client_channel.h +15 -28
  100. data/src/core/ext/filters/client_channel/client_channel_factory.c +13 -31
  101. data/src/core/ext/filters/client_channel/client_channel_factory.h +10 -25
  102. data/src/core/ext/filters/client_channel/client_channel_plugin.c +16 -29
  103. data/src/core/ext/filters/client_channel/connector.c +10 -25
  104. data/src/core/ext/filters/client_channel/connector.h +10 -25
  105. data/src/core/ext/filters/client_channel/http_connect_handshaker.c +15 -30
  106. data/src/core/ext/filters/client_channel/http_connect_handshaker.h +10 -25
  107. data/src/core/ext/filters/client_channel/http_proxy.c +112 -38
  108. data/src/core/ext/filters/client_channel/http_proxy.h +10 -25
  109. data/src/core/ext/filters/client_channel/lb_policy.c +32 -36
  110. data/src/core/ext/filters/client_channel/lb_policy.h +24 -27
  111. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +14 -30
  112. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +10 -25
  113. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +464 -279
  114. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +10 -25
  115. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +15 -28
  116. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c +40 -48
  117. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +65 -49
  118. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +31 -31
  119. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +47 -32
  120. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +11 -26
  121. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +13 -9
  122. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +27 -21
  123. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +373 -136
  124. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +504 -279
  125. data/src/core/ext/filters/client_channel/lb_policy_factory.c +12 -31
  126. data/src/core/ext/filters/client_channel/lb_policy_factory.h +12 -27
  127. data/src/core/ext/filters/client_channel/lb_policy_registry.c +10 -25
  128. data/src/core/ext/filters/client_channel/lb_policy_registry.h +10 -25
  129. data/src/core/ext/filters/client_channel/parse_address.c +10 -25
  130. data/src/core/ext/filters/client_channel/parse_address.h +10 -25
  131. data/src/core/ext/filters/client_channel/proxy_mapper.c +10 -25
  132. data/src/core/ext/filters/client_channel/proxy_mapper.h +10 -25
  133. data/src/core/ext/filters/client_channel/proxy_mapper_registry.c +10 -25
  134. data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +10 -25
  135. data/src/core/ext/filters/client_channel/resolver.c +33 -38
  136. data/src/core/ext/filters/client_channel/resolver.h +19 -30
  137. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +153 -50
  138. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +14 -27
  139. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +33 -30
  140. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +326 -116
  141. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +35 -36
  142. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c +60 -0
  143. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c +19 -34
  144. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c +254 -0
  145. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +60 -0
  146. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c +16 -28
  147. data/src/core/ext/filters/client_channel/resolver_factory.c +10 -25
  148. data/src/core/ext/filters/client_channel/resolver_factory.h +10 -25
  149. data/src/core/ext/filters/client_channel/resolver_registry.c +10 -25
  150. data/src/core/ext/filters/client_channel/resolver_registry.h +10 -25
  151. data/src/core/ext/filters/client_channel/retry_throttle.c +23 -34
  152. data/src/core/ext/filters/client_channel/retry_throttle.h +10 -25
  153. data/src/core/ext/filters/client_channel/subchannel.c +33 -55
  154. data/src/core/ext/filters/client_channel/subchannel.h +16 -26
  155. data/src/core/ext/filters/client_channel/subchannel_index.c +55 -92
  156. data/src/core/ext/filters/client_channel/subchannel_index.h +26 -29
  157. data/src/core/ext/filters/client_channel/uri_parser.c +10 -25
  158. data/src/core/ext/filters/client_channel/uri_parser.h +10 -25
  159. data/src/core/ext/filters/deadline/deadline_filter.c +30 -45
  160. data/src/core/ext/filters/deadline/deadline_filter.h +10 -25
  161. data/src/core/ext/filters/http/client/http_client_filter.c +255 -294
  162. data/src/core/ext/filters/http/client/http_client_filter.h +10 -25
  163. data/src/core/ext/filters/http/http_filters_plugin.c +11 -26
  164. data/src/core/ext/filters/http/message_compress/message_compress_filter.c +133 -105
  165. data/src/core/ext/filters/http/message_compress/message_compress_filter.h +10 -25
  166. data/src/core/ext/filters/http/server/http_server_filter.c +17 -32
  167. data/src/core/ext/filters/http/server/http_server_filter.h +10 -25
  168. data/src/core/ext/filters/load_reporting/load_reporting.c +11 -30
  169. data/src/core/ext/filters/load_reporting/load_reporting.h +10 -25
  170. data/src/core/ext/filters/load_reporting/load_reporting_filter.c +11 -26
  171. data/src/core/ext/filters/load_reporting/load_reporting_filter.h +10 -25
  172. data/src/core/ext/filters/max_age/max_age_filter.c +28 -43
  173. data/src/core/ext/filters/max_age/max_age_filter.h +10 -25
  174. data/src/core/ext/filters/message_size/message_size_filter.c +24 -37
  175. data/src/core/ext/filters/message_size/message_size_filter.h +10 -25
  176. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c +16 -31
  177. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +10 -25
  178. data/src/core/ext/filters/workarounds/workaround_utils.c +12 -26
  179. data/src/core/ext/filters/workarounds/workaround_utils.h +11 -26
  180. data/src/core/ext/transport/chttp2/alpn/alpn.c +10 -25
  181. data/src/core/ext/transport/chttp2/alpn/alpn.h +10 -25
  182. data/src/core/ext/transport/chttp2/client/chttp2_connector.c +13 -28
  183. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +10 -25
  184. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +13 -30
  185. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +12 -29
  186. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +13 -30
  187. data/src/core/ext/transport/chttp2/server/chttp2_server.c +11 -26
  188. data/src/core/ext/transport/chttp2/server/chttp2_server.h +10 -25
  189. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +10 -25
  190. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +10 -25
  191. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +10 -25
  192. data/src/core/ext/transport/chttp2/transport/bin_decoder.c +11 -25
  193. data/src/core/ext/transport/chttp2/transport/bin_decoder.h +10 -25
  194. data/src/core/ext/transport/chttp2/transport/bin_encoder.c +10 -25
  195. data/src/core/ext/transport/chttp2/transport/bin_encoder.h +10 -25
  196. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +15 -27
  197. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +421 -443
  198. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +14 -25
  199. data/src/core/ext/transport/chttp2/transport/flow_control.c +500 -0
  200. data/src/core/ext/transport/chttp2/transport/frame.h +10 -25
  201. data/src/core/ext/transport/chttp2/transport/frame_data.c +20 -28
  202. data/src/core/ext/transport/chttp2/transport/frame_data.h +10 -25
  203. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +10 -25
  204. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +10 -25
  205. data/src/core/ext/transport/chttp2/transport/frame_ping.c +11 -26
  206. data/src/core/ext/transport/chttp2/transport/frame_ping.h +10 -25
  207. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +11 -26
  208. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +10 -25
  209. data/src/core/ext/transport/chttp2/transport/frame_settings.c +16 -29
  210. data/src/core/ext/transport/chttp2/transport/frame_settings.h +10 -25
  211. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +17 -33
  212. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +10 -25
  213. data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +18 -31
  214. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +12 -25
  215. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +15 -30
  216. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +10 -25
  217. data/src/core/ext/transport/chttp2/transport/hpack_table.c +10 -25
  218. data/src/core/ext/transport/chttp2/transport/hpack_table.h +10 -25
  219. data/src/core/ext/transport/chttp2/transport/http2_settings.c +10 -25
  220. data/src/core/ext/transport/chttp2/transport/http2_settings.h +10 -25
  221. data/src/core/ext/transport/chttp2/transport/huffsyms.c +10 -25
  222. data/src/core/ext/transport/chttp2/transport/huffsyms.h +10 -25
  223. data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +10 -25
  224. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +10 -25
  225. data/src/core/ext/transport/chttp2/transport/internal.h +191 -179
  226. data/src/core/ext/transport/chttp2/transport/parsing.c +33 -102
  227. data/src/core/ext/transport/chttp2/transport/stream_lists.c +26 -28
  228. data/src/core/ext/transport/chttp2/transport/stream_map.c +10 -25
  229. data/src/core/ext/transport/chttp2/transport/stream_map.h +10 -25
  230. data/src/core/ext/transport/chttp2/transport/varint.c +14 -25
  231. data/src/core/ext/transport/chttp2/transport/varint.h +10 -25
  232. data/src/core/ext/transport/chttp2/transport/writing.c +164 -106
  233. data/src/core/ext/transport/inproc/inproc_plugin.c +29 -0
  234. data/src/core/ext/transport/inproc/inproc_transport.c +1303 -0
  235. data/src/core/ext/transport/inproc/inproc_transport.h +41 -0
  236. data/src/core/lib/channel/channel_args.c +52 -27
  237. data/src/core/lib/channel/channel_args.h +18 -27
  238. data/src/core/lib/channel/channel_stack.c +11 -26
  239. data/src/core/lib/channel/channel_stack.h +12 -27
  240. data/src/core/lib/channel/channel_stack_builder.c +11 -26
  241. data/src/core/lib/channel/channel_stack_builder.h +10 -25
  242. data/src/core/lib/channel/connected_channel.c +10 -25
  243. data/src/core/lib/channel/connected_channel.h +10 -25
  244. data/src/core/lib/channel/context.h +10 -25
  245. data/src/core/lib/channel/handshaker.c +14 -29
  246. data/src/core/lib/channel/handshaker.h +10 -25
  247. data/src/core/lib/channel/handshaker_factory.c +10 -25
  248. data/src/core/lib/channel/handshaker_factory.h +10 -25
  249. data/src/core/lib/channel/handshaker_registry.c +10 -25
  250. data/src/core/lib/channel/handshaker_registry.h +10 -25
  251. data/src/core/lib/compression/algorithm_metadata.h +10 -25
  252. data/src/core/lib/compression/compression.c +10 -25
  253. data/src/core/lib/compression/message_compress.c +10 -25
  254. data/src/core/lib/compression/message_compress.h +10 -25
  255. data/src/core/lib/compression/stream_compression.c +191 -0
  256. data/src/core/lib/compression/stream_compression.h +90 -0
  257. data/src/core/lib/debug/trace.c +28 -29
  258. data/src/core/lib/debug/trace.h +16 -30
  259. data/src/core/lib/http/format_request.c +10 -25
  260. data/src/core/lib/http/format_request.h +10 -25
  261. data/src/core/lib/http/httpcli.c +19 -35
  262. data/src/core/lib/http/httpcli.h +10 -25
  263. data/src/core/lib/http/httpcli_security_connector.c +17 -30
  264. data/src/core/lib/http/parser.c +11 -26
  265. data/src/core/lib/http/parser.h +10 -25
  266. data/src/core/lib/iomgr/closure.c +62 -25
  267. data/src/core/lib/iomgr/closure.h +81 -26
  268. data/src/core/lib/iomgr/combiner.c +103 -200
  269. data/src/core/lib/iomgr/combiner.h +14 -32
  270. data/src/core/lib/iomgr/endpoint.c +10 -29
  271. data/src/core/lib/iomgr/endpoint.h +10 -29
  272. data/src/core/lib/iomgr/endpoint_pair.h +10 -25
  273. data/src/core/lib/iomgr/endpoint_pair_posix.c +10 -25
  274. data/src/core/lib/iomgr/endpoint_pair_uv.c +10 -25
  275. data/src/core/lib/iomgr/endpoint_pair_windows.c +10 -25
  276. data/src/core/lib/iomgr/error.c +45 -46
  277. data/src/core/lib/iomgr/error.h +21 -34
  278. data/src/core/lib/iomgr/error_internal.h +10 -25
  279. data/src/core/lib/iomgr/ev_epoll1_linux.c +279 -179
  280. data/src/core/lib/iomgr/ev_epoll1_linux.h +10 -25
  281. data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +75 -264
  282. data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.h +10 -25
  283. data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +44 -199
  284. data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.h +10 -25
  285. data/src/core/lib/iomgr/ev_epollex_linux.c +184 -247
  286. data/src/core/lib/iomgr/ev_epollex_linux.h +10 -25
  287. data/src/core/lib/iomgr/ev_epollsig_linux.c +116 -323
  288. data/src/core/lib/iomgr/ev_epollsig_linux.h +10 -25
  289. data/src/core/lib/iomgr/ev_poll_posix.c +328 -184
  290. data/src/core/lib/iomgr/ev_poll_posix.h +10 -25
  291. data/src/core/lib/iomgr/ev_posix.c +25 -56
  292. data/src/core/lib/iomgr/ev_posix.h +15 -44
  293. data/src/core/lib/iomgr/ev_windows.c +11 -26
  294. data/src/core/lib/iomgr/exec_ctx.c +36 -45
  295. data/src/core/lib/iomgr/exec_ctx.h +10 -25
  296. data/src/core/lib/iomgr/executor.c +152 -127
  297. data/src/core/lib/iomgr/executor.h +18 -26
  298. data/src/core/lib/iomgr/gethostname.h +26 -0
  299. data/src/core/lib/iomgr/gethostname_fallback.c +27 -0
  300. data/src/core/lib/iomgr/gethostname_host_name_max.c +37 -0
  301. data/src/core/lib/iomgr/gethostname_sysconf.c +37 -0
  302. data/src/core/lib/iomgr/iocp_windows.c +10 -25
  303. data/src/core/lib/iomgr/iocp_windows.h +10 -25
  304. data/src/core/lib/iomgr/iomgr.c +17 -28
  305. data/src/core/lib/iomgr/iomgr.h +12 -27
  306. data/src/core/lib/iomgr/iomgr_internal.h +10 -25
  307. data/src/core/lib/iomgr/iomgr_posix.c +11 -26
  308. data/src/core/lib/iomgr/iomgr_posix.h +10 -25
  309. data/src/core/lib/iomgr/iomgr_uv.c +19 -26
  310. data/src/core/lib/iomgr/iomgr_uv.h +37 -0
  311. data/src/core/lib/iomgr/iomgr_windows.c +10 -25
  312. data/src/core/lib/iomgr/is_epollexclusive_available.c +10 -25
  313. data/src/core/lib/iomgr/is_epollexclusive_available.h +10 -25
  314. data/src/core/lib/iomgr/load_file.c +10 -25
  315. data/src/core/lib/iomgr/load_file.h +10 -25
  316. data/src/core/lib/iomgr/lockfree_event.c +22 -35
  317. data/src/core/lib/iomgr/lockfree_event.h +13 -27
  318. data/src/core/lib/iomgr/nameser.h +104 -0
  319. data/src/core/lib/iomgr/network_status_tracker.c +10 -25
  320. data/src/core/lib/iomgr/network_status_tracker.h +10 -25
  321. data/src/core/lib/iomgr/polling_entity.c +10 -25
  322. data/src/core/lib/iomgr/polling_entity.h +14 -34
  323. data/src/core/lib/iomgr/pollset.h +14 -25
  324. data/src/core/lib/iomgr/pollset_set.h +10 -25
  325. data/src/core/lib/iomgr/pollset_set_uv.c +10 -25
  326. data/src/core/lib/iomgr/pollset_set_windows.c +10 -25
  327. data/src/core/lib/iomgr/pollset_set_windows.h +10 -25
  328. data/src/core/lib/iomgr/pollset_uv.c +25 -26
  329. data/src/core/lib/iomgr/pollset_uv.h +10 -25
  330. data/src/core/lib/iomgr/pollset_windows.c +17 -27
  331. data/src/core/lib/iomgr/pollset_windows.h +10 -25
  332. data/src/core/lib/iomgr/port.h +24 -25
  333. data/src/core/lib/iomgr/resolve_address.h +10 -25
  334. data/src/core/lib/iomgr/resolve_address_posix.c +13 -28
  335. data/src/core/lib/iomgr/resolve_address_uv.c +31 -35
  336. data/src/core/lib/iomgr/resolve_address_windows.c +13 -28
  337. data/src/core/lib/iomgr/resource_quota.c +52 -67
  338. data/src/core/lib/iomgr/resource_quota.h +10 -25
  339. data/src/core/lib/iomgr/sockaddr.h +10 -25
  340. data/src/core/lib/iomgr/sockaddr_posix.h +10 -25
  341. data/src/core/lib/iomgr/sockaddr_utils.c +15 -25
  342. data/src/core/lib/iomgr/sockaddr_utils.h +12 -25
  343. data/src/core/lib/iomgr/sockaddr_windows.h +10 -25
  344. data/src/core/lib/iomgr/socket_factory_posix.c +13 -31
  345. data/src/core/lib/iomgr/socket_factory_posix.h +10 -25
  346. data/src/core/lib/iomgr/socket_mutator.c +14 -31
  347. data/src/core/lib/iomgr/socket_mutator.h +10 -25
  348. data/src/core/lib/iomgr/socket_utils.h +10 -25
  349. data/src/core/lib/iomgr/socket_utils_common_posix.c +10 -25
  350. data/src/core/lib/iomgr/socket_utils_linux.c +10 -25
  351. data/src/core/lib/iomgr/socket_utils_posix.c +10 -25
  352. data/src/core/lib/iomgr/socket_utils_posix.h +10 -25
  353. data/src/core/lib/iomgr/socket_utils_uv.c +10 -25
  354. data/src/core/lib/iomgr/socket_utils_windows.c +10 -25
  355. data/src/core/lib/iomgr/socket_windows.c +12 -27
  356. data/src/core/lib/iomgr/socket_windows.h +10 -25
  357. data/src/core/lib/iomgr/sys_epoll_wrapper.h +10 -25
  358. data/src/core/lib/iomgr/tcp_client.h +10 -25
  359. data/src/core/lib/iomgr/tcp_client_posix.c +21 -34
  360. data/src/core/lib/iomgr/tcp_client_posix.h +10 -25
  361. data/src/core/lib/iomgr/tcp_client_uv.c +18 -27
  362. data/src/core/lib/iomgr/tcp_client_windows.c +14 -29
  363. data/src/core/lib/iomgr/tcp_posix.c +36 -55
  364. data/src/core/lib/iomgr/tcp_posix.h +10 -25
  365. data/src/core/lib/iomgr/tcp_server.h +10 -25
  366. data/src/core/lib/iomgr/tcp_server_posix.c +16 -31
  367. data/src/core/lib/iomgr/tcp_server_utils_posix.h +10 -25
  368. data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +11 -26
  369. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c +10 -25
  370. data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c +10 -25
  371. data/src/core/lib/iomgr/tcp_server_uv.c +103 -64
  372. data/src/core/lib/iomgr/tcp_server_windows.c +14 -29
  373. data/src/core/lib/iomgr/tcp_uv.c +41 -45
  374. data/src/core/lib/iomgr/tcp_uv.h +10 -25
  375. data/src/core/lib/iomgr/tcp_windows.c +39 -53
  376. data/src/core/lib/iomgr/tcp_windows.h +10 -25
  377. data/src/core/lib/iomgr/time_averaged_stats.c +10 -25
  378. data/src/core/lib/iomgr/time_averaged_stats.h +10 -25
  379. data/src/core/lib/iomgr/timer.h +18 -27
  380. data/src/core/lib/iomgr/timer_generic.c +91 -87
  381. data/src/core/lib/iomgr/timer_generic.h +10 -25
  382. data/src/core/lib/iomgr/timer_heap.c +10 -25
  383. data/src/core/lib/iomgr/timer_heap.h +10 -25
  384. data/src/core/lib/iomgr/timer_manager.c +178 -100
  385. data/src/core/lib/iomgr/timer_manager.h +10 -25
  386. data/src/core/lib/iomgr/timer_uv.c +23 -33
  387. data/src/core/lib/iomgr/timer_uv.h +10 -25
  388. data/src/core/lib/iomgr/udp_server.c +17 -32
  389. data/src/core/lib/iomgr/udp_server.h +10 -25
  390. data/src/core/lib/iomgr/unix_sockets_posix.c +10 -25
  391. data/src/core/lib/iomgr/unix_sockets_posix.h +10 -25
  392. data/src/core/lib/iomgr/unix_sockets_posix_noop.c +10 -25
  393. data/src/core/lib/iomgr/wakeup_fd_cv.c +10 -25
  394. data/src/core/lib/iomgr/wakeup_fd_cv.h +13 -28
  395. data/src/core/lib/iomgr/wakeup_fd_eventfd.c +10 -25
  396. data/src/core/lib/iomgr/wakeup_fd_nospecial.c +10 -25
  397. data/src/core/lib/iomgr/wakeup_fd_pipe.c +10 -25
  398. data/src/core/lib/iomgr/wakeup_fd_pipe.h +10 -25
  399. data/src/core/lib/iomgr/wakeup_fd_posix.c +10 -25
  400. data/src/core/lib/iomgr/wakeup_fd_posix.h +10 -25
  401. data/src/core/lib/json/json.c +10 -25
  402. data/src/core/lib/json/json.h +10 -25
  403. data/src/core/lib/json/json_common.h +10 -25
  404. data/src/core/lib/json/json_reader.c +11 -25
  405. data/src/core/lib/json/json_reader.h +10 -25
  406. data/src/core/lib/json/json_string.c +10 -25
  407. data/src/core/lib/json/json_writer.c +10 -25
  408. data/src/core/lib/json/json_writer.h +10 -25
  409. data/src/core/lib/profiling/basic_timers.c +10 -25
  410. data/src/core/lib/profiling/stap_timers.c +10 -25
  411. data/src/core/lib/profiling/timers.h +10 -25
  412. data/src/core/lib/security/context/security_context.c +32 -40
  413. data/src/core/lib/security/context/security_context.h +15 -26
  414. data/src/core/lib/security/credentials/composite/composite_credentials.c +76 -81
  415. data/src/core/lib/security/credentials/composite/composite_credentials.h +10 -25
  416. data/src/core/lib/security/credentials/credentials.c +29 -49
  417. data/src/core/lib/security/credentials/credentials.h +48 -61
  418. data/src/core/lib/security/credentials/credentials_metadata.c +34 -78
  419. data/src/core/lib/security/credentials/fake/fake_credentials.c +33 -56
  420. data/src/core/lib/security/credentials/fake/fake_credentials.h +12 -27
  421. data/src/core/lib/security/credentials/google_default/credentials_generic.c +10 -25
  422. data/src/core/lib/security/credentials/google_default/google_default_credentials.c +12 -27
  423. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +10 -25
  424. data/src/core/lib/security/credentials/iam/iam_credentials.c +40 -40
  425. data/src/core/lib/security/credentials/iam/iam_credentials.h +11 -26
  426. data/src/core/lib/security/credentials/jwt/json_token.c +10 -25
  427. data/src/core/lib/security/credentials/jwt/json_token.h +10 -25
  428. data/src/core/lib/security/credentials/jwt/jwt_credentials.c +45 -48
  429. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +11 -26
  430. data/src/core/lib/security/credentials/jwt/jwt_verifier.c +53 -33
  431. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +10 -25
  432. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +155 -87
  433. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +24 -28
  434. data/src/core/lib/security/credentials/plugin/plugin_credentials.c +118 -82
  435. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +24 -27
  436. data/src/core/lib/security/credentials/ssl/ssl_credentials.c +13 -32
  437. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +10 -25
  438. data/src/core/lib/security/transport/auth_filters.h +10 -25
  439. data/src/core/lib/security/transport/client_auth_filter.c +217 -112
  440. data/src/core/lib/security/transport/lb_targets_info.c +16 -32
  441. data/src/core/lib/security/transport/lb_targets_info.h +10 -25
  442. data/src/core/lib/security/transport/secure_endpoint.c +29 -43
  443. data/src/core/lib/security/transport/secure_endpoint.h +10 -25
  444. data/src/core/lib/security/transport/security_connector.c +80 -61
  445. data/src/core/lib/security/transport/security_connector.h +35 -35
  446. data/src/core/lib/security/transport/security_handshaker.c +18 -33
  447. data/src/core/lib/security/transport/security_handshaker.h +10 -25
  448. data/src/core/lib/security/transport/server_auth_filter.c +62 -116
  449. data/src/core/lib/security/transport/tsi_error.c +10 -25
  450. data/src/core/lib/security/transport/tsi_error.h +10 -25
  451. data/src/core/lib/security/util/json_util.c +10 -25
  452. data/src/core/lib/security/util/json_util.h +10 -25
  453. data/src/core/lib/slice/b64.c +10 -25
  454. data/src/core/lib/slice/b64.h +10 -25
  455. data/src/core/lib/slice/percent_encoding.c +10 -25
  456. data/src/core/lib/slice/percent_encoding.h +10 -25
  457. data/src/core/lib/slice/slice.c +10 -25
  458. data/src/core/lib/slice/slice_buffer.c +10 -25
  459. data/src/core/lib/slice/slice_hash_table.c +48 -26
  460. data/src/core/lib/slice/slice_hash_table.h +26 -28
  461. data/src/core/lib/slice/slice_intern.c +10 -25
  462. data/src/core/lib/slice/slice_internal.h +10 -25
  463. data/src/core/lib/slice/slice_string_helpers.c +10 -25
  464. data/src/core/lib/slice/slice_string_helpers.h +10 -25
  465. data/src/core/lib/support/alloc.c +10 -25
  466. data/src/core/lib/support/arena.c +12 -27
  467. data/src/core/lib/support/arena.h +10 -25
  468. data/src/core/lib/support/atm.c +17 -32
  469. data/src/core/lib/support/atomic.h +10 -25
  470. data/src/core/lib/support/atomic_with_atm.h +10 -25
  471. data/src/core/lib/support/atomic_with_std.h +10 -25
  472. data/src/core/lib/support/avl.c +101 -101
  473. data/src/core/lib/support/backoff.c +10 -25
  474. data/src/core/lib/support/backoff.h +10 -25
  475. data/src/core/lib/support/block_annotate.h +10 -25
  476. data/src/core/lib/support/cmdline.c +10 -25
  477. data/src/core/lib/support/cpu_iphone.c +10 -25
  478. data/src/core/lib/support/cpu_linux.c +10 -25
  479. data/src/core/lib/support/cpu_posix.c +10 -25
  480. data/src/core/lib/support/cpu_windows.c +10 -25
  481. data/src/core/lib/support/env.h +16 -25
  482. data/src/core/lib/support/env_linux.c +30 -37
  483. data/src/core/lib/support/env_posix.c +15 -25
  484. data/src/core/lib/support/env_windows.c +15 -25
  485. data/src/core/lib/support/histogram.c +10 -25
  486. data/src/core/lib/support/host_port.c +10 -25
  487. data/src/core/lib/support/log.c +20 -29
  488. data/src/core/lib/support/log_android.c +10 -25
  489. data/src/core/lib/support/log_linux.c +13 -26
  490. data/src/core/lib/support/log_posix.c +10 -25
  491. data/src/core/lib/support/log_windows.c +10 -25
  492. data/src/core/lib/support/memory.h +10 -25
  493. data/src/core/lib/support/mpscq.c +11 -49
  494. data/src/core/lib/support/mpscq.h +11 -50
  495. data/src/core/lib/support/murmur_hash.c +12 -25
  496. data/src/core/lib/support/murmur_hash.h +10 -25
  497. data/src/core/lib/support/spinlock.h +10 -25
  498. data/src/core/lib/support/stack_lockfree.c +10 -25
  499. data/src/core/lib/support/stack_lockfree.h +10 -25
  500. data/src/core/lib/support/string.c +10 -25
  501. data/src/core/lib/support/string.h +10 -25
  502. data/src/core/lib/support/string_posix.c +10 -25
  503. data/src/core/lib/support/string_util_windows.c +10 -25
  504. data/src/core/lib/support/string_windows.c +10 -25
  505. data/src/core/lib/support/string_windows.h +10 -25
  506. data/src/core/lib/support/subprocess_posix.c +10 -25
  507. data/src/core/lib/support/subprocess_windows.c +10 -25
  508. data/src/core/lib/support/sync.c +10 -25
  509. data/src/core/lib/support/sync_posix.c +10 -25
  510. data/src/core/lib/support/sync_windows.c +10 -25
  511. data/src/core/lib/support/thd.c +10 -25
  512. data/src/core/lib/support/thd_internal.h +10 -25
  513. data/src/core/lib/support/thd_posix.c +10 -25
  514. data/src/core/lib/support/thd_windows.c +10 -25
  515. data/src/core/lib/support/time.c +10 -25
  516. data/src/core/lib/support/time_posix.c +10 -25
  517. data/src/core/lib/support/time_precise.c +18 -33
  518. data/src/core/lib/support/time_precise.h +10 -25
  519. data/src/core/lib/support/time_windows.c +10 -25
  520. data/src/core/lib/support/tls_pthread.c +10 -25
  521. data/src/core/lib/support/tmpfile.h +10 -25
  522. data/src/core/lib/support/tmpfile_msys.c +10 -25
  523. data/src/core/lib/support/tmpfile_posix.c +10 -25
  524. data/src/core/lib/support/tmpfile_windows.c +10 -25
  525. data/src/core/lib/support/wrap_memcpy.c +10 -25
  526. data/src/core/lib/surface/alarm.c +78 -35
  527. data/src/core/lib/surface/alarm_internal.h +40 -0
  528. data/src/core/lib/surface/api_trace.c +11 -26
  529. data/src/core/lib/surface/api_trace.h +10 -25
  530. data/src/core/lib/surface/byte_buffer.c +10 -25
  531. data/src/core/lib/surface/byte_buffer_reader.c +10 -25
  532. data/src/core/lib/surface/call.c +64 -84
  533. data/src/core/lib/surface/call.h +11 -26
  534. data/src/core/lib/surface/call_details.c +10 -25
  535. data/src/core/lib/surface/call_log_batch.c +10 -25
  536. data/src/core/lib/surface/call_test_only.h +10 -25
  537. data/src/core/lib/surface/channel.c +11 -26
  538. data/src/core/lib/surface/channel.h +11 -26
  539. data/src/core/lib/surface/channel_init.c +10 -25
  540. data/src/core/lib/surface/channel_init.h +10 -25
  541. data/src/core/lib/surface/channel_ping.c +12 -27
  542. data/src/core/lib/surface/channel_stack_type.c +10 -25
  543. data/src/core/lib/surface/channel_stack_type.h +10 -25
  544. data/src/core/lib/surface/completion_queue.c +442 -331
  545. data/src/core/lib/surface/completion_queue.h +16 -33
  546. data/src/core/lib/surface/completion_queue_factory.c +10 -25
  547. data/src/core/lib/surface/completion_queue_factory.h +10 -25
  548. data/src/core/lib/surface/event_string.c +10 -25
  549. data/src/core/lib/surface/event_string.h +10 -25
  550. data/src/core/lib/surface/init.c +38 -47
  551. data/src/core/lib/surface/init.h +10 -25
  552. data/src/core/lib/surface/init_secure.c +20 -27
  553. data/src/core/lib/surface/lame_client.cc +14 -29
  554. data/src/core/lib/surface/lame_client.h +10 -25
  555. data/src/core/lib/surface/metadata_array.c +10 -25
  556. data/src/core/lib/surface/server.c +128 -81
  557. data/src/core/lib/surface/server.h +10 -25
  558. data/src/core/lib/surface/validate_metadata.c +10 -25
  559. data/src/core/lib/surface/validate_metadata.h +10 -25
  560. data/src/core/lib/surface/version.c +11 -26
  561. data/src/core/lib/transport/bdp_estimator.c +19 -29
  562. data/src/core/lib/transport/bdp_estimator.h +16 -29
  563. data/src/core/lib/transport/byte_stream.c +127 -36
  564. data/src/core/lib/transport/byte_stream.h +88 -46
  565. data/src/core/lib/transport/connectivity_state.c +17 -31
  566. data/src/core/lib/transport/connectivity_state.h +10 -25
  567. data/src/core/lib/transport/error_utils.c +10 -25
  568. data/src/core/lib/transport/error_utils.h +10 -25
  569. data/src/core/lib/transport/http2_errors.h +10 -25
  570. data/src/core/lib/transport/metadata.c +87 -85
  571. data/src/core/lib/transport/metadata.h +15 -28
  572. data/src/core/lib/transport/metadata_batch.c +10 -25
  573. data/src/core/lib/transport/metadata_batch.h +10 -25
  574. data/src/core/lib/transport/pid_controller.c +10 -25
  575. data/src/core/lib/transport/pid_controller.h +10 -25
  576. data/src/core/lib/transport/service_config.c +11 -26
  577. data/src/core/lib/transport/service_config.h +10 -25
  578. data/src/core/lib/transport/static_metadata.c +12 -26
  579. data/src/core/lib/transport/static_metadata.h +10 -25
  580. data/src/core/lib/transport/status_conversion.c +10 -25
  581. data/src/core/lib/transport/status_conversion.h +10 -25
  582. data/src/core/lib/transport/timeout_encoding.c +10 -25
  583. data/src/core/lib/transport/timeout_encoding.h +10 -25
  584. data/src/core/lib/transport/transport.c +60 -53
  585. data/src/core/lib/transport/transport.h +36 -34
  586. data/src/core/lib/transport/transport_impl.h +10 -25
  587. data/src/core/lib/transport/transport_op_string.c +10 -28
  588. data/src/core/plugin_registry/grpc_plugin_registry.c +22 -25
  589. data/src/core/tsi/fake_transport_security.c +199 -94
  590. data/src/core/tsi/fake_transport_security.h +11 -26
  591. data/src/core/tsi/gts_transport_security.c +40 -0
  592. data/src/core/tsi/gts_transport_security.h +37 -0
  593. data/src/core/tsi/ssl_transport_security.c +13 -32
  594. data/src/core/tsi/ssl_transport_security.h +10 -25
  595. data/src/core/tsi/ssl_types.h +10 -25
  596. data/src/core/tsi/transport_security.c +48 -78
  597. data/src/core/tsi/transport_security.h +18 -27
  598. data/src/core/tsi/transport_security_adapter.c +17 -29
  599. data/src/core/tsi/transport_security_adapter.h +10 -25
  600. data/src/core/tsi/transport_security_grpc.c +64 -0
  601. data/src/core/tsi/transport_security_grpc.h +80 -0
  602. data/src/core/tsi/transport_security_interface.h +21 -27
  603. data/src/ruby/bin/apis/google/protobuf/empty.rb +10 -25
  604. data/src/ruby/bin/apis/pubsub_demo.rb +10 -25
  605. data/src/ruby/bin/apis/tech/pubsub/proto/pubsub.rb +10 -25
  606. data/src/ruby/bin/apis/tech/pubsub/proto/pubsub_services.rb +10 -25
  607. data/src/ruby/bin/math_client.rb +10 -25
  608. data/src/ruby/bin/math_server.rb +10 -25
  609. data/src/ruby/bin/math_services_pb.rb +10 -25
  610. data/src/ruby/bin/noproto_client.rb +10 -25
  611. data/src/ruby/bin/noproto_server.rb +10 -25
  612. data/src/ruby/ext/grpc/extconf.rb +10 -25
  613. data/src/ruby/ext/grpc/rb_byte_buffer.c +10 -25
  614. data/src/ruby/ext/grpc/rb_byte_buffer.h +10 -25
  615. data/src/ruby/ext/grpc/rb_call.c +44 -25
  616. data/src/ruby/ext/grpc/rb_call.h +10 -25
  617. data/src/ruby/ext/grpc/rb_call_credentials.c +10 -25
  618. data/src/ruby/ext/grpc/rb_call_credentials.h +10 -25
  619. data/src/ruby/ext/grpc/rb_channel.c +10 -25
  620. data/src/ruby/ext/grpc/rb_channel.h +10 -25
  621. data/src/ruby/ext/grpc/rb_channel_args.c +10 -25
  622. data/src/ruby/ext/grpc/rb_channel_args.h +10 -25
  623. data/src/ruby/ext/grpc/rb_channel_credentials.c +10 -25
  624. data/src/ruby/ext/grpc/rb_channel_credentials.h +10 -25
  625. data/src/ruby/ext/grpc/rb_completion_queue.c +10 -25
  626. data/src/ruby/ext/grpc/rb_completion_queue.h +10 -25
  627. data/src/ruby/ext/grpc/rb_compression_options.c +10 -25
  628. data/src/ruby/ext/grpc/rb_compression_options.h +10 -25
  629. data/src/ruby/ext/grpc/rb_event_thread.c +10 -25
  630. data/src/ruby/ext/grpc/rb_event_thread.h +10 -25
  631. data/src/ruby/ext/grpc/rb_grpc.c +10 -25
  632. data/src/ruby/ext/grpc/rb_grpc.h +10 -25
  633. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -25
  634. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +16 -31
  635. data/src/ruby/ext/grpc/rb_loader.c +10 -25
  636. data/src/ruby/ext/grpc/rb_loader.h +10 -25
  637. data/src/ruby/ext/grpc/rb_server.c +10 -25
  638. data/src/ruby/ext/grpc/rb_server.h +10 -25
  639. data/src/ruby/ext/grpc/rb_server_credentials.c +10 -25
  640. data/src/ruby/ext/grpc/rb_server_credentials.h +10 -25
  641. data/src/ruby/lib/grpc.rb +10 -25
  642. data/src/ruby/lib/grpc/core/time_consts.rb +10 -25
  643. data/src/ruby/lib/grpc/errors.rb +16 -30
  644. data/src/ruby/lib/grpc/generic/active_call.rb +25 -27
  645. data/src/ruby/lib/grpc/generic/bidi_call.rb +17 -27
  646. data/src/ruby/lib/grpc/generic/client_stub.rb +10 -25
  647. data/src/ruby/lib/grpc/generic/rpc_desc.rb +10 -25
  648. data/src/ruby/lib/grpc/generic/rpc_server.rb +10 -25
  649. data/src/ruby/lib/grpc/generic/service.rb +10 -25
  650. data/src/ruby/lib/grpc/grpc.rb +10 -25
  651. data/src/ruby/lib/grpc/logconfig.rb +10 -25
  652. data/src/ruby/lib/grpc/notifier.rb +10 -25
  653. data/src/ruby/lib/grpc/version.rb +11 -26
  654. data/src/ruby/pb/generate_proto_ruby.sh +10 -25
  655. data/src/ruby/pb/grpc/health/checker.rb +10 -25
  656. data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +10 -25
  657. data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +10 -25
  658. data/src/ruby/pb/grpc/testing/metrics_services_pb.rb +10 -25
  659. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +10 -25
  660. data/src/ruby/pb/test/client.rb +10 -25
  661. data/src/ruby/pb/test/server.rb +10 -25
  662. data/src/ruby/spec/call_credentials_spec.rb +10 -25
  663. data/src/ruby/spec/call_spec.rb +43 -25
  664. data/src/ruby/spec/channel_connection_spec.rb +10 -25
  665. data/src/ruby/spec/channel_credentials_spec.rb +11 -26
  666. data/src/ruby/spec/channel_spec.rb +10 -25
  667. data/src/ruby/spec/client_auth_spec.rb +10 -25
  668. data/src/ruby/spec/client_server_spec.rb +66 -25
  669. data/src/ruby/spec/compression_options_spec.rb +10 -25
  670. data/src/ruby/spec/error_sanity_spec.rb +10 -25
  671. data/src/ruby/spec/generic/active_call_spec.rb +10 -25
  672. data/src/ruby/spec/generic/client_stub_spec.rb +146 -35
  673. data/src/ruby/spec/generic/rpc_desc_spec.rb +10 -25
  674. data/src/ruby/spec/generic/rpc_server_pool_spec.rb +10 -25
  675. data/src/ruby/spec/generic/rpc_server_spec.rb +124 -34
  676. data/src/ruby/spec/generic/service_spec.rb +10 -25
  677. data/src/ruby/spec/pb/duplicate/codegen_spec.rb +10 -25
  678. data/src/ruby/spec/pb/health/checker_spec.rb +10 -25
  679. data/src/ruby/spec/server_credentials_spec.rb +10 -25
  680. data/src/ruby/spec/server_spec.rb +10 -25
  681. data/src/ruby/spec/spec_helper.rb +10 -25
  682. data/src/ruby/spec/time_consts_spec.rb +10 -25
  683. data/third_party/boringssl/crypto/aes/key_wrap.c +138 -0
  684. data/third_party/boringssl/crypto/asn1/a_bitstr.c +6 -3
  685. data/third_party/boringssl/crypto/asn1/a_enum.c +4 -1
  686. data/third_party/boringssl/crypto/asn1/a_gentm.c +20 -15
  687. data/third_party/boringssl/crypto/asn1/a_int.c +7 -4
  688. data/third_party/boringssl/crypto/asn1/a_object.c +5 -2
  689. data/third_party/boringssl/crypto/asn1/a_time.c +0 -1
  690. data/third_party/boringssl/crypto/asn1/a_utctm.c +1 -2
  691. data/third_party/boringssl/crypto/asn1/asn1_lib.c +5 -2
  692. data/third_party/boringssl/crypto/asn1/asn1_locl.h +35 -0
  693. data/third_party/boringssl/crypto/asn1/tasn_dec.c +3 -1
  694. data/third_party/boringssl/crypto/asn1/tasn_enc.c +6 -3
  695. data/third_party/boringssl/crypto/asn1/tasn_new.c +12 -7
  696. data/third_party/boringssl/crypto/asn1/tasn_utl.c +22 -8
  697. data/third_party/boringssl/crypto/{time_support.c → asn1/time_support.c} +1 -1
  698. data/third_party/boringssl/crypto/asn1/x_long.c +5 -2
  699. data/third_party/boringssl/crypto/base64/base64.c +7 -5
  700. data/third_party/boringssl/crypto/bio/bio.c +24 -10
  701. data/third_party/boringssl/crypto/bio/bio_mem.c +12 -10
  702. data/third_party/boringssl/crypto/bio/connect.c +7 -18
  703. data/third_party/boringssl/crypto/bio/fd.c +3 -6
  704. data/third_party/boringssl/crypto/bio/file.c +6 -6
  705. data/third_party/boringssl/crypto/bio/hexdump.c +4 -2
  706. data/third_party/boringssl/crypto/bio/pair.c +30 -344
  707. data/third_party/boringssl/crypto/bio/socket.c +6 -7
  708. data/third_party/boringssl/crypto/bio/socket_helper.c +4 -3
  709. data/third_party/boringssl/crypto/bn/add.c +1 -1
  710. data/third_party/boringssl/crypto/bn/asm/x86_64-gcc.c +11 -10
  711. data/third_party/boringssl/crypto/bn/bn.c +6 -20
  712. data/third_party/boringssl/crypto/bn/cmp.c +14 -0
  713. data/third_party/boringssl/crypto/bn/convert.c +73 -2
  714. data/third_party/boringssl/crypto/bn/ctx.c +3 -1
  715. data/third_party/boringssl/crypto/bn/div.c +108 -51
  716. data/third_party/boringssl/crypto/bn/exponentiation.c +15 -33
  717. data/third_party/boringssl/crypto/bn/gcd.c +29 -22
  718. data/third_party/boringssl/crypto/bn/generic.c +71 -67
  719. data/third_party/boringssl/crypto/bn/internal.h +19 -6
  720. data/third_party/boringssl/crypto/bn/kronecker.c +1 -0
  721. data/third_party/boringssl/crypto/bn/montgomery.c +9 -10
  722. data/third_party/boringssl/crypto/bn/montgomery_inv.c +47 -0
  723. data/third_party/boringssl/crypto/bn/mul.c +11 -9
  724. data/third_party/boringssl/crypto/bn/random.c +6 -3
  725. data/third_party/boringssl/crypto/bn/rsaz_exp.c +0 -65
  726. data/third_party/boringssl/crypto/bn/rsaz_exp.h +0 -3
  727. data/third_party/boringssl/crypto/bn/shift.c +9 -1
  728. data/third_party/boringssl/crypto/bn/sqrt.c +3 -1
  729. data/third_party/boringssl/crypto/buf/buf.c +6 -4
  730. data/third_party/boringssl/crypto/bytestring/asn1_compat.c +2 -1
  731. data/third_party/boringssl/crypto/bytestring/ber.c +2 -1
  732. data/third_party/boringssl/crypto/bytestring/cbb.c +9 -7
  733. data/third_party/boringssl/crypto/bytestring/cbs.c +54 -2
  734. data/third_party/boringssl/crypto/chacha/chacha.c +1 -1
  735. data/third_party/boringssl/crypto/cipher/aead.c +3 -3
  736. data/third_party/boringssl/crypto/cipher/cipher.c +18 -13
  737. data/third_party/boringssl/crypto/cipher/e_aes.c +335 -281
  738. data/third_party/boringssl/crypto/cipher/e_chacha20poly1305.c +113 -137
  739. data/third_party/boringssl/crypto/cipher/e_null.c +2 -1
  740. data/third_party/boringssl/crypto/cipher/e_rc2.c +54 -49
  741. data/third_party/boringssl/crypto/cipher/e_ssl3.c +4 -3
  742. data/third_party/boringssl/crypto/cipher/e_tls.c +5 -5
  743. data/third_party/boringssl/crypto/cipher/tls_cbc.c +41 -112
  744. data/third_party/boringssl/crypto/cmac/cmac.c +6 -4
  745. data/third_party/boringssl/crypto/conf/conf.c +6 -3
  746. data/third_party/boringssl/crypto/cpu-arm-linux.c +2 -2
  747. data/third_party/boringssl/crypto/curve25519/curve25519.c +28 -34
  748. data/third_party/boringssl/crypto/curve25519/spake25519.c +7 -6
  749. data/third_party/boringssl/crypto/curve25519/x25519-x86_64.c +2 -1
  750. data/third_party/boringssl/crypto/des/des.c +1 -1
  751. data/third_party/boringssl/crypto/des/internal.h +58 -46
  752. data/third_party/boringssl/crypto/dh/dh.c +4 -8
  753. data/third_party/boringssl/crypto/digest/digest.c +5 -2
  754. data/third_party/boringssl/crypto/digest/digests.c +70 -33
  755. data/third_party/boringssl/crypto/digest/md32_common.h +39 -27
  756. data/third_party/boringssl/crypto/dsa/dsa.c +11 -19
  757. data/third_party/boringssl/crypto/ec/ec.c +1 -1
  758. data/third_party/boringssl/crypto/ec/ec_asn1.c +3 -2
  759. data/third_party/boringssl/crypto/ec/ec_key.c +1 -1
  760. data/third_party/boringssl/crypto/ec/ec_montgomery.c +6 -11
  761. data/third_party/boringssl/crypto/ec/oct.c +2 -14
  762. data/third_party/boringssl/crypto/ec/p224-64.c +78 -122
  763. data/third_party/boringssl/crypto/ec/p256-64.c +93 -133
  764. data/third_party/boringssl/crypto/ec/p256-x86_64.c +48 -61
  765. data/third_party/boringssl/crypto/ec/p256-x86_64.h +113 -0
  766. data/third_party/boringssl/crypto/ec/simple.c +2 -1
  767. data/third_party/boringssl/crypto/ec/wnaf.c +52 -43
  768. data/third_party/boringssl/crypto/ecdh/ecdh.c +4 -2
  769. data/third_party/boringssl/crypto/ecdsa/ecdsa.c +17 -16
  770. data/third_party/boringssl/crypto/engine/engine.c +3 -1
  771. data/third_party/boringssl/crypto/err/err.c +5 -5
  772. data/third_party/boringssl/crypto/evp/evp.c +1 -1
  773. data/third_party/boringssl/crypto/evp/evp_asn1.c +1 -1
  774. data/third_party/boringssl/crypto/evp/evp_ctx.c +23 -29
  775. data/third_party/boringssl/crypto/evp/p_ec.c +2 -1
  776. data/third_party/boringssl/crypto/evp/p_rsa.c +9 -3
  777. data/third_party/boringssl/crypto/evp/pbkdf.c +3 -1
  778. data/third_party/boringssl/crypto/hkdf/hkdf.c +3 -1
  779. data/third_party/boringssl/crypto/hmac/hmac.c +4 -2
  780. data/third_party/boringssl/crypto/internal.h +81 -0
  781. data/third_party/boringssl/crypto/lhash/lhash.c +7 -13
  782. data/third_party/boringssl/crypto/md4/md4.c +20 -18
  783. data/third_party/boringssl/crypto/md5/md5.c +31 -21
  784. data/third_party/boringssl/crypto/mem.c +4 -10
  785. data/third_party/boringssl/crypto/modes/cbc.c +2 -6
  786. data/third_party/boringssl/crypto/modes/cfb.c +2 -2
  787. data/third_party/boringssl/crypto/modes/ctr.c +1 -1
  788. data/third_party/boringssl/crypto/modes/gcm.c +117 -334
  789. data/third_party/boringssl/crypto/modes/internal.h +107 -84
  790. data/third_party/boringssl/crypto/modes/ofb.c +3 -3
  791. data/third_party/boringssl/crypto/modes/polyval.c +94 -0
  792. data/third_party/boringssl/crypto/obj/obj.c +13 -8
  793. data/third_party/boringssl/crypto/obj/obj_dat.h +6109 -5187
  794. data/third_party/boringssl/crypto/obj/obj_xref.c +55 -57
  795. data/third_party/boringssl/crypto/pem/pem_lib.c +6 -3
  796. data/third_party/boringssl/crypto/pkcs8/internal.h +27 -8
  797. data/third_party/boringssl/crypto/pkcs8/p5_pbev2.c +137 -352
  798. data/third_party/boringssl/crypto/pkcs8/pkcs8.c +371 -364
  799. data/third_party/boringssl/crypto/poly1305/poly1305.c +12 -18
  800. data/third_party/boringssl/crypto/poly1305/poly1305_arm.c +2 -2
  801. data/third_party/boringssl/crypto/{newhope/reduce.c → pool/internal.h} +24 -21
  802. data/third_party/boringssl/crypto/pool/pool.c +200 -0
  803. data/third_party/boringssl/crypto/rand/deterministic.c +6 -5
  804. data/third_party/boringssl/crypto/rand/fuchsia.c +43 -0
  805. data/third_party/boringssl/crypto/rand/rand.c +7 -7
  806. data/third_party/boringssl/crypto/rand/urandom.c +136 -22
  807. data/third_party/boringssl/crypto/rand/windows.c +2 -2
  808. data/third_party/boringssl/crypto/rsa/blinding.c +2 -1
  809. data/third_party/boringssl/crypto/rsa/padding.c +11 -11
  810. data/third_party/boringssl/crypto/rsa/rsa.c +4 -4
  811. data/third_party/boringssl/crypto/rsa/rsa_asn1.c +7 -1
  812. data/third_party/boringssl/crypto/rsa/rsa_impl.c +41 -80
  813. data/third_party/boringssl/crypto/sha/sha1-altivec.c +346 -0
  814. data/third_party/boringssl/crypto/sha/sha1.c +60 -42
  815. data/third_party/boringssl/crypto/sha/sha256.c +4 -2
  816. data/third_party/boringssl/crypto/sha/sha512.c +9 -7
  817. data/third_party/boringssl/crypto/stack/stack.c +10 -7
  818. data/third_party/boringssl/crypto/thread_pthread.c +2 -2
  819. data/third_party/boringssl/crypto/thread_win.c +2 -2
  820. data/third_party/boringssl/crypto/x509/a_verify.c +1 -1
  821. data/third_party/boringssl/crypto/x509/asn1_gen.c +1 -1
  822. data/third_party/boringssl/crypto/x509/by_dir.c +1 -1
  823. data/third_party/boringssl/crypto/x509/t_x509.c +78 -38
  824. data/third_party/boringssl/crypto/x509/x509_cmp.c +8 -5
  825. data/third_party/boringssl/crypto/x509/x509_lu.c +6 -1
  826. data/third_party/boringssl/crypto/x509/x509_obj.c +4 -1
  827. data/third_party/boringssl/crypto/x509/x509_vfy.c +42 -8
  828. data/third_party/boringssl/crypto/x509/x509_vpm.c +8 -6
  829. data/third_party/boringssl/crypto/x509/x509name.c +4 -1
  830. data/third_party/boringssl/crypto/x509/x_crl.c +4 -2
  831. data/third_party/boringssl/crypto/x509/x_name.c +23 -13
  832. data/third_party/boringssl/crypto/x509/x_pkey.c +4 -1
  833. data/third_party/boringssl/crypto/x509/x_x509.c +42 -3
  834. data/third_party/boringssl/crypto/x509v3/pcy_int.h +2 -2
  835. data/third_party/boringssl/crypto/x509v3/pcy_tree.c +2 -1
  836. data/third_party/boringssl/crypto/x509v3/v3_cpols.c +1 -1
  837. data/third_party/boringssl/crypto/x509v3/v3_ia5.c +4 -1
  838. data/third_party/boringssl/crypto/x509v3/v3_ncons.c +4 -1
  839. data/third_party/boringssl/crypto/x509v3/v3_pci.c +6 -3
  840. data/third_party/boringssl/crypto/x509v3/v3_purp.c +13 -21
  841. data/third_party/boringssl/crypto/x509v3/v3_utl.c +19 -33
  842. data/third_party/boringssl/include/openssl/aead.h +9 -20
  843. data/third_party/boringssl/include/openssl/aes.h +21 -9
  844. data/third_party/boringssl/include/openssl/asn1.h +9 -1
  845. data/third_party/boringssl/include/openssl/base.h +33 -6
  846. data/third_party/boringssl/include/openssl/bio.h +10 -103
  847. data/third_party/boringssl/include/openssl/bn.h +58 -42
  848. data/third_party/boringssl/include/openssl/bytestring.h +17 -0
  849. data/third_party/boringssl/include/openssl/cipher.h +4 -3
  850. data/third_party/boringssl/include/openssl/conf.h +4 -1
  851. data/third_party/boringssl/include/openssl/curve25519.h +13 -0
  852. data/third_party/boringssl/include/openssl/digest.h +5 -3
  853. data/third_party/boringssl/include/openssl/dsa.h +5 -5
  854. data/third_party/boringssl/include/openssl/ec.h +2 -2
  855. data/third_party/boringssl/include/openssl/ecdh.h +3 -4
  856. data/third_party/boringssl/include/openssl/ecdsa.h +10 -10
  857. data/third_party/boringssl/include/openssl/err.h +5 -5
  858. data/third_party/boringssl/include/openssl/evp.h +11 -7
  859. data/third_party/boringssl/include/openssl/lhash.h +2 -3
  860. data/third_party/boringssl/include/openssl/lhash_macros.h +56 -14
  861. data/third_party/boringssl/include/openssl/nid.h +2949 -2916
  862. data/third_party/boringssl/include/openssl/obj.h +1 -1
  863. data/third_party/boringssl/include/openssl/pkcs8.h +21 -42
  864. data/third_party/boringssl/include/openssl/pool.h +87 -0
  865. data/third_party/boringssl/include/openssl/rand.h +1 -1
  866. data/third_party/boringssl/include/openssl/rsa.h +4 -2
  867. data/third_party/boringssl/include/openssl/sha.h +0 -4
  868. data/third_party/boringssl/include/openssl/ssl.h +327 -662
  869. data/third_party/boringssl/include/openssl/ssl3.h +1 -21
  870. data/third_party/boringssl/include/openssl/stack.h +1 -0
  871. data/third_party/boringssl/include/openssl/stack_macros.h +85 -0
  872. data/third_party/boringssl/include/openssl/tls1.h +23 -52
  873. data/third_party/boringssl/include/openssl/type_check.h +4 -0
  874. data/third_party/boringssl/include/openssl/x509.h +10 -59
  875. data/third_party/boringssl/include/openssl/x509_vfy.h +7 -1
  876. data/third_party/boringssl/include/openssl/x509v3.h +4 -4
  877. data/third_party/boringssl/ssl/bio_ssl.c +175 -0
  878. data/third_party/boringssl/ssl/custom_extensions.c +24 -21
  879. data/third_party/boringssl/ssl/d1_both.c +259 -289
  880. data/third_party/boringssl/ssl/d1_lib.c +8 -20
  881. data/third_party/boringssl/ssl/d1_pkt.c +6 -15
  882. data/third_party/boringssl/ssl/dtls_method.c +22 -8
  883. data/third_party/boringssl/ssl/dtls_record.c +27 -2
  884. data/third_party/boringssl/ssl/handshake_client.c +460 -579
  885. data/third_party/boringssl/ssl/handshake_server.c +662 -644
  886. data/third_party/boringssl/ssl/internal.h +1009 -375
  887. data/third_party/boringssl/ssl/s3_both.c +312 -162
  888. data/third_party/boringssl/ssl/s3_lib.c +12 -128
  889. data/third_party/boringssl/ssl/s3_pkt.c +22 -30
  890. data/third_party/boringssl/ssl/ssl_aead_ctx.c +28 -22
  891. data/third_party/boringssl/ssl/ssl_asn1.c +210 -114
  892. data/third_party/boringssl/ssl/ssl_buffer.c +2 -1
  893. data/third_party/boringssl/ssl/ssl_cert.c +417 -219
  894. data/third_party/boringssl/ssl/ssl_cipher.c +191 -393
  895. data/third_party/boringssl/ssl/ssl_ecdh.c +19 -164
  896. data/third_party/boringssl/ssl/ssl_file.c +0 -11
  897. data/third_party/boringssl/ssl/ssl_lib.c +325 -652
  898. data/third_party/boringssl/ssl/{ssl_rsa.c → ssl_privkey.c} +21 -131
  899. data/third_party/boringssl/ssl/ssl_privkey_cc.cc +76 -0
  900. data/third_party/boringssl/ssl/ssl_session.c +206 -95
  901. data/third_party/boringssl/ssl/ssl_stat.c +18 -84
  902. data/third_party/boringssl/ssl/{s3_enc.c → ssl_transcript.c} +150 -157
  903. data/third_party/boringssl/ssl/ssl_x509.c +815 -0
  904. data/third_party/boringssl/ssl/t1_enc.c +188 -174
  905. data/third_party/boringssl/ssl/t1_lib.c +1064 -764
  906. data/third_party/boringssl/ssl/tls13_both.c +290 -96
  907. data/third_party/boringssl/ssl/tls13_client.c +344 -314
  908. data/third_party/boringssl/ssl/tls13_enc.c +239 -200
  909. data/third_party/boringssl/ssl/tls13_server.c +374 -366
  910. data/third_party/boringssl/ssl/tls_method.c +40 -5
  911. data/third_party/boringssl/ssl/tls_record.c +166 -71
  912. metadata +39 -25
  913. data/src/core/lib/iomgr/workqueue.h +0 -87
  914. data/src/core/lib/iomgr/workqueue_uv.c +0 -65
  915. data/src/core/lib/iomgr/workqueue_uv.h +0 -37
  916. data/src/core/lib/iomgr/workqueue_windows.c +0 -63
  917. data/src/core/lib/iomgr/workqueue_windows.h +0 -37
  918. data/third_party/boringssl/crypto/bio/buffer.c +0 -496
  919. data/third_party/boringssl/crypto/newhope/error_correction.c +0 -131
  920. data/third_party/boringssl/crypto/newhope/internal.h +0 -71
  921. data/third_party/boringssl/crypto/newhope/newhope.c +0 -174
  922. data/third_party/boringssl/crypto/newhope/ntt.c +0 -148
  923. data/third_party/boringssl/crypto/newhope/poly.c +0 -183
  924. data/third_party/boringssl/crypto/newhope/precomp.c +0 -306
  925. data/third_party/boringssl/crypto/obj/obj_xref.h +0 -96
  926. data/third_party/boringssl/crypto/pkcs8/p5_pbe.c +0 -151
  927. data/third_party/boringssl/include/openssl/newhope.h +0 -158
  928. data/third_party/boringssl/include/openssl/time_support.h +0 -91
@@ -1,33 +1,18 @@
1
1
  /*
2
2
  *
3
- * Copyright 2016, Google Inc.
4
- * All rights reserved.
3
+ * Copyright 2016 gRPC authors.
5
4
  *
6
- * Redistribution and use in source and binary forms, with or without
7
- * modification, are permitted provided that the following conditions are
8
- * met:
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
9
8
  *
10
- * * Redistributions of source code must retain the above copyright
11
- * notice, this list of conditions and the following disclaimer.
12
- * * Redistributions in binary form must reproduce the above
13
- * copyright notice, this list of conditions and the following disclaimer
14
- * in the documentation and/or other materials provided with the
15
- * distribution.
16
- * * Neither the name of Google Inc. nor the names of its
17
- * contributors may be used to endorse or promote products derived from
18
- * this software without specific prior written permission.
9
+ * http://www.apache.org/licenses/LICENSE-2.0
19
10
  *
20
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
31
16
  *
32
17
  */
33
18
 
@@ -1,33 +1,18 @@
1
1
  /*
2
2
  *
3
- * Copyright 2015, Google Inc.
4
- * All rights reserved.
3
+ * Copyright 2015 gRPC authors.
5
4
  *
6
- * Redistribution and use in source and binary forms, with or without
7
- * modification, are permitted provided that the following conditions are
8
- * met:
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
9
8
  *
10
- * * Redistributions of source code must retain the above copyright
11
- * notice, this list of conditions and the following disclaimer.
12
- * * Redistributions in binary form must reproduce the above
13
- * copyright notice, this list of conditions and the following disclaimer
14
- * in the documentation and/or other materials provided with the
15
- * distribution.
16
- * * Neither the name of Google Inc. nor the names of its
17
- * contributors may be used to endorse or promote products derived from
18
- * this software without specific prior written permission.
9
+ * http://www.apache.org/licenses/LICENSE-2.0
19
10
  *
20
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
31
16
  *
32
17
  */
33
18
 
@@ -126,9 +111,10 @@ static void partly_done(grpc_exec_ctx *exec_ctx, state_watcher *w,
126
111
  } else {
127
112
  grpc_channel_element *client_channel_elem = grpc_channel_stack_last_element(
128
113
  grpc_channel_get_channel_stack(w->channel));
129
- grpc_client_channel_watch_connectivity_state(exec_ctx, client_channel_elem,
130
- grpc_cq_pollset(w->cq), NULL,
131
- &w->on_complete, NULL);
114
+ grpc_client_channel_watch_connectivity_state(
115
+ exec_ctx, client_channel_elem,
116
+ grpc_polling_entity_create_from_pollset(grpc_cq_pollset(w->cq)), NULL,
117
+ &w->on_complete, NULL);
132
118
  }
133
119
 
134
120
  gpr_mu_lock(&w->mu);
@@ -222,12 +208,12 @@ void grpc_channel_watch_connectivity_state(
222
208
  7, (channel, (int)last_observed_state, deadline.tv_sec, deadline.tv_nsec,
223
209
  (int)deadline.clock_type, cq, tag));
224
210
 
225
- grpc_cq_begin_op(cq, tag);
211
+ GPR_ASSERT(grpc_cq_begin_op(cq, tag));
226
212
 
227
213
  gpr_mu_init(&w->mu);
228
- grpc_closure_init(&w->on_complete, watch_complete, w,
214
+ GRPC_CLOSURE_INIT(&w->on_complete, watch_complete, w,
229
215
  grpc_schedule_on_exec_ctx);
230
- grpc_closure_init(&w->on_timeout, timeout_complete, w,
216
+ GRPC_CLOSURE_INIT(&w->on_timeout, timeout_complete, w,
231
217
  grpc_schedule_on_exec_ctx);
232
218
  w->phase = WAITING;
233
219
  w->state = last_observed_state;
@@ -239,13 +225,14 @@ void grpc_channel_watch_connectivity_state(
239
225
  watcher_timer_init_arg *wa = gpr_malloc(sizeof(watcher_timer_init_arg));
240
226
  wa->w = w;
241
227
  wa->deadline = deadline;
242
- grpc_closure_init(&w->watcher_timer_init, watcher_timer_init, wa,
228
+ GRPC_CLOSURE_INIT(&w->watcher_timer_init, watcher_timer_init, wa,
243
229
  grpc_schedule_on_exec_ctx);
244
230
 
245
231
  if (client_channel_elem->filter == &grpc_client_channel_filter) {
246
232
  GRPC_CHANNEL_INTERNAL_REF(channel, "watch_channel_connectivity");
247
233
  grpc_client_channel_watch_connectivity_state(
248
- &exec_ctx, client_channel_elem, grpc_cq_pollset(cq), &w->state,
234
+ &exec_ctx, client_channel_elem,
235
+ grpc_polling_entity_create_from_pollset(grpc_cq_pollset(cq)), &w->state,
249
236
  &w->on_complete, &w->watcher_timer_init);
250
237
  } else {
251
238
  abort();
@@ -1,33 +1,18 @@
1
1
  /*
2
2
  *
3
- * Copyright 2015, Google Inc.
4
- * All rights reserved.
3
+ * Copyright 2015 gRPC authors.
5
4
  *
6
- * Redistribution and use in source and binary forms, with or without
7
- * modification, are permitted provided that the following conditions are
8
- * met:
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
9
8
  *
10
- * * Redistributions of source code must retain the above copyright
11
- * notice, this list of conditions and the following disclaimer.
12
- * * Redistributions in binary form must reproduce the above
13
- * copyright notice, this list of conditions and the following disclaimer
14
- * in the documentation and/or other materials provided with the
15
- * distribution.
16
- * * Neither the name of Google Inc. nor the names of its
17
- * contributors may be used to endorse or promote products derived from
18
- * this software without specific prior written permission.
9
+ * http://www.apache.org/licenses/LICENSE-2.0
19
10
  *
20
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
31
16
  *
32
17
  */
33
18
 
@@ -67,6 +52,9 @@
67
52
 
68
53
  /* Client channel implementation */
69
54
 
55
+ grpc_tracer_flag grpc_client_channel_trace =
56
+ GRPC_TRACER_INITIALIZER(false, "client_channel");
57
+
70
58
  /*************************************************************************
71
59
  * METHOD-CONFIG TABLE
72
60
  */
@@ -193,8 +181,8 @@ typedef struct client_channel_channel_data {
193
181
  grpc_slice_hash_table *method_params_table;
194
182
  /** incoming resolver result - set by resolver.next() */
195
183
  grpc_channel_args *resolver_result;
196
- /** a list of closures that are all waiting for config to come in */
197
- grpc_closure_list waiting_for_config_closures;
184
+ /** a list of closures that are all waiting for resolver result to come in */
185
+ grpc_closure_list waiting_for_resolver_result_closures;
198
186
  /** resolver callback */
199
187
  grpc_closure on_resolver_result_changed;
200
188
  /** connectivity state being tracked */
@@ -256,6 +244,10 @@ static void set_channel_connectivity_state_locked(grpc_exec_ctx *exec_ctx,
256
244
  GRPC_ERROR_REF(error));
257
245
  }
258
246
  }
247
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
248
+ gpr_log(GPR_DEBUG, "chand=%p: setting connectivity state to %s", chand,
249
+ grpc_connectivity_state_name(state));
250
+ }
259
251
  grpc_connectivity_state_set(exec_ctx, &chand->state_tracker, state, error,
260
252
  reason);
261
253
  }
@@ -266,6 +258,10 @@ static void on_lb_policy_state_changed_locked(grpc_exec_ctx *exec_ctx,
266
258
  grpc_connectivity_state publish_state = w->state;
267
259
  /* check if the notification is for the latest policy */
268
260
  if (w->lb_policy == w->chand->lb_policy) {
261
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
262
+ gpr_log(GPR_DEBUG, "chand=%p: lb_policy=%p state changed to %s", w->chand,
263
+ w->lb_policy, grpc_connectivity_state_name(w->state));
264
+ }
269
265
  if (publish_state == GRPC_CHANNEL_SHUTDOWN && w->chand->resolver != NULL) {
270
266
  publish_state = GRPC_CHANNEL_TRANSIENT_FAILURE;
271
267
  grpc_resolver_channel_saw_error_locked(exec_ctx, w->chand->resolver);
@@ -278,7 +274,6 @@ static void on_lb_policy_state_changed_locked(grpc_exec_ctx *exec_ctx,
278
274
  watch_lb_policy_locked(exec_ctx, w->chand, w->lb_policy, w->state);
279
275
  }
280
276
  }
281
-
282
277
  GRPC_CHANNEL_STACK_UNREF(exec_ctx, w->chand->owning_stack, "watch_lb_policy");
283
278
  gpr_free(w);
284
279
  }
@@ -288,16 +283,27 @@ static void watch_lb_policy_locked(grpc_exec_ctx *exec_ctx, channel_data *chand,
288
283
  grpc_connectivity_state current_state) {
289
284
  lb_policy_connectivity_watcher *w = gpr_malloc(sizeof(*w));
290
285
  GRPC_CHANNEL_STACK_REF(chand->owning_stack, "watch_lb_policy");
291
-
292
286
  w->chand = chand;
293
- grpc_closure_init(&w->on_changed, on_lb_policy_state_changed_locked, w,
294
- grpc_combiner_scheduler(chand->combiner, false));
287
+ GRPC_CLOSURE_INIT(&w->on_changed, on_lb_policy_state_changed_locked, w,
288
+ grpc_combiner_scheduler(chand->combiner));
295
289
  w->state = current_state;
296
290
  w->lb_policy = lb_policy;
297
291
  grpc_lb_policy_notify_on_state_change_locked(exec_ctx, lb_policy, &w->state,
298
292
  &w->on_changed);
299
293
  }
300
294
 
295
+ static void start_resolving_locked(grpc_exec_ctx *exec_ctx,
296
+ channel_data *chand) {
297
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
298
+ gpr_log(GPR_DEBUG, "chand=%p: starting name resolution", chand);
299
+ }
300
+ GPR_ASSERT(!chand->started_resolving);
301
+ chand->started_resolving = true;
302
+ GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver");
303
+ grpc_resolver_next_locked(exec_ctx, chand->resolver, &chand->resolver_result,
304
+ &chand->on_resolver_result_changed);
305
+ }
306
+
301
307
  typedef struct {
302
308
  char *server_name;
303
309
  grpc_server_retry_throttle_data *retry_throttle_data;
@@ -357,48 +363,21 @@ static void parse_retry_throttle_params(const grpc_json *field, void *arg) {
357
363
  }
358
364
  }
359
365
 
360
- // Wrap a closure associated with \a lb_policy. The associated callback (\a
361
- // wrapped_on_pick_closure_cb) is responsible for unref'ing \a lb_policy after
362
- // scheduling \a wrapped_closure.
363
- typedef struct wrapped_on_pick_closure_arg {
364
- /* the closure instance using this struct as argument */
365
- grpc_closure wrapper_closure;
366
-
367
- /* the original closure. Usually a on_complete/notify cb for pick() and ping()
368
- * calls against the internal RR instance, respectively. */
369
- grpc_closure *wrapped_closure;
370
-
371
- /* The policy instance related to the closure */
372
- grpc_lb_policy *lb_policy;
373
- } wrapped_on_pick_closure_arg;
374
-
375
- // Invoke \a arg->wrapped_closure, unref \a arg->lb_policy and free \a arg.
376
- static void wrapped_on_pick_closure_cb(grpc_exec_ctx *exec_ctx, void *arg,
377
- grpc_error *error) {
378
- wrapped_on_pick_closure_arg *wc_arg = arg;
379
- GPR_ASSERT(wc_arg != NULL);
380
- GPR_ASSERT(wc_arg->wrapped_closure != NULL);
381
- GPR_ASSERT(wc_arg->lb_policy != NULL);
382
- grpc_closure_run(exec_ctx, wc_arg->wrapped_closure, GRPC_ERROR_REF(error));
383
- GRPC_LB_POLICY_UNREF(exec_ctx, wc_arg->lb_policy, "pick_subchannel_wrapping");
384
- gpr_free(wc_arg);
385
- }
386
-
387
366
  static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
388
367
  void *arg, grpc_error *error) {
389
368
  channel_data *chand = arg;
369
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
370
+ gpr_log(GPR_DEBUG, "chand=%p: got resolver result: error=%s", chand,
371
+ grpc_error_string(error));
372
+ }
373
+ // Extract the following fields from the resolver result, if non-NULL.
374
+ bool lb_policy_updated = false;
390
375
  char *lb_policy_name = NULL;
391
- grpc_lb_policy *lb_policy = NULL;
392
- grpc_lb_policy *old_lb_policy;
393
- grpc_slice_hash_table *method_params_table = NULL;
394
- grpc_connectivity_state state = GRPC_CHANNEL_TRANSIENT_FAILURE;
395
- bool exit_idle = false;
396
- grpc_error *state_error =
397
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("No load balancing policy");
376
+ bool lb_policy_name_changed = false;
377
+ grpc_lb_policy *new_lb_policy = NULL;
398
378
  char *service_config_json = NULL;
399
- service_config_parsing_state parsing_state;
400
- memset(&parsing_state, 0, sizeof(parsing_state));
401
-
379
+ grpc_server_retry_throttle_data *retry_throttle_data = NULL;
380
+ grpc_slice_hash_table *method_params_table = NULL;
402
381
  if (chand->resolver_result != NULL) {
403
382
  // Find LB policy name.
404
383
  const grpc_arg *channel_arg =
@@ -433,18 +412,29 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
433
412
  // Use pick_first if nothing was specified and we didn't select grpclb
434
413
  // above.
435
414
  if (lb_policy_name == NULL) lb_policy_name = "pick_first";
436
- // Instantiate LB policy.
437
415
  grpc_lb_policy_args lb_policy_args;
438
416
  lb_policy_args.args = chand->resolver_result;
439
417
  lb_policy_args.client_channel_factory = chand->client_channel_factory;
440
418
  lb_policy_args.combiner = chand->combiner;
441
- lb_policy =
442
- grpc_lb_policy_create(exec_ctx, lb_policy_name, &lb_policy_args);
443
- if (lb_policy != NULL) {
444
- GRPC_LB_POLICY_REF(lb_policy, "config_change");
445
- GRPC_ERROR_UNREF(state_error);
446
- state = grpc_lb_policy_check_connectivity_locked(exec_ctx, lb_policy,
447
- &state_error);
419
+ // Check to see if we're already using the right LB policy.
420
+ // Note: It's safe to use chand->info_lb_policy_name here without
421
+ // taking a lock on chand->info_mu, because this function is the
422
+ // only thing that modifies its value, and it can only be invoked
423
+ // once at any given time.
424
+ lb_policy_name_changed =
425
+ chand->info_lb_policy_name == NULL ||
426
+ strcmp(chand->info_lb_policy_name, lb_policy_name) != 0;
427
+ if (chand->lb_policy != NULL && !lb_policy_name_changed) {
428
+ // Continue using the same LB policy. Update with new addresses.
429
+ lb_policy_updated = true;
430
+ grpc_lb_policy_update_locked(exec_ctx, chand->lb_policy, &lb_policy_args);
431
+ } else {
432
+ // Instantiate new LB policy.
433
+ new_lb_policy =
434
+ grpc_lb_policy_create(exec_ctx, lb_policy_name, &lb_policy_args);
435
+ if (new_lb_policy == NULL) {
436
+ gpr_log(GPR_ERROR, "could not create LB policy \"%s\"", lb_policy_name);
437
+ }
448
438
  }
449
439
  // Find service config.
450
440
  channel_arg =
@@ -462,12 +452,14 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
462
452
  grpc_uri *uri =
463
453
  grpc_uri_parse(exec_ctx, channel_arg->value.string, true);
464
454
  GPR_ASSERT(uri->path[0] != '\0');
455
+ service_config_parsing_state parsing_state;
456
+ memset(&parsing_state, 0, sizeof(parsing_state));
465
457
  parsing_state.server_name =
466
458
  uri->path[0] == '/' ? uri->path + 1 : uri->path;
467
459
  grpc_service_config_parse_global_params(
468
460
  service_config, parse_retry_throttle_params, &parsing_state);
469
- parsing_state.server_name = NULL;
470
461
  grpc_uri_destroy(uri);
462
+ retry_throttle_data = parsing_state.retry_throttle_data;
471
463
  method_params_table = grpc_service_config_create_method_config_table(
472
464
  exec_ctx, service_config, method_parameters_create_from_json,
473
465
  method_parameters_free);
@@ -481,88 +473,115 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
481
473
  grpc_channel_args_destroy(exec_ctx, chand->resolver_result);
482
474
  chand->resolver_result = NULL;
483
475
  }
484
-
485
- if (lb_policy != NULL) {
486
- grpc_pollset_set_add_pollset_set(exec_ctx, lb_policy->interested_parties,
487
- chand->interested_parties);
488
- }
489
-
476
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
477
+ gpr_log(GPR_DEBUG,
478
+ "chand=%p: resolver result: lb_policy_name=\"%s\"%s, "
479
+ "service_config=\"%s\"",
480
+ chand, lb_policy_name, lb_policy_name_changed ? " (changed)" : "",
481
+ service_config_json);
482
+ }
483
+ // Now swap out fields in chand. Note that the new values may still
484
+ // be NULL if (e.g.) the resolver failed to return results or the
485
+ // results did not contain the necessary data.
486
+ //
487
+ // First, swap out the data used by cc_get_channel_info().
490
488
  gpr_mu_lock(&chand->info_mu);
491
489
  if (lb_policy_name != NULL) {
492
490
  gpr_free(chand->info_lb_policy_name);
493
491
  chand->info_lb_policy_name = lb_policy_name;
494
492
  }
495
- old_lb_policy = chand->lb_policy;
496
- chand->lb_policy = lb_policy;
497
493
  if (service_config_json != NULL) {
498
494
  gpr_free(chand->info_service_config_json);
499
495
  chand->info_service_config_json = service_config_json;
500
496
  }
501
497
  gpr_mu_unlock(&chand->info_mu);
502
-
498
+ // Swap out the retry throttle data.
503
499
  if (chand->retry_throttle_data != NULL) {
504
500
  grpc_server_retry_throttle_data_unref(chand->retry_throttle_data);
505
501
  }
506
- chand->retry_throttle_data = parsing_state.retry_throttle_data;
502
+ chand->retry_throttle_data = retry_throttle_data;
503
+ // Swap out the method params table.
507
504
  if (chand->method_params_table != NULL) {
508
505
  grpc_slice_hash_table_unref(exec_ctx, chand->method_params_table);
509
506
  }
510
507
  chand->method_params_table = method_params_table;
511
- if (lb_policy != NULL) {
512
- grpc_closure_list_sched(exec_ctx, &chand->waiting_for_config_closures);
513
- } else if (chand->resolver == NULL /* disconnected */) {
514
- grpc_closure_list_fail_all(&chand->waiting_for_config_closures,
515
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
516
- "Channel disconnected", &error, 1));
517
- grpc_closure_list_sched(exec_ctx, &chand->waiting_for_config_closures);
518
- }
519
- if (lb_policy != NULL && chand->exit_idle_when_lb_policy_arrives) {
520
- GRPC_LB_POLICY_REF(lb_policy, "exit_idle");
521
- exit_idle = true;
522
- chand->exit_idle_when_lb_policy_arrives = false;
508
+ // If we have a new LB policy or are shutting down (in which case
509
+ // new_lb_policy will be NULL), swap out the LB policy, unreffing the
510
+ // old one and removing its fds from chand->interested_parties.
511
+ // Note that we do NOT do this if either (a) we updated the existing
512
+ // LB policy above or (b) we failed to create the new LB policy (in
513
+ // which case we want to continue using the most recent one we had).
514
+ if (new_lb_policy != NULL || error != GRPC_ERROR_NONE ||
515
+ chand->resolver == NULL) {
516
+ if (chand->lb_policy != NULL) {
517
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
518
+ gpr_log(GPR_DEBUG, "chand=%p: unreffing lb_policy=%p", chand,
519
+ chand->lb_policy);
520
+ }
521
+ grpc_pollset_set_del_pollset_set(exec_ctx,
522
+ chand->lb_policy->interested_parties,
523
+ chand->interested_parties);
524
+ GRPC_LB_POLICY_UNREF(exec_ctx, chand->lb_policy, "channel");
525
+ }
526
+ chand->lb_policy = new_lb_policy;
523
527
  }
524
-
525
- if (error == GRPC_ERROR_NONE && chand->resolver) {
526
- set_channel_connectivity_state_locked(
527
- exec_ctx, chand, state, GRPC_ERROR_REF(state_error), "new_lb+resolver");
528
- if (lb_policy != NULL) {
529
- watch_lb_policy_locked(exec_ctx, chand, lb_policy, state);
528
+ // Now that we've swapped out the relevant fields of chand, check for
529
+ // error or shutdown.
530
+ if (error != GRPC_ERROR_NONE || chand->resolver == NULL) {
531
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
532
+ gpr_log(GPR_DEBUG, "chand=%p: shutting down", chand);
530
533
  }
531
- GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver");
532
- grpc_resolver_next_locked(exec_ctx, chand->resolver,
533
- &chand->resolver_result,
534
- &chand->on_resolver_result_changed);
535
- } else {
536
534
  if (chand->resolver != NULL) {
535
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
536
+ gpr_log(GPR_DEBUG, "chand=%p: shutting down resolver", chand);
537
+ }
537
538
  grpc_resolver_shutdown_locked(exec_ctx, chand->resolver);
538
539
  GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel");
539
540
  chand->resolver = NULL;
540
541
  }
541
- grpc_error *refs[] = {error, state_error};
542
542
  set_channel_connectivity_state_locked(
543
543
  exec_ctx, chand, GRPC_CHANNEL_SHUTDOWN,
544
544
  GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
545
- "Got config after disconnection", refs, GPR_ARRAY_SIZE(refs)),
545
+ "Got resolver result after disconnection", &error, 1),
546
546
  "resolver_gone");
547
+ GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->owning_stack, "resolver");
548
+ grpc_closure_list_fail_all(&chand->waiting_for_resolver_result_closures,
549
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
550
+ "Channel disconnected", &error, 1));
551
+ GRPC_CLOSURE_LIST_SCHED(exec_ctx,
552
+ &chand->waiting_for_resolver_result_closures);
553
+ } else { // Not shutting down.
554
+ grpc_connectivity_state state = GRPC_CHANNEL_TRANSIENT_FAILURE;
555
+ grpc_error *state_error =
556
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("No load balancing policy");
557
+ if (new_lb_policy != NULL) {
558
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
559
+ gpr_log(GPR_DEBUG, "chand=%p: initializing new LB policy", chand);
560
+ }
561
+ GRPC_ERROR_UNREF(state_error);
562
+ state = grpc_lb_policy_check_connectivity_locked(exec_ctx, new_lb_policy,
563
+ &state_error);
564
+ grpc_pollset_set_add_pollset_set(exec_ctx,
565
+ new_lb_policy->interested_parties,
566
+ chand->interested_parties);
567
+ GRPC_CLOSURE_LIST_SCHED(exec_ctx,
568
+ &chand->waiting_for_resolver_result_closures);
569
+ if (chand->exit_idle_when_lb_policy_arrives) {
570
+ grpc_lb_policy_exit_idle_locked(exec_ctx, new_lb_policy);
571
+ chand->exit_idle_when_lb_policy_arrives = false;
572
+ }
573
+ watch_lb_policy_locked(exec_ctx, chand, new_lb_policy, state);
574
+ }
575
+ if (!lb_policy_updated) {
576
+ set_channel_connectivity_state_locked(exec_ctx, chand, state,
577
+ GRPC_ERROR_REF(state_error),
578
+ "new_lb+resolver");
579
+ }
580
+ grpc_resolver_next_locked(exec_ctx, chand->resolver,
581
+ &chand->resolver_result,
582
+ &chand->on_resolver_result_changed);
583
+ GRPC_ERROR_UNREF(state_error);
547
584
  }
548
-
549
- if (exit_idle) {
550
- grpc_lb_policy_exit_idle_locked(exec_ctx, lb_policy);
551
- GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "exit_idle");
552
- }
553
-
554
- if (old_lb_policy != NULL) {
555
- grpc_pollset_set_del_pollset_set(
556
- exec_ctx, old_lb_policy->interested_parties, chand->interested_parties);
557
- GRPC_LB_POLICY_UNREF(exec_ctx, old_lb_policy, "channel");
558
- }
559
-
560
- if (lb_policy != NULL) {
561
- GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "config_change");
562
- }
563
-
564
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->owning_stack, "resolver");
565
- GRPC_ERROR_UNREF(state_error);
566
585
  }
567
586
 
568
587
  static void start_transport_op_locked(grpc_exec_ctx *exec_ctx, void *arg,
@@ -581,7 +600,7 @@ static void start_transport_op_locked(grpc_exec_ctx *exec_ctx, void *arg,
581
600
 
582
601
  if (op->send_ping != NULL) {
583
602
  if (chand->lb_policy == NULL) {
584
- grpc_closure_sched(
603
+ GRPC_CLOSURE_SCHED(
585
604
  exec_ctx, op->send_ping,
586
605
  GRPC_ERROR_CREATE_FROM_STATIC_STRING("Ping with no load balancing"));
587
606
  } else {
@@ -600,9 +619,10 @@ static void start_transport_op_locked(grpc_exec_ctx *exec_ctx, void *arg,
600
619
  GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel");
601
620
  chand->resolver = NULL;
602
621
  if (!chand->started_resolving) {
603
- grpc_closure_list_fail_all(&chand->waiting_for_config_closures,
622
+ grpc_closure_list_fail_all(&chand->waiting_for_resolver_result_closures,
604
623
  GRPC_ERROR_REF(op->disconnect_with_error));
605
- grpc_closure_list_sched(exec_ctx, &chand->waiting_for_config_closures);
624
+ GRPC_CLOSURE_LIST_SCHED(exec_ctx,
625
+ &chand->waiting_for_resolver_result_closures);
606
626
  }
607
627
  if (chand->lb_policy != NULL) {
608
628
  grpc_pollset_set_del_pollset_set(exec_ctx,
@@ -616,7 +636,7 @@ static void start_transport_op_locked(grpc_exec_ctx *exec_ctx, void *arg,
616
636
  }
617
637
  GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->owning_stack, "start_transport_op");
618
638
 
619
- grpc_closure_sched(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
639
+ GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
620
640
  }
621
641
 
622
642
  static void cc_start_transport_op(grpc_exec_ctx *exec_ctx,
@@ -632,10 +652,10 @@ static void cc_start_transport_op(grpc_exec_ctx *exec_ctx,
632
652
 
633
653
  op->handler_private.extra_arg = elem;
634
654
  GRPC_CHANNEL_STACK_REF(chand->owning_stack, "start_transport_op");
635
- grpc_closure_sched(
655
+ GRPC_CLOSURE_SCHED(
636
656
  exec_ctx,
637
- grpc_closure_init(&op->handler_private.closure, start_transport_op_locked,
638
- op, grpc_combiner_scheduler(chand->combiner, false)),
657
+ GRPC_CLOSURE_INIT(&op->handler_private.closure, start_transport_op_locked,
658
+ op, grpc_combiner_scheduler(chand->combiner)),
639
659
  GRPC_ERROR_NONE);
640
660
  }
641
661
 
@@ -666,7 +686,7 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
666
686
  GPR_ASSERT(args->is_last);
667
687
  GPR_ASSERT(elem->filter == &grpc_client_channel_filter);
668
688
  // Initialize data members.
669
- chand->combiner = grpc_combiner_create(NULL);
689
+ chand->combiner = grpc_combiner_create();
670
690
  gpr_mu_init(&chand->info_mu);
671
691
  gpr_mu_init(&chand->external_connectivity_watcher_list_mu);
672
692
 
@@ -675,9 +695,9 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
675
695
  gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
676
696
 
677
697
  chand->owning_stack = args->channel_stack;
678
- grpc_closure_init(&chand->on_resolver_result_changed,
698
+ GRPC_CLOSURE_INIT(&chand->on_resolver_result_changed,
679
699
  on_resolver_result_changed_locked, chand,
680
- grpc_combiner_scheduler(chand->combiner, false));
700
+ grpc_combiner_scheduler(chand->combiner));
681
701
  chand->interested_parties = grpc_pollset_set_create();
682
702
  grpc_connectivity_state_init(&chand->state_tracker, GRPC_CHANNEL_IDLE,
683
703
  "client_channel");
@@ -735,10 +755,9 @@ static void cc_destroy_channel_elem(grpc_exec_ctx *exec_ctx,
735
755
  grpc_channel_element *elem) {
736
756
  channel_data *chand = elem->channel_data;
737
757
  if (chand->resolver != NULL) {
738
- grpc_closure_sched(
739
- exec_ctx,
740
- grpc_closure_create(shutdown_resolver_locked, chand->resolver,
741
- grpc_combiner_scheduler(chand->combiner, false)),
758
+ GRPC_CLOSURE_SCHED(
759
+ exec_ctx, GRPC_CLOSURE_CREATE(shutdown_resolver_locked, chand->resolver,
760
+ grpc_combiner_scheduler(chand->combiner)),
742
761
  GRPC_ERROR_NONE);
743
762
  }
744
763
  if (chand->client_channel_factory != NULL) {
@@ -769,10 +788,15 @@ static void cc_destroy_channel_elem(grpc_exec_ctx *exec_ctx,
769
788
  * PER-CALL FUNCTIONS
770
789
  */
771
790
 
772
- #define GET_CALL(call_data) \
773
- ((grpc_subchannel_call *)(gpr_atm_acq_load(&(call_data)->subchannel_call)))
774
-
775
- #define CANCELLED_CALL ((grpc_subchannel_call *)1)
791
+ // Max number of batches that can be pending on a call at any given
792
+ // time. This includes:
793
+ // recv_initial_metadata
794
+ // send_initial_metadata
795
+ // recv_message
796
+ // send_message
797
+ // recv_trailing_metadata
798
+ // send_trailing_metadata
799
+ #define MAX_WAITING_BATCHES 6
776
800
 
777
801
  /** Call data. Holds a pointer to grpc_subchannel_call and the
778
802
  associated machinery to create such a pointer.
@@ -794,23 +818,22 @@ typedef struct client_channel_call_data {
794
818
  grpc_server_retry_throttle_data *retry_throttle_data;
795
819
  method_parameters *method_params;
796
820
 
797
- grpc_error *cancel_error;
798
-
799
- /** either 0 for no call, 1 for cancelled, or a pointer to a
800
- grpc_subchannel_call */
801
- gpr_atm subchannel_call;
821
+ /** either 0 for no call, a pointer to a grpc_subchannel_call (if the lowest
822
+ bit is 0), or a pointer to an error (if the lowest bit is 1) */
823
+ gpr_atm subchannel_call_or_error;
802
824
  gpr_arena *arena;
803
825
 
804
- bool pick_pending;
826
+ grpc_lb_policy *lb_policy; // Holds ref while LB pick is pending.
827
+ grpc_closure lb_pick_closure;
828
+
805
829
  grpc_connected_subchannel *connected_subchannel;
806
830
  grpc_call_context_element subchannel_call_context[GRPC_CONTEXT_COUNT];
807
831
  grpc_polling_entity *pollent;
808
832
 
809
- grpc_transport_stream_op_batch **waiting_ops;
810
- size_t waiting_ops_count;
811
- size_t waiting_ops_capacity;
833
+ grpc_transport_stream_op_batch *waiting_for_pick_batches[MAX_WAITING_BATCHES];
834
+ size_t waiting_for_pick_batches_count;
812
835
 
813
- grpc_closure next_step;
836
+ grpc_transport_stream_op_batch_payload *initial_metadata_payload;
814
837
 
815
838
  grpc_call_stack *owning_call;
816
839
 
@@ -820,65 +843,103 @@ typedef struct client_channel_call_data {
820
843
  grpc_closure *original_on_complete;
821
844
  } call_data;
822
845
 
846
+ typedef struct {
847
+ grpc_subchannel_call *subchannel_call;
848
+ grpc_error *error;
849
+ } call_or_error;
850
+
851
+ static call_or_error get_call_or_error(call_data *p) {
852
+ gpr_atm c = gpr_atm_acq_load(&p->subchannel_call_or_error);
853
+ if (c == 0)
854
+ return (call_or_error){NULL, NULL};
855
+ else if (c & 1)
856
+ return (call_or_error){NULL, (grpc_error *)((c) & ~(gpr_atm)1)};
857
+ else
858
+ return (call_or_error){(grpc_subchannel_call *)c, NULL};
859
+ }
860
+
861
+ static bool set_call_or_error(call_data *p, call_or_error coe) {
862
+ // this should always be under a lock
863
+ call_or_error existing = get_call_or_error(p);
864
+ if (existing.error != GRPC_ERROR_NONE) {
865
+ GRPC_ERROR_UNREF(coe.error);
866
+ return false;
867
+ }
868
+ GPR_ASSERT(existing.subchannel_call == NULL);
869
+ if (coe.error != GRPC_ERROR_NONE) {
870
+ GPR_ASSERT(coe.subchannel_call == NULL);
871
+ gpr_atm_rel_store(&p->subchannel_call_or_error, 1 | (gpr_atm)coe.error);
872
+ } else {
873
+ GPR_ASSERT(coe.subchannel_call != NULL);
874
+ gpr_atm_rel_store(&p->subchannel_call_or_error,
875
+ (gpr_atm)coe.subchannel_call);
876
+ }
877
+ return true;
878
+ }
879
+
823
880
  grpc_subchannel_call *grpc_client_channel_get_subchannel_call(
824
881
  grpc_call_element *call_elem) {
825
- grpc_subchannel_call *scc = GET_CALL((call_data *)call_elem->call_data);
826
- return scc == CANCELLED_CALL ? NULL : scc;
882
+ return get_call_or_error(call_elem->call_data).subchannel_call;
827
883
  }
828
884
 
829
- static void add_waiting_locked(call_data *calld,
830
- grpc_transport_stream_op_batch *op) {
831
- GPR_TIMER_BEGIN("add_waiting_locked", 0);
832
- if (calld->waiting_ops_count == calld->waiting_ops_capacity) {
833
- calld->waiting_ops_capacity = GPR_MAX(3, 2 * calld->waiting_ops_capacity);
834
- calld->waiting_ops =
835
- gpr_realloc(calld->waiting_ops,
836
- calld->waiting_ops_capacity * sizeof(*calld->waiting_ops));
837
- }
838
- calld->waiting_ops[calld->waiting_ops_count++] = op;
839
- GPR_TIMER_END("add_waiting_locked", 0);
885
+ static void waiting_for_pick_batches_add_locked(
886
+ call_data *calld, grpc_transport_stream_op_batch *batch) {
887
+ GPR_ASSERT(calld->waiting_for_pick_batches_count < MAX_WAITING_BATCHES);
888
+ calld->waiting_for_pick_batches[calld->waiting_for_pick_batches_count++] =
889
+ batch;
840
890
  }
841
891
 
842
- static void fail_locked(grpc_exec_ctx *exec_ctx, call_data *calld,
843
- grpc_error *error) {
844
- size_t i;
845
- for (i = 0; i < calld->waiting_ops_count; i++) {
892
+ static void waiting_for_pick_batches_fail_locked(grpc_exec_ctx *exec_ctx,
893
+ grpc_call_element *elem,
894
+ grpc_error *error) {
895
+ call_data *calld = elem->call_data;
896
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
897
+ gpr_log(GPR_DEBUG,
898
+ "chand=%p calld=%p: failing %" PRIdPTR " pending batches: %s",
899
+ elem->channel_data, calld, calld->waiting_for_pick_batches_count,
900
+ grpc_error_string(error));
901
+ }
902
+ for (size_t i = 0; i < calld->waiting_for_pick_batches_count; ++i) {
846
903
  grpc_transport_stream_op_batch_finish_with_failure(
847
- exec_ctx, calld->waiting_ops[i], GRPC_ERROR_REF(error));
904
+ exec_ctx, calld->waiting_for_pick_batches[i], GRPC_ERROR_REF(error));
848
905
  }
849
- calld->waiting_ops_count = 0;
906
+ calld->waiting_for_pick_batches_count = 0;
850
907
  GRPC_ERROR_UNREF(error);
851
908
  }
852
909
 
853
- static void retry_waiting_locked(grpc_exec_ctx *exec_ctx, call_data *calld) {
854
- if (calld->waiting_ops_count == 0) {
910
+ static void waiting_for_pick_batches_resume_locked(grpc_exec_ctx *exec_ctx,
911
+ grpc_call_element *elem) {
912
+ call_data *calld = elem->call_data;
913
+ if (calld->waiting_for_pick_batches_count == 0) return;
914
+ call_or_error coe = get_call_or_error(calld);
915
+ if (coe.error != GRPC_ERROR_NONE) {
916
+ waiting_for_pick_batches_fail_locked(exec_ctx, elem,
917
+ GRPC_ERROR_REF(coe.error));
855
918
  return;
856
919
  }
857
-
858
- grpc_subchannel_call *call = GET_CALL(calld);
859
- grpc_transport_stream_op_batch **ops = calld->waiting_ops;
860
- size_t nops = calld->waiting_ops_count;
861
- if (call == CANCELLED_CALL) {
862
- fail_locked(exec_ctx, calld, GRPC_ERROR_CANCELLED);
863
- return;
920
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
921
+ gpr_log(GPR_DEBUG, "chand=%p calld=%p: sending %" PRIdPTR
922
+ " pending batches to subchannel_call=%p",
923
+ elem->channel_data, calld, calld->waiting_for_pick_batches_count,
924
+ coe.subchannel_call);
864
925
  }
865
- calld->waiting_ops = NULL;
866
- calld->waiting_ops_count = 0;
867
- calld->waiting_ops_capacity = 0;
868
- for (size_t i = 0; i < nops; i++) {
869
- grpc_subchannel_call_process_op(exec_ctx, call, ops[i]);
926
+ for (size_t i = 0; i < calld->waiting_for_pick_batches_count; ++i) {
927
+ grpc_subchannel_call_process_op(exec_ctx, coe.subchannel_call,
928
+ calld->waiting_for_pick_batches[i]);
870
929
  }
871
- gpr_free(ops);
930
+ calld->waiting_for_pick_batches_count = 0;
872
931
  }
873
932
 
874
- // Sets calld->method_params and calld->retry_throttle_data.
875
- // If the method params specify a timeout, populates
876
- // *per_method_deadline and returns true.
877
- static bool set_call_method_params_from_service_config_locked(
878
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
879
- gpr_timespec *per_method_deadline) {
933
+ // Applies service config to the call. Must be invoked once we know
934
+ // that the resolver has returned results to the channel.
935
+ static void apply_service_config_to_call_locked(grpc_exec_ctx *exec_ctx,
936
+ grpc_call_element *elem) {
880
937
  channel_data *chand = elem->channel_data;
881
938
  call_data *calld = elem->call_data;
939
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
940
+ gpr_log(GPR_DEBUG, "chand=%p calld=%p: applying service config to call",
941
+ chand, calld);
942
+ }
882
943
  if (chand->retry_throttle_data != NULL) {
883
944
  calld->retry_throttle_data =
884
945
  grpc_server_retry_throttle_data_ref(chand->retry_throttle_data);
@@ -888,178 +949,283 @@ static bool set_call_method_params_from_service_config_locked(
888
949
  exec_ctx, chand->method_params_table, calld->path);
889
950
  if (calld->method_params != NULL) {
890
951
  method_parameters_ref(calld->method_params);
891
- if (gpr_time_cmp(calld->method_params->timeout,
952
+ // If the deadline from the service config is shorter than the one
953
+ // from the client API, reset the deadline timer.
954
+ if (chand->deadline_checking_enabled &&
955
+ gpr_time_cmp(calld->method_params->timeout,
892
956
  gpr_time_0(GPR_TIMESPAN)) != 0) {
893
- *per_method_deadline =
957
+ const gpr_timespec per_method_deadline =
894
958
  gpr_time_add(calld->call_start_time, calld->method_params->timeout);
895
- return true;
959
+ if (gpr_time_cmp(per_method_deadline, calld->deadline) < 0) {
960
+ calld->deadline = per_method_deadline;
961
+ grpc_deadline_state_reset(exec_ctx, elem, calld->deadline);
962
+ }
896
963
  }
897
964
  }
898
965
  }
899
- return false;
900
966
  }
901
967
 
902
- static void apply_final_configuration_locked(grpc_exec_ctx *exec_ctx,
903
- grpc_call_element *elem) {
904
- /* apply service-config level configuration to the call (now that we're
905
- * certain it exists) */
968
+ static void create_subchannel_call_locked(grpc_exec_ctx *exec_ctx,
969
+ grpc_call_element *elem,
970
+ grpc_error *error) {
906
971
  call_data *calld = elem->call_data;
907
- channel_data *chand = elem->channel_data;
908
- gpr_timespec per_method_deadline;
909
- if (set_call_method_params_from_service_config_locked(exec_ctx, elem,
910
- &per_method_deadline)) {
911
- // If the deadline from the service config is shorter than the one
912
- // from the client API, reset the deadline timer.
913
- if (chand->deadline_checking_enabled &&
914
- gpr_time_cmp(per_method_deadline, calld->deadline) < 0) {
915
- calld->deadline = per_method_deadline;
916
- grpc_deadline_state_reset(exec_ctx, elem, calld->deadline);
917
- }
972
+ grpc_subchannel_call *subchannel_call = NULL;
973
+ const grpc_connected_subchannel_call_args call_args = {
974
+ .pollent = calld->pollent,
975
+ .path = calld->path,
976
+ .start_time = calld->call_start_time,
977
+ .deadline = calld->deadline,
978
+ .arena = calld->arena,
979
+ .context = calld->subchannel_call_context};
980
+ grpc_error *new_error = grpc_connected_subchannel_create_call(
981
+ exec_ctx, calld->connected_subchannel, &call_args, &subchannel_call);
982
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
983
+ gpr_log(GPR_DEBUG, "chand=%p calld=%p: create subchannel_call=%p: error=%s",
984
+ elem->channel_data, calld, subchannel_call,
985
+ grpc_error_string(new_error));
986
+ }
987
+ GPR_ASSERT(set_call_or_error(
988
+ calld, (call_or_error){.subchannel_call = subchannel_call}));
989
+ if (new_error != GRPC_ERROR_NONE) {
990
+ new_error = grpc_error_add_child(new_error, error);
991
+ waiting_for_pick_batches_fail_locked(exec_ctx, elem, new_error);
992
+ } else {
993
+ waiting_for_pick_batches_resume_locked(exec_ctx, elem);
918
994
  }
995
+ GRPC_ERROR_UNREF(error);
919
996
  }
920
997
 
921
- static void subchannel_ready_locked(grpc_exec_ctx *exec_ctx, void *arg,
998
+ static void subchannel_ready_locked(grpc_exec_ctx *exec_ctx,
999
+ grpc_call_element *elem,
922
1000
  grpc_error *error) {
923
- grpc_call_element *elem = arg;
924
1001
  call_data *calld = elem->call_data;
925
1002
  channel_data *chand = elem->channel_data;
926
- GPR_ASSERT(calld->pick_pending);
927
- calld->pick_pending = false;
928
1003
  grpc_polling_entity_del_from_pollset_set(exec_ctx, calld->pollent,
929
1004
  chand->interested_parties);
1005
+ call_or_error coe = get_call_or_error(calld);
930
1006
  if (calld->connected_subchannel == NULL) {
931
- gpr_atm_no_barrier_store(&calld->subchannel_call, (gpr_atm)CANCELLED_CALL);
932
- fail_locked(exec_ctx, calld,
933
- error == GRPC_ERROR_NONE
934
- ? GRPC_ERROR_CREATE_FROM_STATIC_STRING(
935
- "Call dropped by load balancing policy")
936
- : GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
937
- "Failed to create subchannel", &error, 1));
938
- } else if (GET_CALL(calld) == CANCELLED_CALL) {
1007
+ // Failed to create subchannel.
1008
+ grpc_error *failure =
1009
+ error == GRPC_ERROR_NONE
1010
+ ? GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1011
+ "Call dropped by load balancing policy")
1012
+ : GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
1013
+ "Failed to create subchannel", &error, 1);
1014
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1015
+ gpr_log(GPR_DEBUG,
1016
+ "chand=%p calld=%p: failed to create subchannel: error=%s", chand,
1017
+ calld, grpc_error_string(failure));
1018
+ }
1019
+ set_call_or_error(calld, (call_or_error){.error = GRPC_ERROR_REF(failure)});
1020
+ waiting_for_pick_batches_fail_locked(exec_ctx, elem, failure);
1021
+ } else if (coe.error != GRPC_ERROR_NONE) {
939
1022
  /* already cancelled before subchannel became ready */
1023
+ grpc_error *child_errors[] = {error, coe.error};
940
1024
  grpc_error *cancellation_error =
941
1025
  GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
942
- "Cancelled before creating subchannel", &error, 1);
1026
+ "Cancelled before creating subchannel", child_errors,
1027
+ GPR_ARRAY_SIZE(child_errors));
943
1028
  /* if due to deadline, attach the deadline exceeded status to the error */
944
1029
  if (gpr_time_cmp(calld->deadline, gpr_now(GPR_CLOCK_MONOTONIC)) < 0) {
945
1030
  cancellation_error =
946
1031
  grpc_error_set_int(cancellation_error, GRPC_ERROR_INT_GRPC_STATUS,
947
1032
  GRPC_STATUS_DEADLINE_EXCEEDED);
948
1033
  }
949
- fail_locked(exec_ctx, calld, cancellation_error);
1034
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1035
+ gpr_log(GPR_DEBUG,
1036
+ "chand=%p calld=%p: cancelled before subchannel became ready: %s",
1037
+ chand, calld, grpc_error_string(cancellation_error));
1038
+ }
1039
+ waiting_for_pick_batches_fail_locked(exec_ctx, elem, cancellation_error);
950
1040
  } else {
951
1041
  /* Create call on subchannel. */
952
- grpc_subchannel_call *subchannel_call = NULL;
953
- const grpc_connected_subchannel_call_args call_args = {
954
- .pollent = calld->pollent,
955
- .path = calld->path,
956
- .start_time = calld->call_start_time,
957
- .deadline = calld->deadline,
958
- .arena = calld->arena,
959
- .context = calld->subchannel_call_context};
960
- grpc_error *new_error = grpc_connected_subchannel_create_call(
961
- exec_ctx, calld->connected_subchannel, &call_args, &subchannel_call);
962
- gpr_atm_rel_store(&calld->subchannel_call,
963
- (gpr_atm)(uintptr_t)subchannel_call);
964
- if (new_error != GRPC_ERROR_NONE) {
965
- new_error = grpc_error_add_child(new_error, error);
966
- fail_locked(exec_ctx, calld, new_error);
967
- } else {
968
- retry_waiting_locked(exec_ctx, calld);
969
- }
1042
+ create_subchannel_call_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
970
1043
  }
971
1044
  GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "pick_subchannel");
1045
+ GRPC_ERROR_UNREF(error);
972
1046
  }
973
1047
 
974
1048
  static char *cc_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
975
1049
  call_data *calld = elem->call_data;
976
- grpc_subchannel_call *subchannel_call = GET_CALL(calld);
977
- if (subchannel_call == NULL || subchannel_call == CANCELLED_CALL) {
1050
+ grpc_subchannel_call *subchannel_call =
1051
+ get_call_or_error(calld).subchannel_call;
1052
+ if (subchannel_call == NULL) {
978
1053
  return NULL;
979
1054
  } else {
980
1055
  return grpc_subchannel_call_get_peer(exec_ctx, subchannel_call);
981
1056
  }
982
1057
  }
983
1058
 
1059
+ /** Return true if subchannel is available immediately (in which case
1060
+ subchannel_ready_locked() should not be called), or false otherwise (in
1061
+ which case subchannel_ready_locked() should be called when the subchannel
1062
+ is available). */
1063
+ static bool pick_subchannel_locked(grpc_exec_ctx *exec_ctx,
1064
+ grpc_call_element *elem);
1065
+
984
1066
  typedef struct {
985
- grpc_metadata_batch *initial_metadata;
986
- uint32_t initial_metadata_flags;
987
- grpc_connected_subchannel **connected_subchannel;
988
- grpc_call_context_element *subchannel_call_context;
989
- grpc_closure *on_ready;
990
1067
  grpc_call_element *elem;
1068
+ bool cancelled;
991
1069
  grpc_closure closure;
992
- } continue_picking_args;
1070
+ } pick_after_resolver_result_args;
993
1071
 
994
- /** Return true if subchannel is available immediately (in which case on_ready
995
- should not be called), or false otherwise (in which case on_ready should be
996
- called when the subchannel is available). */
997
- static bool pick_subchannel_locked(
998
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
999
- grpc_metadata_batch *initial_metadata, uint32_t initial_metadata_flags,
1000
- grpc_connected_subchannel **connected_subchannel,
1001
- grpc_call_context_element *subchannel_call_context, grpc_closure *on_ready);
1002
-
1003
- static void continue_picking_locked(grpc_exec_ctx *exec_ctx, void *arg,
1004
- grpc_error *error) {
1005
- continue_picking_args *cpa = arg;
1006
- if (cpa->connected_subchannel == NULL) {
1072
+ static void pick_after_resolver_result_done_locked(grpc_exec_ctx *exec_ctx,
1073
+ void *arg,
1074
+ grpc_error *error) {
1075
+ pick_after_resolver_result_args *args = arg;
1076
+ if (args->cancelled) {
1007
1077
  /* cancelled, do nothing */
1008
- } else if (error != GRPC_ERROR_NONE) {
1009
- grpc_closure_sched(exec_ctx, cpa->on_ready, GRPC_ERROR_REF(error));
1078
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1079
+ gpr_log(GPR_DEBUG, "call cancelled before resolver result");
1080
+ }
1010
1081
  } else {
1011
- if (pick_subchannel_locked(exec_ctx, cpa->elem, cpa->initial_metadata,
1012
- cpa->initial_metadata_flags,
1013
- cpa->connected_subchannel,
1014
- cpa->subchannel_call_context, cpa->on_ready)) {
1015
- grpc_closure_sched(exec_ctx, cpa->on_ready, GRPC_ERROR_NONE);
1082
+ channel_data *chand = args->elem->channel_data;
1083
+ call_data *calld = args->elem->call_data;
1084
+ if (error != GRPC_ERROR_NONE) {
1085
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1086
+ gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver failed to return data",
1087
+ chand, calld);
1088
+ }
1089
+ subchannel_ready_locked(exec_ctx, args->elem, GRPC_ERROR_REF(error));
1090
+ } else {
1091
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1092
+ gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver returned, doing pick",
1093
+ chand, calld);
1094
+ }
1095
+ if (pick_subchannel_locked(exec_ctx, args->elem)) {
1096
+ subchannel_ready_locked(exec_ctx, args->elem, GRPC_ERROR_NONE);
1097
+ }
1016
1098
  }
1017
1099
  }
1018
- gpr_free(cpa);
1100
+ gpr_free(args);
1019
1101
  }
1020
1102
 
1021
- static void cancel_pick_locked(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
1022
- grpc_error *error) {
1103
+ static void pick_after_resolver_result_start_locked(grpc_exec_ctx *exec_ctx,
1104
+ grpc_call_element *elem) {
1023
1105
  channel_data *chand = elem->channel_data;
1024
1106
  call_data *calld = elem->call_data;
1025
- if (chand->lb_policy != NULL) {
1026
- grpc_lb_policy_cancel_pick_locked(exec_ctx, chand->lb_policy,
1027
- &calld->connected_subchannel,
1028
- GRPC_ERROR_REF(error));
1029
- }
1030
- for (grpc_closure *closure = chand->waiting_for_config_closures.head;
1107
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1108
+ gpr_log(GPR_DEBUG,
1109
+ "chand=%p calld=%p: deferring pick pending resolver result", chand,
1110
+ calld);
1111
+ }
1112
+ pick_after_resolver_result_args *args =
1113
+ (pick_after_resolver_result_args *)gpr_zalloc(sizeof(*args));
1114
+ args->elem = elem;
1115
+ GRPC_CLOSURE_INIT(&args->closure, pick_after_resolver_result_done_locked,
1116
+ args, grpc_combiner_scheduler(chand->combiner));
1117
+ grpc_closure_list_append(&chand->waiting_for_resolver_result_closures,
1118
+ &args->closure, GRPC_ERROR_NONE);
1119
+ }
1120
+
1121
+ static void pick_after_resolver_result_cancel_locked(grpc_exec_ctx *exec_ctx,
1122
+ grpc_call_element *elem,
1123
+ grpc_error *error) {
1124
+ channel_data *chand = elem->channel_data;
1125
+ call_data *calld = elem->call_data;
1126
+ // If we don't yet have a resolver result, then a closure for
1127
+ // pick_after_resolver_result_done_locked() will have been added to
1128
+ // chand->waiting_for_resolver_result_closures, and it may not be invoked
1129
+ // until after this call has been destroyed. We mark the operation as
1130
+ // cancelled, so that when pick_after_resolver_result_done_locked()
1131
+ // is called, it will be a no-op. We also immediately invoke
1132
+ // subchannel_ready_locked() to propagate the error back to the caller.
1133
+ for (grpc_closure *closure = chand->waiting_for_resolver_result_closures.head;
1031
1134
  closure != NULL; closure = closure->next_data.next) {
1032
- continue_picking_args *cpa = closure->cb_arg;
1033
- if (cpa->connected_subchannel == &calld->connected_subchannel) {
1034
- cpa->connected_subchannel = NULL;
1035
- grpc_closure_sched(exec_ctx, cpa->on_ready,
1036
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
1037
- "Pick cancelled", &error, 1));
1135
+ pick_after_resolver_result_args *args = closure->cb_arg;
1136
+ if (!args->cancelled && args->elem == elem) {
1137
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1138
+ gpr_log(GPR_DEBUG,
1139
+ "chand=%p calld=%p: "
1140
+ "cancelling pick waiting for resolver result",
1141
+ chand, calld);
1142
+ }
1143
+ args->cancelled = true;
1144
+ subchannel_ready_locked(exec_ctx, elem,
1145
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
1146
+ "Pick cancelled", &error, 1));
1038
1147
  }
1039
1148
  }
1040
1149
  GRPC_ERROR_UNREF(error);
1041
1150
  }
1042
1151
 
1043
- static bool pick_subchannel_locked(
1044
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
1045
- grpc_metadata_batch *initial_metadata, uint32_t initial_metadata_flags,
1046
- grpc_connected_subchannel **connected_subchannel,
1047
- grpc_call_context_element *subchannel_call_context,
1048
- grpc_closure *on_ready) {
1049
- GPR_TIMER_BEGIN("pick_subchannel", 0);
1152
+ // Callback invoked by grpc_lb_policy_pick_locked() for async picks.
1153
+ // Unrefs the LB policy after invoking subchannel_ready_locked().
1154
+ static void pick_callback_done_locked(grpc_exec_ctx *exec_ctx, void *arg,
1155
+ grpc_error *error) {
1156
+ grpc_call_element *elem = arg;
1157
+ channel_data *chand = elem->channel_data;
1158
+ call_data *calld = elem->call_data;
1159
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1160
+ gpr_log(GPR_DEBUG, "chand=%p calld=%p: pick completed asynchronously",
1161
+ chand, calld);
1162
+ }
1163
+ GPR_ASSERT(calld->lb_policy != NULL);
1164
+ GRPC_LB_POLICY_UNREF(exec_ctx, calld->lb_policy, "pick_subchannel");
1165
+ calld->lb_policy = NULL;
1166
+ subchannel_ready_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
1167
+ }
1050
1168
 
1169
+ // Takes a ref to chand->lb_policy and calls grpc_lb_policy_pick_locked().
1170
+ // If the pick was completed synchronously, unrefs the LB policy and
1171
+ // returns true.
1172
+ static bool pick_callback_start_locked(grpc_exec_ctx *exec_ctx,
1173
+ grpc_call_element *elem,
1174
+ const grpc_lb_policy_pick_args *inputs) {
1051
1175
  channel_data *chand = elem->channel_data;
1052
1176
  call_data *calld = elem->call_data;
1177
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1178
+ gpr_log(GPR_DEBUG, "chand=%p calld=%p: starting pick on lb_policy=%p",
1179
+ chand, calld, chand->lb_policy);
1180
+ }
1181
+ // Keep a ref to the LB policy in calld while the pick is pending.
1182
+ GRPC_LB_POLICY_REF(chand->lb_policy, "pick_subchannel");
1183
+ calld->lb_policy = chand->lb_policy;
1184
+ GRPC_CLOSURE_INIT(&calld->lb_pick_closure, pick_callback_done_locked, elem,
1185
+ grpc_combiner_scheduler(chand->combiner));
1186
+ const bool pick_done = grpc_lb_policy_pick_locked(
1187
+ exec_ctx, chand->lb_policy, inputs, &calld->connected_subchannel,
1188
+ calld->subchannel_call_context, NULL, &calld->lb_pick_closure);
1189
+ if (pick_done) {
1190
+ /* synchronous grpc_lb_policy_pick call. Unref the LB policy. */
1191
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1192
+ gpr_log(GPR_DEBUG, "chand=%p calld=%p: pick completed synchronously",
1193
+ chand, calld);
1194
+ }
1195
+ GRPC_LB_POLICY_UNREF(exec_ctx, calld->lb_policy, "pick_subchannel");
1196
+ calld->lb_policy = NULL;
1197
+ }
1198
+ return pick_done;
1199
+ }
1053
1200
 
1054
- GPR_ASSERT(connected_subchannel);
1201
+ static void pick_callback_cancel_locked(grpc_exec_ctx *exec_ctx,
1202
+ grpc_call_element *elem,
1203
+ grpc_error *error) {
1204
+ channel_data *chand = elem->channel_data;
1205
+ call_data *calld = elem->call_data;
1206
+ GPR_ASSERT(calld->lb_policy != NULL);
1207
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1208
+ gpr_log(GPR_DEBUG, "chand=%p calld=%p: cancelling pick from LB policy %p",
1209
+ chand, calld, calld->lb_policy);
1210
+ }
1211
+ grpc_lb_policy_cancel_pick_locked(exec_ctx, calld->lb_policy,
1212
+ &calld->connected_subchannel, error);
1213
+ }
1055
1214
 
1215
+ static bool pick_subchannel_locked(grpc_exec_ctx *exec_ctx,
1216
+ grpc_call_element *elem) {
1217
+ GPR_TIMER_BEGIN("pick_subchannel", 0);
1218
+ channel_data *chand = elem->channel_data;
1219
+ call_data *calld = elem->call_data;
1220
+ bool pick_done = false;
1056
1221
  if (chand->lb_policy != NULL) {
1057
- apply_final_configuration_locked(exec_ctx, elem);
1058
- grpc_lb_policy *lb_policy = chand->lb_policy;
1059
- GRPC_LB_POLICY_REF(lb_policy, "pick_subchannel");
1222
+ apply_service_config_to_call_locked(exec_ctx, elem);
1060
1223
  // If the application explicitly set wait_for_ready, use that.
1061
1224
  // Otherwise, if the service config specified a value for this
1062
1225
  // method, use that.
1226
+ uint32_t initial_metadata_flags =
1227
+ calld->initial_metadata_payload->send_initial_metadata
1228
+ .send_initial_metadata_flags;
1063
1229
  const bool wait_for_ready_set_from_api =
1064
1230
  initial_metadata_flags &
1065
1231
  GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET;
@@ -1075,169 +1241,108 @@ static bool pick_subchannel_locked(
1075
1241
  }
1076
1242
  }
1077
1243
  const grpc_lb_policy_pick_args inputs = {
1078
- initial_metadata, initial_metadata_flags, &calld->lb_token_mdelem};
1079
-
1080
- // Wrap the user-provided callback in order to hold a strong reference to
1081
- // the LB policy for the duration of the pick.
1082
- wrapped_on_pick_closure_arg *w_on_pick_arg =
1083
- gpr_zalloc(sizeof(*w_on_pick_arg));
1084
- grpc_closure_init(&w_on_pick_arg->wrapper_closure,
1085
- wrapped_on_pick_closure_cb, w_on_pick_arg,
1086
- grpc_schedule_on_exec_ctx);
1087
- w_on_pick_arg->wrapped_closure = on_ready;
1088
- GRPC_LB_POLICY_REF(lb_policy, "pick_subchannel_wrapping");
1089
- w_on_pick_arg->lb_policy = lb_policy;
1090
- const bool pick_done = grpc_lb_policy_pick_locked(
1091
- exec_ctx, lb_policy, &inputs, connected_subchannel,
1092
- subchannel_call_context, NULL, &w_on_pick_arg->wrapper_closure);
1093
- if (pick_done) {
1094
- /* synchronous grpc_lb_policy_pick call. Unref the LB policy. */
1095
- GRPC_LB_POLICY_UNREF(exec_ctx, w_on_pick_arg->lb_policy,
1096
- "pick_subchannel_wrapping");
1097
- gpr_free(w_on_pick_arg);
1244
+ calld->initial_metadata_payload->send_initial_metadata
1245
+ .send_initial_metadata,
1246
+ initial_metadata_flags, &calld->lb_token_mdelem};
1247
+ pick_done = pick_callback_start_locked(exec_ctx, elem, &inputs);
1248
+ } else if (chand->resolver != NULL) {
1249
+ if (!chand->started_resolving) {
1250
+ start_resolving_locked(exec_ctx, chand);
1098
1251
  }
1099
- GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "pick_subchannel");
1100
- GPR_TIMER_END("pick_subchannel", 0);
1101
- return pick_done;
1102
- }
1103
- if (chand->resolver != NULL && !chand->started_resolving) {
1104
- chand->started_resolving = true;
1105
- GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver");
1106
- grpc_resolver_next_locked(exec_ctx, chand->resolver,
1107
- &chand->resolver_result,
1108
- &chand->on_resolver_result_changed);
1109
- }
1110
- if (chand->resolver != NULL) {
1111
- continue_picking_args *cpa = gpr_malloc(sizeof(*cpa));
1112
- cpa->initial_metadata = initial_metadata;
1113
- cpa->initial_metadata_flags = initial_metadata_flags;
1114
- cpa->connected_subchannel = connected_subchannel;
1115
- cpa->subchannel_call_context = subchannel_call_context;
1116
- cpa->on_ready = on_ready;
1117
- cpa->elem = elem;
1118
- grpc_closure_init(&cpa->closure, continue_picking_locked, cpa,
1119
- grpc_combiner_scheduler(chand->combiner, true));
1120
- grpc_closure_list_append(&chand->waiting_for_config_closures, &cpa->closure,
1121
- GRPC_ERROR_NONE);
1252
+ pick_after_resolver_result_start_locked(exec_ctx, elem);
1122
1253
  } else {
1123
- grpc_closure_sched(exec_ctx, on_ready,
1124
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Disconnected"));
1254
+ subchannel_ready_locked(
1255
+ exec_ctx, elem, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Disconnected"));
1125
1256
  }
1126
-
1127
1257
  GPR_TIMER_END("pick_subchannel", 0);
1128
- return false;
1258
+ return pick_done;
1129
1259
  }
1130
1260
 
1131
- static void start_transport_stream_op_batch_locked_inner(
1132
- grpc_exec_ctx *exec_ctx, grpc_transport_stream_op_batch *op,
1133
- grpc_call_element *elem) {
1134
- channel_data *chand = elem->channel_data;
1261
+ static void start_transport_stream_op_batch_locked(grpc_exec_ctx *exec_ctx,
1262
+ void *arg,
1263
+ grpc_error *error_ignored) {
1264
+ GPR_TIMER_BEGIN("start_transport_stream_op_batch_locked", 0);
1265
+ grpc_transport_stream_op_batch *batch = arg;
1266
+ grpc_call_element *elem = batch->handler_private.extra_arg;
1135
1267
  call_data *calld = elem->call_data;
1136
- grpc_subchannel_call *call;
1137
-
1268
+ channel_data *chand = elem->channel_data;
1138
1269
  /* need to recheck that another thread hasn't set the call */
1139
- call = GET_CALL(calld);
1140
- if (call == CANCELLED_CALL) {
1270
+ call_or_error coe = get_call_or_error(calld);
1271
+ if (coe.error != GRPC_ERROR_NONE) {
1272
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1273
+ gpr_log(GPR_DEBUG, "chand=%p calld=%p: failing batch with error: %s",
1274
+ chand, calld, grpc_error_string(coe.error));
1275
+ }
1141
1276
  grpc_transport_stream_op_batch_finish_with_failure(
1142
- exec_ctx, op, GRPC_ERROR_REF(calld->cancel_error));
1143
- /* early out */
1144
- return;
1145
- }
1146
- if (call != NULL) {
1147
- grpc_subchannel_call_process_op(exec_ctx, call, op);
1148
- /* early out */
1149
- return;
1150
- }
1151
- /* if this is a cancellation, then we can raise our cancelled flag */
1152
- if (op->cancel_stream) {
1153
- if (!gpr_atm_rel_cas(&calld->subchannel_call, 0,
1154
- (gpr_atm)(uintptr_t)CANCELLED_CALL)) {
1155
- /* recurse to retry */
1156
- start_transport_stream_op_batch_locked_inner(exec_ctx, op, elem);
1157
- /* early out */
1158
- return;
1277
+ exec_ctx, batch, GRPC_ERROR_REF(coe.error));
1278
+ goto done;
1279
+ }
1280
+ if (coe.subchannel_call != NULL) {
1281
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1282
+ gpr_log(GPR_DEBUG,
1283
+ "chand=%p calld=%p: sending batch to subchannel_call=%p", chand,
1284
+ calld, coe.subchannel_call);
1285
+ }
1286
+ grpc_subchannel_call_process_op(exec_ctx, coe.subchannel_call, batch);
1287
+ goto done;
1288
+ }
1289
+ // Add to waiting-for-pick list. If we succeed in getting a
1290
+ // subchannel call below, we'll handle this batch (along with any
1291
+ // other waiting batches) in waiting_for_pick_batches_resume_locked().
1292
+ waiting_for_pick_batches_add_locked(calld, batch);
1293
+ // If this is a cancellation, cancel the pending pick (if any) and
1294
+ // fail any pending batches.
1295
+ if (batch->cancel_stream) {
1296
+ grpc_error *error = batch->payload->cancel_stream.cancel_error;
1297
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1298
+ gpr_log(GPR_DEBUG, "chand=%p calld=%p: recording cancel_error=%s", chand,
1299
+ calld, grpc_error_string(error));
1300
+ }
1301
+ /* Stash a copy of cancel_error in our call data, so that we can use
1302
+ it for subsequent operations. This ensures that if the call is
1303
+ cancelled before any batches are passed down (e.g., if the deadline
1304
+ is in the past when the call starts), we can return the right
1305
+ error to the caller when the first batch does get passed down. */
1306
+ set_call_or_error(calld, (call_or_error){.error = GRPC_ERROR_REF(error)});
1307
+ if (calld->lb_policy != NULL) {
1308
+ pick_callback_cancel_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
1159
1309
  } else {
1160
- /* Stash a copy of cancel_error in our call data, so that we can use
1161
- it for subsequent operations. This ensures that if the call is
1162
- cancelled before any ops are passed down (e.g., if the deadline
1163
- is in the past when the call starts), we can return the right
1164
- error to the caller when the first op does get passed down. */
1165
- calld->cancel_error =
1166
- GRPC_ERROR_REF(op->payload->cancel_stream.cancel_error);
1167
- if (calld->pick_pending) {
1168
- cancel_pick_locked(
1169
- exec_ctx, elem,
1170
- GRPC_ERROR_REF(op->payload->cancel_stream.cancel_error));
1171
- } else {
1172
- fail_locked(exec_ctx, calld,
1173
- GRPC_ERROR_REF(op->payload->cancel_stream.cancel_error));
1174
- }
1175
- grpc_transport_stream_op_batch_finish_with_failure(
1176
- exec_ctx, op,
1177
- GRPC_ERROR_REF(op->payload->cancel_stream.cancel_error));
1178
- /* early out */
1179
- return;
1310
+ pick_after_resolver_result_cancel_locked(exec_ctx, elem,
1311
+ GRPC_ERROR_REF(error));
1180
1312
  }
1313
+ waiting_for_pick_batches_fail_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
1314
+ goto done;
1181
1315
  }
1182
1316
  /* if we don't have a subchannel, try to get one */
1183
- if (!calld->pick_pending && calld->connected_subchannel == NULL &&
1184
- op->send_initial_metadata) {
1185
- calld->pick_pending = true;
1186
- grpc_closure_init(&calld->next_step, subchannel_ready_locked, elem,
1187
- grpc_combiner_scheduler(chand->combiner, true));
1317
+ if (batch->send_initial_metadata) {
1318
+ GPR_ASSERT(calld->connected_subchannel == NULL);
1319
+ calld->initial_metadata_payload = batch->payload;
1188
1320
  GRPC_CALL_STACK_REF(calld->owning_call, "pick_subchannel");
1189
1321
  /* If a subchannel is not available immediately, the polling entity from
1190
1322
  call_data should be provided to channel_data's interested_parties, so
1191
1323
  that IO of the lb_policy and resolver could be done under it. */
1192
- if (pick_subchannel_locked(
1193
- exec_ctx, elem,
1194
- op->payload->send_initial_metadata.send_initial_metadata,
1195
- op->payload->send_initial_metadata.send_initial_metadata_flags,
1196
- &calld->connected_subchannel, calld->subchannel_call_context,
1197
- &calld->next_step)) {
1198
- calld->pick_pending = false;
1324
+ if (pick_subchannel_locked(exec_ctx, elem)) {
1325
+ // Pick was returned synchronously.
1199
1326
  GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "pick_subchannel");
1200
1327
  if (calld->connected_subchannel == NULL) {
1201
- gpr_atm_no_barrier_store(&calld->subchannel_call,
1202
- (gpr_atm)CANCELLED_CALL);
1203
1328
  grpc_error *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1204
1329
  "Call dropped by load balancing policy");
1205
- fail_locked(exec_ctx, calld, GRPC_ERROR_REF(error));
1206
- grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, op, error);
1207
- return; // Early out.
1330
+ set_call_or_error(calld,
1331
+ (call_or_error){.error = GRPC_ERROR_REF(error)});
1332
+ waiting_for_pick_batches_fail_locked(exec_ctx, elem, error);
1333
+ } else {
1334
+ // Create subchannel call.
1335
+ create_subchannel_call_locked(exec_ctx, elem, GRPC_ERROR_NONE);
1208
1336
  }
1209
1337
  } else {
1210
1338
  grpc_polling_entity_add_to_pollset_set(exec_ctx, calld->pollent,
1211
1339
  chand->interested_parties);
1212
1340
  }
1213
1341
  }
1214
- /* if we've got a subchannel, then let's ask it to create a call */
1215
- if (!calld->pick_pending && calld->connected_subchannel != NULL) {
1216
- grpc_subchannel_call *subchannel_call = NULL;
1217
- const grpc_connected_subchannel_call_args call_args = {
1218
- .pollent = calld->pollent,
1219
- .path = calld->path,
1220
- .start_time = calld->call_start_time,
1221
- .deadline = calld->deadline,
1222
- .arena = calld->arena,
1223
- .context = calld->subchannel_call_context};
1224
- grpc_error *error = grpc_connected_subchannel_create_call(
1225
- exec_ctx, calld->connected_subchannel, &call_args, &subchannel_call);
1226
- gpr_atm_rel_store(&calld->subchannel_call,
1227
- (gpr_atm)(uintptr_t)subchannel_call);
1228
- if (error != GRPC_ERROR_NONE) {
1229
- fail_locked(exec_ctx, calld, GRPC_ERROR_REF(error));
1230
- grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, op, error);
1231
- } else {
1232
- retry_waiting_locked(exec_ctx, calld);
1233
- /* recurse to retry */
1234
- start_transport_stream_op_batch_locked_inner(exec_ctx, op, elem);
1235
- }
1236
- /* early out */
1237
- return;
1238
- }
1239
- /* nothing to be done but wait */
1240
- add_waiting_locked(calld, op);
1342
+ done:
1343
+ GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call,
1344
+ "start_transport_stream_op_batch");
1345
+ GPR_TIMER_END("start_transport_stream_op_batch_locked", 0);
1241
1346
  }
1242
1347
 
1243
1348
  static void on_complete(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
@@ -1256,34 +1361,10 @@ static void on_complete(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
1256
1361
  calld->retry_throttle_data);
1257
1362
  }
1258
1363
  }
1259
- grpc_closure_run(exec_ctx, calld->original_on_complete,
1364
+ GRPC_CLOSURE_RUN(exec_ctx, calld->original_on_complete,
1260
1365
  GRPC_ERROR_REF(error));
1261
1366
  }
1262
1367
 
1263
- static void start_transport_stream_op_batch_locked(grpc_exec_ctx *exec_ctx,
1264
- void *arg,
1265
- grpc_error *error_ignored) {
1266
- GPR_TIMER_BEGIN("start_transport_stream_op_batch_locked", 0);
1267
-
1268
- grpc_transport_stream_op_batch *op = arg;
1269
- grpc_call_element *elem = op->handler_private.extra_arg;
1270
- call_data *calld = elem->call_data;
1271
-
1272
- if (op->recv_trailing_metadata) {
1273
- GPR_ASSERT(op->on_complete != NULL);
1274
- calld->original_on_complete = op->on_complete;
1275
- grpc_closure_init(&calld->on_complete, on_complete, elem,
1276
- grpc_schedule_on_exec_ctx);
1277
- op->on_complete = &calld->on_complete;
1278
- }
1279
-
1280
- start_transport_stream_op_batch_locked_inner(exec_ctx, op, elem);
1281
-
1282
- GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call,
1283
- "start_transport_stream_op_batch");
1284
- GPR_TIMER_END("start_transport_stream_op_batch_locked", 0);
1285
- }
1286
-
1287
1368
  /* The logic here is fairly complicated, due to (a) the fact that we
1288
1369
  need to handle the case where we receive the send op before the
1289
1370
  initial metadata op, and (b) the need for efficiency, especially in
@@ -1294,39 +1375,59 @@ static void start_transport_stream_op_batch_locked(grpc_exec_ctx *exec_ctx,
1294
1375
  If it has, we proceed on the fast path. */
1295
1376
  static void cc_start_transport_stream_op_batch(
1296
1377
  grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
1297
- grpc_transport_stream_op_batch *op) {
1378
+ grpc_transport_stream_op_batch *batch) {
1298
1379
  call_data *calld = elem->call_data;
1299
1380
  channel_data *chand = elem->channel_data;
1300
- GRPC_CALL_LOG_OP(GPR_INFO, elem, op);
1381
+ if (GRPC_TRACER_ON(grpc_client_channel_trace) ||
1382
+ GRPC_TRACER_ON(grpc_trace_channel)) {
1383
+ grpc_call_log_op(GPR_INFO, elem, batch);
1384
+ }
1301
1385
  if (chand->deadline_checking_enabled) {
1302
1386
  grpc_deadline_state_client_start_transport_stream_op_batch(exec_ctx, elem,
1303
- op);
1387
+ batch);
1388
+ }
1389
+ // Intercept on_complete for recv_trailing_metadata so that we can
1390
+ // check retry throttle status.
1391
+ if (batch->recv_trailing_metadata) {
1392
+ GPR_ASSERT(batch->on_complete != NULL);
1393
+ calld->original_on_complete = batch->on_complete;
1394
+ GRPC_CLOSURE_INIT(&calld->on_complete, on_complete, elem,
1395
+ grpc_schedule_on_exec_ctx);
1396
+ batch->on_complete = &calld->on_complete;
1304
1397
  }
1305
1398
  /* try to (atomically) get the call */
1306
- grpc_subchannel_call *call = GET_CALL(calld);
1399
+ call_or_error coe = get_call_or_error(calld);
1307
1400
  GPR_TIMER_BEGIN("cc_start_transport_stream_op_batch", 0);
1308
- if (call == CANCELLED_CALL) {
1401
+ if (coe.error != GRPC_ERROR_NONE) {
1402
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1403
+ gpr_log(GPR_DEBUG, "chand=%p calld=%p: failing batch with error: %s",
1404
+ chand, calld, grpc_error_string(coe.error));
1405
+ }
1309
1406
  grpc_transport_stream_op_batch_finish_with_failure(
1310
- exec_ctx, op, GRPC_ERROR_REF(calld->cancel_error));
1311
- GPR_TIMER_END("cc_start_transport_stream_op_batch", 0);
1312
- /* early out */
1313
- return;
1314
- }
1315
- if (call != NULL) {
1316
- grpc_subchannel_call_process_op(exec_ctx, call, op);
1317
- GPR_TIMER_END("cc_start_transport_stream_op_batch", 0);
1318
- /* early out */
1319
- return;
1407
+ exec_ctx, batch, GRPC_ERROR_REF(coe.error));
1408
+ goto done;
1409
+ }
1410
+ if (coe.subchannel_call != NULL) {
1411
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1412
+ gpr_log(GPR_DEBUG,
1413
+ "chand=%p calld=%p: sending batch to subchannel_call=%p", chand,
1414
+ calld, coe.subchannel_call);
1415
+ }
1416
+ grpc_subchannel_call_process_op(exec_ctx, coe.subchannel_call, batch);
1417
+ goto done;
1320
1418
  }
1321
1419
  /* we failed; lock and figure out what to do */
1420
+ if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1421
+ gpr_log(GPR_DEBUG, "chand=%p calld=%p: entering combiner", chand, calld);
1422
+ }
1322
1423
  GRPC_CALL_STACK_REF(calld->owning_call, "start_transport_stream_op_batch");
1323
- op->handler_private.extra_arg = elem;
1324
- grpc_closure_sched(
1325
- exec_ctx,
1326
- grpc_closure_init(&op->handler_private.closure,
1327
- start_transport_stream_op_batch_locked, op,
1328
- grpc_combiner_scheduler(chand->combiner, false)),
1424
+ batch->handler_private.extra_arg = elem;
1425
+ GRPC_CLOSURE_SCHED(
1426
+ exec_ctx, GRPC_CLOSURE_INIT(&batch->handler_private.closure,
1427
+ start_transport_stream_op_batch_locked, batch,
1428
+ grpc_combiner_scheduler(chand->combiner)),
1329
1429
  GRPC_ERROR_NONE);
1430
+ done:
1330
1431
  GPR_TIMER_END("cc_start_transport_stream_op_batch", 0);
1331
1432
  }
1332
1433
 
@@ -1362,15 +1463,17 @@ static void cc_destroy_call_elem(grpc_exec_ctx *exec_ctx,
1362
1463
  if (calld->method_params != NULL) {
1363
1464
  method_parameters_unref(calld->method_params);
1364
1465
  }
1365
- GRPC_ERROR_UNREF(calld->cancel_error);
1366
- grpc_subchannel_call *call = GET_CALL(calld);
1367
- if (call != NULL && call != CANCELLED_CALL) {
1368
- grpc_subchannel_call_set_cleanup_closure(call, then_schedule_closure);
1466
+ call_or_error coe = get_call_or_error(calld);
1467
+ GRPC_ERROR_UNREF(coe.error);
1468
+ if (coe.subchannel_call != NULL) {
1469
+ grpc_subchannel_call_set_cleanup_closure(coe.subchannel_call,
1470
+ then_schedule_closure);
1369
1471
  then_schedule_closure = NULL;
1370
- GRPC_SUBCHANNEL_CALL_UNREF(exec_ctx, call, "client_channel_destroy_call");
1472
+ GRPC_SUBCHANNEL_CALL_UNREF(exec_ctx, coe.subchannel_call,
1473
+ "client_channel_destroy_call");
1371
1474
  }
1372
- GPR_ASSERT(!calld->pick_pending);
1373
- GPR_ASSERT(calld->waiting_ops_count == 0);
1475
+ GPR_ASSERT(calld->lb_policy == NULL);
1476
+ GPR_ASSERT(calld->waiting_for_pick_batches_count == 0);
1374
1477
  if (calld->connected_subchannel != NULL) {
1375
1478
  GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, calld->connected_subchannel,
1376
1479
  "picked");
@@ -1381,8 +1484,7 @@ static void cc_destroy_call_elem(grpc_exec_ctx *exec_ctx,
1381
1484
  calld->subchannel_call_context[i].value);
1382
1485
  }
1383
1486
  }
1384
- gpr_free(calld->waiting_ops);
1385
- grpc_closure_sched(exec_ctx, then_schedule_closure, GRPC_ERROR_NONE);
1487
+ GRPC_CLOSURE_SCHED(exec_ctx, then_schedule_closure, GRPC_ERROR_NONE);
1386
1488
  }
1387
1489
 
1388
1490
  static void cc_set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
@@ -1419,11 +1521,7 @@ static void try_to_connect_locked(grpc_exec_ctx *exec_ctx, void *arg,
1419
1521
  } else {
1420
1522
  chand->exit_idle_when_lb_policy_arrives = true;
1421
1523
  if (!chand->started_resolving && chand->resolver != NULL) {
1422
- GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver");
1423
- chand->started_resolving = true;
1424
- grpc_resolver_next_locked(exec_ctx, chand->resolver,
1425
- &chand->resolver_result,
1426
- &chand->on_resolver_result_changed);
1524
+ start_resolving_locked(exec_ctx, chand);
1427
1525
  }
1428
1526
  }
1429
1527
  GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->owning_stack, "try_to_connect");
@@ -1436,10 +1534,9 @@ grpc_connectivity_state grpc_client_channel_check_connectivity_state(
1436
1534
  grpc_connectivity_state_check(&chand->state_tracker);
1437
1535
  if (out == GRPC_CHANNEL_IDLE && try_to_connect) {
1438
1536
  GRPC_CHANNEL_STACK_REF(chand->owning_stack, "try_to_connect");
1439
- grpc_closure_sched(
1440
- exec_ctx,
1441
- grpc_closure_create(try_to_connect_locked, chand,
1442
- grpc_combiner_scheduler(chand->combiner, false)),
1537
+ GRPC_CLOSURE_SCHED(
1538
+ exec_ctx, GRPC_CLOSURE_CREATE(try_to_connect_locked, chand,
1539
+ grpc_combiner_scheduler(chand->combiner)),
1443
1540
  GRPC_ERROR_NONE);
1444
1541
  }
1445
1542
  return out;
@@ -1447,7 +1544,7 @@ grpc_connectivity_state grpc_client_channel_check_connectivity_state(
1447
1544
 
1448
1545
  typedef struct external_connectivity_watcher {
1449
1546
  channel_data *chand;
1450
- grpc_pollset *pollset;
1547
+ grpc_polling_entity pollent;
1451
1548
  grpc_closure *on_complete;
1452
1549
  grpc_closure *watcher_timer_init;
1453
1550
  grpc_connectivity_state *state;
@@ -1522,13 +1619,13 @@ static void on_external_watch_complete(grpc_exec_ctx *exec_ctx, void *arg,
1522
1619
  grpc_error *error) {
1523
1620
  external_connectivity_watcher *w = arg;
1524
1621
  grpc_closure *follow_up = w->on_complete;
1525
- grpc_pollset_set_del_pollset(exec_ctx, w->chand->interested_parties,
1526
- w->pollset);
1622
+ grpc_polling_entity_del_from_pollset_set(exec_ctx, &w->pollent,
1623
+ w->chand->interested_parties);
1527
1624
  GRPC_CHANNEL_STACK_UNREF(exec_ctx, w->chand->owning_stack,
1528
1625
  "external_connectivity_watcher");
1529
1626
  external_connectivity_watcher_list_remove(w->chand, w);
1530
1627
  gpr_free(w);
1531
- grpc_closure_run(exec_ctx, follow_up, GRPC_ERROR_REF(error));
1628
+ GRPC_CLOSURE_RUN(exec_ctx, follow_up, GRPC_ERROR_REF(error));
1532
1629
  }
1533
1630
 
1534
1631
  static void watch_connectivity_state_locked(grpc_exec_ctx *exec_ctx, void *arg,
@@ -1537,8 +1634,8 @@ static void watch_connectivity_state_locked(grpc_exec_ctx *exec_ctx, void *arg,
1537
1634
  external_connectivity_watcher *found = NULL;
1538
1635
  if (w->state != NULL) {
1539
1636
  external_connectivity_watcher_list_append(w->chand, w);
1540
- grpc_closure_run(exec_ctx, w->watcher_timer_init, GRPC_ERROR_NONE);
1541
- grpc_closure_init(&w->my_closure, on_external_watch_complete, w,
1637
+ GRPC_CLOSURE_RUN(exec_ctx, w->watcher_timer_init, GRPC_ERROR_NONE);
1638
+ GRPC_CLOSURE_INIT(&w->my_closure, on_external_watch_complete, w,
1542
1639
  grpc_schedule_on_exec_ctx);
1543
1640
  grpc_connectivity_state_notify_on_state_change(
1544
1641
  exec_ctx, &w->chand->state_tracker, w->state, &w->my_closure);
@@ -1550,8 +1647,8 @@ static void watch_connectivity_state_locked(grpc_exec_ctx *exec_ctx, void *arg,
1550
1647
  grpc_connectivity_state_notify_on_state_change(
1551
1648
  exec_ctx, &found->chand->state_tracker, NULL, &found->my_closure);
1552
1649
  }
1553
- grpc_pollset_set_del_pollset(exec_ctx, w->chand->interested_parties,
1554
- w->pollset);
1650
+ grpc_polling_entity_del_from_pollset_set(exec_ctx, &w->pollent,
1651
+ w->chand->interested_parties);
1555
1652
  GRPC_CHANNEL_STACK_UNREF(exec_ctx, w->chand->owning_stack,
1556
1653
  "external_connectivity_watcher");
1557
1654
  gpr_free(w);
@@ -1559,23 +1656,23 @@ static void watch_connectivity_state_locked(grpc_exec_ctx *exec_ctx, void *arg,
1559
1656
  }
1560
1657
 
1561
1658
  void grpc_client_channel_watch_connectivity_state(
1562
- grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_pollset *pollset,
1563
- grpc_connectivity_state *state, grpc_closure *closure,
1564
- grpc_closure *watcher_timer_init) {
1659
+ grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
1660
+ grpc_polling_entity pollent, grpc_connectivity_state *state,
1661
+ grpc_closure *closure, grpc_closure *watcher_timer_init) {
1565
1662
  channel_data *chand = elem->channel_data;
1566
1663
  external_connectivity_watcher *w = gpr_zalloc(sizeof(*w));
1567
1664
  w->chand = chand;
1568
- w->pollset = pollset;
1665
+ w->pollent = pollent;
1569
1666
  w->on_complete = closure;
1570
1667
  w->state = state;
1571
1668
  w->watcher_timer_init = watcher_timer_init;
1572
-
1573
- grpc_pollset_set_add_pollset(exec_ctx, chand->interested_parties, pollset);
1669
+ grpc_polling_entity_add_to_pollset_set(exec_ctx, &w->pollent,
1670
+ chand->interested_parties);
1574
1671
  GRPC_CHANNEL_STACK_REF(w->chand->owning_stack,
1575
1672
  "external_connectivity_watcher");
1576
- grpc_closure_sched(
1673
+ GRPC_CLOSURE_SCHED(
1577
1674
  exec_ctx,
1578
- grpc_closure_init(&w->my_closure, watch_connectivity_state_locked, w,
1579
- grpc_combiner_scheduler(chand->combiner, true)),
1675
+ GRPC_CLOSURE_INIT(&w->my_closure, watch_connectivity_state_locked, w,
1676
+ grpc_combiner_scheduler(chand->combiner)),
1580
1677
  GRPC_ERROR_NONE);
1581
1678
  }