grpc 1.2.5 → 1.3.4

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 (327) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1434 -399
  3. data/etc/roots.pem +34 -150
  4. data/include/grpc/grpc.h +71 -0
  5. data/include/grpc/impl/codegen/atm.h +5 -0
  6. data/include/grpc/impl/codegen/atm_gcc_atomic.h +6 -0
  7. data/include/grpc/impl/codegen/atm_gcc_sync.h +2 -0
  8. data/include/grpc/impl/codegen/atm_windows.h +11 -0
  9. data/include/grpc/impl/codegen/grpc_types.h +54 -13
  10. data/include/grpc/impl/codegen/port_platform.h +15 -1
  11. data/include/grpc/support/alloc.h +2 -1
  12. data/include/grpc/support/sync.h +4 -0
  13. data/include/grpc/support/tls.h +1 -1
  14. data/src/core/ext/census/gen/trace_context.pb.h +1 -1
  15. data/src/core/ext/census/grpc_filter.c +14 -10
  16. data/src/core/ext/census/grpc_plugin.c +3 -1
  17. data/src/core/ext/census/trace_label.h +1 -1
  18. data/src/core/ext/census/trace_propagation.h +1 -1
  19. data/src/core/ext/census/trace_status.h +1 -1
  20. data/src/core/ext/census/trace_string.h +1 -1
  21. data/src/core/ext/census/tracing.h +1 -1
  22. data/src/core/ext/{client_channel → filters/client_channel}/channel_connectivity.c +56 -27
  23. data/src/core/ext/{client_channel → filters/client_channel}/client_channel.c +407 -202
  24. data/src/core/ext/{client_channel → filters/client_channel}/client_channel.h +10 -6
  25. data/src/core/ext/{client_channel → filters/client_channel}/client_channel_factory.c +1 -1
  26. data/src/core/ext/{client_channel → filters/client_channel}/client_channel_factory.h +4 -4
  27. data/src/core/ext/{client_channel → filters/client_channel}/client_channel_plugin.c +12 -7
  28. data/src/core/ext/{client_channel → filters/client_channel}/connector.c +1 -1
  29. data/src/core/ext/{client_channel → filters/client_channel}/connector.h +3 -5
  30. data/src/core/ext/{client_channel → filters/client_channel}/http_connect_handshaker.c +6 -6
  31. data/src/core/ext/{client_channel → filters/client_channel}/http_connect_handshaker.h +3 -3
  32. data/src/core/ext/{client_channel → filters/client_channel}/http_proxy.c +4 -4
  33. data/src/core/ext/{client_channel → filters/client_channel}/http_proxy.h +3 -3
  34. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy.c +1 -1
  35. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy.h +4 -4
  36. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb.c +22 -20
  37. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb.h +4 -4
  38. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb_channel.h +5 -4
  39. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb_channel_secure.c +2 -2
  40. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/load_balancer_api.c +1 -1
  41. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/load_balancer_api.h +6 -5
  42. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +1 -1
  43. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +0 -0
  44. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/pick_first/pick_first.c +20 -15
  45. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/round_robin/round_robin.c +21 -16
  46. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_factory.c +1 -1
  47. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_factory.h +5 -5
  48. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_registry.c +1 -1
  49. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_registry.h +4 -4
  50. data/src/core/ext/{client_channel → filters/client_channel}/parse_address.c +1 -1
  51. data/src/core/ext/{client_channel → filters/client_channel}/parse_address.h +4 -4
  52. data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper.c +1 -1
  53. data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper.h +3 -3
  54. data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper_registry.c +10 -4
  55. data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper_registry.h +4 -4
  56. data/src/core/ext/{client_channel → filters/client_channel}/resolver.c +1 -1
  57. data/src/core/ext/{client_channel → filters/client_channel}/resolver.h +4 -4
  58. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +350 -0
  59. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +66 -0
  60. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +319 -0
  61. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +289 -0
  62. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +64 -0
  63. data/src/core/ext/{resolver → filters/client_channel/resolver}/dns/native/dns_resolver.c +21 -5
  64. data/src/core/ext/{resolver → filters/client_channel/resolver}/sockaddr/sockaddr_resolver.c +3 -3
  65. data/src/core/ext/{client_channel → filters/client_channel}/resolver_factory.c +1 -1
  66. data/src/core/ext/{client_channel → filters/client_channel}/resolver_factory.h +6 -6
  67. data/src/core/ext/{client_channel → filters/client_channel}/resolver_registry.c +1 -2
  68. data/src/core/ext/{client_channel → filters/client_channel}/resolver_registry.h +4 -4
  69. data/src/core/ext/filters/client_channel/retry_throttle.c +210 -0
  70. data/src/core/ext/filters/client_channel/retry_throttle.h +65 -0
  71. data/src/core/ext/{client_channel → filters/client_channel}/subchannel.c +49 -43
  72. data/src/core/ext/{client_channel → filters/client_channel}/subchannel.h +21 -7
  73. data/src/core/ext/{client_channel → filters/client_channel}/subchannel_index.c +1 -1
  74. data/src/core/ext/{client_channel → filters/client_channel}/subchannel_index.h +5 -5
  75. data/src/core/ext/{client_channel → filters/client_channel}/uri_parser.c +1 -1
  76. data/src/core/ext/{client_channel → filters/client_channel}/uri_parser.h +3 -3
  77. data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting.c +4 -2
  78. data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting.h +3 -3
  79. data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting_filter.c +17 -14
  80. data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting_filter.h +4 -4
  81. data/src/core/ext/filters/max_age/max_age_filter.c +439 -0
  82. data/src/core/ext/filters/max_age/max_age_filter.h +39 -0
  83. data/src/core/ext/transport/chttp2/client/chttp2_connector.c +6 -41
  84. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +1 -1
  85. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +2 -2
  86. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +3 -3
  87. data/src/core/ext/transport/chttp2/server/chttp2_server.c +2 -2
  88. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +2 -5
  89. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +2 -2
  90. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +449 -204
  91. data/src/core/ext/transport/chttp2/transport/frame_data.c +10 -7
  92. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +3 -2
  93. data/src/core/ext/transport/chttp2/transport/frame_ping.c +37 -7
  94. data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -0
  95. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +4 -3
  96. data/src/core/ext/transport/chttp2/transport/frame_settings.c +18 -38
  97. data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -29
  98. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +2 -2
  99. data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +64 -37
  100. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +11 -4
  101. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +60 -39
  102. data/src/core/ext/transport/chttp2/transport/hpack_table.c +2 -2
  103. data/src/core/ext/transport/chttp2/transport/http2_settings.c +75 -0
  104. data/src/core/ext/transport/chttp2/transport/http2_settings.h +74 -0
  105. data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +22 -43
  106. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +8 -10
  107. data/src/core/ext/transport/chttp2/transport/internal.h +24 -2
  108. data/src/core/ext/transport/chttp2/transport/parsing.c +33 -15
  109. data/src/core/ext/transport/chttp2/transport/writing.c +56 -10
  110. data/src/core/lib/channel/channel_args.c +7 -0
  111. data/src/core/lib/channel/channel_args.h +2 -0
  112. data/src/core/lib/channel/channel_stack.c +20 -27
  113. data/src/core/lib/channel/channel_stack.h +18 -16
  114. data/src/core/lib/channel/compress_filter.c +20 -18
  115. data/src/core/lib/channel/connected_channel.c +9 -8
  116. data/src/core/lib/channel/deadline_filter.c +28 -24
  117. data/src/core/lib/channel/deadline_filter.h +3 -3
  118. data/src/core/lib/channel/handshaker.c +3 -2
  119. data/src/core/lib/channel/http_client_filter.c +119 -61
  120. data/src/core/lib/channel/http_server_filter.c +124 -69
  121. data/src/core/lib/channel/message_size_filter.c +23 -19
  122. data/src/core/lib/http/httpcli.c +8 -6
  123. data/src/core/lib/http/httpcli_security_connector.c +5 -5
  124. data/src/core/lib/http/parser.c +57 -31
  125. data/src/core/lib/iomgr/closure.c +15 -0
  126. data/src/core/lib/iomgr/closure.h +4 -0
  127. data/src/core/lib/iomgr/combiner.c +8 -0
  128. data/src/core/lib/iomgr/endpoint_pair.h +2 -3
  129. data/src/core/lib/iomgr/endpoint_pair_posix.c +10 -7
  130. data/src/core/lib/iomgr/endpoint_pair_uv.c +2 -3
  131. data/src/core/lib/iomgr/endpoint_pair_windows.c +9 -6
  132. data/src/core/lib/iomgr/error.c +360 -177
  133. data/src/core/lib/iomgr/error.h +31 -33
  134. data/src/core/lib/iomgr/error_internal.h +30 -9
  135. data/src/core/lib/iomgr/ev_epoll_linux.c +25 -239
  136. data/src/core/lib/iomgr/ev_poll_posix.c +11 -7
  137. data/src/core/lib/iomgr/ev_posix.c +6 -0
  138. data/src/core/lib/iomgr/ev_posix.h +3 -0
  139. data/src/core/lib/iomgr/exec_ctx.c +6 -0
  140. data/src/core/lib/iomgr/executor.c +8 -2
  141. data/src/core/lib/iomgr/load_file.c +6 -3
  142. data/src/core/lib/iomgr/lockfree_event.c +238 -0
  143. data/src/core/{ext/client_channel/initial_connect_string.h → lib/iomgr/lockfree_event.h} +17 -13
  144. data/src/core/lib/iomgr/pollset.h +4 -0
  145. data/src/core/lib/iomgr/pollset_windows.c +2 -2
  146. data/src/core/lib/iomgr/port.h +9 -0
  147. data/src/core/lib/iomgr/resolve_address_posix.c +15 -9
  148. data/src/core/lib/iomgr/resolve_address_uv.c +8 -6
  149. data/src/core/lib/iomgr/resolve_address_windows.c +2 -2
  150. data/src/core/lib/iomgr/resource_quota.c +19 -4
  151. data/src/core/lib/iomgr/resource_quota.h +2 -0
  152. data/src/core/lib/iomgr/sockaddr_utils.c +3 -1
  153. data/src/core/lib/iomgr/socket_factory_posix.c +110 -0
  154. data/src/core/lib/iomgr/socket_factory_posix.h +90 -0
  155. data/src/core/lib/iomgr/socket_utils_common_posix.c +25 -9
  156. data/src/core/lib/iomgr/socket_utils_posix.h +7 -0
  157. data/src/core/lib/iomgr/tcp_client.h +0 -4
  158. data/src/core/lib/iomgr/tcp_client_posix.c +15 -31
  159. data/src/core/lib/iomgr/tcp_client_uv.c +10 -6
  160. data/src/core/lib/iomgr/tcp_client_windows.c +9 -19
  161. data/src/core/lib/iomgr/tcp_posix.c +111 -22
  162. data/src/core/lib/iomgr/tcp_posix.h +3 -4
  163. data/src/core/lib/iomgr/tcp_server_posix.c +39 -417
  164. data/src/core/lib/iomgr/tcp_server_utils_posix.h +135 -0
  165. data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +221 -0
  166. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c +196 -0
  167. data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c +49 -0
  168. data/src/core/lib/iomgr/tcp_server_uv.c +43 -16
  169. data/src/core/lib/iomgr/tcp_server_windows.c +10 -22
  170. data/src/core/lib/iomgr/tcp_uv.c +16 -13
  171. data/src/core/lib/iomgr/tcp_windows.c +24 -12
  172. data/src/core/lib/iomgr/tcp_windows.h +2 -2
  173. data/src/core/lib/iomgr/timer.h +3 -0
  174. data/src/core/lib/iomgr/timer_generic.c +257 -72
  175. data/src/core/lib/iomgr/timer_generic.h +1 -1
  176. data/src/core/lib/iomgr/timer_heap.c +8 -8
  177. data/src/core/lib/iomgr/udp_server.c +54 -24
  178. data/src/core/lib/iomgr/udp_server.h +7 -7
  179. data/src/core/lib/iomgr/unix_sockets_posix.c +1 -1
  180. data/src/core/lib/iomgr/unix_sockets_posix_noop.c +2 -1
  181. data/src/core/lib/iomgr/wakeup_fd_posix.h +1 -1
  182. data/src/core/lib/profiling/basic_timers.c +1 -1
  183. data/src/core/lib/security/credentials/credentials.h +1 -1
  184. data/src/core/lib/security/credentials/google_default/google_default_credentials.c +10 -9
  185. data/src/core/lib/security/credentials/jwt/json_token.c +1 -1
  186. data/src/core/lib/security/credentials/jwt/jwt_verifier.c +2 -2
  187. data/src/core/lib/security/transport/client_auth_filter.c +33 -26
  188. data/src/core/lib/security/transport/secure_endpoint.c +8 -5
  189. data/src/core/lib/security/transport/security_connector.c +37 -37
  190. data/src/core/lib/security/transport/security_connector.h +1 -1
  191. data/src/core/lib/security/transport/security_handshaker.c +15 -12
  192. data/src/core/lib/security/transport/server_auth_filter.c +20 -18
  193. data/src/core/lib/security/transport/tsi_error.c +5 -3
  194. data/src/core/lib/security/transport/tsi_error.h +1 -1
  195. data/src/core/lib/{security/util → slice}/b64.c +21 -6
  196. data/src/core/lib/{security/util → slice}/b64.h +16 -4
  197. data/src/core/lib/slice/slice.c +4 -2
  198. data/src/core/lib/slice/slice_buffer.c +16 -14
  199. data/src/core/lib/support/arena.c +98 -0
  200. data/src/core/{ext/client_channel/initial_connect_string.c → lib/support/arena.h} +17 -15
  201. data/src/core/{ext/client_channel/default_initial_connect_string.c → lib/support/atm.c} +14 -5
  202. data/src/core/lib/support/cpu_linux.c +5 -0
  203. data/src/core/lib/support/sync.c +4 -0
  204. data/src/core/lib/support/time.c +4 -10
  205. data/src/core/lib/support/wrap_memcpy.c +3 -1
  206. data/src/core/lib/surface/call.c +252 -221
  207. data/src/core/lib/surface/channel.c +72 -21
  208. data/src/core/lib/surface/channel.h +8 -0
  209. data/src/core/lib/surface/completion_queue.c +2 -3
  210. data/src/core/lib/surface/completion_queue_factory.c +77 -0
  211. data/src/core/lib/surface/completion_queue_factory.h +51 -0
  212. data/src/core/lib/surface/init_secure.c +3 -1
  213. data/src/core/lib/surface/lame_client.c +18 -14
  214. data/src/core/lib/surface/server.c +43 -41
  215. data/src/core/lib/surface/validate_metadata.c +8 -4
  216. data/src/core/lib/surface/version.c +2 -2
  217. data/src/core/lib/transport/bdp_estimator.h +1 -1
  218. data/src/core/lib/transport/connectivity_state.c +2 -1
  219. data/src/core/lib/transport/error_utils.c +17 -17
  220. data/src/core/lib/transport/error_utils.h +1 -1
  221. data/src/core/lib/transport/metadata_batch.c +6 -7
  222. data/src/core/lib/transport/pid_controller.c +1 -0
  223. data/src/core/lib/transport/service_config.c +12 -0
  224. data/src/core/lib/transport/service_config.h +6 -0
  225. data/src/core/lib/transport/transport.c +29 -17
  226. data/src/core/lib/transport/transport.h +85 -42
  227. data/src/core/lib/transport/transport_impl.h +5 -3
  228. data/src/core/lib/transport/transport_op_string.c +20 -14
  229. data/src/core/plugin_registry/grpc_plugin_registry.c +8 -0
  230. data/src/core/{lib/tsi → tsi}/fake_transport_security.c +2 -2
  231. data/src/core/{lib/tsi → tsi}/fake_transport_security.h +4 -4
  232. data/src/core/{lib/tsi → tsi}/ssl_transport_security.c +40 -79
  233. data/src/core/{lib/tsi → tsi}/ssl_transport_security.h +44 -21
  234. data/src/core/{lib/tsi → tsi}/ssl_types.h +3 -3
  235. data/src/core/{lib/tsi → tsi}/transport_security.c +2 -2
  236. data/src/core/{lib/tsi → tsi}/transport_security.h +4 -4
  237. data/src/core/{lib/tsi → tsi}/transport_security_interface.h +3 -3
  238. data/src/ruby/ext/grpc/extconf.rb +1 -0
  239. data/src/ruby/ext/grpc/rb_call_credentials.c +2 -2
  240. data/src/ruby/ext/grpc/rb_channel.c +520 -93
  241. data/src/ruby/ext/grpc/rb_channel.h +2 -0
  242. data/src/ruby/ext/grpc/rb_channel_credentials.c +3 -0
  243. data/src/ruby/ext/grpc/rb_compression_options.c +5 -2
  244. data/src/ruby/ext/grpc/rb_event_thread.c +6 -6
  245. data/src/ruby/ext/grpc/rb_grpc.c +29 -7
  246. data/src/ruby/ext/grpc/rb_grpc.h +2 -0
  247. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -0
  248. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +15 -0
  249. data/src/ruby/ext/grpc/rb_server.c +5 -3
  250. data/src/ruby/lib/grpc/version.rb +1 -1
  251. data/src/ruby/spec/channel_connection_spec.rb +173 -0
  252. data/src/ruby/spec/channel_spec.rb +29 -0
  253. data/src/ruby/spec/generic/rpc_server_pool_spec.rb +27 -17
  254. data/third_party/cares/ares_build.h +264 -0
  255. data/third_party/cares/cares/ares.h +636 -0
  256. data/third_party/cares/cares/ares__close_sockets.c +61 -0
  257. data/third_party/cares/cares/ares__get_hostent.c +261 -0
  258. data/third_party/cares/cares/ares__read_line.c +73 -0
  259. data/third_party/cares/cares/ares__timeval.c +111 -0
  260. data/third_party/cares/cares/ares_cancel.c +63 -0
  261. data/third_party/cares/cares/ares_create_query.c +202 -0
  262. data/third_party/cares/cares/ares_data.c +221 -0
  263. data/third_party/cares/cares/ares_data.h +72 -0
  264. data/third_party/cares/cares/ares_destroy.c +108 -0
  265. data/third_party/cares/cares/ares_dns.h +103 -0
  266. data/third_party/cares/cares/ares_expand_name.c +205 -0
  267. data/third_party/cares/cares/ares_expand_string.c +70 -0
  268. data/third_party/cares/cares/ares_fds.c +59 -0
  269. data/third_party/cares/cares/ares_free_hostent.c +41 -0
  270. data/third_party/cares/cares/ares_free_string.c +25 -0
  271. data/third_party/cares/cares/ares_getenv.c +30 -0
  272. data/third_party/cares/cares/ares_getenv.h +26 -0
  273. data/third_party/cares/cares/ares_gethostbyaddr.c +294 -0
  274. data/third_party/cares/cares/ares_gethostbyname.c +518 -0
  275. data/third_party/cares/cares/ares_getnameinfo.c +422 -0
  276. data/third_party/cares/cares/ares_getopt.c +122 -0
  277. data/third_party/cares/cares/ares_getopt.h +53 -0
  278. data/third_party/cares/cares/ares_getsock.c +66 -0
  279. data/third_party/cares/cares/ares_inet_net_pton.h +25 -0
  280. data/third_party/cares/cares/ares_init.c +2146 -0
  281. data/third_party/cares/cares/ares_iphlpapi.h +221 -0
  282. data/third_party/cares/cares/ares_ipv6.h +78 -0
  283. data/third_party/cares/cares/ares_library_init.c +167 -0
  284. data/third_party/cares/cares/ares_library_init.h +42 -0
  285. data/third_party/cares/cares/ares_llist.c +63 -0
  286. data/third_party/cares/cares/ares_llist.h +39 -0
  287. data/third_party/cares/cares/ares_mkquery.c +24 -0
  288. data/third_party/cares/cares/ares_nowarn.c +260 -0
  289. data/third_party/cares/cares/ares_nowarn.h +61 -0
  290. data/third_party/cares/cares/ares_options.c +402 -0
  291. data/third_party/cares/cares/ares_parse_a_reply.c +264 -0
  292. data/third_party/cares/cares/ares_parse_aaaa_reply.c +264 -0
  293. data/third_party/cares/cares/ares_parse_mx_reply.c +170 -0
  294. data/third_party/cares/cares/ares_parse_naptr_reply.c +188 -0
  295. data/third_party/cares/cares/ares_parse_ns_reply.c +183 -0
  296. data/third_party/cares/cares/ares_parse_ptr_reply.c +219 -0
  297. data/third_party/cares/cares/ares_parse_soa_reply.c +133 -0
  298. data/third_party/cares/cares/ares_parse_srv_reply.c +179 -0
  299. data/third_party/cares/cares/ares_parse_txt_reply.c +220 -0
  300. data/third_party/cares/cares/ares_platform.c +11035 -0
  301. data/third_party/cares/cares/ares_platform.h +43 -0
  302. data/third_party/cares/cares/ares_private.h +363 -0
  303. data/third_party/cares/cares/ares_process.c +1359 -0
  304. data/third_party/cares/cares/ares_query.c +186 -0
  305. data/third_party/cares/cares/ares_rules.h +125 -0
  306. data/third_party/cares/cares/ares_search.c +316 -0
  307. data/third_party/cares/cares/ares_send.c +131 -0
  308. data/third_party/cares/cares/ares_setup.h +217 -0
  309. data/third_party/cares/cares/ares_strcasecmp.c +66 -0
  310. data/third_party/cares/cares/ares_strcasecmp.h +30 -0
  311. data/third_party/cares/cares/ares_strdup.c +49 -0
  312. data/third_party/cares/cares/ares_strdup.h +24 -0
  313. data/third_party/cares/cares/ares_strerror.c +56 -0
  314. data/third_party/cares/cares/ares_timeout.c +88 -0
  315. data/third_party/cares/cares/ares_version.c +11 -0
  316. data/third_party/cares/cares/ares_version.h +24 -0
  317. data/third_party/cares/cares/ares_writev.c +79 -0
  318. data/third_party/cares/cares/bitncmp.c +59 -0
  319. data/third_party/cares/cares/bitncmp.h +26 -0
  320. data/third_party/cares/cares/config-win32.h +377 -0
  321. data/third_party/cares/cares/inet_net_pton.c +450 -0
  322. data/third_party/cares/cares/inet_ntop.c +208 -0
  323. data/third_party/cares/cares/setup_once.h +554 -0
  324. data/third_party/cares/cares/windows_port.c +22 -0
  325. data/third_party/cares/config_darwin/ares_config.h +523 -0
  326. data/third_party/cares/config_linux/ares_config.h +524 -0
  327. metadata +164 -68
@@ -38,7 +38,7 @@
38
38
  #include "src/core/lib/iomgr/exec_ctx.h"
39
39
 
40
40
  struct grpc_timer {
41
- gpr_timespec deadline;
41
+ gpr_atm deadline;
42
42
  uint32_t heap_index; /* INVALID_HEAP_INDEX if not in heap */
43
43
  bool pending;
44
44
  struct grpc_timer *next;
@@ -50,7 +50,7 @@
50
50
  static void adjust_upwards(grpc_timer **first, uint32_t i, grpc_timer *t) {
51
51
  while (i > 0) {
52
52
  uint32_t parent = (uint32_t)(((int)i - 1) / 2);
53
- if (gpr_time_cmp(first[parent]->deadline, t->deadline) <= 0) break;
53
+ if (first[parent]->deadline <= t->deadline) break;
54
54
  first[i] = first[parent];
55
55
  first[i]->heap_index = i;
56
56
  i = parent;
@@ -68,12 +68,12 @@ static void adjust_downwards(grpc_timer **first, uint32_t i, uint32_t length,
68
68
  uint32_t left_child = 1u + 2u * i;
69
69
  if (left_child >= length) break;
70
70
  uint32_t right_child = left_child + 1;
71
- uint32_t next_i = right_child < length &&
72
- gpr_time_cmp(first[left_child]->deadline,
73
- first[right_child]->deadline) > 0
74
- ? right_child
75
- : left_child;
76
- if (gpr_time_cmp(t->deadline, first[next_i]->deadline) <= 0) break;
71
+ uint32_t next_i =
72
+ right_child < length &&
73
+ first[left_child]->deadline > first[right_child]->deadline
74
+ ? right_child
75
+ : left_child;
76
+ if (t->deadline <= first[next_i]->deadline) break;
77
77
  first[i] = first[next_i];
78
78
  first[i]->heap_index = i;
79
79
  i = next_i;
@@ -97,7 +97,7 @@ static void maybe_shrink(grpc_timer_heap *heap) {
97
97
  static void note_changed_priority(grpc_timer_heap *heap, grpc_timer *timer) {
98
98
  uint32_t i = timer->heap_index;
99
99
  uint32_t parent = (uint32_t)(((int)i - 1) / 2);
100
- if (gpr_time_cmp(heap->timers[parent]->deadline, timer->deadline) > 0) {
100
+ if (heap->timers[parent]->deadline > timer->deadline) {
101
101
  adjust_upwards(heap->timers, i, timer);
102
102
  } else {
103
103
  adjust_downwards(heap->timers, i, heap->timer_count, timer);
@@ -59,11 +59,13 @@
59
59
  #include <grpc/support/string_util.h>
60
60
  #include <grpc/support/sync.h>
61
61
  #include <grpc/support/time.h>
62
+ #include "src/core/lib/channel/channel_args.h"
62
63
  #include "src/core/lib/iomgr/error.h"
63
64
  #include "src/core/lib/iomgr/ev_posix.h"
64
65
  #include "src/core/lib/iomgr/resolve_address.h"
65
66
  #include "src/core/lib/iomgr/sockaddr.h"
66
67
  #include "src/core/lib/iomgr/sockaddr_utils.h"
68
+ #include "src/core/lib/iomgr/socket_factory_posix.h"
67
69
  #include "src/core/lib/iomgr/socket_utils_posix.h"
68
70
  #include "src/core/lib/iomgr/unix_sockets_posix.h"
69
71
  #include "src/core/lib/support/string.h"
@@ -89,6 +91,9 @@ struct grpc_udp_listener {
89
91
  struct grpc_udp_server {
90
92
  gpr_mu mu;
91
93
 
94
+ /* factory to use for creating and binding sockets, or NULL */
95
+ grpc_socket_factory *socket_factory;
96
+
92
97
  /* active port count: how many ports are actually still listening */
93
98
  size_t active_ports;
94
99
  /* destroyed port count: how many ports are completely destroyed */
@@ -109,13 +114,28 @@ struct grpc_udp_server {
109
114
  grpc_pollset **pollsets;
110
115
  /* number of pollsets in the pollsets array */
111
116
  size_t pollset_count;
112
- /* The parent grpc server */
113
- grpc_server *grpc_server;
117
+ /* opaque object to pass to callbacks */
118
+ void *user_data;
114
119
  };
115
120
 
116
- grpc_udp_server *grpc_udp_server_create(void) {
121
+ static grpc_socket_factory *get_socket_factory(const grpc_channel_args *args) {
122
+ if (args) {
123
+ const grpc_arg *arg = grpc_channel_args_find(args, GRPC_ARG_SOCKET_FACTORY);
124
+ if (arg) {
125
+ GPR_ASSERT(arg->type == GRPC_ARG_POINTER);
126
+ return arg->value.pointer.p;
127
+ }
128
+ }
129
+ return NULL;
130
+ }
131
+
132
+ grpc_udp_server *grpc_udp_server_create(const grpc_channel_args *args) {
117
133
  grpc_udp_server *s = gpr_malloc(sizeof(grpc_udp_server));
118
134
  gpr_mu_init(&s->mu);
135
+ s->socket_factory = get_socket_factory(args);
136
+ if (s->socket_factory) {
137
+ grpc_socket_factory_ref(s->socket_factory);
138
+ }
119
139
  s->active_ports = 0;
120
140
  s->destroyed_ports = 0;
121
141
  s->shutdown = 0;
@@ -139,6 +159,10 @@ static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
139
159
  gpr_free(sp);
140
160
  }
141
161
 
162
+ if (s->socket_factory) {
163
+ grpc_socket_factory_unref(s->socket_factory);
164
+ }
165
+
142
166
  gpr_free(s);
143
167
  }
144
168
 
@@ -162,10 +186,7 @@ static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
162
186
  /* delete ALL the things */
163
187
  gpr_mu_lock(&s->mu);
164
188
 
165
- if (!s->shutdown) {
166
- gpr_mu_unlock(&s->mu);
167
- return;
168
- }
189
+ GPR_ASSERT(s->shutdown);
169
190
 
170
191
  if (s->head) {
171
192
  grpc_udp_listener *sp;
@@ -178,7 +199,7 @@ static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
178
199
  /* Call the orphan_cb to signal that the FD is about to be closed and
179
200
  * should no longer be used. */
180
201
  GPR_ASSERT(sp->orphan_cb);
181
- sp->orphan_cb(exec_ctx, sp->emfd);
202
+ sp->orphan_cb(exec_ctx, sp->emfd, sp->server->user_data);
182
203
 
183
204
  grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL,
184
205
  "udp_listener_shutdown");
@@ -204,9 +225,9 @@ void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *s,
204
225
  if (s->active_ports) {
205
226
  for (sp = s->head; sp; sp = sp->next) {
206
227
  GPR_ASSERT(sp->orphan_cb);
207
- sp->orphan_cb(exec_ctx, sp->emfd);
208
- grpc_fd_shutdown(exec_ctx, sp->emfd,
209
- GRPC_ERROR_CREATE("Server destroyed"));
228
+ sp->orphan_cb(exec_ctx, sp->emfd, sp->server->user_data);
229
+ grpc_fd_shutdown(exec_ctx, sp->emfd, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
230
+ "Server destroyed"));
210
231
  }
211
232
  gpr_mu_unlock(&s->mu);
212
233
  } else {
@@ -215,8 +236,17 @@ void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *s,
215
236
  }
216
237
  }
217
238
 
239
+ static int bind_socket(grpc_socket_factory *socket_factory, int sockfd,
240
+ const grpc_resolved_address *addr) {
241
+ return (socket_factory != NULL)
242
+ ? grpc_socket_factory_bind(socket_factory, sockfd, addr)
243
+ : bind(sockfd, (struct sockaddr *)addr->addr,
244
+ (socklen_t)addr->len);
245
+ }
246
+
218
247
  /* Prepare a recently-created socket for listening. */
219
- static int prepare_socket(int fd, const grpc_resolved_address *addr) {
248
+ static int prepare_socket(grpc_socket_factory *socket_factory, int fd,
249
+ const grpc_resolved_address *addr) {
220
250
  grpc_resolved_address sockname_temp;
221
251
  struct sockaddr *addr_ptr = (struct sockaddr *)addr->addr;
222
252
  /* Set send/receive socket buffers to 1 MB */
@@ -246,7 +276,7 @@ static int prepare_socket(int fd, const grpc_resolved_address *addr) {
246
276
  }
247
277
 
248
278
  GPR_ASSERT(addr->len < ~(socklen_t)0);
249
- if (bind(fd, (struct sockaddr *)addr, (socklen_t)addr->len) < 0) {
279
+ if (bind_socket(socket_factory, fd, addr) < 0) {
250
280
  char *addr_str;
251
281
  grpc_sockaddr_to_string(&addr_str, addr, 0);
252
282
  gpr_log(GPR_ERROR, "bind addr=%s: %s", addr_str, strerror(errno));
@@ -288,7 +318,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
288
318
 
289
319
  gpr_mu_lock(&sp->server->mu);
290
320
  if (error != GRPC_ERROR_NONE) {
291
- if (0 == --sp->server->active_ports) {
321
+ if (0 == --sp->server->active_ports && sp->server->shutdown) {
292
322
  gpr_mu_unlock(&sp->server->mu);
293
323
  deactivated_all_ports(exec_ctx, sp->server);
294
324
  } else {
@@ -299,7 +329,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
299
329
 
300
330
  /* Tell the registered callback that data is available to read. */
301
331
  GPR_ASSERT(sp->read_cb);
302
- sp->read_cb(exec_ctx, sp->emfd, sp->server->grpc_server);
332
+ sp->read_cb(exec_ctx, sp->emfd, sp->server->user_data);
303
333
 
304
334
  /* Re-arm the notification event so we get another chance to read. */
305
335
  grpc_fd_notify_on_read(exec_ctx, sp->emfd, &sp->read_closure);
@@ -311,7 +341,7 @@ static void on_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
311
341
 
312
342
  gpr_mu_lock(&(sp->server->mu));
313
343
  if (error != GRPC_ERROR_NONE) {
314
- if (0 == --sp->server->active_ports) {
344
+ if (0 == --sp->server->active_ports && sp->server->shutdown) {
315
345
  gpr_mu_unlock(&sp->server->mu);
316
346
  deactivated_all_ports(exec_ctx, sp->server);
317
347
  } else {
@@ -322,7 +352,7 @@ static void on_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
322
352
 
323
353
  /* Tell the registered callback that the socket is writeable. */
324
354
  GPR_ASSERT(sp->write_cb);
325
- sp->write_cb(exec_ctx, sp->emfd);
355
+ sp->write_cb(exec_ctx, sp->emfd, sp->server->user_data);
326
356
 
327
357
  /* Re-arm the notification event so we get another chance to write. */
328
358
  grpc_fd_notify_on_write(exec_ctx, sp->emfd, &sp->write_closure);
@@ -339,7 +369,7 @@ static int add_socket_to_server(grpc_udp_server *s, int fd,
339
369
  char *addr_str;
340
370
  char *name;
341
371
 
342
- port = prepare_socket(fd, addr);
372
+ port = prepare_socket(s->socket_factory, fd, addr);
343
373
  if (port >= 0) {
344
374
  grpc_sockaddr_to_string(&addr_str, addr, 1);
345
375
  gpr_asprintf(&name, "udp-server-listener:%s", addr_str);
@@ -417,8 +447,8 @@ int grpc_udp_server_add_port(grpc_udp_server *s,
417
447
  /* Try listening on IPv6 first. */
418
448
  addr = &wild6;
419
449
  // TODO(rjshade): Test and propagate the returned grpc_error*:
420
- GRPC_ERROR_UNREF(grpc_create_dualstack_socket(addr, SOCK_DGRAM, IPPROTO_UDP,
421
- &dsmode, &fd));
450
+ GRPC_ERROR_UNREF(grpc_create_dualstack_socket_using_factory(
451
+ s->socket_factory, addr, SOCK_DGRAM, IPPROTO_UDP, &dsmode, &fd));
422
452
  allocated_port1 =
423
453
  add_socket_to_server(s, fd, addr, read_cb, write_cb, orphan_cb);
424
454
  if (fd >= 0 && dsmode == GRPC_DSMODE_DUALSTACK) {
@@ -433,8 +463,8 @@ int grpc_udp_server_add_port(grpc_udp_server *s,
433
463
  }
434
464
 
435
465
  // TODO(rjshade): Test and propagate the returned grpc_error*:
436
- GRPC_ERROR_UNREF(grpc_create_dualstack_socket(addr, SOCK_DGRAM, IPPROTO_UDP,
437
- &dsmode, &fd));
466
+ GRPC_ERROR_UNREF(grpc_create_dualstack_socket_using_factory(
467
+ s->socket_factory, addr, SOCK_DGRAM, IPPROTO_UDP, &dsmode, &fd));
438
468
  if (fd < 0) {
439
469
  gpr_log(GPR_ERROR, "Unable to create socket: %s", strerror(errno));
440
470
  }
@@ -464,13 +494,13 @@ int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned port_index) {
464
494
 
465
495
  void grpc_udp_server_start(grpc_exec_ctx *exec_ctx, grpc_udp_server *s,
466
496
  grpc_pollset **pollsets, size_t pollset_count,
467
- grpc_server *server) {
497
+ void *user_data) {
468
498
  size_t i;
469
499
  gpr_mu_lock(&s->mu);
470
500
  grpc_udp_listener *sp;
471
501
  GPR_ASSERT(s->active_ports == 0);
472
502
  s->pollsets = pollsets;
473
- s->grpc_server = server;
503
+ s->user_data = user_data;
474
504
 
475
505
  sp = s->head;
476
506
  while (sp != NULL) {
@@ -47,23 +47,23 @@ typedef struct grpc_udp_server grpc_udp_server;
47
47
 
48
48
  /* Called when data is available to read from the socket. */
49
49
  typedef void (*grpc_udp_server_read_cb)(grpc_exec_ctx *exec_ctx, grpc_fd *emfd,
50
- struct grpc_server *server);
50
+ void *user_data);
51
51
 
52
52
  /* Called when the socket is writeable. */
53
- typedef void (*grpc_udp_server_write_cb)(grpc_exec_ctx *exec_ctx,
54
- grpc_fd *emfd);
53
+ typedef void (*grpc_udp_server_write_cb)(grpc_exec_ctx *exec_ctx, grpc_fd *emfd,
54
+ void *user_data);
55
55
 
56
56
  /* Called when the grpc_fd is about to be orphaned (and the FD closed). */
57
57
  typedef void (*grpc_udp_server_orphan_cb)(grpc_exec_ctx *exec_ctx,
58
- grpc_fd *emfd);
58
+ grpc_fd *emfd, void *user_data);
59
59
 
60
60
  /* Create a server, initially not bound to any ports */
61
- grpc_udp_server *grpc_udp_server_create(void);
61
+ grpc_udp_server *grpc_udp_server_create(const grpc_channel_args *args);
62
62
 
63
- /* Start listening to bound ports */
63
+ /* Start listening to bound ports. user_data is passed to callbacks. */
64
64
  void grpc_udp_server_start(grpc_exec_ctx *exec_ctx, grpc_udp_server *udp_server,
65
65
  grpc_pollset **pollsets, size_t pollset_count,
66
- struct grpc_server *server);
66
+ void *user_data);
67
67
 
68
68
  int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned port_index);
69
69
 
@@ -60,7 +60,7 @@ grpc_error *grpc_resolve_unix_domain_address(const char *name,
60
60
  gpr_asprintf(&err_msg,
61
61
  "Path name should not have more than %" PRIuPTR " characters.",
62
62
  GPR_ARRAY_SIZE(un->sun_path) - 1);
63
- err = GRPC_ERROR_CREATE(err_msg);
63
+ err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(err_msg);
64
64
  gpr_free(err_msg);
65
65
  return err;
66
66
  }
@@ -47,7 +47,8 @@ void grpc_create_socketpair_if_unix(int sv[2]) {
47
47
  grpc_error *grpc_resolve_unix_domain_address(
48
48
  const char *name, grpc_resolved_addresses **addresses) {
49
49
  *addresses = NULL;
50
- return GRPC_ERROR_CREATE("Unix domain sockets are not supported on Windows");
50
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
51
+ "Unix domain sockets are not supported on Windows");
51
52
  }
52
53
 
53
54
  int grpc_is_unix_socket(const grpc_resolved_address *addr) { return false; }
@@ -46,7 +46,7 @@
46
46
  *
47
47
  * Setup:
48
48
  * 1. Before calling anything, call global_init() at least once.
49
- * 1. Call grpc_wakeup_fd_create() to get a wakeup_fd.
49
+ * 1. Call grpc_wakeup_fd_init() to set up a wakeup_fd.
50
50
  * 2. Add the result of GRPC_WAKEUP_FD_FD to the set of monitored file
51
51
  * descriptors for the poll() style API you are using. Monitor the file
52
52
  * descriptor for readability.
@@ -218,7 +218,7 @@ void gpr_timers_set_log_filename(const char *filename) {
218
218
  static void init_output() {
219
219
  gpr_thd_options options = gpr_thd_options_default();
220
220
  gpr_thd_options_set_joinable(&options);
221
- gpr_thd_new(&g_writing_thread, writing_thread, NULL, &options);
221
+ GPR_ASSERT(gpr_thd_new(&g_writing_thread, writing_thread, NULL, &options));
222
222
  atexit(finish_writing);
223
223
  }
224
224
 
@@ -71,7 +71,7 @@ typedef enum {
71
71
 
72
72
  #define GRPC_SECURE_TOKEN_REFRESH_THRESHOLD_SECS 60
73
73
 
74
- #define GRPC_COMPUTE_ENGINE_METADATA_HOST "metadata"
74
+ #define GRPC_COMPUTE_ENGINE_METADATA_HOST "metadata.google.internal"
75
75
  #define GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH \
76
76
  "/computeMetadata/v1/instance/service-accounts/default/token"
77
77
 
@@ -180,7 +180,7 @@ static grpc_error *create_default_creds_from_path(
180
180
  grpc_slice creds_data = grpc_empty_slice();
181
181
  grpc_error *error = GRPC_ERROR_NONE;
182
182
  if (creds_path == NULL) {
183
- error = GRPC_ERROR_CREATE("creds_path unset");
183
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("creds_path unset");
184
184
  goto end;
185
185
  }
186
186
  error = grpc_load_file(creds_path, 0, &creds_data);
@@ -190,10 +190,9 @@ static grpc_error *create_default_creds_from_path(
190
190
  json = grpc_json_parse_string_with_len(
191
191
  (char *)GRPC_SLICE_START_PTR(creds_data), GRPC_SLICE_LENGTH(creds_data));
192
192
  if (json == NULL) {
193
- char *dump = grpc_dump_slice(creds_data, GPR_DUMP_HEX | GPR_DUMP_ASCII);
194
- error = grpc_error_set_str(GRPC_ERROR_CREATE("Failed to parse JSON"),
195
- GRPC_ERROR_STR_RAW_BYTES, dump);
196
- gpr_free(dump);
193
+ error = grpc_error_set_str(
194
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to parse JSON"),
195
+ GRPC_ERROR_STR_RAW_BYTES, grpc_slice_ref_internal(creds_data));
197
196
  goto end;
198
197
  }
199
198
 
@@ -204,7 +203,7 @@ static grpc_error *create_default_creds_from_path(
204
203
  grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
205
204
  exec_ctx, key, grpc_max_auth_token_lifetime());
206
205
  if (result == NULL) {
207
- error = GRPC_ERROR_CREATE(
206
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
208
207
  "grpc_service_account_jwt_access_credentials_create_from_auth_json_"
209
208
  "key failed");
210
209
  }
@@ -217,7 +216,7 @@ static grpc_error *create_default_creds_from_path(
217
216
  result =
218
217
  grpc_refresh_token_credentials_create_from_auth_refresh_token(token);
219
218
  if (result == NULL) {
220
- error = GRPC_ERROR_CREATE(
219
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
221
220
  "grpc_refresh_token_credentials_create_from_auth_refresh_token "
222
221
  "failed");
223
222
  }
@@ -236,7 +235,8 @@ end:
236
235
  grpc_channel_credentials *grpc_google_default_credentials_create(void) {
237
236
  grpc_channel_credentials *result = NULL;
238
237
  grpc_call_credentials *call_creds = NULL;
239
- grpc_error *error = GRPC_ERROR_CREATE("Failed to create Google credentials");
238
+ grpc_error *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
239
+ "Failed to create Google credentials");
240
240
  grpc_error *err;
241
241
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
242
242
 
@@ -274,7 +274,8 @@ grpc_channel_credentials *grpc_google_default_credentials_create(void) {
274
274
  call_creds = grpc_google_compute_engine_credentials_create(NULL);
275
275
  if (call_creds == NULL) {
276
276
  error = grpc_error_add_child(
277
- error, GRPC_ERROR_CREATE("Failed to get credentials from network"));
277
+ error, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
278
+ "Failed to get credentials from network"));
278
279
  }
279
280
  }
280
281
  }
@@ -40,8 +40,8 @@
40
40
  #include <grpc/support/string_util.h>
41
41
  #include <grpc/support/time.h>
42
42
 
43
- #include "src/core/lib/security/util/b64.h"
44
43
  #include "src/core/lib/security/util/json_util.h"
44
+ #include "src/core/lib/slice/b64.h"
45
45
  #include "src/core/lib/support/string.h"
46
46
 
47
47
  #include <openssl/bio.h>
@@ -45,10 +45,10 @@
45
45
 
46
46
  #include "src/core/lib/http/httpcli.h"
47
47
  #include "src/core/lib/iomgr/polling_entity.h"
48
- #include "src/core/lib/security/util/b64.h"
48
+ #include "src/core/lib/slice/b64.h"
49
49
  #include "src/core/lib/slice/slice_internal.h"
50
50
  #include "src/core/lib/support/string.h"
51
- #include "src/core/lib/tsi/ssl_types.h"
51
+ #include "src/core/tsi/ssl_types.h"
52
52
 
53
53
  /* --- Utils. --- */
54
54
 
@@ -64,7 +64,7 @@ typedef struct {
64
64
  pollset_set so that work can progress when this call wants work to progress
65
65
  */
66
66
  grpc_polling_entity *pollent;
67
- grpc_transport_stream_op op;
67
+ grpc_transport_stream_op_batch op;
68
68
  uint8_t security_context_set;
69
69
  grpc_linked_mdelem md_links[MAX_CREDENTIALS_METADATA_COUNT];
70
70
  grpc_auth_metadata_context auth_md_context;
@@ -95,7 +95,8 @@ static void reset_auth_metadata_context(
95
95
  static void add_error(grpc_error **combined, grpc_error *error) {
96
96
  if (error == GRPC_ERROR_NONE) return;
97
97
  if (*combined == GRPC_ERROR_NONE) {
98
- *combined = GRPC_ERROR_CREATE("Client auth metadata plugin error");
98
+ *combined = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
99
+ "Client auth metadata plugin error");
99
100
  }
100
101
  *combined = grpc_error_add_child(*combined, error);
101
102
  }
@@ -107,21 +108,22 @@ static void on_credentials_metadata(grpc_exec_ctx *exec_ctx, void *user_data,
107
108
  const char *error_details) {
108
109
  grpc_call_element *elem = (grpc_call_element *)user_data;
109
110
  call_data *calld = elem->call_data;
110
- grpc_transport_stream_op *op = &calld->op;
111
+ grpc_transport_stream_op_batch *op = &calld->op;
111
112
  grpc_metadata_batch *mdb;
112
113
  size_t i;
113
114
  reset_auth_metadata_context(&calld->auth_md_context);
114
115
  grpc_error *error = GRPC_ERROR_NONE;
115
116
  if (status != GRPC_CREDENTIALS_OK) {
116
117
  error = grpc_error_set_int(
117
- GRPC_ERROR_CREATE(error_details != NULL && strlen(error_details) > 0
118
- ? error_details
119
- : "Credentials failed to get metadata."),
118
+ GRPC_ERROR_CREATE_FROM_COPIED_STRING(
119
+ error_details != NULL && strlen(error_details) > 0
120
+ ? error_details
121
+ : "Credentials failed to get metadata."),
120
122
  GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAUTHENTICATED);
121
123
  } else {
122
124
  GPR_ASSERT(num_md <= MAX_CREDENTIALS_METADATA_COUNT);
123
- GPR_ASSERT(op->send_initial_metadata != NULL);
124
- mdb = op->send_initial_metadata;
125
+ GPR_ASSERT(op->send_initial_metadata);
126
+ mdb = op->payload->send_initial_metadata.send_initial_metadata;
125
127
  for (i = 0; i < num_md; i++) {
126
128
  add_error(&error,
127
129
  grpc_metadata_batch_add_tail(
@@ -134,7 +136,7 @@ static void on_credentials_metadata(grpc_exec_ctx *exec_ctx, void *user_data,
134
136
  if (error == GRPC_ERROR_NONE) {
135
137
  grpc_call_next_op(exec_ctx, elem, op);
136
138
  } else {
137
- grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error);
139
+ grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, op, error);
138
140
  }
139
141
  }
140
142
 
@@ -170,11 +172,13 @@ void build_auth_metadata_context(grpc_security_connector *sc,
170
172
 
171
173
  static void send_security_metadata(grpc_exec_ctx *exec_ctx,
172
174
  grpc_call_element *elem,
173
- grpc_transport_stream_op *op) {
175
+ grpc_transport_stream_op_batch *op) {
174
176
  call_data *calld = elem->call_data;
175
177
  channel_data *chand = elem->channel_data;
176
178
  grpc_client_security_context *ctx =
177
- (grpc_client_security_context *)op->context[GRPC_CONTEXT_SECURITY].value;
179
+ (grpc_client_security_context *)op->payload
180
+ ->context[GRPC_CONTEXT_SECURITY]
181
+ .value;
178
182
  grpc_call_credentials *channel_call_creds =
179
183
  chand->security_connector->request_metadata_creds;
180
184
  int call_creds_has_md = (ctx != NULL) && (ctx->creds != NULL);
@@ -189,10 +193,10 @@ static void send_security_metadata(grpc_exec_ctx *exec_ctx,
189
193
  calld->creds = grpc_composite_call_credentials_create(channel_call_creds,
190
194
  ctx->creds, NULL);
191
195
  if (calld->creds == NULL) {
192
- grpc_transport_stream_op_finish_with_failure(
196
+ grpc_transport_stream_op_batch_finish_with_failure(
193
197
  exec_ctx, op,
194
198
  grpc_error_set_int(
195
- GRPC_ERROR_CREATE(
199
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING(
196
200
  "Incompatible credentials set on channel and call."),
197
201
  GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAUTHENTICATED));
198
202
  return;
@@ -225,9 +229,10 @@ static void on_host_checked(grpc_exec_ctx *exec_ctx, void *user_data,
225
229
  host);
226
230
  gpr_free(host);
227
231
  grpc_call_element_signal_error(
228
- exec_ctx, elem, grpc_error_set_int(GRPC_ERROR_CREATE(error_msg),
229
- GRPC_ERROR_INT_GRPC_STATUS,
230
- GRPC_STATUS_UNAUTHENTICATED));
232
+ exec_ctx, elem,
233
+ grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg),
234
+ GRPC_ERROR_INT_GRPC_STATUS,
235
+ GRPC_STATUS_UNAUTHENTICATED));
231
236
  gpr_free(error_msg);
232
237
  }
233
238
  }
@@ -239,7 +244,7 @@ static void on_host_checked(grpc_exec_ctx *exec_ctx, void *user_data,
239
244
  that is being sent or received. */
240
245
  static void auth_start_transport_op(grpc_exec_ctx *exec_ctx,
241
246
  grpc_call_element *elem,
242
- grpc_transport_stream_op *op) {
247
+ grpc_transport_stream_op_batch *op) {
243
248
  GPR_TIMER_BEGIN("auth_start_transport_op", 0);
244
249
 
245
250
  /* grab pointers to our data from the call element */
@@ -248,23 +253,25 @@ static void auth_start_transport_op(grpc_exec_ctx *exec_ctx,
248
253
  grpc_linked_mdelem *l;
249
254
  grpc_client_security_context *sec_ctx = NULL;
250
255
 
251
- if (calld->security_context_set == 0 && op->cancel_error == GRPC_ERROR_NONE) {
256
+ if (calld->security_context_set == 0 && !op->cancel_stream) {
252
257
  calld->security_context_set = 1;
253
- GPR_ASSERT(op->context);
254
- if (op->context[GRPC_CONTEXT_SECURITY].value == NULL) {
255
- op->context[GRPC_CONTEXT_SECURITY].value =
258
+ GPR_ASSERT(op->payload->context != NULL);
259
+ if (op->payload->context[GRPC_CONTEXT_SECURITY].value == NULL) {
260
+ op->payload->context[GRPC_CONTEXT_SECURITY].value =
256
261
  grpc_client_security_context_create();
257
- op->context[GRPC_CONTEXT_SECURITY].destroy =
262
+ op->payload->context[GRPC_CONTEXT_SECURITY].destroy =
258
263
  grpc_client_security_context_destroy;
259
264
  }
260
- sec_ctx = op->context[GRPC_CONTEXT_SECURITY].value;
265
+ sec_ctx = op->payload->context[GRPC_CONTEXT_SECURITY].value;
261
266
  GRPC_AUTH_CONTEXT_UNREF(sec_ctx->auth_context, "client auth filter");
262
267
  sec_ctx->auth_context =
263
268
  GRPC_AUTH_CONTEXT_REF(chand->auth_context, "client_auth_filter");
264
269
  }
265
270
 
266
- if (op->send_initial_metadata != NULL) {
267
- for (l = op->send_initial_metadata->list.head; l != NULL; l = l->next) {
271
+ if (op->send_initial_metadata) {
272
+ for (l = op->payload->send_initial_metadata.send_initial_metadata->list
273
+ .head;
274
+ l != NULL; l = l->next) {
268
275
  grpc_mdelem md = l->md;
269
276
  /* Pointer comparison is OK for md_elems created from the same context.
270
277
  */
@@ -318,7 +325,7 @@ static void set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
318
325
  /* Destructor for call_data */
319
326
  static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
320
327
  const grpc_call_final_info *final_info,
321
- void *ignored) {
328
+ grpc_closure *ignored) {
322
329
  call_data *calld = elem->call_data;
323
330
  grpc_call_credentials_unref(exec_ctx, calld->creds);
324
331
  if (calld->have_host) {