grpc 1.7.3 → 1.8.0

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 (616) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +2106 -2116
  3. data/include/grpc/census.h +1 -432
  4. data/include/grpc/compression.h +9 -9
  5. data/include/grpc/grpc.h +115 -98
  6. data/include/grpc/grpc_cronet.h +3 -3
  7. data/include/grpc/grpc_posix.h +4 -4
  8. data/include/grpc/grpc_security.h +160 -88
  9. data/include/grpc/grpc_security_constants.h +7 -0
  10. data/include/grpc/impl/codegen/atm.h +9 -1
  11. data/include/grpc/impl/codegen/atm_gcc_atomic.h +13 -4
  12. data/include/grpc/impl/codegen/atm_gcc_sync.h +6 -5
  13. data/include/grpc/impl/codegen/atm_windows.h +23 -22
  14. data/include/grpc/impl/codegen/byte_buffer.h +14 -14
  15. data/include/grpc/impl/codegen/byte_buffer_reader.h +2 -2
  16. data/include/grpc/impl/codegen/connectivity_state.h +0 -2
  17. data/include/grpc/impl/codegen/grpc_types.h +32 -28
  18. data/include/grpc/impl/codegen/port_platform.h +48 -0
  19. data/include/grpc/impl/codegen/slice.h +10 -10
  20. data/include/grpc/impl/codegen/sync_generic.h +9 -3
  21. data/include/grpc/slice.h +16 -17
  22. data/include/grpc/slice_buffer.h +22 -22
  23. data/include/grpc/support/alloc.h +11 -11
  24. data/include/grpc/support/avl.h +28 -20
  25. data/include/grpc/support/cmdline.h +13 -13
  26. data/include/grpc/support/histogram.h +17 -17
  27. data/include/grpc/support/host_port.h +2 -2
  28. data/include/grpc/support/log.h +9 -9
  29. data/include/grpc/support/log_windows.h +1 -1
  30. data/include/grpc/support/string_util.h +2 -2
  31. data/include/grpc/support/subprocess.h +5 -5
  32. data/include/grpc/support/sync.h +43 -27
  33. data/include/grpc/support/thd.h +6 -6
  34. data/include/grpc/support/tls_gcc.h +1 -1
  35. data/include/grpc/support/tls_pthread.h +1 -1
  36. data/src/core/ext/census/{grpc_context.c → grpc_context.cc} +5 -8
  37. data/src/core/ext/filters/client_channel/backup_poller.cc +165 -0
  38. data/src/core/ext/{census/grpc_filter.h → filters/client_channel/backup_poller.h} +12 -7
  39. data/src/core/ext/filters/client_channel/{channel_connectivity.c → channel_connectivity.cc} +45 -42
  40. data/src/core/ext/filters/client_channel/{client_channel.c → client_channel.cc} +452 -417
  41. data/src/core/ext/filters/client_channel/client_channel.h +16 -8
  42. data/src/core/ext/filters/client_channel/{client_channel_factory.c → client_channel_factory.cc} +0 -0
  43. data/src/core/ext/filters/client_channel/client_channel_factory.h +29 -21
  44. data/src/core/ext/filters/client_channel/{client_channel_plugin.c → client_channel_plugin.cc} +15 -19
  45. data/src/core/ext/filters/client_channel/{connector.c → connector.cc} +0 -0
  46. data/src/core/ext/filters/client_channel/connector.h +29 -21
  47. data/src/core/ext/filters/client_channel/{http_connect_handshaker.c → http_connect_handshaker.cc} +10 -10
  48. data/src/core/ext/filters/client_channel/http_connect_handshaker.h +8 -0
  49. data/src/core/ext/filters/client_channel/{http_proxy.c → http_proxy.cc} +14 -14
  50. data/src/core/ext/filters/client_channel/http_proxy.h +8 -0
  51. data/src/core/ext/filters/client_channel/{lb_policy.c → lb_policy.cc} +47 -48
  52. data/src/core/ext/filters/client_channel/lb_policy.h +76 -70
  53. data/src/core/ext/filters/client_channel/lb_policy/grpclb/{client_load_reporting_filter.c → client_load_reporting_filter.cc} +28 -29
  54. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +9 -1
  55. data/src/core/ext/filters/client_channel/lb_policy/grpclb/{grpclb.c → grpclb.cc} +554 -563
  56. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +9 -1
  57. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +17 -9
  58. data/src/core/ext/filters/client_channel/lb_policy/grpclb/{grpclb_channel_secure.c → grpclb_channel_secure.cc} +17 -17
  59. data/src/core/ext/filters/client_channel/lb_policy/grpclb/{grpclb_client_stats.c → grpclb_client_stats.cc} +3 -3
  60. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +9 -1
  61. data/src/core/ext/filters/client_channel/lb_policy/grpclb/{load_balancer_api.c → load_balancer_api.cc} +64 -67
  62. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +20 -21
  63. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +599 -0
  64. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +695 -0
  65. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +270 -0
  66. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +153 -0
  67. data/src/core/ext/filters/client_channel/{lb_policy_factory.c → lb_policy_factory.cc} +10 -10
  68. data/src/core/ext/filters/client_channel/lb_policy_factory.h +48 -40
  69. data/src/core/ext/filters/client_channel/{lb_policy_registry.c → lb_policy_registry.cc} +9 -9
  70. data/src/core/ext/filters/client_channel/lb_policy_registry.h +11 -3
  71. data/src/core/ext/filters/client_channel/{parse_address.c → parse_address.cc} +24 -24
  72. data/src/core/ext/filters/client_channel/parse_address.h +14 -6
  73. data/src/core/ext/filters/client_channel/{proxy_mapper.c → proxy_mapper.cc} +0 -0
  74. data/src/core/ext/filters/client_channel/proxy_mapper.h +8 -0
  75. data/src/core/ext/filters/client_channel/{proxy_mapper_registry.c → proxy_mapper_registry.cc} +0 -0
  76. data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +8 -0
  77. data/src/core/ext/filters/client_channel/{resolver.c → resolver.cc} +21 -23
  78. data/src/core/ext/filters/client_channel/resolver.h +33 -27
  79. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/{dns_resolver_ares.c → dns_resolver_ares.cc} +133 -133
  80. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +18 -9
  81. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/{grpc_ares_ev_driver_posix.c → grpc_ares_ev_driver_posix.cc} +58 -56
  82. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/{grpc_ares_wrapper.c → grpc_ares_wrapper.cc} +118 -115
  83. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +23 -15
  84. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +60 -0
  85. data/src/core/ext/filters/client_channel/resolver/dns/native/{dns_resolver.c → dns_resolver.cc} +100 -94
  86. data/src/core/ext/filters/client_channel/resolver/fake/{fake_resolver.c → fake_resolver.cc} +14 -14
  87. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +9 -1
  88. data/src/core/ext/filters/client_channel/resolver/sockaddr/{sockaddr_resolver.c → sockaddr_resolver.cc} +60 -60
  89. data/src/core/ext/filters/client_channel/{resolver_factory.c → resolver_factory.cc} +2 -2
  90. data/src/core/ext/filters/client_channel/resolver_factory.h +27 -19
  91. data/src/core/ext/filters/client_channel/{resolver_registry.c → resolver_registry.cc} +35 -35
  92. data/src/core/ext/filters/client_channel/resolver_registry.h +18 -10
  93. data/src/core/ext/filters/client_channel/{retry_throttle.c → retry_throttle.cc} +10 -10
  94. data/src/core/ext/filters/client_channel/retry_throttle.h +8 -0
  95. data/src/core/ext/filters/client_channel/{subchannel.c → subchannel.cc} +210 -213
  96. data/src/core/ext/filters/client_channel/subchannel.h +68 -60
  97. data/src/core/ext/filters/client_channel/{subchannel_index.c → subchannel_index.cc} +52 -52
  98. data/src/core/ext/filters/client_channel/subchannel_index.h +22 -14
  99. data/src/core/ext/filters/client_channel/{uri_parser.c → uri_parser.cc} +29 -27
  100. data/src/core/ext/filters/client_channel/uri_parser.h +18 -10
  101. data/src/core/ext/filters/deadline/{deadline_filter.c → deadline_filter.cc} +12 -15
  102. data/src/core/ext/filters/deadline/deadline_filter.h +11 -2
  103. data/src/core/ext/filters/http/client/{http_client_filter.c → http_client_filter.cc} +83 -83
  104. data/src/core/ext/filters/http/client/http_client_filter.h +8 -0
  105. data/src/core/ext/filters/http/{http_filters_plugin.c → http_filters_plugin.cc} +20 -21
  106. data/src/core/ext/filters/http/message_compress/{message_compress_filter.c → message_compress_filter.cc} +84 -83
  107. data/src/core/ext/filters/http/message_compress/message_compress_filter.h +9 -1
  108. data/src/core/ext/filters/http/server/{http_server_filter.c → http_server_filter.cc} +80 -78
  109. data/src/core/ext/filters/http/server/http_server_filter.h +8 -0
  110. data/src/core/ext/filters/load_reporting/{server_load_reporting_filter.c → server_load_reporting_filter.cc} +29 -29
  111. data/src/core/ext/filters/load_reporting/server_load_reporting_filter.h +9 -1
  112. data/src/core/ext/filters/load_reporting/{server_load_reporting_plugin.c → server_load_reporting_plugin.cc} +11 -11
  113. data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h +13 -5
  114. data/src/core/ext/filters/max_age/{max_age_filter.c → max_age_filter.cc} +46 -56
  115. data/src/core/ext/filters/max_age/max_age_filter.h +8 -0
  116. data/src/core/ext/filters/message_size/{message_size_filter.c → message_size_filter.cc} +62 -40
  117. data/src/core/ext/filters/message_size/message_size_filter.h +8 -0
  118. data/src/core/ext/filters/workarounds/{workaround_cronet_compression_filter.c → workaround_cronet_compression_filter.cc} +11 -11
  119. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +8 -0
  120. data/src/core/ext/filters/workarounds/{workaround_utils.c → workaround_utils.cc} +7 -7
  121. data/src/core/ext/filters/workarounds/workaround_utils.h +9 -1
  122. data/src/core/ext/transport/chttp2/alpn/{alpn.c → alpn.cc} +3 -3
  123. data/src/core/ext/transport/chttp2/alpn/alpn.h +10 -2
  124. data/src/core/ext/transport/chttp2/client/{chttp2_connector.c → chttp2_connector.cc} +49 -45
  125. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +8 -0
  126. data/src/core/ext/transport/chttp2/client/insecure/{channel_create.c → channel_create.cc} +28 -27
  127. data/src/core/ext/transport/chttp2/client/insecure/{channel_create_posix.c → channel_create_posix.cc} +14 -13
  128. data/src/core/ext/transport/chttp2/client/secure/{secure_channel_create.c → secure_channel_create.cc} +68 -66
  129. data/src/core/ext/transport/chttp2/server/{chttp2_server.c → chttp2_server.cc} +76 -77
  130. data/src/core/ext/transport/chttp2/server/chttp2_server.h +11 -3
  131. data/src/core/ext/transport/chttp2/server/insecure/{server_chttp2.c → server_chttp2.cc} +3 -3
  132. data/src/core/ext/transport/chttp2/server/insecure/{server_chttp2_posix.c → server_chttp2_posix.cc} +13 -12
  133. data/src/core/ext/transport/chttp2/server/secure/{server_secure_chttp2.c → server_secure_chttp2.cc} +12 -10
  134. data/src/core/ext/transport/chttp2/transport/{bin_decoder.c → bin_decoder.cc} +7 -7
  135. data/src/core/ext/transport/chttp2/transport/bin_decoder.h +15 -7
  136. data/src/core/ext/transport/chttp2/transport/{bin_encoder.c → bin_encoder.cc} +11 -11
  137. data/src/core/ext/transport/chttp2/transport/bin_encoder.h +8 -0
  138. data/src/core/ext/transport/chttp2/transport/{chttp2_plugin.c → chttp2_plugin.cc} +2 -9
  139. data/src/core/ext/transport/chttp2/transport/{chttp2_transport.c → chttp2_transport.cc} +778 -778
  140. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +14 -10
  141. data/src/core/ext/transport/chttp2/transport/flow_control.cc +385 -0
  142. data/src/core/ext/transport/chttp2/transport/flow_control.h +337 -0
  143. data/src/core/ext/transport/chttp2/transport/frame.h +8 -0
  144. data/src/core/ext/transport/chttp2/transport/{frame_data.c → frame_data.cc} +34 -34
  145. data/src/core/ext/transport/chttp2/transport/frame_data.h +25 -17
  146. data/src/core/ext/transport/chttp2/transport/{frame_goaway.c → frame_goaway.cc} +18 -18
  147. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +18 -10
  148. data/src/core/ext/transport/chttp2/transport/{frame_ping.c → frame_ping.cc} +18 -19
  149. data/src/core/ext/transport/chttp2/transport/frame_ping.h +12 -4
  150. data/src/core/ext/transport/chttp2/transport/{frame_rst_stream.c → frame_rst_stream.cc} +16 -16
  151. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +16 -8
  152. data/src/core/ext/transport/chttp2/transport/{frame_settings.c → frame_settings.cc} +23 -24
  153. data/src/core/ext/transport/chttp2/transport/frame_settings.h +17 -9
  154. data/src/core/ext/transport/chttp2/transport/{frame_window_update.c → frame_window_update.cc} +22 -24
  155. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +14 -6
  156. data/src/core/ext/transport/chttp2/transport/{hpack_encoder.c → hpack_encoder.cc} +206 -161
  157. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +23 -13
  158. data/src/core/ext/transport/chttp2/transport/{hpack_parser.c → hpack_parser.cc} +340 -334
  159. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +30 -22
  160. data/src/core/ext/transport/chttp2/transport/{hpack_table.c → hpack_table.cc} +25 -25
  161. data/src/core/ext/transport/chttp2/transport/hpack_table.h +19 -11
  162. data/src/core/ext/transport/chttp2/transport/{http2_settings.c → http2_settings.cc} +1 -1
  163. data/src/core/ext/transport/chttp2/transport/http2_settings.h +10 -2
  164. data/src/core/ext/transport/chttp2/transport/{huffsyms.c → huffsyms.cc} +0 -0
  165. data/src/core/ext/transport/chttp2/transport/huffsyms.h +8 -0
  166. data/src/core/ext/transport/chttp2/transport/{incoming_metadata.c → incoming_metadata.cc} +14 -13
  167. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +18 -10
  168. data/src/core/ext/transport/chttp2/transport/internal.h +214 -340
  169. data/src/core/ext/transport/chttp2/transport/{parsing.c → parsing.cc} +152 -141
  170. data/src/core/ext/transport/chttp2/transport/{stream_lists.c → stream_lists.cc} +53 -53
  171. data/src/core/ext/transport/chttp2/transport/{stream_map.c → stream_map.cc} +35 -34
  172. data/src/core/ext/transport/chttp2/transport/stream_map.h +22 -14
  173. data/src/core/ext/transport/chttp2/transport/{varint.c → varint.cc} +0 -0
  174. data/src/core/ext/transport/chttp2/transport/varint.h +8 -0
  175. data/src/core/ext/transport/chttp2/transport/writing.cc +636 -0
  176. data/src/core/ext/transport/inproc/{inproc_plugin.c → inproc_plugin.cc} +5 -6
  177. data/src/core/ext/transport/inproc/{inproc_transport.c → inproc_transport.cc} +479 -544
  178. data/src/core/ext/transport/inproc/inproc_transport.h +4 -4
  179. data/src/core/lib/backoff/backoff.cc +80 -0
  180. data/src/core/lib/backoff/backoff.h +83 -0
  181. data/src/core/lib/channel/{channel_args.c → channel_args.cc} +92 -92
  182. data/src/core/lib/channel/channel_args.h +45 -37
  183. data/src/core/lib/channel/{channel_stack.c → channel_stack.cc} +67 -68
  184. data/src/core/lib/channel/channel_stack.h +76 -75
  185. data/src/core/lib/channel/{channel_stack_builder.c → channel_stack_builder.cc} +91 -91
  186. data/src/core/lib/channel/channel_stack_builder.h +45 -45
  187. data/src/core/lib/channel/{connected_channel.c → connected_channel.cc} +70 -70
  188. data/src/core/lib/channel/connected_channel.h +12 -4
  189. data/src/core/lib/channel/context.h +2 -2
  190. data/src/core/lib/channel/{handshaker.c → handshaker.cc} +7 -9
  191. data/src/core/lib/channel/handshaker.h +9 -1
  192. data/src/core/lib/channel/{handshaker_factory.c → handshaker_factory.cc} +7 -7
  193. data/src/core/lib/channel/handshaker_factory.h +18 -10
  194. data/src/core/lib/channel/{handshaker_registry.c → handshaker_registry.cc} +0 -0
  195. data/src/core/lib/channel/handshaker_registry.h +8 -0
  196. data/src/core/lib/compression/algorithm_metadata.h +8 -0
  197. data/src/core/lib/compression/{compression.c → compression.cc} +9 -9
  198. data/src/core/lib/compression/{message_compress.c → message_compress.cc} +0 -0
  199. data/src/core/lib/compression/message_compress.h +8 -0
  200. data/src/core/lib/compression/{stream_compression.c → stream_compression.cc} +12 -12
  201. data/src/core/lib/compression/stream_compression.h +27 -19
  202. data/src/core/lib/compression/{stream_compression_gzip.c → stream_compression_gzip.cc} +35 -36
  203. data/src/core/lib/compression/stream_compression_gzip.h +8 -0
  204. data/src/core/lib/compression/{stream_compression_identity.c → stream_compression_identity.cc} +19 -20
  205. data/src/core/lib/compression/stream_compression_identity.h +8 -0
  206. data/src/core/lib/debug/{stats.c → stats.cc} +19 -19
  207. data/src/core/lib/debug/stats.h +17 -9
  208. data/src/core/lib/debug/{stats_data.c → stats_data.cc} +45 -22
  209. data/src/core/lib/debug/stats_data.h +58 -19
  210. data/src/core/lib/debug/trace.cc +142 -0
  211. data/src/core/lib/debug/trace.h +74 -14
  212. data/src/core/lib/http/{format_request.c → format_request.cc} +10 -10
  213. data/src/core/lib/http/format_request.h +12 -4
  214. data/src/core/lib/http/{httpcli.c → httpcli.cc} +80 -80
  215. data/src/core/lib/http/httpcli.h +41 -33
  216. data/src/core/lib/http/{httpcli_security_connector.c → httpcli_security_connector.cc} +69 -55
  217. data/src/core/lib/http/{parser.c → parser.cc} +42 -42
  218. data/src/core/lib/http/parser.h +28 -20
  219. data/src/core/lib/{support → iomgr}/block_annotate.h +17 -8
  220. data/src/core/lib/iomgr/{call_combiner.c → call_combiner.cc} +29 -17
  221. data/src/core/lib/iomgr/call_combiner.h +9 -1
  222. data/src/core/lib/iomgr/closure.h +220 -62
  223. data/src/core/lib/iomgr/{combiner.c → combiner.cc} +63 -62
  224. data/src/core/lib/iomgr/combiner.h +16 -8
  225. data/src/core/lib/iomgr/{endpoint.c → endpoint.cc} +6 -0
  226. data/src/core/lib/iomgr/endpoint.h +47 -32
  227. data/src/core/lib/iomgr/endpoint_pair.h +12 -4
  228. data/src/core/lib/iomgr/{endpoint_pair_posix.c → endpoint_pair_posix.cc} +3 -3
  229. data/src/core/lib/iomgr/{endpoint_pair_uv.c → endpoint_pair_uv.cc} +2 -2
  230. data/src/core/lib/iomgr/{endpoint_pair_windows.c → endpoint_pair_windows.cc} +6 -6
  231. data/src/core/lib/iomgr/{error.c → error.cc} +125 -124
  232. data/src/core/lib/iomgr/error.h +32 -27
  233. data/src/core/lib/iomgr/error_internal.h +11 -2
  234. data/src/core/lib/iomgr/{ev_epoll1_linux.c → ev_epoll1_linux.cc} +214 -215
  235. data/src/core/lib/iomgr/ev_epoll1_linux.h +9 -1
  236. data/src/core/lib/iomgr/ev_epollex_linux.cc +1488 -0
  237. data/src/core/lib/iomgr/ev_epollex_linux.h +9 -1
  238. data/src/core/lib/iomgr/{ev_epollsig_linux.c → ev_epollsig_linux.cc} +304 -305
  239. data/src/core/lib/iomgr/ev_epollsig_linux.h +12 -4
  240. data/src/core/lib/iomgr/{ev_poll_posix.c → ev_poll_posix.cc} +272 -283
  241. data/src/core/lib/iomgr/ev_poll_posix.h +10 -2
  242. data/src/core/lib/iomgr/ev_posix.cc +288 -0
  243. data/src/core/lib/iomgr/ev_posix.h +75 -67
  244. data/src/core/lib/iomgr/{ev_windows.c → ev_windows.cc} +2 -2
  245. data/src/core/lib/iomgr/exec_ctx.cc +177 -0
  246. data/src/core/lib/iomgr/exec_ctx.h +35 -13
  247. data/src/core/lib/iomgr/{executor.c → executor.cc} +34 -35
  248. data/src/core/lib/iomgr/executor.h +12 -4
  249. data/src/core/lib/iomgr/{fork_posix.c → fork_posix.cc} +0 -0
  250. data/src/core/lib/iomgr/{fork_windows.c → fork_windows.cc} +0 -0
  251. data/src/core/lib/iomgr/gethostname.h +9 -1
  252. data/src/core/lib/iomgr/{gethostname_fallback.c → gethostname_fallback.cc} +2 -1
  253. data/src/core/lib/iomgr/{gethostname_host_name_max.c → gethostname_host_name_max.cc} +4 -3
  254. data/src/core/lib/iomgr/{gethostname_sysconf.c → gethostname_sysconf.cc} +3 -2
  255. data/src/core/lib/iomgr/{iocp_windows.c → iocp_windows.cc} +23 -25
  256. data/src/core/lib/iomgr/iocp_windows.h +17 -3
  257. data/src/core/lib/iomgr/{iomgr.c → iomgr.cc} +25 -19
  258. data/src/core/lib/iomgr/iomgr.h +11 -3
  259. data/src/core/lib/iomgr/iomgr_internal.h +13 -5
  260. data/src/core/lib/iomgr/{iomgr_posix.c → iomgr_posix.cc} +0 -1
  261. data/src/core/lib/iomgr/{iomgr_uv.c → iomgr_uv.cc} +1 -1
  262. data/src/core/lib/iomgr/iomgr_uv.h +8 -0
  263. data/src/core/lib/iomgr/{iomgr_windows.c → iomgr_windows.cc} +0 -0
  264. data/src/core/lib/iomgr/{is_epollexclusive_available.c → is_epollexclusive_available.cc} +1 -1
  265. data/src/core/lib/iomgr/is_epollexclusive_available.h +8 -0
  266. data/src/core/lib/iomgr/{load_file.c → load_file.cc} +12 -12
  267. data/src/core/lib/iomgr/load_file.h +2 -2
  268. data/src/core/lib/iomgr/{lockfree_event.c → lockfree_event.cc} +76 -68
  269. data/src/core/lib/iomgr/lockfree_event.h +30 -11
  270. data/src/core/lib/iomgr/{network_status_tracker.c → network_status_tracker.cc} +3 -2
  271. data/src/core/lib/iomgr/network_status_tracker.h +2 -2
  272. data/src/core/lib/iomgr/{polling_entity.c → polling_entity.cc} +18 -18
  273. data/src/core/lib/iomgr/polling_entity.h +21 -13
  274. data/src/core/lib/iomgr/pollset.h +17 -11
  275. data/src/core/lib/iomgr/pollset_set.h +23 -15
  276. data/src/core/lib/iomgr/{pollset_set_uv.c → pollset_set_uv.cc} +0 -0
  277. data/src/core/lib/iomgr/{pollset_set_windows.c → pollset_set_windows.cc} +0 -0
  278. data/src/core/lib/iomgr/{pollset_uv.c → pollset_uv.cc} +31 -29
  279. data/src/core/lib/iomgr/pollset_uv.h +8 -0
  280. data/src/core/lib/iomgr/{pollset_windows.c → pollset_windows.cc} +24 -24
  281. data/src/core/lib/iomgr/pollset_windows.h +17 -4
  282. data/src/core/lib/iomgr/port.h +10 -0
  283. data/src/core/lib/iomgr/resolve_address.h +18 -10
  284. data/src/core/lib/iomgr/{resolve_address_posix.c → resolve_address_posix.cc} +40 -40
  285. data/src/core/lib/iomgr/{resolve_address_uv.c → resolve_address_uv.cc} +61 -56
  286. data/src/core/lib/iomgr/{resolve_address_windows.c → resolve_address_windows.cc} +36 -34
  287. data/src/core/lib/iomgr/{resource_quota.c → resource_quota.cc} +209 -180
  288. data/src/core/lib/iomgr/resource_quota.h +45 -37
  289. data/src/core/lib/iomgr/{sockaddr_utils.c → sockaddr_utils.cc} +61 -61
  290. data/src/core/lib/iomgr/sockaddr_utils.h +23 -15
  291. data/src/core/lib/iomgr/sockaddr_windows.h +6 -0
  292. data/src/core/lib/iomgr/{socket_factory_posix.c → socket_factory_posix.cc} +20 -20
  293. data/src/core/lib/iomgr/socket_factory_posix.h +15 -15
  294. data/src/core/lib/iomgr/{socket_mutator.c → socket_mutator.cc} +18 -18
  295. data/src/core/lib/iomgr/socket_mutator.h +11 -11
  296. data/src/core/lib/iomgr/socket_utils.h +9 -1
  297. data/src/core/lib/iomgr/{socket_utils_common_posix.c → socket_utils_common_posix.cc} +28 -28
  298. data/src/core/lib/iomgr/{socket_utils_linux.c → socket_utils_linux.cc} +3 -3
  299. data/src/core/lib/iomgr/{socket_utils_posix.c → socket_utils_posix.cc} +3 -3
  300. data/src/core/lib/iomgr/socket_utils_posix.h +26 -18
  301. data/src/core/lib/iomgr/{socket_utils_uv.c → socket_utils_uv.cc} +1 -1
  302. data/src/core/lib/iomgr/{socket_utils_windows.c → socket_utils_windows.cc} +2 -2
  303. data/src/core/lib/iomgr/{socket_windows.c → socket_windows.cc} +18 -18
  304. data/src/core/lib/iomgr/socket_windows.h +26 -13
  305. data/src/core/lib/iomgr/tcp_client.h +14 -6
  306. data/src/core/lib/iomgr/{tcp_client_posix.c → tcp_client_posix.cc} +69 -70
  307. data/src/core/lib/iomgr/tcp_client_posix.h +11 -3
  308. data/src/core/lib/iomgr/{tcp_client_uv.c → tcp_client_uv.cc} +47 -48
  309. data/src/core/lib/iomgr/{tcp_client_windows.c → tcp_client_windows.cc} +46 -44
  310. data/src/core/lib/iomgr/{tcp_posix.c → tcp_posix.cc} +198 -175
  311. data/src/core/lib/iomgr/tcp_posix.h +15 -7
  312. data/src/core/lib/iomgr/tcp_server.h +31 -23
  313. data/src/core/lib/iomgr/{tcp_server_posix.c → tcp_server_posix.cc} +78 -77
  314. data/src/core/lib/iomgr/tcp_server_utils_posix.h +27 -19
  315. data/src/core/lib/iomgr/{tcp_server_utils_posix_common.c → tcp_server_utils_posix_common.cc} +27 -27
  316. data/src/core/lib/iomgr/{tcp_server_utils_posix_ifaddrs.c → tcp_server_utils_posix_ifaddrs.cc} +25 -25
  317. data/src/core/lib/iomgr/{tcp_server_utils_posix_noifaddrs.c → tcp_server_utils_posix_noifaddrs.cc} +2 -2
  318. data/src/core/lib/iomgr/{tcp_server_uv.c → tcp_server_uv.cc} +133 -105
  319. data/src/core/lib/iomgr/{tcp_server_windows.c → tcp_server_windows.cc} +81 -77
  320. data/src/core/lib/iomgr/tcp_uv.cc +420 -0
  321. data/src/core/lib/iomgr/tcp_uv.h +18 -4
  322. data/src/core/lib/iomgr/{tcp_windows.c → tcp_windows.cc} +90 -79
  323. data/src/core/lib/iomgr/tcp_windows.h +17 -4
  324. data/src/core/lib/iomgr/{time_averaged_stats.c → time_averaged_stats.cc} +0 -0
  325. data/src/core/lib/iomgr/time_averaged_stats.h +8 -0
  326. data/src/core/lib/iomgr/timer.h +16 -9
  327. data/src/core/lib/iomgr/{timer_generic.c → timer_generic.cc} +130 -171
  328. data/src/core/lib/iomgr/timer_generic.h +4 -4
  329. data/src/core/lib/iomgr/{timer_heap.c → timer_heap.cc} +20 -21
  330. data/src/core/lib/iomgr/timer_heap.h +16 -8
  331. data/src/core/lib/iomgr/{timer_manager.c → timer_manager.cc} +54 -52
  332. data/src/core/lib/iomgr/timer_manager.h +8 -0
  333. data/src/core/lib/iomgr/{timer_uv.c → timer_uv.cc} +22 -24
  334. data/src/core/lib/iomgr/timer_uv.h +2 -2
  335. data/src/core/lib/iomgr/{udp_server.c → udp_server.cc} +75 -75
  336. data/src/core/lib/iomgr/udp_server.h +25 -17
  337. data/src/core/lib/iomgr/{unix_sockets_posix.c → unix_sockets_posix.cc} +22 -21
  338. data/src/core/lib/iomgr/unix_sockets_posix.h +14 -6
  339. data/src/core/lib/iomgr/{unix_sockets_posix_noop.c → unix_sockets_posix_noop.cc} +5 -5
  340. data/src/core/lib/iomgr/{wakeup_fd_cv.c → wakeup_fd_cv.cc} +2 -2
  341. data/src/core/lib/iomgr/wakeup_fd_cv.h +10 -0
  342. data/src/core/lib/iomgr/{wakeup_fd_eventfd.c → wakeup_fd_eventfd.cc} +0 -0
  343. data/src/core/lib/iomgr/{wakeup_fd_nospecial.c → wakeup_fd_nospecial.cc} +0 -0
  344. data/src/core/lib/iomgr/{wakeup_fd_pipe.c → wakeup_fd_pipe.cc} +1 -0
  345. data/src/core/lib/iomgr/wakeup_fd_pipe.h +9 -1
  346. data/src/core/lib/iomgr/{wakeup_fd_posix.c → wakeup_fd_posix.cc} +6 -7
  347. data/src/core/lib/iomgr/wakeup_fd_posix.h +8 -0
  348. data/src/core/lib/json/{json.c → json.cc} +0 -0
  349. data/src/core/lib/json/json.h +8 -0
  350. data/src/core/lib/json/{json_reader.c → json_reader.cc} +18 -18
  351. data/src/core/lib/json/json_reader.h +26 -18
  352. data/src/core/lib/json/{json_string.c → json_string.cc} +57 -57
  353. data/src/core/lib/json/{json_writer.c → json_writer.cc} +20 -20
  354. data/src/core/lib/json/json_writer.h +23 -15
  355. data/src/core/lib/profiling/{basic_timers.c → basic_timers.cc} +34 -34
  356. data/src/core/lib/profiling/{stap_timers.c → stap_timers.cc} +5 -5
  357. data/src/core/lib/profiling/timers.h +6 -6
  358. data/src/core/lib/security/context/{security_context.c → security_context.cc} +98 -95
  359. data/src/core/lib/security/context/security_context.h +27 -29
  360. data/src/core/lib/security/credentials/composite/{composite_credentials.c → composite_credentials.cc} +79 -73
  361. data/src/core/lib/security/credentials/composite/composite_credentials.h +17 -9
  362. data/src/core/lib/security/credentials/{credentials.c → credentials.cc} +97 -92
  363. data/src/core/lib/security/credentials/credentials.h +83 -75
  364. data/src/core/lib/security/credentials/{credentials_metadata.c → credentials_metadata.cc} +7 -6
  365. data/src/core/lib/security/credentials/fake/{fake_credentials.c → fake_credentials.cc} +39 -36
  366. data/src/core/lib/security/credentials/fake/fake_credentials.h +13 -5
  367. data/src/core/lib/security/credentials/google_default/{credentials_generic.c → credentials_generic.cc} +5 -5
  368. data/src/core/lib/security/credentials/google_default/{google_default_credentials.c → google_default_credentials.cc} +55 -55
  369. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +9 -1
  370. data/src/core/lib/security/credentials/iam/{iam_credentials.c → iam_credentials.cc} +19 -18
  371. data/src/core/lib/security/credentials/jwt/{json_token.c → json_token.cc} +80 -75
  372. data/src/core/lib/security/credentials/jwt/json_token.h +23 -15
  373. data/src/core/lib/security/credentials/jwt/{jwt_credentials.c → jwt_credentials.cc} +45 -41
  374. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +11 -3
  375. data/src/core/lib/security/credentials/jwt/{jwt_verifier.c → jwt_verifier.cc} +262 -252
  376. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +38 -30
  377. data/src/core/lib/security/credentials/oauth2/{oauth2_credentials.c → oauth2_credentials.cc} +138 -141
  378. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +30 -22
  379. data/src/core/lib/security/credentials/plugin/{plugin_credentials.c → plugin_credentials.cc} +52 -53
  380. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +7 -7
  381. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +344 -0
  382. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +27 -0
  383. data/src/core/lib/security/transport/auth_filters.h +16 -0
  384. data/src/core/lib/security/transport/{client_auth_filter.c → client_auth_filter.cc} +127 -115
  385. data/src/core/lib/security/transport/{lb_targets_info.c → lb_targets_info.cc} +16 -13
  386. data/src/core/lib/security/transport/lb_targets_info.h +11 -3
  387. data/src/core/lib/security/transport/{secure_endpoint.c → secure_endpoint.cc} +84 -76
  388. data/src/core/lib/security/transport/secure_endpoint.h +13 -5
  389. data/src/core/lib/security/transport/security_connector.cc +1121 -0
  390. data/src/core/lib/security/transport/security_connector.h +97 -79
  391. data/src/core/lib/security/transport/{security_handshaker.c → security_handshaker.cc} +139 -132
  392. data/src/core/lib/security/transport/security_handshaker.h +11 -3
  393. data/src/core/lib/security/transport/{server_auth_filter.c → server_auth_filter.cc} +68 -68
  394. data/src/core/lib/security/transport/{tsi_error.c → tsi_error.cc} +1 -1
  395. data/src/core/lib/security/transport/tsi_error.h +9 -1
  396. data/src/core/lib/security/util/{json_util.c → json_util.cc} +11 -11
  397. data/src/core/lib/security/util/json_util.h +12 -4
  398. data/src/core/lib/slice/{b64.c → b64.cc} +15 -15
  399. data/src/core/lib/slice/b64.h +12 -4
  400. data/src/core/lib/slice/{percent_encoding.c → percent_encoding.cc} +15 -15
  401. data/src/core/lib/slice/percent_encoding.h +11 -3
  402. data/src/core/lib/slice/{slice.c → slice.cc} +64 -64
  403. data/src/core/lib/slice/{slice_buffer.c → slice_buffer.cc} +38 -38
  404. data/src/core/lib/slice/{slice_hash_table.c → slice_hash_table.cc} +7 -7
  405. data/src/core/lib/slice/slice_hash_table.h +19 -11
  406. data/src/core/lib/slice/{slice_intern.c → slice_intern.cc} +35 -34
  407. data/src/core/lib/slice/slice_internal.h +17 -6
  408. data/src/core/lib/slice/{slice_string_helpers.c → slice_string_helpers.cc} +9 -9
  409. data/src/core/lib/slice/slice_string_helpers.h +3 -3
  410. data/src/core/lib/support/abstract.h +29 -0
  411. data/src/core/lib/support/{alloc.c → alloc.cc} +22 -22
  412. data/src/core/lib/support/{arena.c → arena.cc} +12 -12
  413. data/src/core/lib/support/arena.h +11 -3
  414. data/src/core/lib/support/{atm.c → atm.cc} +1 -1
  415. data/src/core/lib/support/{avl.c → avl.cc} +71 -70
  416. data/src/core/lib/support/{cmdline.c → cmdline.cc} +62 -62
  417. data/src/core/lib/support/{cpu_iphone.c → cpu_iphone.cc} +2 -0
  418. data/src/core/lib/support/{cpu_linux.c → cpu_linux.cc} +10 -0
  419. data/src/core/lib/support/{cpu_posix.c → cpu_posix.cc} +27 -4
  420. data/src/core/lib/support/{cpu_windows.c → cpu_windows.cc} +1 -0
  421. data/src/core/lib/support/env.h +3 -3
  422. data/src/core/lib/support/{env_linux.c → env_linux.cc} +11 -11
  423. data/src/core/lib/support/{env_posix.c → env_posix.cc} +4 -4
  424. data/src/core/lib/support/{env_windows.c → env_windows.cc} +5 -5
  425. data/src/core/lib/support/{fork.c → fork.cc} +2 -2
  426. data/src/core/lib/support/{histogram.c → histogram.cc} +25 -26
  427. data/src/core/lib/support/{host_port.c → host_port.cc} +16 -16
  428. data/src/core/lib/support/{log.c → log.cc} +8 -8
  429. data/src/core/lib/support/{log_android.c → log_android.cc} +7 -7
  430. data/src/core/lib/support/{log_linux.c → log_linux.cc} +8 -8
  431. data/src/core/lib/support/{log_posix.c → log_posix.cc} +9 -10
  432. data/src/core/lib/support/{log_windows.c → log_windows.cc} +7 -7
  433. data/src/core/lib/support/manual_constructor.h +211 -0
  434. data/src/core/lib/support/memory.h +41 -0
  435. data/src/core/lib/support/mpscq.cc +114 -0
  436. data/src/core/lib/support/mpscq.h +45 -7
  437. data/src/core/lib/support/{murmur_hash.c → murmur_hash.cc} +9 -12
  438. data/src/core/lib/support/murmur_hash.h +9 -1
  439. data/src/core/lib/support/spinlock.h +8 -1
  440. data/src/core/lib/support/{string.c → string.cc} +56 -55
  441. data/src/core/lib/support/string.h +21 -21
  442. data/src/core/lib/support/{string_posix.c → string_posix.cc} +5 -4
  443. data/src/core/lib/support/{string_util_windows.c → string_util_windows.cc} +9 -6
  444. data/src/core/lib/support/{string_windows.c → string_windows.cc} +3 -2
  445. data/src/core/lib/support/string_windows.h +8 -0
  446. data/src/core/lib/support/{subprocess_posix.c → subprocess_posix.cc} +13 -13
  447. data/src/core/lib/support/{subprocess_windows.c → subprocess_windows.cc} +9 -9
  448. data/src/core/lib/support/{sync.c → sync.cc} +22 -22
  449. data/src/core/lib/support/{sync_posix.c → sync_posix.cc} +6 -2
  450. data/src/core/lib/support/{sync_windows.c → sync_windows.cc} +14 -14
  451. data/src/core/lib/support/{thd.c → thd.cc} +0 -0
  452. data/src/core/lib/support/{thd_posix.c → thd_posix.cc} +10 -10
  453. data/src/core/lib/support/{thd_windows.c → thd_windows.cc} +10 -10
  454. data/src/core/lib/support/{time.c → time.cc} +0 -0
  455. data/src/core/lib/support/{time_posix.c → time_posix.cc} +5 -6
  456. data/src/core/lib/support/{time_precise.c → time_precise.cc} +6 -4
  457. data/src/core/lib/support/time_precise.h +9 -1
  458. data/src/core/lib/support/{time_windows.c → time_windows.cc} +2 -3
  459. data/src/core/lib/support/{tls_pthread.c → tls_pthread.cc} +2 -2
  460. data/src/core/lib/support/tmpfile.h +1 -1
  461. data/src/core/lib/support/{tmpfile_msys.c → tmpfile_msys.cc} +2 -2
  462. data/src/core/lib/support/{tmpfile_posix.c → tmpfile_posix.cc} +7 -7
  463. data/src/core/lib/support/{tmpfile_windows.c → tmpfile_windows.cc} +2 -2
  464. data/src/core/lib/support/{wrap_memcpy.c → wrap_memcpy.cc} +4 -2
  465. data/src/core/lib/surface/{alarm.c → alarm.cc} +32 -31
  466. data/src/core/lib/surface/alarm_internal.h +10 -2
  467. data/src/core/lib/surface/{api_trace.c → api_trace.cc} +1 -1
  468. data/src/core/lib/surface/api_trace.h +2 -2
  469. data/src/core/lib/surface/{byte_buffer.c → byte_buffer.cc} +13 -13
  470. data/src/core/lib/surface/{byte_buffer_reader.c → byte_buffer_reader.cc} +9 -9
  471. data/src/core/lib/surface/{call.c → call.cc} +379 -372
  472. data/src/core/lib/surface/call.h +37 -38
  473. data/src/core/lib/surface/{call_details.c → call_details.cc} +0 -0
  474. data/src/core/lib/surface/{call_log_batch.c → call_log_batch.cc} +13 -11
  475. data/src/core/lib/surface/call_test_only.h +5 -5
  476. data/src/core/lib/surface/{channel.c → channel.cc} +94 -95
  477. data/src/core/lib/surface/channel.h +29 -21
  478. data/src/core/lib/surface/{channel_init.c → channel_init.cc} +13 -13
  479. data/src/core/lib/surface/channel_init.h +6 -6
  480. data/src/core/lib/surface/{channel_ping.c → channel_ping.cc} +12 -12
  481. data/src/core/lib/surface/{channel_stack_type.c → channel_stack_type.cc} +1 -1
  482. data/src/core/lib/surface/channel_stack_type.h +9 -1
  483. data/src/core/lib/surface/{completion_queue.c → completion_queue.cc} +416 -379
  484. data/src/core/lib/surface/completion_queue.h +29 -29
  485. data/src/core/lib/surface/{completion_queue_factory.c → completion_queue_factory.cc} +1 -1
  486. data/src/core/lib/surface/completion_queue_factory.h +8 -0
  487. data/src/core/lib/surface/{event_string.c → event_string.cc} +9 -9
  488. data/src/core/lib/surface/event_string.h +9 -1
  489. data/src/core/lib/surface/{init.c → init.cc} +16 -39
  490. data/src/core/lib/surface/init.h +8 -0
  491. data/src/core/lib/surface/{init_secure.c → init_secure.cc} +12 -25
  492. data/src/core/lib/surface/lame_client.cc +38 -40
  493. data/src/core/lib/surface/lame_client.h +8 -0
  494. data/src/core/lib/surface/{metadata_array.c → metadata_array.cc} +0 -0
  495. data/src/core/lib/surface/{server.c → server.cc} +340 -404
  496. data/src/core/lib/surface/server.h +22 -14
  497. data/src/core/lib/surface/{validate_metadata.c → validate_metadata.cc} +10 -9
  498. data/src/core/lib/surface/validate_metadata.h +10 -2
  499. data/src/core/lib/surface/{version.c → version.cc} +2 -2
  500. data/src/core/lib/transport/bdp_estimator.cc +84 -0
  501. data/src/core/lib/transport/bdp_estimator.h +67 -42
  502. data/src/core/lib/transport/{byte_stream.c → byte_stream.cc} +51 -51
  503. data/src/core/lib/transport/byte_stream.h +41 -33
  504. data/src/core/lib/transport/{connectivity_state.c → connectivity_state.cc} +36 -40
  505. data/src/core/lib/transport/connectivity_state.h +29 -21
  506. data/src/core/lib/transport/{error_utils.c → error_utils.cc} +26 -22
  507. data/src/core/lib/transport/error_utils.h +18 -6
  508. data/src/core/lib/transport/{metadata.c → metadata.cc} +92 -88
  509. data/src/core/lib/transport/metadata.h +22 -20
  510. data/src/core/lib/transport/{metadata_batch.c → metadata_batch.cc} +78 -79
  511. data/src/core/lib/transport/metadata_batch.h +46 -45
  512. data/src/core/lib/transport/pid_controller.cc +48 -0
  513. data/src/core/lib/transport/pid_controller.h +84 -32
  514. data/src/core/lib/transport/{service_config.c → service_config.cc} +66 -48
  515. data/src/core/lib/transport/service_config.h +11 -2
  516. data/src/core/lib/transport/{static_metadata.c → static_metadata.cc} +2 -2
  517. data/src/core/lib/transport/static_metadata.h +30 -23
  518. data/src/core/lib/transport/{status_conversion.c → status_conversion.cc} +4 -3
  519. data/src/core/lib/transport/status_conversion.h +12 -2
  520. data/src/core/lib/transport/{timeout_encoding.c → timeout_encoding.cc} +28 -61
  521. data/src/core/lib/transport/timeout_encoding.h +11 -2
  522. data/src/core/lib/transport/{transport.c → transport.cc} +79 -79
  523. data/src/core/lib/transport/transport.h +78 -80
  524. data/src/core/lib/transport/transport_impl.h +27 -19
  525. data/src/core/lib/transport/{transport_op_string.c → transport_op_string.cc} +32 -30
  526. data/src/core/plugin_registry/{grpc_plugin_registry.c → grpc_plugin_registry.cc} +34 -38
  527. data/src/core/tsi/{fake_transport_security.c → fake_transport_security.cc} +141 -132
  528. data/src/core/tsi/fake_transport_security.h +5 -5
  529. data/src/core/tsi/{gts_transport_security.c → gts_transport_security.cc} +4 -4
  530. data/src/core/tsi/gts_transport_security.h +11 -3
  531. data/src/core/tsi/{ssl_transport_security.c → ssl_transport_security.cc} +309 -300
  532. data/src/core/tsi/ssl_transport_security.h +25 -25
  533. data/src/core/tsi/ssl_types.h +8 -0
  534. data/src/core/tsi/{transport_security.c → transport_security.cc} +94 -87
  535. data/src/core/tsi/transport_security.h +55 -55
  536. data/src/core/tsi/{transport_security_adapter.c → transport_security_adapter.cc} +58 -55
  537. data/src/core/tsi/transport_security_adapter.h +2 -2
  538. data/src/core/tsi/{transport_security_grpc.c → transport_security_grpc.cc} +21 -21
  539. data/src/core/tsi/transport_security_grpc.h +19 -19
  540. data/src/core/tsi/transport_security_interface.h +41 -41
  541. data/src/ruby/ext/grpc/extconf.rb +4 -2
  542. data/src/ruby/ext/grpc/rb_byte_buffer.c +5 -5
  543. data/src/ruby/ext/grpc/rb_byte_buffer.h +2 -2
  544. data/src/ruby/ext/grpc/rb_call.c +41 -42
  545. data/src/ruby/ext/grpc/rb_call.h +6 -6
  546. data/src/ruby/ext/grpc/rb_call_credentials.c +30 -30
  547. data/src/ruby/ext/grpc/rb_channel.c +87 -87
  548. data/src/ruby/ext/grpc/rb_channel_credentials.c +23 -23
  549. data/src/ruby/ext/grpc/rb_completion_queue.c +11 -11
  550. data/src/ruby/ext/grpc/rb_completion_queue.h +3 -3
  551. data/src/ruby/ext/grpc/rb_compression_options.c +20 -20
  552. data/src/ruby/ext/grpc/rb_event_thread.c +14 -14
  553. data/src/ruby/ext/grpc/rb_event_thread.h +1 -1
  554. data/src/ruby/ext/grpc/rb_grpc.c +8 -8
  555. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +16 -58
  556. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +242 -306
  557. data/src/ruby/ext/grpc/rb_server.c +23 -23
  558. data/src/ruby/ext/grpc/rb_server_credentials.c +13 -13
  559. data/src/ruby/lib/grpc/generic/rpc_server.rb +25 -12
  560. data/src/ruby/lib/grpc/version.rb +1 -1
  561. data/src/ruby/pb/grpc/health/checker.rb +14 -0
  562. data/src/ruby/spec/pb/health/checker_spec.rb +29 -0
  563. data/third_party/cares/config_freebsd/ares_config.h +502 -0
  564. data/third_party/cares/config_openbsd/ares_config.h +502 -0
  565. metadata +302 -328
  566. data/src/core/ext/census/aggregation.h +0 -51
  567. data/src/core/ext/census/base_resources.c +0 -56
  568. data/src/core/ext/census/base_resources.h +0 -24
  569. data/src/core/ext/census/census_interface.h +0 -61
  570. data/src/core/ext/census/census_rpc_stats.h +0 -86
  571. data/src/core/ext/census/context.c +0 -496
  572. data/src/core/ext/census/gen/census.pb.c +0 -161
  573. data/src/core/ext/census/gen/census.pb.h +0 -280
  574. data/src/core/ext/census/gen/trace_context.pb.c +0 -39
  575. data/src/core/ext/census/gen/trace_context.pb.h +0 -78
  576. data/src/core/ext/census/grpc_filter.c +0 -196
  577. data/src/core/ext/census/grpc_plugin.c +0 -70
  578. data/src/core/ext/census/initialize.c +0 -51
  579. data/src/core/ext/census/intrusive_hash_map.c +0 -305
  580. data/src/core/ext/census/intrusive_hash_map.h +0 -152
  581. data/src/core/ext/census/intrusive_hash_map_internal.h +0 -48
  582. data/src/core/ext/census/mlog.c +0 -586
  583. data/src/core/ext/census/mlog.h +0 -80
  584. data/src/core/ext/census/operation.c +0 -48
  585. data/src/core/ext/census/placeholders.c +0 -49
  586. data/src/core/ext/census/resource.c +0 -303
  587. data/src/core/ext/census/resource.h +0 -48
  588. data/src/core/ext/census/rpc_metric_id.h +0 -36
  589. data/src/core/ext/census/trace_context.c +0 -71
  590. data/src/core/ext/census/trace_context.h +0 -56
  591. data/src/core/ext/census/trace_label.h +0 -46
  592. data/src/core/ext/census/trace_propagation.h +0 -48
  593. data/src/core/ext/census/trace_status.h +0 -30
  594. data/src/core/ext/census/trace_string.h +0 -35
  595. data/src/core/ext/census/tracing.c +0 -55
  596. data/src/core/ext/census/tracing.h +0 -109
  597. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +0 -714
  598. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +0 -924
  599. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c +0 -60
  600. data/src/core/ext/transport/chttp2/transport/flow_control.c +0 -502
  601. data/src/core/ext/transport/chttp2/transport/writing.c +0 -534
  602. data/src/core/lib/debug/trace.c +0 -146
  603. data/src/core/lib/iomgr/closure.c +0 -219
  604. data/src/core/lib/iomgr/ev_epollex_linux.c +0 -1461
  605. data/src/core/lib/iomgr/ev_posix.c +0 -266
  606. data/src/core/lib/iomgr/exec_ctx.c +0 -113
  607. data/src/core/lib/iomgr/tcp_uv.c +0 -381
  608. data/src/core/lib/security/credentials/ssl/ssl_credentials.c +0 -194
  609. data/src/core/lib/security/transport/security_connector.c +0 -914
  610. data/src/core/lib/support/backoff.c +0 -72
  611. data/src/core/lib/support/backoff.h +0 -56
  612. data/src/core/lib/support/mpscq.c +0 -79
  613. data/src/core/lib/support/stack_lockfree.c +0 -137
  614. data/src/core/lib/support/stack_lockfree.h +0 -38
  615. data/src/core/lib/transport/bdp_estimator.c +0 -110
  616. data/src/core/lib/transport/pid_controller.c +0 -63
@@ -0,0 +1,165 @@
1
+ /*
2
+ *
3
+ * Copyright 2015 gRPC authors.
4
+ *
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
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
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.
16
+ *
17
+ */
18
+
19
+ #include "src/core/ext/filters/client_channel/backup_poller.h"
20
+
21
+ #include <grpc/grpc.h>
22
+ #include <grpc/support/alloc.h>
23
+ #include <grpc/support/log.h>
24
+ #include <grpc/support/sync.h>
25
+ #include "src/core/ext/filters/client_channel/client_channel.h"
26
+ #include "src/core/lib/iomgr/error.h"
27
+ #include "src/core/lib/iomgr/pollset.h"
28
+ #include "src/core/lib/iomgr/timer.h"
29
+ #include "src/core/lib/support/env.h"
30
+ #include "src/core/lib/support/string.h"
31
+ #include "src/core/lib/surface/channel.h"
32
+ #include "src/core/lib/surface/completion_queue.h"
33
+
34
+ #define DEFAULT_POLL_INTERVAL_MS 5000
35
+
36
+ typedef struct backup_poller {
37
+ grpc_timer polling_timer;
38
+ grpc_closure run_poller_closure;
39
+ grpc_closure shutdown_closure;
40
+ gpr_mu* pollset_mu;
41
+ grpc_pollset* pollset; // guarded by pollset_mu
42
+ bool shutting_down; // guarded by pollset_mu
43
+ gpr_refcount refs;
44
+ gpr_refcount shutdown_refs;
45
+ } backup_poller;
46
+
47
+ static gpr_once g_once = GPR_ONCE_INIT;
48
+ static gpr_mu g_poller_mu;
49
+ static backup_poller* g_poller = nullptr; // guarded by g_poller_mu
50
+ // g_poll_interval_ms is set only once at the first time
51
+ // grpc_client_channel_start_backup_polling() is called, after that it is
52
+ // treated as const.
53
+ static int g_poll_interval_ms = DEFAULT_POLL_INTERVAL_MS;
54
+
55
+ static void init_globals() {
56
+ gpr_mu_init(&g_poller_mu);
57
+ char* env = gpr_getenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS");
58
+ if (env != nullptr) {
59
+ int poll_interval_ms = gpr_parse_nonnegative_int(env);
60
+ if (poll_interval_ms == -1) {
61
+ gpr_log(GPR_ERROR,
62
+ "Invalid GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS: %s, "
63
+ "default value %d will be used.",
64
+ env, g_poll_interval_ms);
65
+ } else {
66
+ g_poll_interval_ms = poll_interval_ms;
67
+ }
68
+ }
69
+ gpr_free(env);
70
+ }
71
+
72
+ static void backup_poller_shutdown_unref(grpc_exec_ctx* exec_ctx,
73
+ backup_poller* p) {
74
+ if (gpr_unref(&p->shutdown_refs)) {
75
+ grpc_pollset_destroy(exec_ctx, p->pollset);
76
+ gpr_free(p->pollset);
77
+ gpr_free(p);
78
+ }
79
+ }
80
+
81
+ static void done_poller(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
82
+ backup_poller_shutdown_unref(exec_ctx, (backup_poller*)arg);
83
+ }
84
+
85
+ static void g_poller_unref(grpc_exec_ctx* exec_ctx) {
86
+ if (gpr_unref(&g_poller->refs)) {
87
+ gpr_mu_lock(&g_poller_mu);
88
+ backup_poller* p = g_poller;
89
+ g_poller = nullptr;
90
+ gpr_mu_unlock(&g_poller_mu);
91
+ gpr_mu_lock(p->pollset_mu);
92
+ p->shutting_down = true;
93
+ grpc_pollset_shutdown(exec_ctx, p->pollset,
94
+ GRPC_CLOSURE_INIT(&p->shutdown_closure, done_poller,
95
+ p, grpc_schedule_on_exec_ctx));
96
+ gpr_mu_unlock(p->pollset_mu);
97
+ grpc_timer_cancel(exec_ctx, &p->polling_timer);
98
+ }
99
+ }
100
+
101
+ static void run_poller(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
102
+ backup_poller* p = (backup_poller*)arg;
103
+ if (error != GRPC_ERROR_NONE) {
104
+ if (error != GRPC_ERROR_CANCELLED) {
105
+ GRPC_LOG_IF_ERROR("run_poller", GRPC_ERROR_REF(error));
106
+ }
107
+ backup_poller_shutdown_unref(exec_ctx, p);
108
+ return;
109
+ }
110
+ gpr_mu_lock(p->pollset_mu);
111
+ if (p->shutting_down) {
112
+ gpr_mu_unlock(p->pollset_mu);
113
+ backup_poller_shutdown_unref(exec_ctx, p);
114
+ return;
115
+ }
116
+ grpc_error* err = grpc_pollset_work(exec_ctx, p->pollset, nullptr,
117
+ grpc_exec_ctx_now(exec_ctx));
118
+ gpr_mu_unlock(p->pollset_mu);
119
+ GRPC_LOG_IF_ERROR("Run client channel backup poller", err);
120
+ grpc_timer_init(exec_ctx, &p->polling_timer,
121
+ grpc_exec_ctx_now(exec_ctx) + g_poll_interval_ms,
122
+ &p->run_poller_closure);
123
+ }
124
+
125
+ void grpc_client_channel_start_backup_polling(
126
+ grpc_exec_ctx* exec_ctx, grpc_pollset_set* interested_parties) {
127
+ gpr_once_init(&g_once, init_globals);
128
+ if (g_poll_interval_ms == 0) {
129
+ return;
130
+ }
131
+ gpr_mu_lock(&g_poller_mu);
132
+ if (g_poller == nullptr) {
133
+ g_poller = (backup_poller*)gpr_zalloc(sizeof(backup_poller));
134
+ g_poller->pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
135
+ g_poller->shutting_down = false;
136
+ grpc_pollset_init(g_poller->pollset, &g_poller->pollset_mu);
137
+ gpr_ref_init(&g_poller->refs, 0);
138
+ // one for timer cancellation, one for pollset shutdown
139
+ gpr_ref_init(&g_poller->shutdown_refs, 2);
140
+ GRPC_CLOSURE_INIT(&g_poller->run_poller_closure, run_poller, g_poller,
141
+ grpc_schedule_on_exec_ctx);
142
+ grpc_timer_init(exec_ctx, &g_poller->polling_timer,
143
+ grpc_exec_ctx_now(exec_ctx) + g_poll_interval_ms,
144
+ &g_poller->run_poller_closure);
145
+ }
146
+
147
+ gpr_ref(&g_poller->refs);
148
+ /* Get a reference to g_poller->pollset before releasing g_poller_mu to make
149
+ * TSAN happy. Otherwise, reading from g_poller (i.e g_poller->pollset) after
150
+ * releasing the lock and setting g_poller to NULL in g_poller_unref() is
151
+ * being flagged as a data-race by TSAN */
152
+ grpc_pollset* pollset = g_poller->pollset;
153
+ gpr_mu_unlock(&g_poller_mu);
154
+
155
+ grpc_pollset_set_add_pollset(exec_ctx, interested_parties, pollset);
156
+ }
157
+
158
+ void grpc_client_channel_stop_backup_polling(
159
+ grpc_exec_ctx* exec_ctx, grpc_pollset_set* interested_parties) {
160
+ if (g_poll_interval_ms == 0) {
161
+ return;
162
+ }
163
+ grpc_pollset_set_del_pollset(exec_ctx, interested_parties, g_poller->pollset);
164
+ g_poller_unref(exec_ctx);
165
+ }
@@ -16,14 +16,19 @@
16
16
  *
17
17
  */
18
18
 
19
- #ifndef GRPC_CORE_EXT_CENSUS_GRPC_FILTER_H
20
- #define GRPC_CORE_EXT_CENSUS_GRPC_FILTER_H
19
+ #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_BACKUP_POLLER_H
20
+ #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_BACKUP_POLLER_H
21
21
 
22
+ #include <grpc/grpc.h>
22
23
  #include "src/core/lib/channel/channel_stack.h"
24
+ #include "src/core/lib/iomgr/exec_ctx.h"
23
25
 
24
- /* Census filters: provides tracing and stats collection functionalities. It
25
- needs to reside right below the surface filter in the channel stack. */
26
- extern const grpc_channel_filter grpc_client_census_filter;
27
- extern const grpc_channel_filter grpc_server_census_filter;
26
+ /* Start polling \a interested_parties periodically in the timer thread */
27
+ void grpc_client_channel_start_backup_polling(
28
+ grpc_exec_ctx* exec_ctx, grpc_pollset_set* interested_parties);
28
29
 
29
- #endif /* GRPC_CORE_EXT_CENSUS_GRPC_FILTER_H */
30
+ /* Stop polling \a interested_parties */
31
+ void grpc_client_channel_stop_backup_polling(
32
+ grpc_exec_ctx* exec_ctx, grpc_pollset_set* interested_parties);
33
+
34
+ #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_BACKUP_POLLER_H */
@@ -18,6 +18,8 @@
18
18
 
19
19
  #include "src/core/lib/surface/channel.h"
20
20
 
21
+ #include <inttypes.h>
22
+
21
23
  #include <grpc/support/alloc.h>
22
24
  #include <grpc/support/log.h>
23
25
 
@@ -27,9 +29,9 @@
27
29
  #include "src/core/lib/surface/completion_queue.h"
28
30
 
29
31
  grpc_connectivity_state grpc_channel_check_connectivity_state(
30
- grpc_channel *channel, int try_to_connect) {
32
+ grpc_channel* channel, int try_to_connect) {
31
33
  /* forward through to the underlying client channel */
32
- grpc_channel_element *client_channel_elem =
34
+ grpc_channel_element* client_channel_elem =
33
35
  grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
34
36
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
35
37
  grpc_connectivity_state state;
@@ -64,15 +66,15 @@ typedef struct {
64
66
  grpc_closure watcher_timer_init;
65
67
  grpc_timer alarm;
66
68
  grpc_connectivity_state state;
67
- grpc_completion_queue *cq;
69
+ grpc_completion_queue* cq;
68
70
  grpc_cq_completion completion_storage;
69
- grpc_channel *channel;
70
- grpc_error *error;
71
- void *tag;
71
+ grpc_channel* channel;
72
+ grpc_error* error;
73
+ void* tag;
72
74
  } state_watcher;
73
75
 
74
- static void delete_state_watcher(grpc_exec_ctx *exec_ctx, state_watcher *w) {
75
- grpc_channel_element *client_channel_elem = grpc_channel_stack_last_element(
76
+ static void delete_state_watcher(grpc_exec_ctx* exec_ctx, state_watcher* w) {
77
+ grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element(
76
78
  grpc_channel_get_channel_stack(w->channel));
77
79
  if (client_channel_elem->filter == &grpc_client_channel_filter) {
78
80
  GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, w->channel,
@@ -84,10 +86,10 @@ static void delete_state_watcher(grpc_exec_ctx *exec_ctx, state_watcher *w) {
84
86
  gpr_free(w);
85
87
  }
86
88
 
87
- static void finished_completion(grpc_exec_ctx *exec_ctx, void *pw,
88
- grpc_cq_completion *ignored) {
89
+ static void finished_completion(grpc_exec_ctx* exec_ctx, void* pw,
90
+ grpc_cq_completion* ignored) {
89
91
  bool should_delete = false;
90
- state_watcher *w = (state_watcher *)pw;
92
+ state_watcher* w = (state_watcher*)pw;
91
93
  gpr_mu_lock(&w->mu);
92
94
  switch (w->phase) {
93
95
  case WAITING:
@@ -104,23 +106,23 @@ static void finished_completion(grpc_exec_ctx *exec_ctx, void *pw,
104
106
  }
105
107
  }
106
108
 
107
- static void partly_done(grpc_exec_ctx *exec_ctx, state_watcher *w,
108
- bool due_to_completion, grpc_error *error) {
109
+ static void partly_done(grpc_exec_ctx* exec_ctx, state_watcher* w,
110
+ bool due_to_completion, grpc_error* error) {
109
111
  if (due_to_completion) {
110
112
  grpc_timer_cancel(exec_ctx, &w->alarm);
111
113
  } else {
112
- grpc_channel_element *client_channel_elem = grpc_channel_stack_last_element(
114
+ grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element(
113
115
  grpc_channel_get_channel_stack(w->channel));
114
116
  grpc_client_channel_watch_connectivity_state(
115
117
  exec_ctx, client_channel_elem,
116
- grpc_polling_entity_create_from_pollset(grpc_cq_pollset(w->cq)), NULL,
117
- &w->on_complete, NULL);
118
+ grpc_polling_entity_create_from_pollset(grpc_cq_pollset(w->cq)),
119
+ nullptr, &w->on_complete, nullptr);
118
120
  }
119
121
 
120
122
  gpr_mu_lock(&w->mu);
121
123
 
122
124
  if (due_to_completion) {
123
- if (GRPC_TRACER_ON(grpc_trace_operation_failures)) {
125
+ if (grpc_trace_operation_failures.enabled()) {
124
126
  GRPC_LOG_IF_ERROR("watch_completion_error", GRPC_ERROR_REF(error));
125
127
  }
126
128
  GRPC_ERROR_UNREF(error);
@@ -159,51 +161,51 @@ static void partly_done(grpc_exec_ctx *exec_ctx, state_watcher *w,
159
161
  GRPC_ERROR_UNREF(error);
160
162
  }
161
163
 
162
- static void watch_complete(grpc_exec_ctx *exec_ctx, void *pw,
163
- grpc_error *error) {
164
- partly_done(exec_ctx, (state_watcher *)pw, true, GRPC_ERROR_REF(error));
164
+ static void watch_complete(grpc_exec_ctx* exec_ctx, void* pw,
165
+ grpc_error* error) {
166
+ partly_done(exec_ctx, (state_watcher*)pw, true, GRPC_ERROR_REF(error));
165
167
  }
166
168
 
167
- static void timeout_complete(grpc_exec_ctx *exec_ctx, void *pw,
168
- grpc_error *error) {
169
- partly_done(exec_ctx, (state_watcher *)pw, false, GRPC_ERROR_REF(error));
169
+ static void timeout_complete(grpc_exec_ctx* exec_ctx, void* pw,
170
+ grpc_error* error) {
171
+ partly_done(exec_ctx, (state_watcher*)pw, false, GRPC_ERROR_REF(error));
170
172
  }
171
173
 
172
- int grpc_channel_num_external_connectivity_watchers(grpc_channel *channel) {
173
- grpc_channel_element *client_channel_elem =
174
+ int grpc_channel_num_external_connectivity_watchers(grpc_channel* channel) {
175
+ grpc_channel_element* client_channel_elem =
174
176
  grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
175
177
  return grpc_client_channel_num_external_connectivity_watchers(
176
178
  client_channel_elem);
177
179
  }
178
180
 
179
181
  typedef struct watcher_timer_init_arg {
180
- state_watcher *w;
182
+ state_watcher* w;
181
183
  gpr_timespec deadline;
182
184
  } watcher_timer_init_arg;
183
185
 
184
- static void watcher_timer_init(grpc_exec_ctx *exec_ctx, void *arg,
185
- grpc_error *error_ignored) {
186
- watcher_timer_init_arg *wa = (watcher_timer_init_arg *)arg;
186
+ static void watcher_timer_init(grpc_exec_ctx* exec_ctx, void* arg,
187
+ grpc_error* error_ignored) {
188
+ watcher_timer_init_arg* wa = (watcher_timer_init_arg*)arg;
187
189
 
188
190
  grpc_timer_init(exec_ctx, &wa->w->alarm,
189
- gpr_convert_clock_type(wa->deadline, GPR_CLOCK_MONOTONIC),
190
- &wa->w->on_timeout, gpr_now(GPR_CLOCK_MONOTONIC));
191
+ grpc_timespec_to_millis_round_up(wa->deadline),
192
+ &wa->w->on_timeout);
191
193
  gpr_free(wa);
192
194
  }
193
195
 
194
- int grpc_channel_support_connectivity_watcher(grpc_channel *channel) {
195
- grpc_channel_element *client_channel_elem =
196
+ int grpc_channel_support_connectivity_watcher(grpc_channel* channel) {
197
+ grpc_channel_element* client_channel_elem =
196
198
  grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
197
199
  return client_channel_elem->filter != &grpc_client_channel_filter ? 0 : 1;
198
200
  }
199
201
 
200
202
  void grpc_channel_watch_connectivity_state(
201
- grpc_channel *channel, grpc_connectivity_state last_observed_state,
202
- gpr_timespec deadline, grpc_completion_queue *cq, void *tag) {
203
- grpc_channel_element *client_channel_elem =
203
+ grpc_channel* channel, grpc_connectivity_state last_observed_state,
204
+ gpr_timespec deadline, grpc_completion_queue* cq, void* tag) {
205
+ grpc_channel_element* client_channel_elem =
204
206
  grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
205
207
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
206
- state_watcher *w = (state_watcher *)gpr_malloc(sizeof(*w));
208
+ state_watcher* w = (state_watcher*)gpr_malloc(sizeof(*w));
207
209
 
208
210
  GRPC_API_TRACE(
209
211
  "grpc_channel_watch_connectivity_state("
@@ -211,8 +213,9 @@ void grpc_channel_watch_connectivity_state(
211
213
  "deadline=gpr_timespec { tv_sec: %" PRId64
212
214
  ", tv_nsec: %d, clock_type: %d }, "
213
215
  "cq=%p, tag=%p)",
214
- 7, (channel, (int)last_observed_state, deadline.tv_sec, deadline.tv_nsec,
215
- (int)deadline.clock_type, cq, tag));
216
+ 7,
217
+ (channel, (int)last_observed_state, deadline.tv_sec, deadline.tv_nsec,
218
+ (int)deadline.clock_type, cq, tag));
216
219
 
217
220
  GPR_ASSERT(grpc_cq_begin_op(cq, tag));
218
221
 
@@ -226,10 +229,10 @@ void grpc_channel_watch_connectivity_state(
226
229
  w->cq = cq;
227
230
  w->tag = tag;
228
231
  w->channel = channel;
229
- w->error = NULL;
232
+ w->error = nullptr;
230
233
 
231
- watcher_timer_init_arg *wa =
232
- (watcher_timer_init_arg *)gpr_malloc(sizeof(watcher_timer_init_arg));
234
+ watcher_timer_init_arg* wa =
235
+ (watcher_timer_init_arg*)gpr_malloc(sizeof(watcher_timer_init_arg));
233
236
  wa->w = w;
234
237
  wa->deadline = deadline;
235
238
  GRPC_CLOSURE_INIT(&w->watcher_timer_init, watcher_timer_init, wa,
@@ -16,8 +16,11 @@
16
16
  *
17
17
  */
18
18
 
19
+ #include <grpc/support/port_platform.h>
20
+
19
21
  #include "src/core/ext/filters/client_channel/client_channel.h"
20
22
 
23
+ #include <inttypes.h>
21
24
  #include <stdbool.h>
22
25
  #include <stdio.h>
23
26
  #include <string.h>
@@ -28,6 +31,7 @@
28
31
  #include <grpc/support/sync.h>
29
32
  #include <grpc/support/useful.h>
30
33
 
34
+ #include "src/core/ext/filters/client_channel/backup_poller.h"
31
35
  #include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
32
36
  #include "src/core/ext/filters/client_channel/lb_policy_registry.h"
33
37
  #include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
@@ -52,8 +56,7 @@
52
56
 
53
57
  /* Client channel implementation */
54
58
 
55
- grpc_tracer_flag grpc_client_channel_trace =
56
- GRPC_TRACER_INITIALIZER(false, "client_channel");
59
+ grpc_core::TraceFlag grpc_client_channel_trace(false, "client_channel");
57
60
 
58
61
  /*************************************************************************
59
62
  * METHOD-CONFIG TABLE
@@ -68,28 +71,33 @@ typedef enum {
68
71
 
69
72
  typedef struct {
70
73
  gpr_refcount refs;
71
- gpr_timespec timeout;
74
+ grpc_millis timeout;
72
75
  wait_for_ready_value wait_for_ready;
73
76
  } method_parameters;
74
77
 
75
- static method_parameters *method_parameters_ref(
76
- method_parameters *method_params) {
78
+ static method_parameters* method_parameters_ref(
79
+ method_parameters* method_params) {
77
80
  gpr_ref(&method_params->refs);
78
81
  return method_params;
79
82
  }
80
83
 
81
- static void method_parameters_unref(method_parameters *method_params) {
84
+ static void method_parameters_unref(method_parameters* method_params) {
82
85
  if (gpr_unref(&method_params->refs)) {
83
86
  gpr_free(method_params);
84
87
  }
85
88
  }
86
89
 
87
- static void method_parameters_free(grpc_exec_ctx *exec_ctx, void *value) {
88
- method_parameters_unref((method_parameters *)value);
90
+ // Wrappers to pass to grpc_service_config_create_method_config_table().
91
+ static void* method_parameters_ref_wrapper(void* value) {
92
+ return method_parameters_ref((method_parameters*)value);
93
+ }
94
+ static void method_parameters_unref_wrapper(grpc_exec_ctx* exec_ctx,
95
+ void* value) {
96
+ method_parameters_unref((method_parameters*)value);
89
97
  }
90
98
 
91
- static bool parse_wait_for_ready(grpc_json *field,
92
- wait_for_ready_value *wait_for_ready) {
99
+ static bool parse_wait_for_ready(grpc_json* field,
100
+ wait_for_ready_value* wait_for_ready) {
93
101
  if (field->type != GRPC_JSON_TRUE && field->type != GRPC_JSON_FALSE) {
94
102
  return false;
95
103
  }
@@ -98,58 +106,52 @@ static bool parse_wait_for_ready(grpc_json *field,
98
106
  return true;
99
107
  }
100
108
 
101
- static bool parse_timeout(grpc_json *field, gpr_timespec *timeout) {
109
+ static bool parse_timeout(grpc_json* field, grpc_millis* timeout) {
102
110
  if (field->type != GRPC_JSON_STRING) return false;
103
111
  size_t len = strlen(field->value);
104
112
  if (field->value[len - 1] != 's') return false;
105
- char *buf = gpr_strdup(field->value);
113
+ char* buf = gpr_strdup(field->value);
106
114
  buf[len - 1] = '\0'; // Remove trailing 's'.
107
- char *decimal_point = strchr(buf, '.');
108
- if (decimal_point != NULL) {
115
+ char* decimal_point = strchr(buf, '.');
116
+ int nanos = 0;
117
+ if (decimal_point != nullptr) {
109
118
  *decimal_point = '\0';
110
- timeout->tv_nsec = gpr_parse_nonnegative_int(decimal_point + 1);
111
- if (timeout->tv_nsec == -1) {
119
+ nanos = gpr_parse_nonnegative_int(decimal_point + 1);
120
+ if (nanos == -1) {
121
+ gpr_free(buf);
122
+ return false;
123
+ }
124
+ int num_digits = (int)strlen(decimal_point + 1);
125
+ if (num_digits > 9) { // We don't accept greater precision than nanos.
112
126
  gpr_free(buf);
113
127
  return false;
114
128
  }
115
- // There should always be exactly 3, 6, or 9 fractional digits.
116
- int multiplier = 1;
117
- switch (strlen(decimal_point + 1)) {
118
- case 9:
119
- break;
120
- case 6:
121
- multiplier *= 1000;
122
- break;
123
- case 3:
124
- multiplier *= 1000000;
125
- break;
126
- default: // Unsupported number of digits.
127
- gpr_free(buf);
128
- return false;
129
+ for (int i = 0; i < (9 - num_digits); ++i) {
130
+ nanos *= 10;
129
131
  }
130
- timeout->tv_nsec *= multiplier;
131
132
  }
132
- timeout->tv_sec = gpr_parse_nonnegative_int(buf);
133
+ int seconds = decimal_point == buf ? 0 : gpr_parse_nonnegative_int(buf);
133
134
  gpr_free(buf);
134
- if (timeout->tv_sec == -1) return false;
135
+ if (seconds == -1) return false;
136
+ *timeout = seconds * GPR_MS_PER_SEC + nanos / GPR_NS_PER_MS;
135
137
  return true;
136
138
  }
137
139
 
138
- static void *method_parameters_create_from_json(const grpc_json *json) {
140
+ static void* method_parameters_create_from_json(const grpc_json* json) {
139
141
  wait_for_ready_value wait_for_ready = WAIT_FOR_READY_UNSET;
140
- gpr_timespec timeout = {0, 0, GPR_TIMESPAN};
141
- for (grpc_json *field = json->child; field != NULL; field = field->next) {
142
- if (field->key == NULL) continue;
142
+ grpc_millis timeout = 0;
143
+ for (grpc_json* field = json->child; field != nullptr; field = field->next) {
144
+ if (field->key == nullptr) continue;
143
145
  if (strcmp(field->key, "waitForReady") == 0) {
144
- if (wait_for_ready != WAIT_FOR_READY_UNSET) return NULL; // Duplicate.
145
- if (!parse_wait_for_ready(field, &wait_for_ready)) return NULL;
146
+ if (wait_for_ready != WAIT_FOR_READY_UNSET) return nullptr; // Duplicate.
147
+ if (!parse_wait_for_ready(field, &wait_for_ready)) return nullptr;
146
148
  } else if (strcmp(field->key, "timeout") == 0) {
147
- if (timeout.tv_sec > 0 || timeout.tv_nsec > 0) return NULL; // Duplicate.
148
- if (!parse_timeout(field, &timeout)) return NULL;
149
+ if (timeout > 0) return nullptr; // Duplicate.
150
+ if (!parse_timeout(field, &timeout)) return nullptr;
149
151
  }
150
152
  }
151
- method_parameters *value =
152
- (method_parameters *)gpr_malloc(sizeof(method_parameters));
153
+ method_parameters* value =
154
+ (method_parameters*)gpr_malloc(sizeof(method_parameters));
153
155
  gpr_ref_init(&value->refs, 1);
154
156
  value->timeout = timeout;
155
157
  value->wait_for_ready = wait_for_ready;
@@ -164,24 +166,24 @@ struct external_connectivity_watcher;
164
166
 
165
167
  typedef struct client_channel_channel_data {
166
168
  /** resolver for this channel */
167
- grpc_resolver *resolver;
169
+ grpc_resolver* resolver;
168
170
  /** have we started resolving this channel */
169
171
  bool started_resolving;
170
172
  /** is deadline checking enabled? */
171
173
  bool deadline_checking_enabled;
172
174
  /** client channel factory */
173
- grpc_client_channel_factory *client_channel_factory;
175
+ grpc_client_channel_factory* client_channel_factory;
174
176
 
175
177
  /** combiner protecting all variables below in this data structure */
176
- grpc_combiner *combiner;
178
+ grpc_combiner* combiner;
177
179
  /** currently active load balancer */
178
- grpc_lb_policy *lb_policy;
180
+ grpc_lb_policy* lb_policy;
179
181
  /** retry throttle data */
180
- grpc_server_retry_throttle_data *retry_throttle_data;
182
+ grpc_server_retry_throttle_data* retry_throttle_data;
181
183
  /** maps method names to method_parameters structs */
182
- grpc_slice_hash_table *method_params_table;
184
+ grpc_slice_hash_table* method_params_table;
183
185
  /** incoming resolver result - set by resolver.next() */
184
- grpc_channel_args *resolver_result;
186
+ grpc_channel_args* resolver_result;
185
187
  /** a list of closures that are all waiting for resolver result to come in */
186
188
  grpc_closure_list waiting_for_resolver_result_closures;
187
189
  /** resolver callback */
@@ -191,47 +193,47 @@ typedef struct client_channel_channel_data {
191
193
  /** when an lb_policy arrives, should we try to exit idle */
192
194
  bool exit_idle_when_lb_policy_arrives;
193
195
  /** owning stack */
194
- grpc_channel_stack *owning_stack;
196
+ grpc_channel_stack* owning_stack;
195
197
  /** interested parties (owned) */
196
- grpc_pollset_set *interested_parties;
198
+ grpc_pollset_set* interested_parties;
197
199
 
198
200
  /* external_connectivity_watcher_list head is guarded by its own mutex, since
199
201
  * counts need to be grabbed immediately without polling on a cq */
200
202
  gpr_mu external_connectivity_watcher_list_mu;
201
- struct external_connectivity_watcher *external_connectivity_watcher_list_head;
203
+ struct external_connectivity_watcher* external_connectivity_watcher_list_head;
202
204
 
203
205
  /* the following properties are guarded by a mutex since API's require them
204
206
  to be instantaneously available */
205
207
  gpr_mu info_mu;
206
- char *info_lb_policy_name;
208
+ char* info_lb_policy_name;
207
209
  /** service config in JSON form */
208
- char *info_service_config_json;
210
+ char* info_service_config_json;
209
211
  } channel_data;
210
212
 
211
213
  /** We create one watcher for each new lb_policy that is returned from a
212
214
  resolver, to watch for state changes from the lb_policy. When a state
213
215
  change is seen, we update the channel, and create a new watcher. */
214
216
  typedef struct {
215
- channel_data *chand;
217
+ channel_data* chand;
216
218
  grpc_closure on_changed;
217
219
  grpc_connectivity_state state;
218
- grpc_lb_policy *lb_policy;
220
+ grpc_lb_policy* lb_policy;
219
221
  } lb_policy_connectivity_watcher;
220
222
 
221
- static void watch_lb_policy_locked(grpc_exec_ctx *exec_ctx, channel_data *chand,
222
- grpc_lb_policy *lb_policy,
223
+ static void watch_lb_policy_locked(grpc_exec_ctx* exec_ctx, channel_data* chand,
224
+ grpc_lb_policy* lb_policy,
223
225
  grpc_connectivity_state current_state);
224
226
 
225
- static void set_channel_connectivity_state_locked(grpc_exec_ctx *exec_ctx,
226
- channel_data *chand,
227
+ static void set_channel_connectivity_state_locked(grpc_exec_ctx* exec_ctx,
228
+ channel_data* chand,
227
229
  grpc_connectivity_state state,
228
- grpc_error *error,
229
- const char *reason) {
230
+ grpc_error* error,
231
+ const char* reason) {
230
232
  /* TODO: Improve failure handling:
231
233
  * - Make it possible for policies to return GRPC_CHANNEL_TRANSIENT_FAILURE.
232
234
  * - Hand over pending picks from old policies during the switch that happens
233
235
  * when resolver provides an update. */
234
- if (chand->lb_policy != NULL) {
236
+ if (chand->lb_policy != nullptr) {
235
237
  if (state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
236
238
  /* cancel picks with wait_for_ready=false */
237
239
  grpc_lb_policy_cancel_picks_locked(
@@ -245,7 +247,7 @@ static void set_channel_connectivity_state_locked(grpc_exec_ctx *exec_ctx,
245
247
  GRPC_ERROR_REF(error));
246
248
  }
247
249
  }
248
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
250
+ if (grpc_client_channel_trace.enabled()) {
249
251
  gpr_log(GPR_DEBUG, "chand=%p: setting connectivity state to %s", chand,
250
252
  grpc_connectivity_state_name(state));
251
253
  }
@@ -253,21 +255,22 @@ static void set_channel_connectivity_state_locked(grpc_exec_ctx *exec_ctx,
253
255
  reason);
254
256
  }
255
257
 
256
- static void on_lb_policy_state_changed_locked(grpc_exec_ctx *exec_ctx,
257
- void *arg, grpc_error *error) {
258
- lb_policy_connectivity_watcher *w = (lb_policy_connectivity_watcher *)arg;
258
+ static void on_lb_policy_state_changed_locked(grpc_exec_ctx* exec_ctx,
259
+ void* arg, grpc_error* error) {
260
+ lb_policy_connectivity_watcher* w = (lb_policy_connectivity_watcher*)arg;
259
261
  grpc_connectivity_state publish_state = w->state;
260
262
  /* check if the notification is for the latest policy */
261
263
  if (w->lb_policy == w->chand->lb_policy) {
262
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
264
+ if (grpc_client_channel_trace.enabled()) {
263
265
  gpr_log(GPR_DEBUG, "chand=%p: lb_policy=%p state changed to %s", w->chand,
264
266
  w->lb_policy, grpc_connectivity_state_name(w->state));
265
267
  }
266
- if (publish_state == GRPC_CHANNEL_SHUTDOWN && w->chand->resolver != NULL) {
268
+ if (publish_state == GRPC_CHANNEL_SHUTDOWN &&
269
+ w->chand->resolver != nullptr) {
267
270
  publish_state = GRPC_CHANNEL_TRANSIENT_FAILURE;
268
271
  grpc_resolver_channel_saw_error_locked(exec_ctx, w->chand->resolver);
269
272
  GRPC_LB_POLICY_UNREF(exec_ctx, w->chand->lb_policy, "channel");
270
- w->chand->lb_policy = NULL;
273
+ w->chand->lb_policy = nullptr;
271
274
  }
272
275
  set_channel_connectivity_state_locked(exec_ctx, w->chand, publish_state,
273
276
  GRPC_ERROR_REF(error), "lb_changed");
@@ -279,11 +282,11 @@ static void on_lb_policy_state_changed_locked(grpc_exec_ctx *exec_ctx,
279
282
  gpr_free(w);
280
283
  }
281
284
 
282
- static void watch_lb_policy_locked(grpc_exec_ctx *exec_ctx, channel_data *chand,
283
- grpc_lb_policy *lb_policy,
285
+ static void watch_lb_policy_locked(grpc_exec_ctx* exec_ctx, channel_data* chand,
286
+ grpc_lb_policy* lb_policy,
284
287
  grpc_connectivity_state current_state) {
285
- lb_policy_connectivity_watcher *w =
286
- (lb_policy_connectivity_watcher *)gpr_malloc(sizeof(*w));
288
+ lb_policy_connectivity_watcher* w =
289
+ (lb_policy_connectivity_watcher*)gpr_malloc(sizeof(*w));
287
290
  GRPC_CHANNEL_STACK_REF(chand->owning_stack, "watch_lb_policy");
288
291
  w->chand = chand;
289
292
  GRPC_CLOSURE_INIT(&w->on_changed, on_lb_policy_state_changed_locked, w,
@@ -294,9 +297,9 @@ static void watch_lb_policy_locked(grpc_exec_ctx *exec_ctx, channel_data *chand,
294
297
  &w->on_changed);
295
298
  }
296
299
 
297
- static void start_resolving_locked(grpc_exec_ctx *exec_ctx,
298
- channel_data *chand) {
299
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
300
+ static void start_resolving_locked(grpc_exec_ctx* exec_ctx,
301
+ channel_data* chand) {
302
+ if (grpc_client_channel_trace.enabled()) {
300
303
  gpr_log(GPR_DEBUG, "chand=%p: starting name resolution", chand);
301
304
  }
302
305
  GPR_ASSERT(!chand->started_resolving);
@@ -307,21 +310,21 @@ static void start_resolving_locked(grpc_exec_ctx *exec_ctx,
307
310
  }
308
311
 
309
312
  typedef struct {
310
- char *server_name;
311
- grpc_server_retry_throttle_data *retry_throttle_data;
313
+ char* server_name;
314
+ grpc_server_retry_throttle_data* retry_throttle_data;
312
315
  } service_config_parsing_state;
313
316
 
314
- static void parse_retry_throttle_params(const grpc_json *field, void *arg) {
315
- service_config_parsing_state *parsing_state =
316
- (service_config_parsing_state *)arg;
317
+ static void parse_retry_throttle_params(const grpc_json* field, void* arg) {
318
+ service_config_parsing_state* parsing_state =
319
+ (service_config_parsing_state*)arg;
317
320
  if (strcmp(field->key, "retryThrottling") == 0) {
318
- if (parsing_state->retry_throttle_data != NULL) return; // Duplicate.
321
+ if (parsing_state->retry_throttle_data != nullptr) return; // Duplicate.
319
322
  if (field->type != GRPC_JSON_OBJECT) return;
320
323
  int max_milli_tokens = 0;
321
324
  int milli_token_ratio = 0;
322
- for (grpc_json *sub_field = field->child; sub_field != NULL;
325
+ for (grpc_json* sub_field = field->child; sub_field != nullptr;
323
326
  sub_field = sub_field->next) {
324
- if (sub_field->key == NULL) return;
327
+ if (sub_field->key == nullptr) return;
325
328
  if (strcmp(sub_field->key, "maxTokens") == 0) {
326
329
  if (max_milli_tokens != 0) return; // Duplicate.
327
330
  if (sub_field->type != GRPC_JSON_NUMBER) return;
@@ -335,8 +338,8 @@ static void parse_retry_throttle_params(const grpc_json *field, void *arg) {
335
338
  size_t whole_len = strlen(sub_field->value);
336
339
  uint32_t multiplier = 1;
337
340
  uint32_t decimal_value = 0;
338
- const char *decimal_point = strchr(sub_field->value, '.');
339
- if (decimal_point != NULL) {
341
+ const char* decimal_point = strchr(sub_field->value, '.');
342
+ if (decimal_point != nullptr) {
340
343
  whole_len = (size_t)(decimal_point - sub_field->value);
341
344
  multiplier = 1000;
342
345
  size_t decimal_len = strlen(decimal_point + 1);
@@ -366,27 +369,27 @@ static void parse_retry_throttle_params(const grpc_json *field, void *arg) {
366
369
  }
367
370
  }
368
371
 
369
- static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
370
- void *arg, grpc_error *error) {
371
- channel_data *chand = (channel_data *)arg;
372
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
372
+ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
373
+ void* arg, grpc_error* error) {
374
+ channel_data* chand = (channel_data*)arg;
375
+ if (grpc_client_channel_trace.enabled()) {
373
376
  gpr_log(GPR_DEBUG, "chand=%p: got resolver result: error=%s", chand,
374
377
  grpc_error_string(error));
375
378
  }
376
379
  // Extract the following fields from the resolver result, if non-NULL.
377
380
  bool lb_policy_updated = false;
378
- char *lb_policy_name_dup = NULL;
381
+ char* lb_policy_name_dup = nullptr;
379
382
  bool lb_policy_name_changed = false;
380
- grpc_lb_policy *new_lb_policy = NULL;
381
- char *service_config_json = NULL;
382
- grpc_server_retry_throttle_data *retry_throttle_data = NULL;
383
- grpc_slice_hash_table *method_params_table = NULL;
384
- if (chand->resolver_result != NULL) {
383
+ grpc_lb_policy* new_lb_policy = nullptr;
384
+ char* service_config_json = nullptr;
385
+ grpc_server_retry_throttle_data* retry_throttle_data = nullptr;
386
+ grpc_slice_hash_table* method_params_table = nullptr;
387
+ if (chand->resolver_result != nullptr) {
385
388
  // Find LB policy name.
386
- const char *lb_policy_name = NULL;
387
- const grpc_arg *channel_arg =
389
+ const char* lb_policy_name = nullptr;
390
+ const grpc_arg* channel_arg =
388
391
  grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_POLICY_NAME);
389
- if (channel_arg != NULL) {
392
+ if (channel_arg != nullptr) {
390
393
  GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
391
394
  lb_policy_name = channel_arg->value.string;
392
395
  }
@@ -394,9 +397,9 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
394
397
  // the grpclb policy, regardless of what the resolver actually specified.
395
398
  channel_arg =
396
399
  grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_ADDRESSES);
397
- if (channel_arg != NULL && channel_arg->type == GRPC_ARG_POINTER) {
398
- grpc_lb_addresses *addresses =
399
- (grpc_lb_addresses *)channel_arg->value.pointer.p;
400
+ if (channel_arg != nullptr && channel_arg->type == GRPC_ARG_POINTER) {
401
+ grpc_lb_addresses* addresses =
402
+ (grpc_lb_addresses*)channel_arg->value.pointer.p;
400
403
  bool found_balancer_address = false;
401
404
  for (size_t i = 0; i < addresses->num_addresses; ++i) {
402
405
  if (addresses->addresses[i].is_balancer) {
@@ -405,7 +408,8 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
405
408
  }
406
409
  }
407
410
  if (found_balancer_address) {
408
- if (lb_policy_name != NULL && strcmp(lb_policy_name, "grpclb") != 0) {
411
+ if (lb_policy_name != nullptr &&
412
+ strcmp(lb_policy_name, "grpclb") != 0) {
409
413
  gpr_log(GPR_INFO,
410
414
  "resolver requested LB policy %s but provided at least one "
411
415
  "balancer address -- forcing use of grpclb LB policy",
@@ -416,7 +420,7 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
416
420
  }
417
421
  // Use pick_first if nothing was specified and we didn't select grpclb
418
422
  // above.
419
- if (lb_policy_name == NULL) lb_policy_name = "pick_first";
423
+ if (lb_policy_name == nullptr) lb_policy_name = "pick_first";
420
424
  grpc_lb_policy_args lb_policy_args;
421
425
  lb_policy_args.args = chand->resolver_result;
422
426
  lb_policy_args.client_channel_factory = chand->client_channel_factory;
@@ -427,9 +431,9 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
427
431
  // only thing that modifies its value, and it can only be invoked
428
432
  // once at any given time.
429
433
  lb_policy_name_changed =
430
- chand->info_lb_policy_name == NULL ||
434
+ chand->info_lb_policy_name == nullptr ||
431
435
  strcmp(chand->info_lb_policy_name, lb_policy_name) != 0;
432
- if (chand->lb_policy != NULL && !lb_policy_name_changed) {
436
+ if (chand->lb_policy != nullptr && !lb_policy_name_changed) {
433
437
  // Continue using the same LB policy. Update with new addresses.
434
438
  lb_policy_updated = true;
435
439
  grpc_lb_policy_update_locked(exec_ctx, chand->lb_policy, &lb_policy_args);
@@ -437,24 +441,24 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
437
441
  // Instantiate new LB policy.
438
442
  new_lb_policy =
439
443
  grpc_lb_policy_create(exec_ctx, lb_policy_name, &lb_policy_args);
440
- if (new_lb_policy == NULL) {
444
+ if (new_lb_policy == nullptr) {
441
445
  gpr_log(GPR_ERROR, "could not create LB policy \"%s\"", lb_policy_name);
442
446
  }
443
447
  }
444
448
  // Find service config.
445
449
  channel_arg =
446
450
  grpc_channel_args_find(chand->resolver_result, GRPC_ARG_SERVICE_CONFIG);
447
- if (channel_arg != NULL) {
451
+ if (channel_arg != nullptr) {
448
452
  GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
449
453
  service_config_json = gpr_strdup(channel_arg->value.string);
450
- grpc_service_config *service_config =
454
+ grpc_service_config* service_config =
451
455
  grpc_service_config_create(service_config_json);
452
- if (service_config != NULL) {
456
+ if (service_config != nullptr) {
453
457
  channel_arg =
454
458
  grpc_channel_args_find(chand->resolver_result, GRPC_ARG_SERVER_URI);
455
- GPR_ASSERT(channel_arg != NULL);
459
+ GPR_ASSERT(channel_arg != nullptr);
456
460
  GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
457
- grpc_uri *uri =
461
+ grpc_uri* uri =
458
462
  grpc_uri_parse(exec_ctx, channel_arg->value.string, true);
459
463
  GPR_ASSERT(uri->path[0] != '\0');
460
464
  service_config_parsing_state parsing_state;
@@ -467,7 +471,7 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
467
471
  retry_throttle_data = parsing_state.retry_throttle_data;
468
472
  method_params_table = grpc_service_config_create_method_config_table(
469
473
  exec_ctx, service_config, method_parameters_create_from_json,
470
- method_parameters_free);
474
+ method_parameters_ref_wrapper, method_parameters_unref_wrapper);
471
475
  grpc_service_config_destroy(service_config);
472
476
  }
473
477
  }
@@ -476,9 +480,9 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
476
480
  // The copy will be saved in chand->lb_policy_name below.
477
481
  lb_policy_name_dup = gpr_strdup(lb_policy_name);
478
482
  grpc_channel_args_destroy(exec_ctx, chand->resolver_result);
479
- chand->resolver_result = NULL;
483
+ chand->resolver_result = nullptr;
480
484
  }
481
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
485
+ if (grpc_client_channel_trace.enabled()) {
482
486
  gpr_log(GPR_DEBUG,
483
487
  "chand=%p: resolver result: lb_policy_name=\"%s\"%s, "
484
488
  "service_config=\"%s\"",
@@ -491,22 +495,22 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
491
495
  //
492
496
  // First, swap out the data used by cc_get_channel_info().
493
497
  gpr_mu_lock(&chand->info_mu);
494
- if (lb_policy_name_dup != NULL) {
498
+ if (lb_policy_name_dup != nullptr) {
495
499
  gpr_free(chand->info_lb_policy_name);
496
500
  chand->info_lb_policy_name = lb_policy_name_dup;
497
501
  }
498
- if (service_config_json != NULL) {
502
+ if (service_config_json != nullptr) {
499
503
  gpr_free(chand->info_service_config_json);
500
504
  chand->info_service_config_json = service_config_json;
501
505
  }
502
506
  gpr_mu_unlock(&chand->info_mu);
503
507
  // Swap out the retry throttle data.
504
- if (chand->retry_throttle_data != NULL) {
508
+ if (chand->retry_throttle_data != nullptr) {
505
509
  grpc_server_retry_throttle_data_unref(chand->retry_throttle_data);
506
510
  }
507
511
  chand->retry_throttle_data = retry_throttle_data;
508
512
  // Swap out the method params table.
509
- if (chand->method_params_table != NULL) {
513
+ if (chand->method_params_table != nullptr) {
510
514
  grpc_slice_hash_table_unref(exec_ctx, chand->method_params_table);
511
515
  }
512
516
  chand->method_params_table = method_params_table;
@@ -516,10 +520,10 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
516
520
  // Note that we do NOT do this if either (a) we updated the existing
517
521
  // LB policy above or (b) we failed to create the new LB policy (in
518
522
  // which case we want to continue using the most recent one we had).
519
- if (new_lb_policy != NULL || error != GRPC_ERROR_NONE ||
520
- chand->resolver == NULL) {
521
- if (chand->lb_policy != NULL) {
522
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
523
+ if (new_lb_policy != nullptr || error != GRPC_ERROR_NONE ||
524
+ chand->resolver == nullptr) {
525
+ if (chand->lb_policy != nullptr) {
526
+ if (grpc_client_channel_trace.enabled()) {
523
527
  gpr_log(GPR_DEBUG, "chand=%p: unreffing lb_policy=%p", chand,
524
528
  chand->lb_policy);
525
529
  }
@@ -532,17 +536,17 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
532
536
  }
533
537
  // Now that we've swapped out the relevant fields of chand, check for
534
538
  // error or shutdown.
535
- if (error != GRPC_ERROR_NONE || chand->resolver == NULL) {
536
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
539
+ if (error != GRPC_ERROR_NONE || chand->resolver == nullptr) {
540
+ if (grpc_client_channel_trace.enabled()) {
537
541
  gpr_log(GPR_DEBUG, "chand=%p: shutting down", chand);
538
542
  }
539
- if (chand->resolver != NULL) {
540
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
543
+ if (chand->resolver != nullptr) {
544
+ if (grpc_client_channel_trace.enabled()) {
541
545
  gpr_log(GPR_DEBUG, "chand=%p: shutting down resolver", chand);
542
546
  }
543
547
  grpc_resolver_shutdown_locked(exec_ctx, chand->resolver);
544
548
  GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel");
545
- chand->resolver = NULL;
549
+ chand->resolver = nullptr;
546
550
  }
547
551
  set_channel_connectivity_state_locked(
548
552
  exec_ctx, chand, GRPC_CHANNEL_SHUTDOWN,
@@ -557,10 +561,10 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
557
561
  &chand->waiting_for_resolver_result_closures);
558
562
  } else { // Not shutting down.
559
563
  grpc_connectivity_state state = GRPC_CHANNEL_TRANSIENT_FAILURE;
560
- grpc_error *state_error =
564
+ grpc_error* state_error =
561
565
  GRPC_ERROR_CREATE_FROM_STATIC_STRING("No load balancing policy");
562
- if (new_lb_policy != NULL) {
563
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
566
+ if (new_lb_policy != nullptr) {
567
+ if (grpc_client_channel_trace.enabled()) {
564
568
  gpr_log(GPR_DEBUG, "chand=%p: initializing new LB policy", chand);
565
569
  }
566
570
  GRPC_ERROR_UNREF(state_error);
@@ -589,53 +593,53 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
589
593
  }
590
594
  }
591
595
 
592
- static void start_transport_op_locked(grpc_exec_ctx *exec_ctx, void *arg,
593
- grpc_error *error_ignored) {
594
- grpc_transport_op *op = (grpc_transport_op *)arg;
595
- grpc_channel_element *elem =
596
- (grpc_channel_element *)op->handler_private.extra_arg;
597
- channel_data *chand = (channel_data *)elem->channel_data;
596
+ static void start_transport_op_locked(grpc_exec_ctx* exec_ctx, void* arg,
597
+ grpc_error* error_ignored) {
598
+ grpc_transport_op* op = (grpc_transport_op*)arg;
599
+ grpc_channel_element* elem =
600
+ (grpc_channel_element*)op->handler_private.extra_arg;
601
+ channel_data* chand = (channel_data*)elem->channel_data;
598
602
 
599
- if (op->on_connectivity_state_change != NULL) {
603
+ if (op->on_connectivity_state_change != nullptr) {
600
604
  grpc_connectivity_state_notify_on_state_change(
601
605
  exec_ctx, &chand->state_tracker, op->connectivity_state,
602
606
  op->on_connectivity_state_change);
603
- op->on_connectivity_state_change = NULL;
604
- op->connectivity_state = NULL;
607
+ op->on_connectivity_state_change = nullptr;
608
+ op->connectivity_state = nullptr;
605
609
  }
606
610
 
607
- if (op->send_ping != NULL) {
608
- if (chand->lb_policy == NULL) {
611
+ if (op->send_ping != nullptr) {
612
+ if (chand->lb_policy == nullptr) {
609
613
  GRPC_CLOSURE_SCHED(
610
614
  exec_ctx, op->send_ping,
611
615
  GRPC_ERROR_CREATE_FROM_STATIC_STRING("Ping with no load balancing"));
612
616
  } else {
613
617
  grpc_lb_policy_ping_one_locked(exec_ctx, chand->lb_policy, op->send_ping);
614
- op->bind_pollset = NULL;
618
+ op->bind_pollset = nullptr;
615
619
  }
616
- op->send_ping = NULL;
620
+ op->send_ping = nullptr;
617
621
  }
618
622
 
619
623
  if (op->disconnect_with_error != GRPC_ERROR_NONE) {
620
- if (chand->resolver != NULL) {
624
+ if (chand->resolver != nullptr) {
621
625
  set_channel_connectivity_state_locked(
622
626
  exec_ctx, chand, GRPC_CHANNEL_SHUTDOWN,
623
627
  GRPC_ERROR_REF(op->disconnect_with_error), "disconnect");
624
628
  grpc_resolver_shutdown_locked(exec_ctx, chand->resolver);
625
629
  GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel");
626
- chand->resolver = NULL;
630
+ chand->resolver = nullptr;
627
631
  if (!chand->started_resolving) {
628
632
  grpc_closure_list_fail_all(&chand->waiting_for_resolver_result_closures,
629
633
  GRPC_ERROR_REF(op->disconnect_with_error));
630
634
  GRPC_CLOSURE_LIST_SCHED(exec_ctx,
631
635
  &chand->waiting_for_resolver_result_closures);
632
636
  }
633
- if (chand->lb_policy != NULL) {
637
+ if (chand->lb_policy != nullptr) {
634
638
  grpc_pollset_set_del_pollset_set(exec_ctx,
635
639
  chand->lb_policy->interested_parties,
636
640
  chand->interested_parties);
637
641
  GRPC_LB_POLICY_UNREF(exec_ctx, chand->lb_policy, "channel");
638
- chand->lb_policy = NULL;
642
+ chand->lb_policy = nullptr;
639
643
  }
640
644
  }
641
645
  GRPC_ERROR_UNREF(op->disconnect_with_error);
@@ -645,13 +649,13 @@ static void start_transport_op_locked(grpc_exec_ctx *exec_ctx, void *arg,
645
649
  GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
646
650
  }
647
651
 
648
- static void cc_start_transport_op(grpc_exec_ctx *exec_ctx,
649
- grpc_channel_element *elem,
650
- grpc_transport_op *op) {
651
- channel_data *chand = (channel_data *)elem->channel_data;
652
+ static void cc_start_transport_op(grpc_exec_ctx* exec_ctx,
653
+ grpc_channel_element* elem,
654
+ grpc_transport_op* op) {
655
+ channel_data* chand = (channel_data*)elem->channel_data;
652
656
 
653
657
  GPR_ASSERT(op->set_accept_stream == false);
654
- if (op->bind_pollset != NULL) {
658
+ if (op->bind_pollset != nullptr) {
655
659
  grpc_pollset_set_add_pollset(exec_ctx, chand->interested_parties,
656
660
  op->bind_pollset);
657
661
  }
@@ -665,30 +669,30 @@ static void cc_start_transport_op(grpc_exec_ctx *exec_ctx,
665
669
  GRPC_ERROR_NONE);
666
670
  }
667
671
 
668
- static void cc_get_channel_info(grpc_exec_ctx *exec_ctx,
669
- grpc_channel_element *elem,
670
- const grpc_channel_info *info) {
671
- channel_data *chand = (channel_data *)elem->channel_data;
672
+ static void cc_get_channel_info(grpc_exec_ctx* exec_ctx,
673
+ grpc_channel_element* elem,
674
+ const grpc_channel_info* info) {
675
+ channel_data* chand = (channel_data*)elem->channel_data;
672
676
  gpr_mu_lock(&chand->info_mu);
673
- if (info->lb_policy_name != NULL) {
674
- *info->lb_policy_name = chand->info_lb_policy_name == NULL
675
- ? NULL
677
+ if (info->lb_policy_name != nullptr) {
678
+ *info->lb_policy_name = chand->info_lb_policy_name == nullptr
679
+ ? nullptr
676
680
  : gpr_strdup(chand->info_lb_policy_name);
677
681
  }
678
- if (info->service_config_json != NULL) {
682
+ if (info->service_config_json != nullptr) {
679
683
  *info->service_config_json =
680
- chand->info_service_config_json == NULL
681
- ? NULL
684
+ chand->info_service_config_json == nullptr
685
+ ? nullptr
682
686
  : gpr_strdup(chand->info_service_config_json);
683
687
  }
684
688
  gpr_mu_unlock(&chand->info_mu);
685
689
  }
686
690
 
687
691
  /* Constructor for channel_data */
688
- static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
689
- grpc_channel_element *elem,
690
- grpc_channel_element_args *args) {
691
- channel_data *chand = (channel_data *)elem->channel_data;
692
+ static grpc_error* cc_init_channel_elem(grpc_exec_ctx* exec_ctx,
693
+ grpc_channel_element* elem,
694
+ grpc_channel_element_args* args) {
695
+ channel_data* chand = (channel_data*)elem->channel_data;
692
696
  GPR_ASSERT(args->is_last);
693
697
  GPR_ASSERT(elem->filter == &grpc_client_channel_filter);
694
698
  // Initialize data members.
@@ -697,7 +701,7 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
697
701
  gpr_mu_init(&chand->external_connectivity_watcher_list_mu);
698
702
 
699
703
  gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
700
- chand->external_connectivity_watcher_list_head = NULL;
704
+ chand->external_connectivity_watcher_list_head = nullptr;
701
705
  gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
702
706
 
703
707
  chand->owning_stack = args->channel_stack;
@@ -707,10 +711,11 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
707
711
  chand->interested_parties = grpc_pollset_set_create();
708
712
  grpc_connectivity_state_init(&chand->state_tracker, GRPC_CHANNEL_IDLE,
709
713
  "client_channel");
714
+ grpc_client_channel_start_backup_polling(exec_ctx, chand->interested_parties);
710
715
  // Record client channel factory.
711
- const grpc_arg *arg = grpc_channel_args_find(args->channel_args,
716
+ const grpc_arg* arg = grpc_channel_args_find(args->channel_args,
712
717
  GRPC_ARG_CLIENT_CHANNEL_FACTORY);
713
- if (arg == NULL) {
718
+ if (arg == nullptr) {
714
719
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
715
720
  "Missing client channel factory in args for client channel filter");
716
721
  }
@@ -719,12 +724,12 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
719
724
  "client channel factory arg must be a pointer");
720
725
  }
721
726
  grpc_client_channel_factory_ref(
722
- (grpc_client_channel_factory *)arg->value.pointer.p);
727
+ (grpc_client_channel_factory*)arg->value.pointer.p);
723
728
  chand->client_channel_factory =
724
- (grpc_client_channel_factory *)arg->value.pointer.p;
729
+ (grpc_client_channel_factory*)arg->value.pointer.p;
725
730
  // Get server name to resolve, using proxy mapper if needed.
726
731
  arg = grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVER_URI);
727
- if (arg == NULL) {
732
+ if (arg == nullptr) {
728
733
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
729
734
  "Missing server uri in args for client channel filter");
730
735
  }
@@ -732,18 +737,18 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
732
737
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
733
738
  "server uri arg must be a string");
734
739
  }
735
- char *proxy_name = NULL;
736
- grpc_channel_args *new_args = NULL;
740
+ char* proxy_name = nullptr;
741
+ grpc_channel_args* new_args = nullptr;
737
742
  grpc_proxy_mappers_map_name(exec_ctx, arg->value.string, args->channel_args,
738
743
  &proxy_name, &new_args);
739
744
  // Instantiate resolver.
740
745
  chand->resolver = grpc_resolver_create(
741
- exec_ctx, proxy_name != NULL ? proxy_name : arg->value.string,
742
- new_args != NULL ? new_args : args->channel_args,
746
+ exec_ctx, proxy_name != nullptr ? proxy_name : arg->value.string,
747
+ new_args != nullptr ? new_args : args->channel_args,
743
748
  chand->interested_parties, chand->combiner);
744
- if (proxy_name != NULL) gpr_free(proxy_name);
745
- if (new_args != NULL) grpc_channel_args_destroy(exec_ctx, new_args);
746
- if (chand->resolver == NULL) {
749
+ if (proxy_name != nullptr) gpr_free(proxy_name);
750
+ if (new_args != nullptr) grpc_channel_args_destroy(exec_ctx, new_args);
751
+ if (chand->resolver == nullptr) {
747
752
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("resolver creation failed");
748
753
  }
749
754
  chand->deadline_checking_enabled =
@@ -751,27 +756,28 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx,
751
756
  return GRPC_ERROR_NONE;
752
757
  }
753
758
 
754
- static void shutdown_resolver_locked(grpc_exec_ctx *exec_ctx, void *arg,
755
- grpc_error *error) {
756
- grpc_resolver *resolver = (grpc_resolver *)arg;
759
+ static void shutdown_resolver_locked(grpc_exec_ctx* exec_ctx, void* arg,
760
+ grpc_error* error) {
761
+ grpc_resolver* resolver = (grpc_resolver*)arg;
757
762
  grpc_resolver_shutdown_locked(exec_ctx, resolver);
758
763
  GRPC_RESOLVER_UNREF(exec_ctx, resolver, "channel");
759
764
  }
760
765
 
761
766
  /* Destructor for channel_data */
762
- static void cc_destroy_channel_elem(grpc_exec_ctx *exec_ctx,
763
- grpc_channel_element *elem) {
764
- channel_data *chand = (channel_data *)elem->channel_data;
765
- if (chand->resolver != NULL) {
767
+ static void cc_destroy_channel_elem(grpc_exec_ctx* exec_ctx,
768
+ grpc_channel_element* elem) {
769
+ channel_data* chand = (channel_data*)elem->channel_data;
770
+ if (chand->resolver != nullptr) {
766
771
  GRPC_CLOSURE_SCHED(
767
- exec_ctx, GRPC_CLOSURE_CREATE(shutdown_resolver_locked, chand->resolver,
768
- grpc_combiner_scheduler(chand->combiner)),
772
+ exec_ctx,
773
+ GRPC_CLOSURE_CREATE(shutdown_resolver_locked, chand->resolver,
774
+ grpc_combiner_scheduler(chand->combiner)),
769
775
  GRPC_ERROR_NONE);
770
776
  }
771
- if (chand->client_channel_factory != NULL) {
777
+ if (chand->client_channel_factory != nullptr) {
772
778
  grpc_client_channel_factory_unref(exec_ctx, chand->client_channel_factory);
773
779
  }
774
- if (chand->lb_policy != NULL) {
780
+ if (chand->lb_policy != nullptr) {
775
781
  grpc_pollset_set_del_pollset_set(exec_ctx,
776
782
  chand->lb_policy->interested_parties,
777
783
  chand->interested_parties);
@@ -779,12 +785,13 @@ static void cc_destroy_channel_elem(grpc_exec_ctx *exec_ctx,
779
785
  }
780
786
  gpr_free(chand->info_lb_policy_name);
781
787
  gpr_free(chand->info_service_config_json);
782
- if (chand->retry_throttle_data != NULL) {
788
+ if (chand->retry_throttle_data != nullptr) {
783
789
  grpc_server_retry_throttle_data_unref(chand->retry_throttle_data);
784
790
  }
785
- if (chand->method_params_table != NULL) {
791
+ if (chand->method_params_table != nullptr) {
786
792
  grpc_slice_hash_table_unref(exec_ctx, chand->method_params_table);
787
793
  }
794
+ grpc_client_channel_stop_backup_polling(exec_ctx, chand->interested_parties);
788
795
  grpc_connectivity_state_destroy(exec_ctx, &chand->state_tracker);
789
796
  grpc_pollset_set_destroy(exec_ctx, chand->interested_parties);
790
797
  GRPC_COMBINER_UNREF(exec_ctx, chand->combiner, "client_channel");
@@ -823,48 +830,48 @@ typedef struct client_channel_call_data {
823
830
 
824
831
  grpc_slice path; // Request path.
825
832
  gpr_timespec call_start_time;
826
- gpr_timespec deadline;
827
- gpr_arena *arena;
828
- grpc_call_stack *owning_call;
829
- grpc_call_combiner *call_combiner;
833
+ grpc_millis deadline;
834
+ gpr_arena* arena;
835
+ grpc_call_stack* owning_call;
836
+ grpc_call_combiner* call_combiner;
830
837
 
831
- grpc_server_retry_throttle_data *retry_throttle_data;
832
- method_parameters *method_params;
838
+ grpc_server_retry_throttle_data* retry_throttle_data;
839
+ method_parameters* method_params;
833
840
 
834
- grpc_subchannel_call *subchannel_call;
835
- grpc_error *error;
841
+ grpc_subchannel_call* subchannel_call;
842
+ grpc_error* error;
836
843
 
837
- grpc_lb_policy *lb_policy; // Holds ref while LB pick is pending.
844
+ grpc_lb_policy* lb_policy; // Holds ref while LB pick is pending.
838
845
  grpc_closure lb_pick_closure;
839
846
  grpc_closure lb_pick_cancel_closure;
840
847
 
841
- grpc_connected_subchannel *connected_subchannel;
848
+ grpc_connected_subchannel* connected_subchannel;
842
849
  grpc_call_context_element subchannel_call_context[GRPC_CONTEXT_COUNT];
843
- grpc_polling_entity *pollent;
850
+ grpc_polling_entity* pollent;
844
851
 
845
- grpc_transport_stream_op_batch *waiting_for_pick_batches[MAX_WAITING_BATCHES];
852
+ grpc_transport_stream_op_batch* waiting_for_pick_batches[MAX_WAITING_BATCHES];
846
853
  size_t waiting_for_pick_batches_count;
847
854
  grpc_closure handle_pending_batch_in_call_combiner[MAX_WAITING_BATCHES];
848
855
 
849
- grpc_transport_stream_op_batch *initial_metadata_batch;
856
+ grpc_transport_stream_op_batch* initial_metadata_batch;
850
857
 
851
858
  grpc_linked_mdelem lb_token_mdelem;
852
859
 
853
860
  grpc_closure on_complete;
854
- grpc_closure *original_on_complete;
861
+ grpc_closure* original_on_complete;
855
862
  } call_data;
856
863
 
857
- grpc_subchannel_call *grpc_client_channel_get_subchannel_call(
858
- grpc_call_element *elem) {
859
- call_data *calld = (call_data *)elem->call_data;
864
+ grpc_subchannel_call* grpc_client_channel_get_subchannel_call(
865
+ grpc_call_element* elem) {
866
+ call_data* calld = (call_data*)elem->call_data;
860
867
  return calld->subchannel_call;
861
868
  }
862
869
 
863
870
  // This is called via the call combiner, so access to calld is synchronized.
864
871
  static void waiting_for_pick_batches_add(
865
- call_data *calld, grpc_transport_stream_op_batch *batch) {
872
+ call_data* calld, grpc_transport_stream_op_batch* batch) {
866
873
  if (batch->send_initial_metadata) {
867
- GPR_ASSERT(calld->initial_metadata_batch == NULL);
874
+ GPR_ASSERT(calld->initial_metadata_batch == nullptr);
868
875
  calld->initial_metadata_batch = batch;
869
876
  } else {
870
877
  GPR_ASSERT(calld->waiting_for_pick_batches_count < MAX_WAITING_BATCHES);
@@ -874,9 +881,9 @@ static void waiting_for_pick_batches_add(
874
881
  }
875
882
 
876
883
  // This is called via the call combiner, so access to calld is synchronized.
877
- static void fail_pending_batch_in_call_combiner(grpc_exec_ctx *exec_ctx,
878
- void *arg, grpc_error *error) {
879
- call_data *calld = (call_data *)arg;
884
+ static void fail_pending_batch_in_call_combiner(grpc_exec_ctx* exec_ctx,
885
+ void* arg, grpc_error* error) {
886
+ call_data* calld = (call_data*)arg;
880
887
  if (calld->waiting_for_pick_batches_count > 0) {
881
888
  --calld->waiting_for_pick_batches_count;
882
889
  grpc_transport_stream_op_batch_finish_with_failure(
@@ -887,13 +894,13 @@ static void fail_pending_batch_in_call_combiner(grpc_exec_ctx *exec_ctx,
887
894
  }
888
895
 
889
896
  // This is called via the call combiner, so access to calld is synchronized.
890
- static void waiting_for_pick_batches_fail(grpc_exec_ctx *exec_ctx,
891
- grpc_call_element *elem,
892
- grpc_error *error) {
893
- call_data *calld = (call_data *)elem->call_data;
894
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
897
+ static void waiting_for_pick_batches_fail(grpc_exec_ctx* exec_ctx,
898
+ grpc_call_element* elem,
899
+ grpc_error* error) {
900
+ call_data* calld = (call_data*)elem->call_data;
901
+ if (grpc_client_channel_trace.enabled()) {
895
902
  gpr_log(GPR_DEBUG,
896
- "chand=%p calld=%p: failing %" PRIdPTR " pending batches: %s",
903
+ "chand=%p calld=%p: failing %" PRIuPTR " pending batches: %s",
897
904
  elem->channel_data, calld, calld->waiting_for_pick_batches_count,
898
905
  grpc_error_string(error));
899
906
  }
@@ -906,7 +913,7 @@ static void waiting_for_pick_batches_fail(grpc_exec_ctx *exec_ctx,
906
913
  GRPC_ERROR_REF(error),
907
914
  "waiting_for_pick_batches_fail");
908
915
  }
909
- if (calld->initial_metadata_batch != NULL) {
916
+ if (calld->initial_metadata_batch != nullptr) {
910
917
  grpc_transport_stream_op_batch_finish_with_failure(
911
918
  exec_ctx, calld->initial_metadata_batch, GRPC_ERROR_REF(error),
912
919
  calld->call_combiner);
@@ -918,9 +925,9 @@ static void waiting_for_pick_batches_fail(grpc_exec_ctx *exec_ctx,
918
925
  }
919
926
 
920
927
  // This is called via the call combiner, so access to calld is synchronized.
921
- static void run_pending_batch_in_call_combiner(grpc_exec_ctx *exec_ctx,
922
- void *arg, grpc_error *ignored) {
923
- call_data *calld = (call_data *)arg;
928
+ static void run_pending_batch_in_call_combiner(grpc_exec_ctx* exec_ctx,
929
+ void* arg, grpc_error* ignored) {
930
+ call_data* calld = (call_data*)arg;
924
931
  if (calld->waiting_for_pick_batches_count > 0) {
925
932
  --calld->waiting_for_pick_batches_count;
926
933
  grpc_subchannel_call_process_op(
@@ -930,13 +937,14 @@ static void run_pending_batch_in_call_combiner(grpc_exec_ctx *exec_ctx,
930
937
  }
931
938
 
932
939
  // This is called via the call combiner, so access to calld is synchronized.
933
- static void waiting_for_pick_batches_resume(grpc_exec_ctx *exec_ctx,
934
- grpc_call_element *elem) {
935
- channel_data *chand = (channel_data *)elem->channel_data;
936
- call_data *calld = (call_data *)elem->call_data;
937
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
938
- gpr_log(GPR_DEBUG, "chand=%p calld=%p: sending %" PRIdPTR
939
- " pending batches to subchannel_call=%p",
940
+ static void waiting_for_pick_batches_resume(grpc_exec_ctx* exec_ctx,
941
+ grpc_call_element* elem) {
942
+ channel_data* chand = (channel_data*)elem->channel_data;
943
+ call_data* calld = (call_data*)elem->call_data;
944
+ if (grpc_client_channel_trace.enabled()) {
945
+ gpr_log(GPR_DEBUG,
946
+ "chand=%p calld=%p: sending %" PRIuPTR
947
+ " pending batches to subchannel_call=%p",
940
948
  chand, calld, calld->waiting_for_pick_batches_count,
941
949
  calld->subchannel_call);
942
950
  }
@@ -949,38 +957,38 @@ static void waiting_for_pick_batches_resume(grpc_exec_ctx *exec_ctx,
949
957
  GRPC_ERROR_NONE,
950
958
  "waiting_for_pick_batches_resume");
951
959
  }
952
- GPR_ASSERT(calld->initial_metadata_batch != NULL);
960
+ GPR_ASSERT(calld->initial_metadata_batch != nullptr);
953
961
  grpc_subchannel_call_process_op(exec_ctx, calld->subchannel_call,
954
962
  calld->initial_metadata_batch);
955
963
  }
956
964
 
957
965
  // Applies service config to the call. Must be invoked once we know
958
966
  // that the resolver has returned results to the channel.
959
- static void apply_service_config_to_call_locked(grpc_exec_ctx *exec_ctx,
960
- grpc_call_element *elem) {
961
- channel_data *chand = (channel_data *)elem->channel_data;
962
- call_data *calld = (call_data *)elem->call_data;
963
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
967
+ static void apply_service_config_to_call_locked(grpc_exec_ctx* exec_ctx,
968
+ grpc_call_element* elem) {
969
+ channel_data* chand = (channel_data*)elem->channel_data;
970
+ call_data* calld = (call_data*)elem->call_data;
971
+ if (grpc_client_channel_trace.enabled()) {
964
972
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: applying service config to call",
965
973
  chand, calld);
966
974
  }
967
- if (chand->retry_throttle_data != NULL) {
975
+ if (chand->retry_throttle_data != nullptr) {
968
976
  calld->retry_throttle_data =
969
977
  grpc_server_retry_throttle_data_ref(chand->retry_throttle_data);
970
978
  }
971
- if (chand->method_params_table != NULL) {
972
- calld->method_params = (method_parameters *)grpc_method_config_table_get(
979
+ if (chand->method_params_table != nullptr) {
980
+ calld->method_params = (method_parameters*)grpc_method_config_table_get(
973
981
  exec_ctx, chand->method_params_table, calld->path);
974
- if (calld->method_params != NULL) {
982
+ if (calld->method_params != nullptr) {
975
983
  method_parameters_ref(calld->method_params);
976
984
  // If the deadline from the service config is shorter than the one
977
985
  // from the client API, reset the deadline timer.
978
986
  if (chand->deadline_checking_enabled &&
979
- gpr_time_cmp(calld->method_params->timeout,
980
- gpr_time_0(GPR_TIMESPAN)) != 0) {
981
- const gpr_timespec per_method_deadline =
982
- gpr_time_add(calld->call_start_time, calld->method_params->timeout);
983
- if (gpr_time_cmp(per_method_deadline, calld->deadline) < 0) {
987
+ calld->method_params->timeout != 0) {
988
+ const grpc_millis per_method_deadline =
989
+ grpc_timespec_to_millis_round_up(calld->call_start_time) +
990
+ calld->method_params->timeout;
991
+ if (per_method_deadline < calld->deadline) {
984
992
  calld->deadline = per_method_deadline;
985
993
  grpc_deadline_state_reset(exec_ctx, elem, calld->deadline);
986
994
  }
@@ -989,23 +997,24 @@ static void apply_service_config_to_call_locked(grpc_exec_ctx *exec_ctx,
989
997
  }
990
998
  }
991
999
 
992
- static void create_subchannel_call_locked(grpc_exec_ctx *exec_ctx,
993
- grpc_call_element *elem,
994
- grpc_error *error) {
995
- channel_data *chand = (channel_data *)elem->channel_data;
996
- call_data *calld = (call_data *)elem->call_data;
1000
+ static void create_subchannel_call_locked(grpc_exec_ctx* exec_ctx,
1001
+ grpc_call_element* elem,
1002
+ grpc_error* error) {
1003
+ channel_data* chand = (channel_data*)elem->channel_data;
1004
+ call_data* calld = (call_data*)elem->call_data;
997
1005
  const grpc_connected_subchannel_call_args call_args = {
998
- .pollent = calld->pollent,
999
- .path = calld->path,
1000
- .start_time = calld->call_start_time,
1001
- .deadline = calld->deadline,
1002
- .arena = calld->arena,
1003
- .context = calld->subchannel_call_context,
1004
- .call_combiner = calld->call_combiner};
1005
- grpc_error *new_error = grpc_connected_subchannel_create_call(
1006
+ calld->pollent, // pollent
1007
+ calld->path, // path
1008
+ calld->call_start_time, // start_time
1009
+ calld->deadline, // deadline
1010
+ calld->arena, // arena
1011
+ calld->subchannel_call_context, // context
1012
+ calld->call_combiner // call_combiner
1013
+ };
1014
+ grpc_error* new_error = grpc_connected_subchannel_create_call(
1006
1015
  exec_ctx, calld->connected_subchannel, &call_args,
1007
1016
  &calld->subchannel_call);
1008
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1017
+ if (grpc_client_channel_trace.enabled()) {
1009
1018
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: create subchannel_call=%p: error=%s",
1010
1019
  chand, calld, calld->subchannel_call, grpc_error_string(new_error));
1011
1020
  }
@@ -1019,11 +1028,11 @@ static void create_subchannel_call_locked(grpc_exec_ctx *exec_ctx,
1019
1028
  }
1020
1029
 
1021
1030
  // Invoked when a pick is completed, on both success or failure.
1022
- static void pick_done_locked(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
1023
- grpc_error *error) {
1024
- call_data *calld = (call_data *)elem->call_data;
1025
- channel_data *chand = (channel_data *)elem->channel_data;
1026
- if (calld->connected_subchannel == NULL) {
1031
+ static void pick_done_locked(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
1032
+ grpc_error* error) {
1033
+ call_data* calld = (call_data*)elem->call_data;
1034
+ channel_data* chand = (channel_data*)elem->channel_data;
1035
+ if (calld->connected_subchannel == nullptr) {
1027
1036
  // Failed to create subchannel.
1028
1037
  GRPC_ERROR_UNREF(calld->error);
1029
1038
  calld->error = error == GRPC_ERROR_NONE
@@ -1031,7 +1040,7 @@ static void pick_done_locked(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
1031
1040
  "Call dropped by load balancing policy")
1032
1041
  : GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
1033
1042
  "Failed to create subchannel", &error, 1);
1034
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1043
+ if (grpc_client_channel_trace.enabled()) {
1035
1044
  gpr_log(GPR_DEBUG,
1036
1045
  "chand=%p calld=%p: failed to create subchannel: error=%s", chand,
1037
1046
  calld, grpc_error_string(calld->error));
@@ -1048,10 +1057,10 @@ static void pick_done_locked(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
1048
1057
  // either (a) the pick was deferred pending a resolver result or (b) the
1049
1058
  // pick was done asynchronously. Removes the call's polling entity from
1050
1059
  // chand->interested_parties before invoking pick_done_locked().
1051
- static void async_pick_done_locked(grpc_exec_ctx *exec_ctx,
1052
- grpc_call_element *elem, grpc_error *error) {
1053
- channel_data *chand = (channel_data *)elem->channel_data;
1054
- call_data *calld = (call_data *)elem->call_data;
1060
+ static void async_pick_done_locked(grpc_exec_ctx* exec_ctx,
1061
+ grpc_call_element* elem, grpc_error* error) {
1062
+ channel_data* chand = (channel_data*)elem->channel_data;
1063
+ call_data* calld = (call_data*)elem->call_data;
1055
1064
  grpc_polling_entity_del_from_pollset_set(exec_ctx, calld->pollent,
1056
1065
  chand->interested_parties);
1057
1066
  pick_done_locked(exec_ctx, elem, error);
@@ -1059,13 +1068,13 @@ static void async_pick_done_locked(grpc_exec_ctx *exec_ctx,
1059
1068
 
1060
1069
  // Note: This runs under the client_channel combiner, but will NOT be
1061
1070
  // holding the call combiner.
1062
- static void pick_callback_cancel_locked(grpc_exec_ctx *exec_ctx, void *arg,
1063
- grpc_error *error) {
1064
- grpc_call_element *elem = (grpc_call_element *)arg;
1065
- channel_data *chand = (channel_data *)elem->channel_data;
1066
- call_data *calld = (call_data *)elem->call_data;
1067
- if (calld->lb_policy != NULL) {
1068
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1071
+ static void pick_callback_cancel_locked(grpc_exec_ctx* exec_ctx, void* arg,
1072
+ grpc_error* error) {
1073
+ grpc_call_element* elem = (grpc_call_element*)arg;
1074
+ channel_data* chand = (channel_data*)elem->channel_data;
1075
+ call_data* calld = (call_data*)elem->call_data;
1076
+ if (calld->lb_policy != nullptr) {
1077
+ if (grpc_client_channel_trace.enabled()) {
1069
1078
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: cancelling pick from LB policy %p",
1070
1079
  chand, calld, calld->lb_policy);
1071
1080
  }
@@ -1078,29 +1087,29 @@ static void pick_callback_cancel_locked(grpc_exec_ctx *exec_ctx, void *arg,
1078
1087
 
1079
1088
  // Callback invoked by grpc_lb_policy_pick_locked() for async picks.
1080
1089
  // Unrefs the LB policy and invokes async_pick_done_locked().
1081
- static void pick_callback_done_locked(grpc_exec_ctx *exec_ctx, void *arg,
1082
- grpc_error *error) {
1083
- grpc_call_element *elem = (grpc_call_element *)arg;
1084
- channel_data *chand = (channel_data *)elem->channel_data;
1085
- call_data *calld = (call_data *)elem->call_data;
1086
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1090
+ static void pick_callback_done_locked(grpc_exec_ctx* exec_ctx, void* arg,
1091
+ grpc_error* error) {
1092
+ grpc_call_element* elem = (grpc_call_element*)arg;
1093
+ channel_data* chand = (channel_data*)elem->channel_data;
1094
+ call_data* calld = (call_data*)elem->call_data;
1095
+ if (grpc_client_channel_trace.enabled()) {
1087
1096
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: pick completed asynchronously",
1088
1097
  chand, calld);
1089
1098
  }
1090
- GPR_ASSERT(calld->lb_policy != NULL);
1099
+ GPR_ASSERT(calld->lb_policy != nullptr);
1091
1100
  GRPC_LB_POLICY_UNREF(exec_ctx, calld->lb_policy, "pick_subchannel");
1092
- calld->lb_policy = NULL;
1101
+ calld->lb_policy = nullptr;
1093
1102
  async_pick_done_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
1094
1103
  }
1095
1104
 
1096
1105
  // Takes a ref to chand->lb_policy and calls grpc_lb_policy_pick_locked().
1097
1106
  // If the pick was completed synchronously, unrefs the LB policy and
1098
1107
  // returns true.
1099
- static bool pick_callback_start_locked(grpc_exec_ctx *exec_ctx,
1100
- grpc_call_element *elem) {
1101
- channel_data *chand = (channel_data *)elem->channel_data;
1102
- call_data *calld = (call_data *)elem->call_data;
1103
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1108
+ static bool pick_callback_start_locked(grpc_exec_ctx* exec_ctx,
1109
+ grpc_call_element* elem) {
1110
+ channel_data* chand = (channel_data*)elem->channel_data;
1111
+ call_data* calld = (call_data*)elem->call_data;
1112
+ if (grpc_client_channel_trace.enabled()) {
1104
1113
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: starting pick on lb_policy=%p",
1105
1114
  chand, calld, chand->lb_policy);
1106
1115
  }
@@ -1115,7 +1124,7 @@ static bool pick_callback_start_locked(grpc_exec_ctx *exec_ctx,
1115
1124
  initial_metadata_flags &
1116
1125
  GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET;
1117
1126
  const bool wait_for_ready_set_from_service_config =
1118
- calld->method_params != NULL &&
1127
+ calld->method_params != nullptr &&
1119
1128
  calld->method_params->wait_for_ready != WAIT_FOR_READY_UNSET;
1120
1129
  if (!wait_for_ready_set_from_api && wait_for_ready_set_from_service_config) {
1121
1130
  if (calld->method_params->wait_for_ready == WAIT_FOR_READY_TRUE) {
@@ -1135,15 +1144,15 @@ static bool pick_callback_start_locked(grpc_exec_ctx *exec_ctx,
1135
1144
  grpc_combiner_scheduler(chand->combiner));
1136
1145
  const bool pick_done = grpc_lb_policy_pick_locked(
1137
1146
  exec_ctx, chand->lb_policy, &inputs, &calld->connected_subchannel,
1138
- calld->subchannel_call_context, NULL, &calld->lb_pick_closure);
1147
+ calld->subchannel_call_context, nullptr, &calld->lb_pick_closure);
1139
1148
  if (pick_done) {
1140
1149
  /* synchronous grpc_lb_policy_pick call. Unref the LB policy. */
1141
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1150
+ if (grpc_client_channel_trace.enabled()) {
1142
1151
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: pick completed synchronously",
1143
1152
  chand, calld);
1144
1153
  }
1145
1154
  GRPC_LB_POLICY_UNREF(exec_ctx, calld->lb_policy, "pick_subchannel");
1146
- calld->lb_policy = NULL;
1155
+ calld->lb_policy = nullptr;
1147
1156
  } else {
1148
1157
  GRPC_CALL_STACK_REF(calld->owning_call, "pick_callback_cancel");
1149
1158
  grpc_call_combiner_set_notify_on_cancel(
@@ -1156,7 +1165,7 @@ static bool pick_callback_start_locked(grpc_exec_ctx *exec_ctx,
1156
1165
  }
1157
1166
 
1158
1167
  typedef struct {
1159
- grpc_call_element *elem;
1168
+ grpc_call_element* elem;
1160
1169
  bool finished;
1161
1170
  grpc_closure closure;
1162
1171
  grpc_closure cancel_closure;
@@ -1164,11 +1173,10 @@ typedef struct {
1164
1173
 
1165
1174
  // Note: This runs under the client_channel combiner, but will NOT be
1166
1175
  // holding the call combiner.
1167
- static void pick_after_resolver_result_cancel_locked(grpc_exec_ctx *exec_ctx,
1168
- void *arg,
1169
- grpc_error *error) {
1170
- pick_after_resolver_result_args *args =
1171
- (pick_after_resolver_result_args *)arg;
1176
+ static void pick_after_resolver_result_cancel_locked(grpc_exec_ctx* exec_ctx,
1177
+ void* arg,
1178
+ grpc_error* error) {
1179
+ pick_after_resolver_result_args* args = (pick_after_resolver_result_args*)arg;
1172
1180
  if (args->finished) {
1173
1181
  gpr_free(args);
1174
1182
  return;
@@ -1181,10 +1189,10 @@ static void pick_after_resolver_result_cancel_locked(grpc_exec_ctx *exec_ctx,
1181
1189
  // is called, it will be a no-op. We also immediately invoke
1182
1190
  // async_pick_done_locked() to propagate the error back to the caller.
1183
1191
  args->finished = true;
1184
- grpc_call_element *elem = args->elem;
1185
- channel_data *chand = (channel_data *)elem->channel_data;
1186
- call_data *calld = (call_data *)elem->call_data;
1187
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1192
+ grpc_call_element* elem = args->elem;
1193
+ channel_data* chand = (channel_data*)elem->channel_data;
1194
+ call_data* calld = (call_data*)elem->call_data;
1195
+ if (grpc_client_channel_trace.enabled()) {
1188
1196
  gpr_log(GPR_DEBUG,
1189
1197
  "chand=%p calld=%p: cancelling pick waiting for resolver result",
1190
1198
  chand, calld);
@@ -1199,31 +1207,33 @@ static void pick_after_resolver_result_cancel_locked(grpc_exec_ctx *exec_ctx,
1199
1207
  "Pick cancelled", &error, 1));
1200
1208
  }
1201
1209
 
1202
- static void pick_after_resolver_result_done_locked(grpc_exec_ctx *exec_ctx,
1203
- void *arg,
1204
- grpc_error *error) {
1205
- pick_after_resolver_result_args *args =
1206
- (pick_after_resolver_result_args *)arg;
1210
+ static void pick_after_resolver_result_start_locked(grpc_exec_ctx* exec_ctx,
1211
+ grpc_call_element* elem);
1212
+
1213
+ static void pick_after_resolver_result_done_locked(grpc_exec_ctx* exec_ctx,
1214
+ void* arg,
1215
+ grpc_error* error) {
1216
+ pick_after_resolver_result_args* args = (pick_after_resolver_result_args*)arg;
1207
1217
  if (args->finished) {
1208
1218
  /* cancelled, do nothing */
1209
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1219
+ if (grpc_client_channel_trace.enabled()) {
1210
1220
  gpr_log(GPR_DEBUG, "call cancelled before resolver result");
1211
1221
  }
1212
1222
  gpr_free(args);
1213
1223
  return;
1214
1224
  }
1215
1225
  args->finished = true;
1216
- grpc_call_element *elem = args->elem;
1217
- channel_data *chand = (channel_data *)elem->channel_data;
1218
- call_data *calld = (call_data *)elem->call_data;
1226
+ grpc_call_element* elem = args->elem;
1227
+ channel_data* chand = (channel_data*)elem->channel_data;
1228
+ call_data* calld = (call_data*)elem->call_data;
1219
1229
  if (error != GRPC_ERROR_NONE) {
1220
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1230
+ if (grpc_client_channel_trace.enabled()) {
1221
1231
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver failed to return data",
1222
1232
  chand, calld);
1223
1233
  }
1224
1234
  async_pick_done_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
1225
- } else {
1226
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1235
+ } else if (chand->lb_policy != nullptr) {
1236
+ if (grpc_client_channel_trace.enabled()) {
1227
1237
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver returned, doing pick",
1228
1238
  chand, calld);
1229
1239
  }
@@ -1236,19 +1246,43 @@ static void pick_after_resolver_result_done_locked(grpc_exec_ctx *exec_ctx,
1236
1246
  async_pick_done_locked(exec_ctx, elem, GRPC_ERROR_NONE);
1237
1247
  }
1238
1248
  }
1249
+ // TODO(roth): It should be impossible for chand->lb_policy to be NULL
1250
+ // here, so the rest of this code should never actually be executed.
1251
+ // However, we have reports of a crash on iOS that triggers this case,
1252
+ // so we are temporarily adding this to restore branches that were
1253
+ // removed in https://github.com/grpc/grpc/pull/12297. Need to figure
1254
+ // out what is actually causing this to occur and then figure out the
1255
+ // right way to deal with it.
1256
+ else if (chand->resolver != nullptr) {
1257
+ // No LB policy, so try again.
1258
+ if (grpc_client_channel_trace.enabled()) {
1259
+ gpr_log(GPR_DEBUG,
1260
+ "chand=%p calld=%p: resolver returned but no LB policy, "
1261
+ "trying again",
1262
+ chand, calld);
1263
+ }
1264
+ pick_after_resolver_result_start_locked(exec_ctx, elem);
1265
+ } else {
1266
+ if (grpc_client_channel_trace.enabled()) {
1267
+ gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver disconnected", chand,
1268
+ calld);
1269
+ }
1270
+ async_pick_done_locked(
1271
+ exec_ctx, elem, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Disconnected"));
1272
+ }
1239
1273
  }
1240
1274
 
1241
- static void pick_after_resolver_result_start_locked(grpc_exec_ctx *exec_ctx,
1242
- grpc_call_element *elem) {
1243
- channel_data *chand = (channel_data *)elem->channel_data;
1244
- call_data *calld = (call_data *)elem->call_data;
1245
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1275
+ static void pick_after_resolver_result_start_locked(grpc_exec_ctx* exec_ctx,
1276
+ grpc_call_element* elem) {
1277
+ channel_data* chand = (channel_data*)elem->channel_data;
1278
+ call_data* calld = (call_data*)elem->call_data;
1279
+ if (grpc_client_channel_trace.enabled()) {
1246
1280
  gpr_log(GPR_DEBUG,
1247
1281
  "chand=%p calld=%p: deferring pick pending resolver result", chand,
1248
1282
  calld);
1249
1283
  }
1250
- pick_after_resolver_result_args *args =
1251
- (pick_after_resolver_result_args *)gpr_zalloc(sizeof(*args));
1284
+ pick_after_resolver_result_args* args =
1285
+ (pick_after_resolver_result_args*)gpr_zalloc(sizeof(*args));
1252
1286
  args->elem = elem;
1253
1287
  GRPC_CLOSURE_INIT(&args->closure, pick_after_resolver_result_done_locked,
1254
1288
  args, grpc_combiner_scheduler(chand->combiner));
@@ -1261,13 +1295,13 @@ static void pick_after_resolver_result_start_locked(grpc_exec_ctx *exec_ctx,
1261
1295
  grpc_combiner_scheduler(chand->combiner)));
1262
1296
  }
1263
1297
 
1264
- static void start_pick_locked(grpc_exec_ctx *exec_ctx, void *arg,
1265
- grpc_error *ignored) {
1266
- grpc_call_element *elem = (grpc_call_element *)arg;
1267
- call_data *calld = (call_data *)elem->call_data;
1268
- channel_data *chand = (channel_data *)elem->channel_data;
1269
- GPR_ASSERT(calld->connected_subchannel == NULL);
1270
- if (chand->lb_policy != NULL) {
1298
+ static void start_pick_locked(grpc_exec_ctx* exec_ctx, void* arg,
1299
+ grpc_error* ignored) {
1300
+ grpc_call_element* elem = (grpc_call_element*)arg;
1301
+ call_data* calld = (call_data*)elem->call_data;
1302
+ channel_data* chand = (channel_data*)elem->channel_data;
1303
+ GPR_ASSERT(calld->connected_subchannel == nullptr);
1304
+ if (chand->lb_policy != nullptr) {
1271
1305
  // We already have an LB policy, so ask it for a pick.
1272
1306
  if (pick_callback_start_locked(exec_ctx, elem)) {
1273
1307
  // Pick completed synchronously.
@@ -1276,7 +1310,7 @@ static void start_pick_locked(grpc_exec_ctx *exec_ctx, void *arg,
1276
1310
  }
1277
1311
  } else {
1278
1312
  // We do not yet have an LB policy, so wait for a resolver result.
1279
- if (chand->resolver == NULL) {
1313
+ if (chand->resolver == nullptr) {
1280
1314
  pick_done_locked(exec_ctx, elem,
1281
1315
  GRPC_ERROR_CREATE_FROM_STATIC_STRING("Disconnected"));
1282
1316
  return;
@@ -1295,10 +1329,10 @@ static void start_pick_locked(grpc_exec_ctx *exec_ctx, void *arg,
1295
1329
  chand->interested_parties);
1296
1330
  }
1297
1331
 
1298
- static void on_complete(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
1299
- grpc_call_element *elem = (grpc_call_element *)arg;
1300
- call_data *calld = (call_data *)elem->call_data;
1301
- if (calld->retry_throttle_data != NULL) {
1332
+ static void on_complete(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
1333
+ grpc_call_element* elem = (grpc_call_element*)arg;
1334
+ call_data* calld = (call_data*)elem->call_data;
1335
+ if (calld->retry_throttle_data != nullptr) {
1302
1336
  if (error == GRPC_ERROR_NONE) {
1303
1337
  grpc_server_retry_throttle_data_record_success(
1304
1338
  calld->retry_throttle_data);
@@ -1316,10 +1350,10 @@ static void on_complete(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
1316
1350
  }
1317
1351
 
1318
1352
  static void cc_start_transport_stream_op_batch(
1319
- grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
1320
- grpc_transport_stream_op_batch *batch) {
1321
- call_data *calld = (call_data *)elem->call_data;
1322
- channel_data *chand = (channel_data *)elem->channel_data;
1353
+ grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
1354
+ grpc_transport_stream_op_batch* batch) {
1355
+ call_data* calld = (call_data*)elem->call_data;
1356
+ channel_data* chand = (channel_data*)elem->channel_data;
1323
1357
  if (chand->deadline_checking_enabled) {
1324
1358
  grpc_deadline_state_client_start_transport_stream_op_batch(exec_ctx, elem,
1325
1359
  batch);
@@ -1327,7 +1361,7 @@ static void cc_start_transport_stream_op_batch(
1327
1361
  GPR_TIMER_BEGIN("cc_start_transport_stream_op_batch", 0);
1328
1362
  // If we've previously been cancelled, immediately fail any new batches.
1329
1363
  if (calld->error != GRPC_ERROR_NONE) {
1330
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1364
+ if (grpc_client_channel_trace.enabled()) {
1331
1365
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: failing batch with error: %s",
1332
1366
  chand, calld, grpc_error_string(calld->error));
1333
1367
  }
@@ -1343,13 +1377,13 @@ static void cc_start_transport_stream_op_batch(
1343
1377
  // error to the caller when the first batch does get passed down.
1344
1378
  GRPC_ERROR_UNREF(calld->error);
1345
1379
  calld->error = GRPC_ERROR_REF(batch->payload->cancel_stream.cancel_error);
1346
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1380
+ if (grpc_client_channel_trace.enabled()) {
1347
1381
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: recording cancel_error=%s", chand,
1348
1382
  calld, grpc_error_string(calld->error));
1349
1383
  }
1350
1384
  // If we have a subchannel call, send the cancellation batch down.
1351
1385
  // Otherwise, fail all pending batches.
1352
- if (calld->subchannel_call != NULL) {
1386
+ if (calld->subchannel_call != nullptr) {
1353
1387
  grpc_subchannel_call_process_op(exec_ctx, calld->subchannel_call, batch);
1354
1388
  } else {
1355
1389
  waiting_for_pick_batches_add(calld, batch);
@@ -1361,7 +1395,7 @@ static void cc_start_transport_stream_op_batch(
1361
1395
  // Intercept on_complete for recv_trailing_metadata so that we can
1362
1396
  // check retry throttle status.
1363
1397
  if (batch->recv_trailing_metadata) {
1364
- GPR_ASSERT(batch->on_complete != NULL);
1398
+ GPR_ASSERT(batch->on_complete != nullptr);
1365
1399
  calld->original_on_complete = batch->on_complete;
1366
1400
  GRPC_CLOSURE_INIT(&calld->on_complete, on_complete, elem,
1367
1401
  grpc_schedule_on_exec_ctx);
@@ -1371,8 +1405,8 @@ static void cc_start_transport_stream_op_batch(
1371
1405
  // Note that once we have completed the pick, we do not need to enter
1372
1406
  // the channel combiner, which is more efficient (especially for
1373
1407
  // streaming calls).
1374
- if (calld->subchannel_call != NULL) {
1375
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1408
+ if (calld->subchannel_call != nullptr) {
1409
+ if (grpc_client_channel_trace.enabled()) {
1376
1410
  gpr_log(GPR_DEBUG,
1377
1411
  "chand=%p calld=%p: sending batch to subchannel_call=%p", chand,
1378
1412
  calld, calld->subchannel_call);
@@ -1386,7 +1420,7 @@ static void cc_start_transport_stream_op_batch(
1386
1420
  // For batches containing a send_initial_metadata op, enter the channel
1387
1421
  // combiner to start a pick.
1388
1422
  if (batch->send_initial_metadata) {
1389
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1423
+ if (grpc_client_channel_trace.enabled()) {
1390
1424
  gpr_log(GPR_DEBUG, "chand=%p calld=%p: entering client_channel combiner",
1391
1425
  chand, calld);
1392
1426
  }
@@ -1397,7 +1431,7 @@ static void cc_start_transport_stream_op_batch(
1397
1431
  GRPC_ERROR_NONE);
1398
1432
  } else {
1399
1433
  // For all other batches, release the call combiner.
1400
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
1434
+ if (grpc_client_channel_trace.enabled()) {
1401
1435
  gpr_log(GPR_DEBUG,
1402
1436
  "chand=%p calld=%p: saved batch, yeilding call combiner", chand,
1403
1437
  calld);
@@ -1410,15 +1444,15 @@ done:
1410
1444
  }
1411
1445
 
1412
1446
  /* Constructor for call_data */
1413
- static grpc_error *cc_init_call_elem(grpc_exec_ctx *exec_ctx,
1414
- grpc_call_element *elem,
1415
- const grpc_call_element_args *args) {
1416
- call_data *calld = (call_data *)elem->call_data;
1417
- channel_data *chand = (channel_data *)elem->channel_data;
1447
+ static grpc_error* cc_init_call_elem(grpc_exec_ctx* exec_ctx,
1448
+ grpc_call_element* elem,
1449
+ const grpc_call_element_args* args) {
1450
+ call_data* calld = (call_data*)elem->call_data;
1451
+ channel_data* chand = (channel_data*)elem->channel_data;
1418
1452
  // Initialize data members.
1419
1453
  calld->path = grpc_slice_ref_internal(args->path);
1420
1454
  calld->call_start_time = args->start_time;
1421
- calld->deadline = gpr_convert_clock_type(args->deadline, GPR_CLOCK_MONOTONIC);
1455
+ calld->deadline = args->deadline;
1422
1456
  calld->arena = args->arena;
1423
1457
  calld->owning_call = args->call_stack;
1424
1458
  calld->call_combiner = args->call_combiner;
@@ -1430,35 +1464,35 @@ static grpc_error *cc_init_call_elem(grpc_exec_ctx *exec_ctx,
1430
1464
  }
1431
1465
 
1432
1466
  /* Destructor for call_data */
1433
- static void cc_destroy_call_elem(grpc_exec_ctx *exec_ctx,
1434
- grpc_call_element *elem,
1435
- const grpc_call_final_info *final_info,
1436
- grpc_closure *then_schedule_closure) {
1437
- call_data *calld = (call_data *)elem->call_data;
1438
- channel_data *chand = (channel_data *)elem->channel_data;
1467
+ static void cc_destroy_call_elem(grpc_exec_ctx* exec_ctx,
1468
+ grpc_call_element* elem,
1469
+ const grpc_call_final_info* final_info,
1470
+ grpc_closure* then_schedule_closure) {
1471
+ call_data* calld = (call_data*)elem->call_data;
1472
+ channel_data* chand = (channel_data*)elem->channel_data;
1439
1473
  if (chand->deadline_checking_enabled) {
1440
1474
  grpc_deadline_state_destroy(exec_ctx, elem);
1441
1475
  }
1442
1476
  grpc_slice_unref_internal(exec_ctx, calld->path);
1443
- if (calld->method_params != NULL) {
1477
+ if (calld->method_params != nullptr) {
1444
1478
  method_parameters_unref(calld->method_params);
1445
1479
  }
1446
1480
  GRPC_ERROR_UNREF(calld->error);
1447
- if (calld->subchannel_call != NULL) {
1481
+ if (calld->subchannel_call != nullptr) {
1448
1482
  grpc_subchannel_call_set_cleanup_closure(calld->subchannel_call,
1449
1483
  then_schedule_closure);
1450
- then_schedule_closure = NULL;
1484
+ then_schedule_closure = nullptr;
1451
1485
  GRPC_SUBCHANNEL_CALL_UNREF(exec_ctx, calld->subchannel_call,
1452
1486
  "client_channel_destroy_call");
1453
1487
  }
1454
- GPR_ASSERT(calld->lb_policy == NULL);
1488
+ GPR_ASSERT(calld->lb_policy == nullptr);
1455
1489
  GPR_ASSERT(calld->waiting_for_pick_batches_count == 0);
1456
- if (calld->connected_subchannel != NULL) {
1490
+ if (calld->connected_subchannel != nullptr) {
1457
1491
  GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, calld->connected_subchannel,
1458
1492
  "picked");
1459
1493
  }
1460
1494
  for (size_t i = 0; i < GRPC_CONTEXT_COUNT; ++i) {
1461
- if (calld->subchannel_call_context[i].value != NULL) {
1495
+ if (calld->subchannel_call_context[i].value != nullptr) {
1462
1496
  calld->subchannel_call_context[i].destroy(
1463
1497
  calld->subchannel_call_context[i].value);
1464
1498
  }
@@ -1466,10 +1500,10 @@ static void cc_destroy_call_elem(grpc_exec_ctx *exec_ctx,
1466
1500
  GRPC_CLOSURE_SCHED(exec_ctx, then_schedule_closure, GRPC_ERROR_NONE);
1467
1501
  }
1468
1502
 
1469
- static void cc_set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
1470
- grpc_call_element *elem,
1471
- grpc_polling_entity *pollent) {
1472
- call_data *calld = (call_data *)elem->call_data;
1503
+ static void cc_set_pollset_or_pollset_set(grpc_exec_ctx* exec_ctx,
1504
+ grpc_call_element* elem,
1505
+ grpc_polling_entity* pollent) {
1506
+ call_data* calld = (call_data*)elem->call_data;
1473
1507
  calld->pollent = pollent;
1474
1508
  }
1475
1509
 
@@ -1491,14 +1525,14 @@ const grpc_channel_filter grpc_client_channel_filter = {
1491
1525
  "client-channel",
1492
1526
  };
1493
1527
 
1494
- static void try_to_connect_locked(grpc_exec_ctx *exec_ctx, void *arg,
1495
- grpc_error *error_ignored) {
1496
- channel_data *chand = (channel_data *)arg;
1497
- if (chand->lb_policy != NULL) {
1528
+ static void try_to_connect_locked(grpc_exec_ctx* exec_ctx, void* arg,
1529
+ grpc_error* error_ignored) {
1530
+ channel_data* chand = (channel_data*)arg;
1531
+ if (chand->lb_policy != nullptr) {
1498
1532
  grpc_lb_policy_exit_idle_locked(exec_ctx, chand->lb_policy);
1499
1533
  } else {
1500
1534
  chand->exit_idle_when_lb_policy_arrives = true;
1501
- if (!chand->started_resolving && chand->resolver != NULL) {
1535
+ if (!chand->started_resolving && chand->resolver != nullptr) {
1502
1536
  start_resolving_locked(exec_ctx, chand);
1503
1537
  }
1504
1538
  }
@@ -1506,36 +1540,37 @@ static void try_to_connect_locked(grpc_exec_ctx *exec_ctx, void *arg,
1506
1540
  }
1507
1541
 
1508
1542
  grpc_connectivity_state grpc_client_channel_check_connectivity_state(
1509
- grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, int try_to_connect) {
1510
- channel_data *chand = (channel_data *)elem->channel_data;
1543
+ grpc_exec_ctx* exec_ctx, grpc_channel_element* elem, int try_to_connect) {
1544
+ channel_data* chand = (channel_data*)elem->channel_data;
1511
1545
  grpc_connectivity_state out =
1512
1546
  grpc_connectivity_state_check(&chand->state_tracker);
1513
1547
  if (out == GRPC_CHANNEL_IDLE && try_to_connect) {
1514
1548
  GRPC_CHANNEL_STACK_REF(chand->owning_stack, "try_to_connect");
1515
1549
  GRPC_CLOSURE_SCHED(
1516
- exec_ctx, GRPC_CLOSURE_CREATE(try_to_connect_locked, chand,
1517
- grpc_combiner_scheduler(chand->combiner)),
1550
+ exec_ctx,
1551
+ GRPC_CLOSURE_CREATE(try_to_connect_locked, chand,
1552
+ grpc_combiner_scheduler(chand->combiner)),
1518
1553
  GRPC_ERROR_NONE);
1519
1554
  }
1520
1555
  return out;
1521
1556
  }
1522
1557
 
1523
1558
  typedef struct external_connectivity_watcher {
1524
- channel_data *chand;
1559
+ channel_data* chand;
1525
1560
  grpc_polling_entity pollent;
1526
- grpc_closure *on_complete;
1527
- grpc_closure *watcher_timer_init;
1528
- grpc_connectivity_state *state;
1561
+ grpc_closure* on_complete;
1562
+ grpc_closure* watcher_timer_init;
1563
+ grpc_connectivity_state* state;
1529
1564
  grpc_closure my_closure;
1530
- struct external_connectivity_watcher *next;
1565
+ struct external_connectivity_watcher* next;
1531
1566
  } external_connectivity_watcher;
1532
1567
 
1533
- static external_connectivity_watcher *lookup_external_connectivity_watcher(
1534
- channel_data *chand, grpc_closure *on_complete) {
1568
+ static external_connectivity_watcher* lookup_external_connectivity_watcher(
1569
+ channel_data* chand, grpc_closure* on_complete) {
1535
1570
  gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
1536
- external_connectivity_watcher *w =
1571
+ external_connectivity_watcher* w =
1537
1572
  chand->external_connectivity_watcher_list_head;
1538
- while (w != NULL && w->on_complete != on_complete) {
1573
+ while (w != nullptr && w->on_complete != on_complete) {
1539
1574
  w = w->next;
1540
1575
  }
1541
1576
  gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
@@ -1543,7 +1578,7 @@ static external_connectivity_watcher *lookup_external_connectivity_watcher(
1543
1578
  }
1544
1579
 
1545
1580
  static void external_connectivity_watcher_list_append(
1546
- channel_data *chand, external_connectivity_watcher *w) {
1581
+ channel_data* chand, external_connectivity_watcher* w) {
1547
1582
  GPR_ASSERT(!lookup_external_connectivity_watcher(chand, w->on_complete));
1548
1583
 
1549
1584
  gpr_mu_lock(&w->chand->external_connectivity_watcher_list_mu);
@@ -1554,7 +1589,7 @@ static void external_connectivity_watcher_list_append(
1554
1589
  }
1555
1590
 
1556
1591
  static void external_connectivity_watcher_list_remove(
1557
- channel_data *chand, external_connectivity_watcher *too_remove) {
1592
+ channel_data* chand, external_connectivity_watcher* too_remove) {
1558
1593
  GPR_ASSERT(
1559
1594
  lookup_external_connectivity_watcher(chand, too_remove->on_complete));
1560
1595
  gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
@@ -1563,9 +1598,9 @@ static void external_connectivity_watcher_list_remove(
1563
1598
  gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
1564
1599
  return;
1565
1600
  }
1566
- external_connectivity_watcher *w =
1601
+ external_connectivity_watcher* w =
1567
1602
  chand->external_connectivity_watcher_list_head;
1568
- while (w != NULL) {
1603
+ while (w != nullptr) {
1569
1604
  if (w->next == too_remove) {
1570
1605
  w->next = w->next->next;
1571
1606
  gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
@@ -1577,14 +1612,14 @@ static void external_connectivity_watcher_list_remove(
1577
1612
  }
1578
1613
 
1579
1614
  int grpc_client_channel_num_external_connectivity_watchers(
1580
- grpc_channel_element *elem) {
1581
- channel_data *chand = (channel_data *)elem->channel_data;
1615
+ grpc_channel_element* elem) {
1616
+ channel_data* chand = (channel_data*)elem->channel_data;
1582
1617
  int count = 0;
1583
1618
 
1584
1619
  gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
1585
- external_connectivity_watcher *w =
1620
+ external_connectivity_watcher* w =
1586
1621
  chand->external_connectivity_watcher_list_head;
1587
- while (w != NULL) {
1622
+ while (w != nullptr) {
1588
1623
  count++;
1589
1624
  w = w->next;
1590
1625
  }
@@ -1593,10 +1628,10 @@ int grpc_client_channel_num_external_connectivity_watchers(
1593
1628
  return count;
1594
1629
  }
1595
1630
 
1596
- static void on_external_watch_complete(grpc_exec_ctx *exec_ctx, void *arg,
1597
- grpc_error *error) {
1598
- external_connectivity_watcher *w = (external_connectivity_watcher *)arg;
1599
- grpc_closure *follow_up = w->on_complete;
1631
+ static void on_external_watch_complete_locked(grpc_exec_ctx* exec_ctx,
1632
+ void* arg, grpc_error* error) {
1633
+ external_connectivity_watcher* w = (external_connectivity_watcher*)arg;
1634
+ grpc_closure* follow_up = w->on_complete;
1600
1635
  grpc_polling_entity_del_from_pollset_set(exec_ctx, &w->pollent,
1601
1636
  w->chand->interested_parties);
1602
1637
  GRPC_CHANNEL_STACK_UNREF(exec_ctx, w->chand->owning_stack,
@@ -1606,24 +1641,24 @@ static void on_external_watch_complete(grpc_exec_ctx *exec_ctx, void *arg,
1606
1641
  GRPC_CLOSURE_RUN(exec_ctx, follow_up, GRPC_ERROR_REF(error));
1607
1642
  }
1608
1643
 
1609
- static void watch_connectivity_state_locked(grpc_exec_ctx *exec_ctx, void *arg,
1610
- grpc_error *error_ignored) {
1611
- external_connectivity_watcher *w = (external_connectivity_watcher *)arg;
1612
- external_connectivity_watcher *found = NULL;
1613
- if (w->state != NULL) {
1644
+ static void watch_connectivity_state_locked(grpc_exec_ctx* exec_ctx, void* arg,
1645
+ grpc_error* error_ignored) {
1646
+ external_connectivity_watcher* w = (external_connectivity_watcher*)arg;
1647
+ external_connectivity_watcher* found = nullptr;
1648
+ if (w->state != nullptr) {
1614
1649
  external_connectivity_watcher_list_append(w->chand, w);
1615
1650
  GRPC_CLOSURE_RUN(exec_ctx, w->watcher_timer_init, GRPC_ERROR_NONE);
1616
- GRPC_CLOSURE_INIT(&w->my_closure, on_external_watch_complete, w,
1617
- grpc_schedule_on_exec_ctx);
1651
+ GRPC_CLOSURE_INIT(&w->my_closure, on_external_watch_complete_locked, w,
1652
+ grpc_combiner_scheduler(w->chand->combiner));
1618
1653
  grpc_connectivity_state_notify_on_state_change(
1619
1654
  exec_ctx, &w->chand->state_tracker, w->state, &w->my_closure);
1620
1655
  } else {
1621
- GPR_ASSERT(w->watcher_timer_init == NULL);
1656
+ GPR_ASSERT(w->watcher_timer_init == nullptr);
1622
1657
  found = lookup_external_connectivity_watcher(w->chand, w->on_complete);
1623
1658
  if (found) {
1624
1659
  GPR_ASSERT(found->on_complete == w->on_complete);
1625
1660
  grpc_connectivity_state_notify_on_state_change(
1626
- exec_ctx, &found->chand->state_tracker, NULL, &found->my_closure);
1661
+ exec_ctx, &found->chand->state_tracker, nullptr, &found->my_closure);
1627
1662
  }
1628
1663
  grpc_polling_entity_del_from_pollset_set(exec_ctx, &w->pollent,
1629
1664
  w->chand->interested_parties);
@@ -1634,12 +1669,12 @@ static void watch_connectivity_state_locked(grpc_exec_ctx *exec_ctx, void *arg,
1634
1669
  }
1635
1670
 
1636
1671
  void grpc_client_channel_watch_connectivity_state(
1637
- grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
1638
- grpc_polling_entity pollent, grpc_connectivity_state *state,
1639
- grpc_closure *closure, grpc_closure *watcher_timer_init) {
1640
- channel_data *chand = (channel_data *)elem->channel_data;
1641
- external_connectivity_watcher *w =
1642
- (external_connectivity_watcher *)gpr_zalloc(sizeof(*w));
1672
+ grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
1673
+ grpc_polling_entity pollent, grpc_connectivity_state* state,
1674
+ grpc_closure* closure, grpc_closure* watcher_timer_init) {
1675
+ channel_data* chand = (channel_data*)elem->channel_data;
1676
+ external_connectivity_watcher* w =
1677
+ (external_connectivity_watcher*)gpr_zalloc(sizeof(*w));
1643
1678
  w->chand = chand;
1644
1679
  w->pollent = pollent;
1645
1680
  w->on_complete = closure;