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
@@ -56,6 +56,7 @@
56
56
 
57
57
  #include "src/core/lib/debug/trace.h"
58
58
  #include "src/core/lib/iomgr/polling_entity.h"
59
+ #include "src/core/lib/support/arena.h"
59
60
  #include "src/core/lib/transport/transport.h"
60
61
 
61
62
  #ifdef __cplusplus
@@ -84,6 +85,7 @@ typedef struct {
84
85
  grpc_slice path;
85
86
  gpr_timespec start_time;
86
87
  gpr_timespec deadline;
88
+ gpr_arena *arena;
87
89
  } grpc_call_element_args;
88
90
 
89
91
  typedef struct {
@@ -110,9 +112,9 @@ typedef struct {
110
112
  typedef struct {
111
113
  /* Called to eg. send/receive data on a call.
112
114
  See grpc_call_next_op on how to call the next element in the stack */
113
- void (*start_transport_stream_op)(grpc_exec_ctx *exec_ctx,
114
- grpc_call_element *elem,
115
- grpc_transport_stream_op *op);
115
+ void (*start_transport_stream_op_batch)(grpc_exec_ctx *exec_ctx,
116
+ grpc_call_element *elem,
117
+ grpc_transport_stream_op_batch *op);
116
118
  /* Called to handle channel level operations - e.g. new calls, or transport
117
119
  closure.
118
120
  See grpc_channel_next_op on how to call the next element in the stack */
@@ -139,12 +141,12 @@ typedef struct {
139
141
  /* Destroy per call data.
140
142
  The filter does not need to do any chaining.
141
143
  The bottom filter of a stack will be passed a non-NULL pointer to
142
- \a and_free_memory that should be passed to gpr_free when destruction
143
- is complete. \a final_info contains data about the completed call, mainly
144
- for reporting purposes. */
144
+ \a then_schedule_closure that should be passed to grpc_closure_sched when
145
+ destruction is complete. \a final_info contains data about the completed
146
+ call, mainly for reporting purposes. */
145
147
  void (*destroy_call_elem)(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
146
148
  const grpc_call_final_info *final_info,
147
- void *and_free_memory);
149
+ grpc_closure *then_schedule_closure);
148
150
 
149
151
  /* sizeof(per channel data) */
150
152
  size_t sizeof_channel_data;
@@ -236,12 +238,11 @@ void grpc_channel_stack_destroy(grpc_exec_ctx *exec_ctx,
236
238
  /* Initialize a call stack given a channel stack. transport_server_data is
237
239
  expected to be NULL on a client, or an opaque transport owned pointer on the
238
240
  server. */
239
- grpc_error *grpc_call_stack_init(
240
- grpc_exec_ctx *exec_ctx, grpc_channel_stack *channel_stack,
241
- int initial_refs, grpc_iomgr_cb_func destroy, void *destroy_arg,
242
- grpc_call_context_element *context, const void *transport_server_data,
243
- grpc_slice path, gpr_timespec start_time, gpr_timespec deadline,
244
- grpc_call_stack *call_stack);
241
+ grpc_error *grpc_call_stack_init(grpc_exec_ctx *exec_ctx,
242
+ grpc_channel_stack *channel_stack,
243
+ int initial_refs, grpc_iomgr_cb_func destroy,
244
+ void *destroy_arg,
245
+ const grpc_call_element_args *elem_args);
245
246
  /* Set a pollset or a pollset_set for a call stack: must occur before the first
246
247
  * op is started */
247
248
  void grpc_call_stack_set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
@@ -271,7 +272,7 @@ void grpc_call_stack_set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
271
272
  /* Destroy a call stack */
272
273
  void grpc_call_stack_destroy(grpc_exec_ctx *exec_ctx, grpc_call_stack *stack,
273
274
  const grpc_call_final_info *final_info,
274
- void *and_free_memory);
275
+ grpc_closure *then_schedule_closure);
275
276
 
276
277
  /* Ignore set pollset{_set} - used by filters if they don't care about pollsets
277
278
  * at all. Does nothing. */
@@ -280,7 +281,7 @@ void grpc_call_stack_ignore_set_pollset_or_pollset_set(
280
281
  grpc_polling_entity *pollent);
281
282
  /* Call the next operation in a call stack */
282
283
  void grpc_call_next_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
283
- grpc_transport_stream_op *op);
284
+ grpc_transport_stream_op_batch *op);
284
285
  /* Call the next operation (depending on call directionality) in a channel
285
286
  stack */
286
287
  void grpc_channel_next_op(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
@@ -299,7 +300,8 @@ grpc_channel_stack *grpc_channel_stack_from_top_element(
299
300
  grpc_call_stack *grpc_call_stack_from_top_element(grpc_call_element *elem);
300
301
 
301
302
  void grpc_call_log_op(char *file, int line, gpr_log_severity severity,
302
- grpc_call_element *elem, grpc_transport_stream_op *op);
303
+ grpc_call_element *elem,
304
+ grpc_transport_stream_op_batch *op);
303
305
 
304
306
  void grpc_call_element_signal_error(grpc_exec_ctx *exec_ctx,
305
307
  grpc_call_element *cur_elem,
@@ -62,7 +62,7 @@ typedef struct call_data {
62
62
  /** If true, contents of \a compression_algorithm are authoritative */
63
63
  int has_compression_algorithm;
64
64
 
65
- grpc_transport_stream_op *send_op;
65
+ grpc_transport_stream_op_batch *send_op;
66
66
  uint32_t send_length;
67
67
  uint32_t send_flags;
68
68
  grpc_slice incoming_slice;
@@ -210,7 +210,8 @@ static void finish_send_message(grpc_exec_ctx *exec_ctx,
210
210
 
211
211
  grpc_slice_buffer_stream_init(&calld->replacement_stream, &calld->slices,
212
212
  calld->send_flags);
213
- calld->send_op->send_message = &calld->replacement_stream.base;
213
+ calld->send_op->payload->send_message.send_message =
214
+ &calld->replacement_stream.base;
214
215
  calld->post_send = calld->send_op->on_complete;
215
216
  calld->send_op->on_complete = &calld->send_done;
216
217
 
@@ -231,9 +232,9 @@ static void got_slice(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) {
231
232
  static void continue_send_message(grpc_exec_ctx *exec_ctx,
232
233
  grpc_call_element *elem) {
233
234
  call_data *calld = elem->call_data;
234
- while (grpc_byte_stream_next(exec_ctx, calld->send_op->send_message,
235
- &calld->incoming_slice, ~(size_t)0,
236
- &calld->got_slice)) {
235
+ while (grpc_byte_stream_next(
236
+ exec_ctx, calld->send_op->payload->send_message.send_message,
237
+ &calld->incoming_slice, ~(size_t)0, &calld->got_slice)) {
237
238
  grpc_slice_buffer_add(&calld->slices, calld->incoming_slice);
238
239
  if (calld->send_length == calld->slices.length) {
239
240
  finish_send_message(exec_ctx, elem);
@@ -242,33 +243,34 @@ static void continue_send_message(grpc_exec_ctx *exec_ctx,
242
243
  }
243
244
  }
244
245
 
245
- static void compress_start_transport_stream_op(grpc_exec_ctx *exec_ctx,
246
- grpc_call_element *elem,
247
- grpc_transport_stream_op *op) {
246
+ static void compress_start_transport_stream_op_batch(
247
+ grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
248
+ grpc_transport_stream_op_batch *op) {
248
249
  call_data *calld = elem->call_data;
249
250
 
250
- GPR_TIMER_BEGIN("compress_start_transport_stream_op", 0);
251
+ GPR_TIMER_BEGIN("compress_start_transport_stream_op_batch", 0);
251
252
 
252
253
  if (op->send_initial_metadata) {
253
254
  grpc_error *error = process_send_initial_metadata(
254
- exec_ctx, elem, op->send_initial_metadata);
255
+ exec_ctx, elem,
256
+ op->payload->send_initial_metadata.send_initial_metadata);
255
257
  if (error != GRPC_ERROR_NONE) {
256
- grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error);
258
+ grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, op, error);
257
259
  return;
258
260
  }
259
261
  }
260
- if (op->send_message != NULL &&
261
- !skip_compression(elem, op->send_message->flags)) {
262
+ if (op->send_message &&
263
+ !skip_compression(elem, op->payload->send_message.send_message->flags)) {
262
264
  calld->send_op = op;
263
- calld->send_length = op->send_message->length;
264
- calld->send_flags = op->send_message->flags;
265
+ calld->send_length = op->payload->send_message.send_message->length;
266
+ calld->send_flags = op->payload->send_message.send_message->flags;
265
267
  continue_send_message(exec_ctx, elem);
266
268
  } else {
267
269
  /* pass control down the stack */
268
270
  grpc_call_next_op(exec_ctx, elem, op);
269
271
  }
270
272
 
271
- GPR_TIMER_END("compress_start_transport_stream_op", 0);
273
+ GPR_TIMER_END("compress_start_transport_stream_op_batch", 0);
272
274
  }
273
275
 
274
276
  /* Constructor for call_data */
@@ -292,7 +294,7 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
292
294
  /* Destructor for call_data */
293
295
  static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
294
296
  const grpc_call_final_info *final_info,
295
- void *ignored) {
297
+ grpc_closure *ignored) {
296
298
  /* grab pointers to our data from the call element */
297
299
  call_data *calld = elem->call_data;
298
300
  grpc_slice_buffer_destroy_internal(exec_ctx, &calld->slices);
@@ -337,7 +339,7 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
337
339
  grpc_channel_element *elem) {}
338
340
 
339
341
  const grpc_channel_filter grpc_compress_filter = {
340
- compress_start_transport_stream_op,
342
+ compress_start_transport_stream_op_batch,
341
343
  grpc_channel_next_op,
342
344
  sizeof(call_data),
343
345
  init_call_elem,
@@ -62,9 +62,9 @@ typedef struct connected_channel_call_data { void *unused; } call_data;
62
62
 
63
63
  /* Intercept a call operation and either push it directly up or translate it
64
64
  into transport stream operations */
65
- static void con_start_transport_stream_op(grpc_exec_ctx *exec_ctx,
66
- grpc_call_element *elem,
67
- grpc_transport_stream_op *op) {
65
+ static void con_start_transport_stream_op_batch(
66
+ grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
67
+ grpc_transport_stream_op_batch *op) {
68
68
  call_data *calld = elem->call_data;
69
69
  channel_data *chand = elem->channel_data;
70
70
  GRPC_CALL_LOG_OP(GPR_INFO, elem, op);
@@ -88,9 +88,10 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
88
88
  channel_data *chand = elem->channel_data;
89
89
  int r = grpc_transport_init_stream(
90
90
  exec_ctx, chand->transport, TRANSPORT_STREAM_FROM_CALL_DATA(calld),
91
- &args->call_stack->refcount, args->server_transport_data);
91
+ &args->call_stack->refcount, args->server_transport_data, args->arena);
92
92
  return r == 0 ? GRPC_ERROR_NONE
93
- : GRPC_ERROR_CREATE("transport stream initialization failed");
93
+ : GRPC_ERROR_CREATE_FROM_STATIC_STRING(
94
+ "transport stream initialization failed");
94
95
  }
95
96
 
96
97
  static void set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
@@ -105,12 +106,12 @@ static void set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
105
106
  /* Destructor for call_data */
106
107
  static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
107
108
  const grpc_call_final_info *final_info,
108
- void *and_free_memory) {
109
+ grpc_closure *then_schedule_closure) {
109
110
  call_data *calld = elem->call_data;
110
111
  channel_data *chand = elem->channel_data;
111
112
  grpc_transport_destroy_stream(exec_ctx, chand->transport,
112
113
  TRANSPORT_STREAM_FROM_CALL_DATA(calld),
113
- and_free_memory);
114
+ then_schedule_closure);
114
115
  }
115
116
 
116
117
  /* Constructor for channel_data */
@@ -141,7 +142,7 @@ static void con_get_channel_info(grpc_exec_ctx *exec_ctx,
141
142
  const grpc_channel_info *channel_info) {}
142
143
 
143
144
  const grpc_channel_filter grpc_connected_filter = {
144
- con_start_transport_stream_op,
145
+ con_start_transport_stream_op_batch,
145
146
  con_start_transport_op,
146
147
  sizeof(call_data),
147
148
  init_call_elem,
@@ -55,9 +55,9 @@ static void timer_callback(grpc_exec_ctx* exec_ctx, void* arg,
55
55
  if (error != GRPC_ERROR_CANCELLED) {
56
56
  grpc_call_element_signal_error(
57
57
  exec_ctx, elem,
58
- grpc_error_set_int(GRPC_ERROR_CREATE("Deadline Exceeded"),
59
- GRPC_ERROR_INT_GRPC_STATUS,
60
- GRPC_STATUS_DEADLINE_EXCEEDED));
58
+ grpc_error_set_int(
59
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Deadline Exceeded"),
60
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_DEADLINE_EXCEEDED));
61
61
  }
62
62
  GRPC_CALL_STACK_UNREF(exec_ctx, deadline_state->call_stack, "deadline_timer");
63
63
  }
@@ -134,7 +134,7 @@ static void on_complete(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
134
134
 
135
135
  // Inject our own on_complete callback into op.
136
136
  static void inject_on_complete_cb(grpc_deadline_state* deadline_state,
137
- grpc_transport_stream_op* op) {
137
+ grpc_transport_stream_op_batch* op) {
138
138
  deadline_state->next_on_complete = op->on_complete;
139
139
  grpc_closure_init(&deadline_state->on_complete, on_complete, deadline_state,
140
140
  grpc_schedule_on_exec_ctx);
@@ -196,16 +196,16 @@ void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
196
196
  start_timer_if_needed(exec_ctx, elem, new_deadline);
197
197
  }
198
198
 
199
- void grpc_deadline_state_client_start_transport_stream_op(
199
+ void grpc_deadline_state_client_start_transport_stream_op_batch(
200
200
  grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
201
- grpc_transport_stream_op* op) {
201
+ grpc_transport_stream_op_batch* op) {
202
202
  grpc_deadline_state* deadline_state = elem->call_data;
203
- if (op->cancel_error != GRPC_ERROR_NONE) {
203
+ if (op->cancel_stream) {
204
204
  cancel_timer_if_needed(exec_ctx, deadline_state);
205
205
  } else {
206
206
  // Make sure we know when the call is complete, so that we can cancel
207
207
  // the timer.
208
- if (op->recv_trailing_metadata != NULL) {
208
+ if (op->recv_trailing_metadata) {
209
209
  inject_on_complete_cb(deadline_state, op);
210
210
  }
211
211
  }
@@ -256,15 +256,16 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
256
256
  // Destructor for call_data. Used for both client and server filters.
257
257
  static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
258
258
  const grpc_call_final_info* final_info,
259
- void* and_free_memory) {
259
+ grpc_closure* ignored) {
260
260
  grpc_deadline_state_destroy(exec_ctx, elem);
261
261
  }
262
262
 
263
263
  // Method for starting a call op for client filter.
264
- static void client_start_transport_stream_op(grpc_exec_ctx* exec_ctx,
265
- grpc_call_element* elem,
266
- grpc_transport_stream_op* op) {
267
- grpc_deadline_state_client_start_transport_stream_op(exec_ctx, elem, op);
264
+ static void client_start_transport_stream_op_batch(
265
+ grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
266
+ grpc_transport_stream_op_batch* op) {
267
+ grpc_deadline_state_client_start_transport_stream_op_batch(exec_ctx, elem,
268
+ op);
268
269
  // Chain to next filter.
269
270
  grpc_call_next_op(exec_ctx, elem, op);
270
271
  }
@@ -282,30 +283,33 @@ static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx, void* arg,
282
283
  }
283
284
 
284
285
  // Method for starting a call op for server filter.
285
- static void server_start_transport_stream_op(grpc_exec_ctx* exec_ctx,
286
- grpc_call_element* elem,
287
- grpc_transport_stream_op* op) {
286
+ static void server_start_transport_stream_op_batch(
287
+ grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
288
+ grpc_transport_stream_op_batch* op) {
288
289
  server_call_data* calld = elem->call_data;
289
- if (op->cancel_error != GRPC_ERROR_NONE) {
290
+ if (op->cancel_stream) {
290
291
  cancel_timer_if_needed(exec_ctx, &calld->base.deadline_state);
291
292
  } else {
292
293
  // If we're receiving initial metadata, we need to get the deadline
293
294
  // from the recv_initial_metadata_ready callback. So we inject our
294
295
  // own callback into that hook.
295
- if (op->recv_initial_metadata_ready != NULL) {
296
- calld->next_recv_initial_metadata_ready = op->recv_initial_metadata_ready;
297
- calld->recv_initial_metadata = op->recv_initial_metadata;
296
+ if (op->recv_initial_metadata) {
297
+ calld->next_recv_initial_metadata_ready =
298
+ op->payload->recv_initial_metadata.recv_initial_metadata_ready;
299
+ calld->recv_initial_metadata =
300
+ op->payload->recv_initial_metadata.recv_initial_metadata;
298
301
  grpc_closure_init(&calld->recv_initial_metadata_ready,
299
302
  recv_initial_metadata_ready, elem,
300
303
  grpc_schedule_on_exec_ctx);
301
- op->recv_initial_metadata_ready = &calld->recv_initial_metadata_ready;
304
+ op->payload->recv_initial_metadata.recv_initial_metadata_ready =
305
+ &calld->recv_initial_metadata_ready;
302
306
  }
303
307
  // Make sure we know when the call is complete, so that we can cancel
304
308
  // the timer.
305
309
  // Note that we trigger this on recv_trailing_metadata, even though
306
310
  // the client never sends trailing metadata, because this is the
307
311
  // hook that tells us when the call is complete on the server side.
308
- if (op->recv_trailing_metadata != NULL) {
312
+ if (op->recv_trailing_metadata) {
309
313
  inject_on_complete_cb(&calld->base.deadline_state, op);
310
314
  }
311
315
  }
@@ -314,7 +318,7 @@ static void server_start_transport_stream_op(grpc_exec_ctx* exec_ctx,
314
318
  }
315
319
 
316
320
  const grpc_channel_filter grpc_client_deadline_filter = {
317
- client_start_transport_stream_op,
321
+ client_start_transport_stream_op_batch,
318
322
  grpc_channel_next_op,
319
323
  sizeof(base_call_data),
320
324
  init_call_elem,
@@ -329,7 +333,7 @@ const grpc_channel_filter grpc_client_deadline_filter = {
329
333
  };
330
334
 
331
335
  const grpc_channel_filter grpc_server_deadline_filter = {
332
- server_start_transport_stream_op,
336
+ server_start_transport_stream_op_batch,
333
337
  grpc_channel_next_op,
334
338
  sizeof(server_call_data),
335
339
  init_call_elem,
@@ -83,15 +83,15 @@ void grpc_deadline_state_start(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
83
83
  void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
84
84
  gpr_timespec new_deadline);
85
85
 
86
- // To be called from the client-side filter's start_transport_stream_op()
86
+ // To be called from the client-side filter's start_transport_stream_op_batch()
87
87
  // method. Ensures that the deadline timer is cancelled when the call
88
88
  // is completed.
89
89
  //
90
90
  // Note: It is the caller's responsibility to chain to the next filter if
91
91
  // necessary after this function returns.
92
- void grpc_deadline_state_client_start_transport_stream_op(
92
+ void grpc_deadline_state_client_start_transport_stream_op_batch(
93
93
  grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
94
- grpc_transport_stream_op* op);
94
+ grpc_transport_stream_op_batch* op);
95
95
 
96
96
  // Deadline filters for direct client channels and server channels.
97
97
  // Note: Deadlines for non-direct client channels are handled by the
@@ -236,8 +236,9 @@ static void call_next_handshaker(grpc_exec_ctx* exec_ctx, void* arg,
236
236
  static void on_timeout(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
237
237
  grpc_handshake_manager* mgr = arg;
238
238
  if (error == GRPC_ERROR_NONE) { // Timer fired, rather than being cancelled.
239
- grpc_handshake_manager_shutdown(exec_ctx, mgr,
240
- GRPC_ERROR_CREATE("Handshake timed out"));
239
+ grpc_handshake_manager_shutdown(
240
+ exec_ctx, mgr,
241
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshake timed out"));
241
242
  }
242
243
  grpc_handshake_manager_unref(exec_ctx, mgr);
243
244
  }
@@ -36,6 +36,7 @@
36
36
  #include <grpc/support/string_util.h>
37
37
  #include <string.h>
38
38
  #include "src/core/lib/profiling/timers.h"
39
+ #include "src/core/lib/slice/b64.h"
39
40
  #include "src/core/lib/slice/percent_encoding.h"
40
41
  #include "src/core/lib/slice/slice_internal.h"
41
42
  #include "src/core/lib/slice/slice_string_helpers.h"
@@ -56,14 +57,13 @@ typedef struct call_data {
56
57
  grpc_linked_mdelem te_trailers;
57
58
  grpc_linked_mdelem content_type;
58
59
  grpc_linked_mdelem user_agent;
59
- grpc_linked_mdelem payload_bin;
60
60
 
61
61
  grpc_metadata_batch *recv_initial_metadata;
62
62
  grpc_metadata_batch *recv_trailing_metadata;
63
63
  uint8_t *payload_bytes;
64
64
 
65
65
  /* Vars to read data off of send_message */
66
- grpc_transport_stream_op send_op;
66
+ grpc_transport_stream_op_batch *send_op;
67
67
  uint32_t send_length;
68
68
  uint32_t send_flags;
69
69
  grpc_slice incoming_slice;
@@ -108,11 +108,11 @@ static grpc_error *client_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
108
108
  grpc_error *e = grpc_error_set_str(
109
109
  grpc_error_set_int(
110
110
  grpc_error_set_str(
111
- GRPC_ERROR_CREATE(
111
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING(
112
112
  "Received http2 :status header with non-200 OK status"),
113
- GRPC_ERROR_STR_VALUE, val),
113
+ GRPC_ERROR_STR_VALUE, grpc_slice_from_copied_string(val)),
114
114
  GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_CANCELLED),
115
- GRPC_ERROR_STR_GRPC_MESSAGE, msg);
115
+ GRPC_ERROR_STR_GRPC_MESSAGE, grpc_slice_from_copied_string(msg));
116
116
  gpr_free(val);
117
117
  gpr_free(msg);
118
118
  return e;
@@ -219,9 +219,9 @@ static void continue_send_message(grpc_exec_ctx *exec_ctx,
219
219
  grpc_call_element *elem) {
220
220
  call_data *calld = elem->call_data;
221
221
  uint8_t *wrptr = calld->payload_bytes;
222
- while (grpc_byte_stream_next(exec_ctx, calld->send_op.send_message,
223
- &calld->incoming_slice, ~(size_t)0,
224
- &calld->got_slice)) {
222
+ while (grpc_byte_stream_next(
223
+ exec_ctx, calld->send_op->payload->send_message.send_message,
224
+ &calld->incoming_slice, ~(size_t)0, &calld->got_slice)) {
225
225
  memcpy(wrptr, GRPC_SLICE_START_PTR(calld->incoming_slice),
226
226
  GRPC_SLICE_LENGTH(calld->incoming_slice));
227
227
  wrptr += GRPC_SLICE_LENGTH(calld->incoming_slice);
@@ -242,10 +242,11 @@ static void got_slice(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) {
242
242
  /* Pass down the original send_message op that was blocked.*/
243
243
  grpc_slice_buffer_stream_init(&calld->replacement_stream, &calld->slices,
244
244
  calld->send_flags);
245
- calld->send_op.send_message = &calld->replacement_stream.base;
246
- calld->post_send = calld->send_op.on_complete;
247
- calld->send_op.on_complete = &calld->send_done;
248
- grpc_call_next_op(exec_ctx, elem, &calld->send_op);
245
+ calld->send_op->payload->send_message.send_message =
246
+ &calld->replacement_stream.base;
247
+ calld->post_send = calld->send_op->on_complete;
248
+ calld->send_op->on_complete = &calld->send_done;
249
+ grpc_call_next_op(exec_ctx, elem, calld->send_op);
249
250
  } else {
250
251
  continue_send_message(exec_ctx, elem);
251
252
  }
@@ -253,29 +254,30 @@ static void got_slice(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) {
253
254
 
254
255
  static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx,
255
256
  grpc_call_element *elem,
256
- grpc_transport_stream_op *op) {
257
+ grpc_transport_stream_op_batch *op) {
257
258
  /* grab pointers to our data from the call element */
258
259
  call_data *calld = elem->call_data;
259
260
  channel_data *channeld = elem->channel_data;
260
261
  grpc_error *error;
261
262
 
262
- if (op->send_initial_metadata != NULL) {
263
+ if (op->send_initial_metadata) {
263
264
  /* Decide which HTTP VERB to use. We use GET if the request is marked
264
265
  cacheable, and the operation contains both initial metadata and send
265
266
  message, and the payload is below the size threshold, and all the data
266
267
  for this request is immediately available. */
267
268
  grpc_mdelem method = GRPC_MDELEM_METHOD_POST;
268
- if ((op->send_initial_metadata_flags &
269
+ if (op->send_message &&
270
+ (op->payload->send_initial_metadata.send_initial_metadata_flags &
269
271
  GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) &&
270
- op->send_message != NULL &&
271
- op->send_message->length < channeld->max_payload_size_for_get) {
272
+ op->payload->send_message.send_message->length <
273
+ channeld->max_payload_size_for_get) {
272
274
  method = GRPC_MDELEM_METHOD_GET;
273
275
  /* The following write to calld->send_message_blocked isn't racy with
274
276
  reads in hc_start_transport_op (which deals with SEND_MESSAGE ops) because
275
277
  being here means ops->send_message is not NULL, which is primarily
276
278
  guarding the read there. */
277
279
  calld->send_message_blocked = true;
278
- } else if (op->send_initial_metadata_flags &
280
+ } else if (op->payload->send_initial_metadata.send_initial_metadata_flags &
279
281
  GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) {
280
282
  method = GRPC_MDELEM_METHOD_PUT;
281
283
  }
@@ -283,28 +285,71 @@ static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx,
283
285
  /* Attempt to read the data from send_message and create a header field. */
284
286
  if (grpc_mdelem_eq(method, GRPC_MDELEM_METHOD_GET)) {
285
287
  /* allocate memory to hold the entire payload */
286
- calld->payload_bytes = gpr_malloc(op->send_message->length);
288
+ calld->payload_bytes =
289
+ gpr_malloc(op->payload->send_message.send_message->length);
287
290
 
288
291
  /* read slices of send_message and copy into payload_bytes */
289
- calld->send_op = *op;
290
- calld->send_length = op->send_message->length;
291
- calld->send_flags = op->send_message->flags;
292
+ calld->send_op = op;
293
+ calld->send_length = op->payload->send_message.send_message->length;
294
+ calld->send_flags = op->payload->send_message.send_message->flags;
292
295
  continue_send_message(exec_ctx, elem);
293
296
 
294
297
  if (calld->send_message_blocked == false) {
295
- /* when all the send_message data is available, then create a MDELEM and
296
- append to headers */
297
- grpc_mdelem payload_bin = grpc_mdelem_from_slices(
298
- exec_ctx, GRPC_MDSTR_GRPC_PAYLOAD_BIN,
299
- grpc_slice_from_copied_buffer((const char *)calld->payload_bytes,
300
- op->send_message->length));
301
- error =
302
- grpc_metadata_batch_add_tail(exec_ctx, op->send_initial_metadata,
303
- &calld->payload_bin, payload_bin);
298
+ /* when all the send_message data is available, then modify the path
299
+ * MDELEM by appending base64 encoded query to the path */
300
+ const int k_url_safe = 1;
301
+ const int k_multi_line = 0;
302
+ const unsigned char k_query_separator = '?';
303
+
304
+ grpc_slice path_slice =
305
+ GRPC_MDVALUE(op->payload->send_initial_metadata
306
+ .send_initial_metadata->idx.named.path->md);
307
+ /* sum up individual component's lengths and allocate enough memory to
308
+ * hold combined path+query */
309
+ size_t estimated_len = GRPC_SLICE_LENGTH(path_slice);
310
+ estimated_len++; /* for the '?' */
311
+ estimated_len += grpc_base64_estimate_encoded_size(
312
+ op->payload->send_message.send_message->length, k_url_safe,
313
+ k_multi_line);
314
+ estimated_len += 1; /* for the trailing 0 */
315
+ grpc_slice path_with_query_slice = grpc_slice_malloc(estimated_len);
316
+
317
+ /* memcopy individual pieces into this slice */
318
+ uint8_t *write_ptr =
319
+ (uint8_t *)GRPC_SLICE_START_PTR(path_with_query_slice);
320
+ uint8_t *original_path = (uint8_t *)GRPC_SLICE_START_PTR(path_slice);
321
+ memcpy(write_ptr, original_path, GRPC_SLICE_LENGTH(path_slice));
322
+ write_ptr += GRPC_SLICE_LENGTH(path_slice);
323
+
324
+ *write_ptr = k_query_separator;
325
+ write_ptr++; /* for the '?' */
326
+
327
+ grpc_base64_encode_core((char *)write_ptr, calld->payload_bytes,
328
+ op->payload->send_message.send_message->length,
329
+ k_url_safe, k_multi_line);
330
+
331
+ /* remove trailing unused memory and add trailing 0 to terminate string
332
+ */
333
+ char *t = (char *)GRPC_SLICE_START_PTR(path_with_query_slice);
334
+ /* safe to use strlen since base64_encode will always add '\0' */
335
+ size_t path_length = strlen(t) + 1;
336
+ *(t + path_length) = '\0';
337
+ path_with_query_slice =
338
+ grpc_slice_sub(path_with_query_slice, 0, path_length);
339
+
340
+ /* substitute previous path with the new path+query */
341
+ grpc_mdelem mdelem_path_and_query = grpc_mdelem_from_slices(
342
+ exec_ctx, GRPC_MDSTR_PATH, path_with_query_slice);
343
+ grpc_metadata_batch *b =
344
+ op->payload->send_initial_metadata.send_initial_metadata;
345
+ error = grpc_metadata_batch_substitute(exec_ctx, b, b->idx.named.path,
346
+ mdelem_path_and_query);
304
347
  if (error != GRPC_ERROR_NONE) return error;
348
+
305
349
  calld->on_complete = op->on_complete;
306
350
  op->on_complete = &calld->hc_on_complete;
307
- op->send_message = NULL;
351
+ op->send_message = false;
352
+ grpc_slice_unref_internal(exec_ctx, path_with_query_slice);
308
353
  } else {
309
354
  /* Not all data is available. Fall back to POST. */
310
355
  gpr_log(GPR_DEBUG,
@@ -314,47 +359,60 @@ static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx,
314
359
  }
315
360
  }
316
361
 
317
- remove_if_present(exec_ctx, op->send_initial_metadata, GRPC_BATCH_METHOD);
318
- remove_if_present(exec_ctx, op->send_initial_metadata, GRPC_BATCH_SCHEME);
319
- remove_if_present(exec_ctx, op->send_initial_metadata, GRPC_BATCH_TE);
320
- remove_if_present(exec_ctx, op->send_initial_metadata,
362
+ remove_if_present(exec_ctx,
363
+ op->payload->send_initial_metadata.send_initial_metadata,
364
+ GRPC_BATCH_METHOD);
365
+ remove_if_present(exec_ctx,
366
+ op->payload->send_initial_metadata.send_initial_metadata,
367
+ GRPC_BATCH_SCHEME);
368
+ remove_if_present(exec_ctx,
369
+ op->payload->send_initial_metadata.send_initial_metadata,
370
+ GRPC_BATCH_TE);
371
+ remove_if_present(exec_ctx,
372
+ op->payload->send_initial_metadata.send_initial_metadata,
321
373
  GRPC_BATCH_CONTENT_TYPE);
322
- remove_if_present(exec_ctx, op->send_initial_metadata,
374
+ remove_if_present(exec_ctx,
375
+ op->payload->send_initial_metadata.send_initial_metadata,
323
376
  GRPC_BATCH_USER_AGENT);
324
377
 
325
378
  /* Send : prefixed headers, which have to be before any application
326
379
  layer headers. */
327
- error = grpc_metadata_batch_add_head(exec_ctx, op->send_initial_metadata,
328
- &calld->method, method);
380
+ error = grpc_metadata_batch_add_head(
381
+ exec_ctx, op->payload->send_initial_metadata.send_initial_metadata,
382
+ &calld->method, method);
329
383
  if (error != GRPC_ERROR_NONE) return error;
330
- error =
331
- grpc_metadata_batch_add_head(exec_ctx, op->send_initial_metadata,
332
- &calld->scheme, channeld->static_scheme);
384
+ error = grpc_metadata_batch_add_head(
385
+ exec_ctx, op->payload->send_initial_metadata.send_initial_metadata,
386
+ &calld->scheme, channeld->static_scheme);
333
387
  if (error != GRPC_ERROR_NONE) return error;
334
- error = grpc_metadata_batch_add_tail(exec_ctx, op->send_initial_metadata,
335
- &calld->te_trailers,
336
- GRPC_MDELEM_TE_TRAILERS);
388
+ error = grpc_metadata_batch_add_tail(
389
+ exec_ctx, op->payload->send_initial_metadata.send_initial_metadata,
390
+ &calld->te_trailers, GRPC_MDELEM_TE_TRAILERS);
337
391
  if (error != GRPC_ERROR_NONE) return error;
338
392
  error = grpc_metadata_batch_add_tail(
339
- exec_ctx, op->send_initial_metadata, &calld->content_type,
340
- GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC);
393
+ exec_ctx, op->payload->send_initial_metadata.send_initial_metadata,
394
+ &calld->content_type, GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC);
341
395
  if (error != GRPC_ERROR_NONE) return error;
342
- error = grpc_metadata_batch_add_tail(exec_ctx, op->send_initial_metadata,
343
- &calld->user_agent,
344
- GRPC_MDELEM_REF(channeld->user_agent));
396
+ error = grpc_metadata_batch_add_tail(
397
+ exec_ctx, op->payload->send_initial_metadata.send_initial_metadata,
398
+ &calld->user_agent, GRPC_MDELEM_REF(channeld->user_agent));
345
399
  if (error != GRPC_ERROR_NONE) return error;
346
400
  }
347
401
 
348
- if (op->recv_initial_metadata != NULL) {
402
+ if (op->recv_initial_metadata) {
349
403
  /* substitute our callback for the higher callback */
350
- calld->recv_initial_metadata = op->recv_initial_metadata;
351
- calld->on_done_recv_initial_metadata = op->recv_initial_metadata_ready;
352
- op->recv_initial_metadata_ready = &calld->hc_on_recv_initial_metadata;
404
+ calld->recv_initial_metadata =
405
+ op->payload->recv_initial_metadata.recv_initial_metadata;
406
+ calld->on_done_recv_initial_metadata =
407
+ op->payload->recv_initial_metadata.recv_initial_metadata_ready;
408
+ op->payload->recv_initial_metadata.recv_initial_metadata_ready =
409
+ &calld->hc_on_recv_initial_metadata;
353
410
  }
354
411
 
355
- if (op->recv_trailing_metadata != NULL) {
412
+ if (op->recv_trailing_metadata) {
356
413
  /* substitute our callback for the higher callback */
357
- calld->recv_trailing_metadata = op->recv_trailing_metadata;
414
+ calld->recv_trailing_metadata =
415
+ op->payload->recv_trailing_metadata.recv_trailing_metadata;
358
416
  calld->on_done_recv_trailing_metadata = op->on_complete;
359
417
  op->on_complete = &calld->hc_on_recv_trailing_metadata;
360
418
  }
@@ -364,17 +422,17 @@ static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx,
364
422
 
365
423
  static void hc_start_transport_op(grpc_exec_ctx *exec_ctx,
366
424
  grpc_call_element *elem,
367
- grpc_transport_stream_op *op) {
425
+ grpc_transport_stream_op_batch *op) {
368
426
  GPR_TIMER_BEGIN("hc_start_transport_op", 0);
369
427
  GRPC_CALL_LOG_OP(GPR_INFO, elem, op);
370
428
  grpc_error *error = hc_mutate_op(exec_ctx, elem, op);
371
429
  if (error != GRPC_ERROR_NONE) {
372
- grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error);
430
+ grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, op, error);
373
431
  } else {
374
432
  call_data *calld = elem->call_data;
375
- if (op->send_message != NULL && calld->send_message_blocked) {
433
+ if (op->send_message && calld->send_message_blocked) {
376
434
  /* Don't forward the op. send_message contains slices that aren't ready
377
- yet. The call will be forwarded by the op_complete of slice read call.
435
+ yet. The call will be forwarded by the op_complete of slice read call.
378
436
  */
379
437
  } else {
380
438
  grpc_call_next_op(exec_ctx, elem, op);
@@ -412,7 +470,7 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
412
470
  /* Destructor for call_data */
413
471
  static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
414
472
  const grpc_call_final_info *final_info,
415
- void *ignored) {
473
+ grpc_closure *ignored) {
416
474
  call_data *calld = elem->call_data;
417
475
  grpc_slice_buffer_destroy_internal(exec_ctx, &calld->slices);
418
476
  }