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
@@ -90,11 +90,18 @@ void grpc_chttp2_hpack_compressor_set_max_table_size(
90
90
  void grpc_chttp2_hpack_compressor_set_max_usable_size(
91
91
  grpc_chttp2_hpack_compressor *c, uint32_t max_table_size);
92
92
 
93
+ typedef struct {
94
+ uint32_t stream_id;
95
+ bool is_eof;
96
+ bool use_true_binary_metadata;
97
+ size_t max_frame_size;
98
+ grpc_transport_one_way_stats *stats;
99
+ } grpc_encode_header_options;
100
+
93
101
  void grpc_chttp2_encode_header(grpc_exec_ctx *exec_ctx,
94
- grpc_chttp2_hpack_compressor *c, uint32_t id,
95
- grpc_metadata_batch *metadata, int is_eof,
96
- size_t max_frame_size,
97
- grpc_transport_one_way_stats *stats,
102
+ grpc_chttp2_hpack_compressor *c,
103
+ grpc_metadata_batch *metadata,
104
+ const grpc_encode_header_options *options,
98
105
  grpc_slice_buffer *outbuf);
99
106
 
100
107
  #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H */
@@ -38,11 +38,6 @@
38
38
  #include <stddef.h>
39
39
  #include <string.h>
40
40
 
41
- /* This is here for grpc_is_binary_header
42
- * TODO(murgatroid99): Remove this
43
- */
44
- #include <grpc/grpc.h>
45
-
46
41
  #include <grpc/support/alloc.h>
47
42
  #include <grpc/support/log.h>
48
43
  #include <grpc/support/port_platform.h>
@@ -55,13 +50,11 @@
55
50
  #include "src/core/lib/support/string.h"
56
51
  #include "src/core/lib/transport/http2_errors.h"
57
52
 
58
- /* TODO(ctiller): remove before submission */
59
- #include "src/core/lib/slice/slice_string_helpers.h"
60
-
61
53
  extern int grpc_http_trace;
62
54
 
63
55
  typedef enum {
64
56
  NOT_BINARY,
57
+ BINARY_BEGIN,
65
58
  B64_BYTE0,
66
59
  B64_BYTE1,
67
60
  B64_BYTE2,
@@ -693,7 +686,7 @@ static grpc_error *on_hdr(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p,
693
686
  }
694
687
  if (p->on_header == NULL) {
695
688
  GRPC_MDELEM_UNREF(exec_ctx, md);
696
- return GRPC_ERROR_CREATE("on_header callback not set");
689
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING("on_header callback not set");
697
690
  }
698
691
  p->on_header(exec_ctx, p->on_header_user_data, md);
699
692
  return GRPC_ERROR_NONE;
@@ -810,7 +803,8 @@ static grpc_error *finish_indexed_field(grpc_exec_ctx *exec_ctx,
810
803
  grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
811
804
  if (GRPC_MDISNULL(md)) {
812
805
  return grpc_error_set_int(
813
- grpc_error_set_int(GRPC_ERROR_CREATE("Invalid HPACK index received"),
806
+ grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
807
+ "Invalid HPACK index received"),
814
808
  GRPC_ERROR_INT_INDEX, (intptr_t)p->index),
815
809
  GRPC_ERROR_INT_SIZE, (intptr_t)p->table.num_ents);
816
810
  }
@@ -1074,7 +1068,7 @@ static grpc_error *parse_max_tbl_size(grpc_exec_ctx *exec_ctx,
1074
1068
  if (p->dynamic_table_update_allowed == 0) {
1075
1069
  return parse_error(
1076
1070
  exec_ctx, p, cur, end,
1077
- GRPC_ERROR_CREATE(
1071
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1078
1072
  "More than two max table size changes in a single frame"));
1079
1073
  }
1080
1074
  p->dynamic_table_update_allowed--;
@@ -1092,7 +1086,7 @@ static grpc_error *parse_max_tbl_size_x(grpc_exec_ctx *exec_ctx,
1092
1086
  if (p->dynamic_table_update_allowed == 0) {
1093
1087
  return parse_error(
1094
1088
  exec_ctx, p, cur, end,
1095
- GRPC_ERROR_CREATE(
1089
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1096
1090
  "More than two max table size changes in a single frame"));
1097
1091
  }
1098
1092
  p->dynamic_table_update_allowed--;
@@ -1126,7 +1120,7 @@ static grpc_error *parse_illegal_op(grpc_exec_ctx *exec_ctx,
1126
1120
  GPR_ASSERT(cur != end);
1127
1121
  char *msg;
1128
1122
  gpr_asprintf(&msg, "Illegal hpack op code %d", *cur);
1129
- grpc_error *err = GRPC_ERROR_CREATE(msg);
1123
+ grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
1130
1124
  gpr_free(msg);
1131
1125
  return parse_error(exec_ctx, p, cur, end, err);
1132
1126
  }
@@ -1246,7 +1240,7 @@ error:
1246
1240
  "integer overflow in hpack integer decoding: have 0x%08x, "
1247
1241
  "got byte 0x%02x on byte 5",
1248
1242
  *p->parsing.value, *cur);
1249
- grpc_error *err = GRPC_ERROR_CREATE(msg);
1243
+ grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
1250
1244
  gpr_free(msg);
1251
1245
  return parse_error(exec_ctx, p, cur, end, err);
1252
1246
  }
@@ -1275,7 +1269,7 @@ static grpc_error *parse_value5up(grpc_exec_ctx *exec_ctx,
1275
1269
  "integer overflow in hpack integer decoding: have 0x%08x, "
1276
1270
  "got byte 0x%02x sometime after byte 5",
1277
1271
  *p->parsing.value, *cur);
1278
- grpc_error *err = GRPC_ERROR_CREATE(msg);
1272
+ grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
1279
1273
  gpr_free(msg);
1280
1274
  return parse_error(exec_ctx, p, cur, end, err);
1281
1275
  }
@@ -1324,6 +1318,19 @@ static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
1324
1318
  case NOT_BINARY:
1325
1319
  append_bytes(str, cur, (size_t)(end - cur));
1326
1320
  return GRPC_ERROR_NONE;
1321
+ case BINARY_BEGIN:
1322
+ if (cur == end) {
1323
+ p->binary = BINARY_BEGIN;
1324
+ return GRPC_ERROR_NONE;
1325
+ }
1326
+ if (*cur == 0) {
1327
+ /* 'true-binary' case */
1328
+ ++cur;
1329
+ p->binary = NOT_BINARY;
1330
+ append_bytes(str, cur, (size_t)(end - cur));
1331
+ return GRPC_ERROR_NONE;
1332
+ }
1333
+ /* fallthrough */
1327
1334
  b64_byte0:
1328
1335
  case B64_BYTE0:
1329
1336
  if (cur == end) {
@@ -1333,8 +1340,9 @@ static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
1333
1340
  bits = inverse_base64[*cur];
1334
1341
  ++cur;
1335
1342
  if (bits == 255)
1336
- return parse_error(exec_ctx, p, cur, end,
1337
- GRPC_ERROR_CREATE("Illegal base64 character"));
1343
+ return parse_error(
1344
+ exec_ctx, p, cur, end,
1345
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
1338
1346
  else if (bits == 64)
1339
1347
  goto b64_byte0;
1340
1348
  p->base64_buffer = bits << 18;
@@ -1348,8 +1356,9 @@ static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
1348
1356
  bits = inverse_base64[*cur];
1349
1357
  ++cur;
1350
1358
  if (bits == 255)
1351
- return parse_error(exec_ctx, p, cur, end,
1352
- GRPC_ERROR_CREATE("Illegal base64 character"));
1359
+ return parse_error(
1360
+ exec_ctx, p, cur, end,
1361
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
1353
1362
  else if (bits == 64)
1354
1363
  goto b64_byte1;
1355
1364
  p->base64_buffer |= bits << 12;
@@ -1363,8 +1372,9 @@ static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
1363
1372
  bits = inverse_base64[*cur];
1364
1373
  ++cur;
1365
1374
  if (bits == 255)
1366
- return parse_error(exec_ctx, p, cur, end,
1367
- GRPC_ERROR_CREATE("Illegal base64 character"));
1375
+ return parse_error(
1376
+ exec_ctx, p, cur, end,
1377
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
1368
1378
  else if (bits == 64)
1369
1379
  goto b64_byte2;
1370
1380
  p->base64_buffer |= bits << 6;
@@ -1378,8 +1388,9 @@ static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
1378
1388
  bits = inverse_base64[*cur];
1379
1389
  ++cur;
1380
1390
  if (bits == 255)
1381
- return parse_error(exec_ctx, p, cur, end,
1382
- GRPC_ERROR_CREATE("Illegal base64 character"));
1391
+ return parse_error(
1392
+ exec_ctx, p, cur, end,
1393
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
1383
1394
  else if (bits == 64)
1384
1395
  goto b64_byte3;
1385
1396
  p->base64_buffer |= bits;
@@ -1391,7 +1402,8 @@ static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
1391
1402
  goto b64_byte0;
1392
1403
  }
1393
1404
  GPR_UNREACHABLE_CODE(return parse_error(
1394
- exec_ctx, p, cur, end, GRPC_ERROR_CREATE("Should never reach here")));
1405
+ exec_ctx, p, cur, end,
1406
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Should never reach here")));
1395
1407
  }
1396
1408
 
1397
1409
  static grpc_error *finish_str(grpc_exec_ctx *exec_ctx,
@@ -1403,19 +1415,21 @@ static grpc_error *finish_str(grpc_exec_ctx *exec_ctx,
1403
1415
  switch ((binary_state)p->binary) {
1404
1416
  case NOT_BINARY:
1405
1417
  break;
1418
+ case BINARY_BEGIN:
1419
+ break;
1406
1420
  case B64_BYTE0:
1407
1421
  break;
1408
1422
  case B64_BYTE1:
1409
- return parse_error(
1410
- exec_ctx, p, cur, end,
1411
- GRPC_ERROR_CREATE("illegal base64 encoding")); /* illegal encoding */
1423
+ return parse_error(exec_ctx, p, cur, end,
1424
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1425
+ "illegal base64 encoding")); /* illegal encoding */
1412
1426
  case B64_BYTE2:
1413
1427
  bits = p->base64_buffer;
1414
1428
  if (bits & 0xffff) {
1415
1429
  char *msg;
1416
1430
  gpr_asprintf(&msg, "trailing bits in base64 encoding: 0x%04x",
1417
1431
  bits & 0xffff);
1418
- grpc_error *err = GRPC_ERROR_CREATE(msg);
1432
+ grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
1419
1433
  gpr_free(msg);
1420
1434
  return parse_error(exec_ctx, p, cur, end, err);
1421
1435
  }
@@ -1428,7 +1442,7 @@ static grpc_error *finish_str(grpc_exec_ctx *exec_ctx,
1428
1442
  char *msg;
1429
1443
  gpr_asprintf(&msg, "trailing bits in base64 encoding: 0x%02x",
1430
1444
  bits & 0xff);
1431
- grpc_error *err = GRPC_ERROR_CREATE(msg);
1445
+ grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
1432
1446
  gpr_free(msg);
1433
1447
  return parse_error(exec_ctx, p, cur, end, err);
1434
1448
  }
@@ -1550,7 +1564,8 @@ static grpc_error *is_binary_indexed_header(grpc_chttp2_hpack_parser *p,
1550
1564
  grpc_mdelem elem = grpc_chttp2_hptbl_lookup(&p->table, p->index);
1551
1565
  if (GRPC_MDISNULL(elem)) {
1552
1566
  return grpc_error_set_int(
1553
- grpc_error_set_int(GRPC_ERROR_CREATE("Invalid HPACK index received"),
1567
+ grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1568
+ "Invalid HPACK index received"),
1554
1569
  GRPC_ERROR_INT_INDEX, (intptr_t)p->index),
1555
1570
  GRPC_ERROR_INT_SIZE, (intptr_t)p->table.num_ents);
1556
1571
  }
@@ -1564,7 +1579,7 @@ static grpc_error *parse_value_string(grpc_exec_ctx *exec_ctx,
1564
1579
  const uint8_t *cur, const uint8_t *end,
1565
1580
  bool is_binary) {
1566
1581
  return begin_parse_string(exec_ctx, p, cur, end,
1567
- is_binary ? B64_BYTE0 : NOT_BINARY, &p->value);
1582
+ is_binary ? BINARY_BEGIN : NOT_BINARY, &p->value);
1568
1583
  }
1569
1584
 
1570
1585
  static grpc_error *parse_value_string_with_indexed_key(
@@ -1620,13 +1635,18 @@ void grpc_chttp2_hpack_parser_destroy(grpc_exec_ctx *exec_ctx,
1620
1635
  grpc_error *grpc_chttp2_hpack_parser_parse(grpc_exec_ctx *exec_ctx,
1621
1636
  grpc_chttp2_hpack_parser *p,
1622
1637
  grpc_slice slice) {
1623
- /* TODO(ctiller): limit the distance of end from beg, and perform multiple
1624
- steps in the event of a large chunk of data to limit
1625
- stack space usage when no tail call optimization is
1626
- available */
1638
+ /* max number of bytes to parse at a time... limits call stack depth on
1639
+ * compilers without TCO */
1640
+ #define MAX_PARSE_LENGTH 1024
1627
1641
  p->current_slice_refcount = slice.refcount;
1628
- grpc_error *error = p->state(exec_ctx, p, GRPC_SLICE_START_PTR(slice),
1629
- GRPC_SLICE_END_PTR(slice));
1642
+ uint8_t *start = GRPC_SLICE_START_PTR(slice);
1643
+ uint8_t *end = GRPC_SLICE_END_PTR(slice);
1644
+ grpc_error *error = GRPC_ERROR_NONE;
1645
+ while (start != end && error == GRPC_ERROR_NONE) {
1646
+ uint8_t *target = start + GPR_MIN(MAX_PARSE_LENGTH, end - start);
1647
+ error = p->state(exec_ctx, p, start, target);
1648
+ start = target;
1649
+ }
1630
1650
  p->current_slice_refcount = NULL;
1631
1651
  return error;
1632
1652
  }
@@ -1670,7 +1690,7 @@ grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx,
1670
1690
  if (is_last) {
1671
1691
  if (parser->is_boundary && parser->state != parse_begin) {
1672
1692
  GPR_TIMER_END("grpc_chttp2_hpack_parser_parse", 0);
1673
- return GRPC_ERROR_CREATE(
1693
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1674
1694
  "end of header frame not aligned with a hpack record boundary");
1675
1695
  }
1676
1696
  /* need to check for null stream: this can occur if we receive an invalid
@@ -1678,7 +1698,8 @@ grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx,
1678
1698
  if (s != NULL) {
1679
1699
  if (parser->is_boundary) {
1680
1700
  if (s->header_frames_received == GPR_ARRAY_SIZE(s->metadata_buffer)) {
1681
- return GRPC_ERROR_CREATE("Too many trailer frames");
1701
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1702
+ "Too many trailer frames");
1682
1703
  }
1683
1704
  s->published_metadata[s->header_frames_received] =
1684
1705
  GRPC_METADATA_PUBLISHED_FROM_WIRE;
@@ -280,7 +280,7 @@ grpc_error *grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx *exec_ctx,
280
280
  gpr_asprintf(&msg,
281
281
  "Attempt to make hpack table %d bytes when max is %d bytes",
282
282
  bytes, tbl->max_bytes);
283
- grpc_error *err = GRPC_ERROR_CREATE(msg);
283
+ grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
284
284
  gpr_free(msg);
285
285
  return err;
286
286
  }
@@ -317,7 +317,7 @@ grpc_error *grpc_chttp2_hptbl_add(grpc_exec_ctx *exec_ctx,
317
317
  "HPACK max table size reduced to %d but not reflected by hpack "
318
318
  "stream (still at %d)",
319
319
  tbl->max_bytes, tbl->current_table_bytes);
320
- grpc_error *err = GRPC_ERROR_CREATE(msg);
320
+ grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
321
321
  gpr_free(msg);
322
322
  return err;
323
323
  }
@@ -0,0 +1,75 @@
1
+ /*
2
+ * Copyright 2017, Google Inc.
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions are
7
+ * met:
8
+ *
9
+ * * Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * * Redistributions in binary form must reproduce the above
12
+ * copyright notice, this list of conditions and the following disclaimer
13
+ * in the documentation and/or other materials provided with the
14
+ * distribution.
15
+ * * Neither the name of Google Inc. nor the names of its
16
+ * contributors may be used to endorse or promote products derived from
17
+ * this software without specific prior written permission.
18
+ *
19
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+ */
31
+
32
+ /*
33
+ * Automatically generated by tools/codegen/core/gen_settings_ids.py
34
+ */
35
+
36
+ #include "src/core/ext/transport/chttp2/transport/http2_settings.h"
37
+
38
+ #include <grpc/support/useful.h>
39
+ #include "src/core/lib/transport/http2_errors.h"
40
+
41
+ const uint16_t grpc_setting_id_to_wire_id[] = {1, 2, 3, 4, 5, 6, 65027};
42
+
43
+ bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id *out) {
44
+ uint32_t i = wire_id - 1;
45
+ uint32_t x = i % 256;
46
+ uint32_t y = i / 256;
47
+ uint32_t h = x;
48
+ switch (y) {
49
+ case 254:
50
+ h += 4;
51
+ break;
52
+ }
53
+ *out = (grpc_chttp2_setting_id)h;
54
+ return h < GPR_ARRAY_SIZE(grpc_setting_id_to_wire_id) &&
55
+ grpc_setting_id_to_wire_id[h] == wire_id;
56
+ }
57
+
58
+ const grpc_chttp2_setting_parameters
59
+ grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS] = {
60
+ {"HEADER_TABLE_SIZE", 4096u, 0u, 4294967295u,
61
+ GRPC_CHTTP2_CLAMP_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR},
62
+ {"ENABLE_PUSH", 1u, 0u, 1u, GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE,
63
+ GRPC_HTTP2_PROTOCOL_ERROR},
64
+ {"MAX_CONCURRENT_STREAMS", 4294967295u, 0u, 4294967295u,
65
+ GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR},
66
+ {"INITIAL_WINDOW_SIZE", 65535u, 0u, 2147483647u,
67
+ GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE,
68
+ GRPC_HTTP2_FLOW_CONTROL_ERROR},
69
+ {"MAX_FRAME_SIZE", 16384u, 16384u, 16777215u,
70
+ GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR},
71
+ {"MAX_HEADER_LIST_SIZE", 16777216u, 0u, 16777216u,
72
+ GRPC_CHTTP2_CLAMP_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR},
73
+ {"GRPC_ALLOW_TRUE_BINARY_METADATA", 0u, 0u, 1u,
74
+ GRPC_CHTTP2_CLAMP_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR},
75
+ };
@@ -0,0 +1,74 @@
1
+ /*
2
+ * Copyright 2017, Google Inc.
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions are
7
+ * met:
8
+ *
9
+ * * Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * * Redistributions in binary form must reproduce the above
12
+ * copyright notice, this list of conditions and the following disclaimer
13
+ * in the documentation and/or other materials provided with the
14
+ * distribution.
15
+ * * Neither the name of Google Inc. nor the names of its
16
+ * contributors may be used to endorse or promote products derived from
17
+ * this software without specific prior written permission.
18
+ *
19
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+ */
31
+
32
+ /*
33
+ * Automatically generated by tools/codegen/core/gen_settings_ids.py
34
+ */
35
+
36
+ #ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H
37
+ #define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H
38
+
39
+ #include <stdbool.h>
40
+ #include <stdint.h>
41
+
42
+ typedef enum {
43
+ GRPC_CHTTP2_SETTINGS_HEADER_TABLE_SIZE = 0, /* wire id 1 */
44
+ GRPC_CHTTP2_SETTINGS_ENABLE_PUSH = 1, /* wire id 2 */
45
+ GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS = 2, /* wire id 3 */
46
+ GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE = 3, /* wire id 4 */
47
+ GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE = 4, /* wire id 5 */
48
+ GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE = 5, /* wire id 6 */
49
+ GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA = 6, /* wire id 65027 */
50
+ } grpc_chttp2_setting_id;
51
+
52
+ #define GRPC_CHTTP2_NUM_SETTINGS 7
53
+ extern const uint16_t grpc_setting_id_to_wire_id[];
54
+
55
+ bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id *out);
56
+
57
+ typedef enum {
58
+ GRPC_CHTTP2_CLAMP_INVALID_VALUE,
59
+ GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE
60
+ } grpc_chttp2_invalid_value_behavior;
61
+
62
+ typedef struct {
63
+ const char *name;
64
+ uint32_t default_value;
65
+ uint32_t min_value;
66
+ uint32_t max_value;
67
+ grpc_chttp2_invalid_value_behavior invalid_value_behavior;
68
+ uint32_t error_value;
69
+ } grpc_chttp2_setting_parameters;
70
+
71
+ extern const grpc_chttp2_setting_parameters
72
+ grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS];
73
+
74
+ #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H */
@@ -41,69 +41,48 @@
41
41
  #include <grpc/support/log.h>
42
42
 
43
43
  void grpc_chttp2_incoming_metadata_buffer_init(
44
- grpc_chttp2_incoming_metadata_buffer *buffer) {
45
- buffer->deadline = gpr_inf_future(GPR_CLOCK_REALTIME);
44
+ grpc_chttp2_incoming_metadata_buffer *buffer, gpr_arena *arena) {
45
+ buffer->arena = arena;
46
+ grpc_metadata_batch_init(&buffer->batch);
47
+ buffer->batch.deadline = gpr_inf_future(GPR_CLOCK_REALTIME);
46
48
  }
47
49
 
48
50
  void grpc_chttp2_incoming_metadata_buffer_destroy(
49
51
  grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer) {
50
- size_t i;
51
- if (!buffer->published) {
52
- for (i = 0; i < buffer->count; i++) {
53
- GRPC_MDELEM_UNREF(exec_ctx, buffer->elems[i].md);
54
- }
55
- }
56
- gpr_free(buffer->elems);
52
+ grpc_metadata_batch_destroy(exec_ctx, &buffer->batch);
57
53
  }
58
54
 
59
- void grpc_chttp2_incoming_metadata_buffer_add(
60
- grpc_chttp2_incoming_metadata_buffer *buffer, grpc_mdelem elem) {
61
- GPR_ASSERT(!buffer->published);
62
- if (buffer->capacity == buffer->count) {
63
- buffer->capacity = GPR_MAX(8, 2 * buffer->capacity);
64
- buffer->elems =
65
- gpr_realloc(buffer->elems, sizeof(*buffer->elems) * buffer->capacity);
66
- }
67
- buffer->elems[buffer->count++].md = elem;
55
+ grpc_error *grpc_chttp2_incoming_metadata_buffer_add(
56
+ grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer,
57
+ grpc_mdelem elem) {
68
58
  buffer->size += GRPC_MDELEM_LENGTH(elem);
59
+ return grpc_metadata_batch_add_tail(
60
+ exec_ctx, &buffer->batch,
61
+ gpr_arena_alloc(buffer->arena, sizeof(grpc_linked_mdelem)), elem);
69
62
  }
70
63
 
71
- void grpc_chttp2_incoming_metadata_buffer_replace_or_add(
64
+ grpc_error *grpc_chttp2_incoming_metadata_buffer_replace_or_add(
72
65
  grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer,
73
66
  grpc_mdelem elem) {
74
- for (size_t i = 0; i < buffer->count; i++) {
75
- if (grpc_slice_eq(GRPC_MDKEY(buffer->elems[i].md), GRPC_MDKEY(elem))) {
76
- GRPC_MDELEM_UNREF(exec_ctx, buffer->elems[i].md);
77
- buffer->elems[i].md = elem;
78
- return;
67
+ for (grpc_linked_mdelem *l = buffer->batch.list.head; l != NULL;
68
+ l = l->next) {
69
+ if (grpc_slice_eq(GRPC_MDKEY(l->md), GRPC_MDKEY(elem))) {
70
+ GRPC_MDELEM_UNREF(exec_ctx, l->md);
71
+ l->md = elem;
72
+ return GRPC_ERROR_NONE;
79
73
  }
80
74
  }
81
- grpc_chttp2_incoming_metadata_buffer_add(buffer, elem);
75
+ return grpc_chttp2_incoming_metadata_buffer_add(exec_ctx, buffer, elem);
82
76
  }
83
77
 
84
78
  void grpc_chttp2_incoming_metadata_buffer_set_deadline(
85
79
  grpc_chttp2_incoming_metadata_buffer *buffer, gpr_timespec deadline) {
86
- GPR_ASSERT(!buffer->published);
87
- buffer->deadline = deadline;
80
+ buffer->batch.deadline = deadline;
88
81
  }
89
82
 
90
83
  void grpc_chttp2_incoming_metadata_buffer_publish(
91
84
  grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer,
92
85
  grpc_metadata_batch *batch) {
93
- GPR_ASSERT(!buffer->published);
94
- buffer->published = 1;
95
- if (buffer->count > 0) {
96
- size_t i;
97
- for (i = 0; i < buffer->count; i++) {
98
- /* TODO(ctiller): do something better here */
99
- if (!GRPC_LOG_IF_ERROR("grpc_chttp2_incoming_metadata_buffer_publish",
100
- grpc_metadata_batch_link_tail(
101
- exec_ctx, batch, &buffer->elems[i]))) {
102
- GRPC_MDELEM_UNREF(exec_ctx, buffer->elems[i].md);
103
- }
104
- }
105
- } else {
106
- batch->list.head = batch->list.tail = NULL;
107
- }
108
- batch->deadline = buffer->deadline;
86
+ *batch = buffer->batch;
87
+ grpc_metadata_batch_init(&buffer->batch);
109
88
  }