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
@@ -49,7 +49,7 @@
49
49
  #include "src/core/lib/slice/slice_internal.h"
50
50
  #include "src/core/lib/slice/slice_string_helpers.h"
51
51
  #include "src/core/lib/support/string.h"
52
- #include "src/core/lib/tsi/transport_security_interface.h"
52
+ #include "src/core/tsi/transport_security_interface.h"
53
53
 
54
54
  #define STAGING_BUFFER_SIZE 8192
55
55
 
@@ -162,7 +162,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
162
162
 
163
163
  if (error != GRPC_ERROR_NONE) {
164
164
  grpc_slice_buffer_reset_and_unref_internal(exec_ctx, ep->read_buffer);
165
- call_read_cb(exec_ctx, ep, GRPC_ERROR_CREATE_REFERENCING(
165
+ call_read_cb(exec_ctx, ep, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
166
166
  "Secure read failed", &error, 1));
167
167
  return;
168
168
  }
@@ -220,8 +220,10 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
220
220
 
221
221
  if (result != TSI_OK) {
222
222
  grpc_slice_buffer_reset_and_unref_internal(exec_ctx, ep->read_buffer);
223
- call_read_cb(exec_ctx, ep, grpc_set_tsi_error_result(
224
- GRPC_ERROR_CREATE("Unwrap failed"), result));
223
+ call_read_cb(
224
+ exec_ctx, ep,
225
+ grpc_set_tsi_error_result(
226
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unwrap failed"), result));
225
227
  return;
226
228
  }
227
229
 
@@ -332,7 +334,8 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
332
334
  grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &ep->output_buffer);
333
335
  grpc_closure_sched(
334
336
  exec_ctx, cb,
335
- grpc_set_tsi_error_result(GRPC_ERROR_CREATE("Wrap failed"), result));
337
+ grpc_set_tsi_error_result(
338
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Wrap failed"), result));
336
339
  GPR_TIMER_END("secure_endpoint.endpoint_write", 0);
337
340
  return;
338
341
  }
@@ -54,8 +54,8 @@
54
54
  #include "src/core/lib/security/transport/security_handshaker.h"
55
55
  #include "src/core/lib/support/env.h"
56
56
  #include "src/core/lib/support/string.h"
57
- #include "src/core/lib/tsi/fake_transport_security.h"
58
- #include "src/core/lib/tsi/ssl_transport_security.h"
57
+ #include "src/core/tsi/fake_transport_security.h"
58
+ #include "src/core/tsi/ssl_transport_security.h"
59
59
 
60
60
  /* -- Constants. -- */
61
61
 
@@ -137,9 +137,9 @@ void grpc_security_connector_check_peer(grpc_exec_ctx *exec_ctx,
137
137
  grpc_auth_context **auth_context,
138
138
  grpc_closure *on_peer_checked) {
139
139
  if (sc == NULL) {
140
- grpc_closure_sched(
141
- exec_ctx, on_peer_checked,
142
- GRPC_ERROR_CREATE("cannot check peer -- no security connector"));
140
+ grpc_closure_sched(exec_ctx, on_peer_checked,
141
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING(
142
+ "cannot check peer -- no security connector"));
143
143
  tsi_peer_destruct(&peer);
144
144
  } else {
145
145
  sc->vtable->check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked);
@@ -330,7 +330,8 @@ static void fake_check_peer(grpc_exec_ctx *exec_ctx,
330
330
  grpc_error *error = GRPC_ERROR_NONE;
331
331
  *auth_context = NULL;
332
332
  if (peer.property_count != 1) {
333
- error = GRPC_ERROR_CREATE("Fake peers should only have 1 property.");
333
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
334
+ "Fake peers should only have 1 property.");
334
335
  goto end;
335
336
  }
336
337
  prop_name = peer.properties[0].name;
@@ -339,13 +340,14 @@ static void fake_check_peer(grpc_exec_ctx *exec_ctx,
339
340
  char *msg;
340
341
  gpr_asprintf(&msg, "Unexpected property in fake peer: %s.",
341
342
  prop_name == NULL ? "<EMPTY>" : prop_name);
342
- error = GRPC_ERROR_CREATE(msg);
343
+ error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
343
344
  gpr_free(msg);
344
345
  goto end;
345
346
  }
346
347
  if (strncmp(peer.properties[0].value.data, TSI_FAKE_CERTIFICATE_TYPE,
347
348
  peer.properties[0].value.length)) {
348
- error = GRPC_ERROR_CREATE("Invalid value for cert type property.");
349
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
350
+ "Invalid value for cert type property.");
349
351
  goto end;
350
352
  }
351
353
  *auth_context = grpc_auth_context_create(NULL);
@@ -446,14 +448,14 @@ grpc_server_security_connector *grpc_fake_server_security_connector_create(
446
448
 
447
449
  typedef struct {
448
450
  grpc_channel_security_connector base;
449
- tsi_ssl_handshaker_factory *handshaker_factory;
451
+ tsi_ssl_client_handshaker_factory *handshaker_factory;
450
452
  char *target_name;
451
453
  char *overridden_target_name;
452
454
  } grpc_ssl_channel_security_connector;
453
455
 
454
456
  typedef struct {
455
457
  grpc_server_security_connector base;
456
- tsi_ssl_handshaker_factory *handshaker_factory;
458
+ tsi_ssl_server_handshaker_factory *handshaker_factory;
457
459
  } grpc_ssl_server_security_connector;
458
460
 
459
461
  static void ssl_channel_destroy(grpc_exec_ctx *exec_ctx,
@@ -462,7 +464,7 @@ static void ssl_channel_destroy(grpc_exec_ctx *exec_ctx,
462
464
  (grpc_ssl_channel_security_connector *)sc;
463
465
  grpc_call_credentials_unref(exec_ctx, c->base.request_metadata_creds);
464
466
  if (c->handshaker_factory != NULL) {
465
- tsi_ssl_handshaker_factory_destroy(c->handshaker_factory);
467
+ tsi_ssl_client_handshaker_factory_destroy(c->handshaker_factory);
466
468
  }
467
469
  if (c->target_name != NULL) gpr_free(c->target_name);
468
470
  if (c->overridden_target_name != NULL) gpr_free(c->overridden_target_name);
@@ -474,26 +476,11 @@ static void ssl_server_destroy(grpc_exec_ctx *exec_ctx,
474
476
  grpc_ssl_server_security_connector *c =
475
477
  (grpc_ssl_server_security_connector *)sc;
476
478
  if (c->handshaker_factory != NULL) {
477
- tsi_ssl_handshaker_factory_destroy(c->handshaker_factory);
479
+ tsi_ssl_server_handshaker_factory_destroy(c->handshaker_factory);
478
480
  }
479
481
  gpr_free(sc);
480
482
  }
481
483
 
482
- static grpc_security_status ssl_create_handshaker(
483
- tsi_ssl_handshaker_factory *handshaker_factory, bool is_client,
484
- const char *peer_name, tsi_handshaker **handshaker) {
485
- tsi_result result = TSI_OK;
486
- if (handshaker_factory == NULL) return GRPC_SECURITY_ERROR;
487
- result = tsi_ssl_handshaker_factory_create_handshaker(
488
- handshaker_factory, is_client ? peer_name : NULL, handshaker);
489
- if (result != TSI_OK) {
490
- gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
491
- tsi_result_to_string(result));
492
- return GRPC_SECURITY_ERROR;
493
- }
494
- return GRPC_SECURITY_OK;
495
- }
496
-
497
484
  static void ssl_channel_add_handshakers(grpc_exec_ctx *exec_ctx,
498
485
  grpc_channel_security_connector *sc,
499
486
  grpc_handshake_manager *handshake_mgr) {
@@ -501,11 +488,17 @@ static void ssl_channel_add_handshakers(grpc_exec_ctx *exec_ctx,
501
488
  (grpc_ssl_channel_security_connector *)sc;
502
489
  // Instantiate TSI handshaker.
503
490
  tsi_handshaker *tsi_hs = NULL;
504
- ssl_create_handshaker(c->handshaker_factory, true /* is_client */,
505
- c->overridden_target_name != NULL
506
- ? c->overridden_target_name
507
- : c->target_name,
508
- &tsi_hs);
491
+ tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker(
492
+ c->handshaker_factory,
493
+ c->overridden_target_name != NULL ? c->overridden_target_name
494
+ : c->target_name,
495
+ &tsi_hs);
496
+ if (result != TSI_OK) {
497
+ gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
498
+ tsi_result_to_string(result));
499
+ return;
500
+ }
501
+
509
502
  // Create handshakers.
510
503
  grpc_handshake_manager_add(handshake_mgr, grpc_security_handshaker_create(
511
504
  exec_ctx, tsi_hs, &sc->base));
@@ -518,8 +511,14 @@ static void ssl_server_add_handshakers(grpc_exec_ctx *exec_ctx,
518
511
  (grpc_ssl_server_security_connector *)sc;
519
512
  // Instantiate TSI handshaker.
520
513
  tsi_handshaker *tsi_hs = NULL;
521
- ssl_create_handshaker(c->handshaker_factory, false /* is_client */,
522
- NULL /* peer_name */, &tsi_hs);
514
+ tsi_result result = tsi_ssl_server_handshaker_factory_create_handshaker(
515
+ c->handshaker_factory, &tsi_hs);
516
+ if (result != TSI_OK) {
517
+ gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
518
+ tsi_result_to_string(result));
519
+ return;
520
+ }
521
+
523
522
  // Create handshakers.
524
523
  grpc_handshake_manager_add(handshake_mgr, grpc_security_handshaker_create(
525
524
  exec_ctx, tsi_hs, &sc->base));
@@ -586,18 +585,19 @@ static grpc_error *ssl_check_peer(grpc_security_connector *sc,
586
585
  const tsi_peer_property *p =
587
586
  tsi_peer_get_property_by_name(peer, TSI_SSL_ALPN_SELECTED_PROTOCOL);
588
587
  if (p == NULL) {
589
- return GRPC_ERROR_CREATE(
588
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
590
589
  "Cannot check peer: missing selected ALPN property.");
591
590
  }
592
591
  if (!grpc_chttp2_is_alpn_version_supported(p->value.data, p->value.length)) {
593
- return GRPC_ERROR_CREATE("Cannot check peer: invalid ALPN value.");
592
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
593
+ "Cannot check peer: invalid ALPN value.");
594
594
  }
595
595
 
596
596
  /* Check the peer name if specified. */
597
597
  if (peer_name != NULL && !ssl_host_matches_name(peer, peer_name)) {
598
598
  char *msg;
599
599
  gpr_asprintf(&msg, "Peer name %s is not in peer certificate", peer_name);
600
- grpc_error *error = GRPC_ERROR_CREATE(msg);
600
+ grpc_error *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
601
601
  gpr_free(msg);
602
602
  return error;
603
603
  }
@@ -39,7 +39,7 @@
39
39
  #include "src/core/lib/channel/handshaker.h"
40
40
  #include "src/core/lib/iomgr/endpoint.h"
41
41
  #include "src/core/lib/iomgr/tcp_server.h"
42
- #include "src/core/lib/tsi/transport_security_interface.h"
42
+ #include "src/core/tsi/transport_security_interface.h"
43
43
 
44
44
  /* --- status enum. --- */
45
45
 
@@ -120,7 +120,7 @@ static void security_handshake_failed_locked(grpc_exec_ctx *exec_ctx,
120
120
  if (error == GRPC_ERROR_NONE) {
121
121
  // If we were shut down after the handshake succeeded but before an
122
122
  // endpoint callback was invoked, we need to generate our own error.
123
- error = GRPC_ERROR_CREATE("Handshaker shutdown");
123
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshaker shutdown");
124
124
  }
125
125
  const char *msg = grpc_error_string(error);
126
126
  gpr_log(GPR_DEBUG, "Security handshake failed: %s", msg);
@@ -156,7 +156,8 @@ static void on_peer_checked(grpc_exec_ctx *exec_ctx, void *arg,
156
156
  tsi_handshaker_create_frame_protector(h->handshaker, NULL, &protector);
157
157
  if (result != TSI_OK) {
158
158
  error = grpc_set_tsi_error_result(
159
- GRPC_ERROR_CREATE("Frame protector creation failed"), result);
159
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Frame protector creation failed"),
160
+ result);
160
161
  security_handshake_failed_locked(exec_ctx, h, error);
161
162
  goto done;
162
163
  }
@@ -191,7 +192,7 @@ static grpc_error *check_peer_locked(grpc_exec_ctx *exec_ctx,
191
192
  tsi_result result = tsi_handshaker_extract_peer(h->handshaker, &peer);
192
193
  if (result != TSI_OK) {
193
194
  return grpc_set_tsi_error_result(
194
- GRPC_ERROR_CREATE("Peer extraction failed"), result);
195
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Peer extraction failed"), result);
195
196
  }
196
197
  grpc_security_connector_check_peer(exec_ctx, h->connector, peer,
197
198
  &h->auth_context, &h->on_peer_checked);
@@ -215,8 +216,8 @@ static grpc_error *send_handshake_bytes_to_peer_locked(grpc_exec_ctx *exec_ctx,
215
216
  }
216
217
  } while (result == TSI_INCOMPLETE_DATA);
217
218
  if (result != TSI_OK) {
218
- return grpc_set_tsi_error_result(GRPC_ERROR_CREATE("Handshake failed"),
219
- result);
219
+ return grpc_set_tsi_error_result(
220
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshake failed"), result);
220
221
  }
221
222
  // Send data.
222
223
  grpc_slice to_send =
@@ -234,8 +235,8 @@ static void on_handshake_data_received_from_peer(grpc_exec_ctx *exec_ctx,
234
235
  gpr_mu_lock(&h->mu);
235
236
  if (error != GRPC_ERROR_NONE || h->shutdown) {
236
237
  security_handshake_failed_locked(
237
- exec_ctx, h,
238
- GRPC_ERROR_CREATE_REFERENCING("Handshake read failed", &error, 1));
238
+ exec_ctx, h, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
239
+ "Handshake read failed", &error, 1));
239
240
  gpr_mu_unlock(&h->mu);
240
241
  security_handshaker_unref(exec_ctx, h);
241
242
  return;
@@ -270,8 +271,9 @@ static void on_handshake_data_received_from_peer(grpc_exec_ctx *exec_ctx,
270
271
  }
271
272
  if (result != TSI_OK) {
272
273
  security_handshake_failed_locked(
273
- exec_ctx, h, grpc_set_tsi_error_result(
274
- GRPC_ERROR_CREATE("Handshake failed"), result));
274
+ exec_ctx, h,
275
+ grpc_set_tsi_error_result(
276
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshake failed"), result));
275
277
  gpr_mu_unlock(&h->mu);
276
278
  security_handshaker_unref(exec_ctx, h);
277
279
  return;
@@ -313,8 +315,8 @@ static void on_handshake_data_sent_to_peer(grpc_exec_ctx *exec_ctx, void *arg,
313
315
  gpr_mu_lock(&h->mu);
314
316
  if (error != GRPC_ERROR_NONE || h->shutdown) {
315
317
  security_handshake_failed_locked(
316
- exec_ctx, h,
317
- GRPC_ERROR_CREATE_REFERENCING("Handshake write failed", &error, 1));
318
+ exec_ctx, h, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
319
+ "Handshake write failed", &error, 1));
318
320
  gpr_mu_unlock(&h->mu);
319
321
  security_handshaker_unref(exec_ctx, h);
320
322
  return;
@@ -428,7 +430,8 @@ static void fail_handshaker_do_handshake(grpc_exec_ctx *exec_ctx,
428
430
  grpc_closure *on_handshake_done,
429
431
  grpc_handshaker_args *args) {
430
432
  grpc_closure_sched(exec_ctx, on_handshake_done,
431
- GRPC_ERROR_CREATE("Failed to create security handshaker"));
433
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING(
434
+ "Failed to create security handshaker"));
432
435
  }
433
436
 
434
437
  static const grpc_handshaker_vtable fail_handshaker_vtable = {
@@ -49,7 +49,7 @@ typedef struct call_data {
49
49
  up-call on transport_op, and remember to call our on_done_recv member after
50
50
  handling it. */
51
51
  grpc_closure auth_on_recv;
52
- grpc_transport_stream_op *transport_op;
52
+ grpc_transport_stream_op_batch *transport_op;
53
53
  grpc_metadata_array md;
54
54
  const grpc_metadata *consumed_md;
55
55
  size_t num_consumed_md;
@@ -138,15 +138,15 @@ static void on_md_processing_done(
138
138
  error_details = error_details != NULL
139
139
  ? error_details
140
140
  : "Authentication metadata processing failed.";
141
- calld->transport_op->send_initial_metadata = NULL;
142
- if (calld->transport_op->send_message != NULL) {
143
- grpc_byte_stream_destroy(&exec_ctx, calld->transport_op->send_message);
144
- calld->transport_op->send_message = NULL;
141
+ if (calld->transport_op->send_message) {
142
+ grpc_byte_stream_destroy(
143
+ &exec_ctx, calld->transport_op->payload->send_message.send_message);
144
+ calld->transport_op->payload->send_message.send_message = NULL;
145
145
  }
146
- calld->transport_op->send_trailing_metadata = NULL;
147
- grpc_closure_sched(&exec_ctx, calld->on_done_recv,
148
- grpc_error_set_int(GRPC_ERROR_CREATE(error_details),
149
- GRPC_ERROR_INT_GRPC_STATUS, status));
146
+ grpc_closure_sched(
147
+ &exec_ctx, calld->on_done_recv,
148
+ grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_details),
149
+ GRPC_ERROR_INT_GRPC_STATUS, status));
150
150
  }
151
151
 
152
152
  grpc_exec_ctx_finish(&exec_ctx);
@@ -158,7 +158,7 @@ static void auth_on_recv(grpc_exec_ctx *exec_ctx, void *user_data,
158
158
  call_data *calld = elem->call_data;
159
159
  channel_data *chand = elem->channel_data;
160
160
  if (error == GRPC_ERROR_NONE) {
161
- if (chand->creds->processor.process != NULL) {
161
+ if (chand->creds != NULL && chand->creds->processor.process != NULL) {
162
162
  calld->md = metadata_batch_to_md_array(calld->recv_initial_metadata);
163
163
  chand->creds->processor.process(
164
164
  chand->creds->processor.state, calld->auth_context,
@@ -170,14 +170,17 @@ static void auth_on_recv(grpc_exec_ctx *exec_ctx, void *user_data,
170
170
  }
171
171
 
172
172
  static void set_recv_ops_md_callbacks(grpc_call_element *elem,
173
- grpc_transport_stream_op *op) {
173
+ grpc_transport_stream_op_batch *op) {
174
174
  call_data *calld = elem->call_data;
175
175
 
176
- if (op->recv_initial_metadata != NULL) {
176
+ if (op->recv_initial_metadata) {
177
177
  /* substitute our callback for the higher callback */
178
- calld->recv_initial_metadata = op->recv_initial_metadata;
179
- calld->on_done_recv = op->recv_initial_metadata_ready;
180
- op->recv_initial_metadata_ready = &calld->auth_on_recv;
178
+ calld->recv_initial_metadata =
179
+ op->payload->recv_initial_metadata.recv_initial_metadata;
180
+ calld->on_done_recv =
181
+ op->payload->recv_initial_metadata.recv_initial_metadata_ready;
182
+ op->payload->recv_initial_metadata.recv_initial_metadata_ready =
183
+ &calld->auth_on_recv;
181
184
  calld->transport_op = op;
182
185
  }
183
186
  }
@@ -189,7 +192,7 @@ static void set_recv_ops_md_callbacks(grpc_call_element *elem,
189
192
  that is being sent or received. */
190
193
  static void auth_start_transport_op(grpc_exec_ctx *exec_ctx,
191
194
  grpc_call_element *elem,
192
- grpc_transport_stream_op *op) {
195
+ grpc_transport_stream_op_batch *op) {
193
196
  set_recv_ops_md_callbacks(elem, op);
194
197
  grpc_call_next_op(exec_ctx, elem, op);
195
198
  }
@@ -227,7 +230,7 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
227
230
  /* Destructor for call_data */
228
231
  static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
229
232
  const grpc_call_final_info *final_info,
230
- void *ignored) {}
233
+ grpc_closure *ignored) {}
231
234
 
232
235
  /* Constructor for channel_data */
233
236
  static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
@@ -242,7 +245,6 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
242
245
 
243
246
  GPR_ASSERT(!args->is_last);
244
247
  GPR_ASSERT(auth_context != NULL);
245
- GPR_ASSERT(creds != NULL);
246
248
 
247
249
  /* initialize members */
248
250
  chand->auth_context =
@@ -34,7 +34,9 @@
34
34
  #include "src/core/lib/security/transport/tsi_error.h"
35
35
 
36
36
  grpc_error *grpc_set_tsi_error_result(grpc_error *error, tsi_result result) {
37
- return grpc_error_set_int(grpc_error_set_str(error, GRPC_ERROR_STR_TSI_ERROR,
38
- tsi_result_to_string(result)),
39
- GRPC_ERROR_INT_TSI_CODE, result);
37
+ return grpc_error_set_int(
38
+ grpc_error_set_str(
39
+ error, GRPC_ERROR_STR_TSI_ERROR,
40
+ grpc_slice_from_static_string(tsi_result_to_string(result))),
41
+ GRPC_ERROR_INT_TSI_CODE, result);
40
42
  }
@@ -35,7 +35,7 @@
35
35
  #define GRPC_CORE_LIB_SECURITY_TRANSPORT_TSI_ERROR_H
36
36
 
37
37
  #include "src/core/lib/iomgr/error.h"
38
- #include "src/core/lib/tsi/transport_security_interface.h"
38
+ #include "src/core/tsi/transport_security_interface.h"
39
39
 
40
40
  grpc_error *grpc_set_tsi_error_result(grpc_error *error, tsi_result result);
41
41
 
@@ -31,7 +31,7 @@
31
31
  *
32
32
  */
33
33
 
34
- #include "src/core/lib/security/util/b64.h"
34
+ #include "src/core/lib/slice/b64.h"
35
35
 
36
36
  #include <stdint.h>
37
37
  #include <string.h>
@@ -71,15 +71,31 @@ static const char base64_url_safe_chars[] =
71
71
 
72
72
  char *grpc_base64_encode(const void *vdata, size_t data_size, int url_safe,
73
73
  int multiline) {
74
- const unsigned char *data = vdata;
75
- const char *base64_chars =
76
- url_safe ? base64_url_safe_chars : base64_url_unsafe_chars;
74
+ size_t result_projected_size =
75
+ grpc_base64_estimate_encoded_size(data_size, url_safe, multiline);
76
+ char *result = gpr_malloc(result_projected_size);
77
+ grpc_base64_encode_core(result, vdata, data_size, url_safe, multiline);
78
+ return result;
79
+ }
80
+
81
+ size_t grpc_base64_estimate_encoded_size(size_t data_size, int url_safe,
82
+ int multiline) {
77
83
  size_t result_projected_size =
78
84
  4 * ((data_size + 3) / 3) +
79
85
  2 * (multiline ? (data_size / (3 * GRPC_BASE64_MULTILINE_NUM_BLOCKS))
80
86
  : 0) +
81
87
  1;
82
- char *result = gpr_malloc(result_projected_size);
88
+ return result_projected_size;
89
+ }
90
+
91
+ void grpc_base64_encode_core(char *result, const void *vdata, size_t data_size,
92
+ int url_safe, int multiline) {
93
+ const unsigned char *data = vdata;
94
+ const char *base64_chars =
95
+ url_safe ? base64_url_safe_chars : base64_url_unsafe_chars;
96
+ const size_t result_projected_size =
97
+ grpc_base64_estimate_encoded_size(data_size, url_safe, multiline);
98
+
83
99
  char *current = result;
84
100
  size_t num_blocks = 0;
85
101
  size_t i = 0;
@@ -119,7 +135,6 @@ char *grpc_base64_encode(const void *vdata, size_t data_size, int url_safe,
119
135
  GPR_ASSERT(current >= result);
120
136
  GPR_ASSERT((uintptr_t)(current - result) < result_projected_size);
121
137
  result[current - result] = '\0';
122
- return result;
123
138
  }
124
139
 
125
140
  grpc_slice grpc_base64_decode(grpc_exec_ctx *exec_ctx, const char *b64,