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
@@ -68,6 +68,8 @@ struct grpc_channel {
68
68
  grpc_compression_options compression_options;
69
69
  grpc_mdelem default_authority;
70
70
 
71
+ gpr_atm call_size_estimate;
72
+
71
73
  gpr_mu registered_call_mu;
72
74
  registered_call *registered_calls;
73
75
 
@@ -83,19 +85,10 @@ struct grpc_channel {
83
85
  static void destroy_channel(grpc_exec_ctx *exec_ctx, void *arg,
84
86
  grpc_error *error);
85
87
 
86
- grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target,
87
- const grpc_channel_args *input_args,
88
- grpc_channel_stack_type channel_stack_type,
89
- grpc_transport *optional_transport) {
90
- grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create();
91
- grpc_channel_stack_builder_set_channel_arguments(exec_ctx, builder,
92
- input_args);
93
- grpc_channel_stack_builder_set_target(builder, target);
94
- grpc_channel_stack_builder_set_transport(builder, optional_transport);
95
- if (!grpc_channel_init_create_stack(exec_ctx, builder, channel_stack_type)) {
96
- grpc_channel_stack_builder_destroy(exec_ctx, builder);
97
- return NULL;
98
- }
88
+ grpc_channel *grpc_channel_create_with_builder(
89
+ grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder,
90
+ grpc_channel_stack_type channel_stack_type) {
91
+ char *target = gpr_strdup(grpc_channel_stack_builder_get_target(builder));
99
92
  grpc_channel_args *args = grpc_channel_args_copy(
100
93
  grpc_channel_stack_builder_get_channel_arguments(builder));
101
94
  grpc_channel *channel;
@@ -106,15 +99,20 @@ grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target,
106
99
  gpr_log(GPR_ERROR, "channel stack builder failed: %s",
107
100
  grpc_error_string(error));
108
101
  GRPC_ERROR_UNREF(error);
102
+ gpr_free(target);
109
103
  goto done;
110
104
  }
111
105
 
112
106
  memset(channel, 0, sizeof(*channel));
113
- channel->target = gpr_strdup(target);
107
+ channel->target = target;
114
108
  channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type);
115
109
  gpr_mu_init(&channel->registered_call_mu);
116
110
  channel->registered_calls = NULL;
117
111
 
112
+ gpr_atm_no_barrier_store(
113
+ &channel->call_size_estimate,
114
+ (gpr_atm)CHANNEL_STACK_FROM_CHANNEL(channel)->call_stack_size);
115
+
118
116
  grpc_compression_options_init(&channel->compression_options);
119
117
  for (size_t i = 0; i < args->num_args; i++) {
120
118
  if (0 == strcmp(args->args[i].key, GRPC_ARG_DEFAULT_AUTHORITY)) {
@@ -152,17 +150,20 @@ grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target,
152
150
  } else if (0 == strcmp(args->args[i].key,
153
151
  GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL)) {
154
152
  channel->compression_options.default_level.is_set = true;
155
- GPR_ASSERT(args->args[i].value.integer >= 0 &&
156
- args->args[i].value.integer < GRPC_COMPRESS_LEVEL_COUNT);
157
153
  channel->compression_options.default_level.level =
158
- (grpc_compression_level)args->args[i].value.integer;
154
+ (grpc_compression_level)grpc_channel_arg_get_integer(
155
+ &args->args[i],
156
+ (grpc_integer_options){GRPC_COMPRESS_LEVEL_NONE,
157
+ GRPC_COMPRESS_LEVEL_NONE,
158
+ GRPC_COMPRESS_LEVEL_COUNT - 1});
159
159
  } else if (0 == strcmp(args->args[i].key,
160
160
  GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM)) {
161
161
  channel->compression_options.default_algorithm.is_set = true;
162
- GPR_ASSERT(args->args[i].value.integer >= 0 &&
163
- args->args[i].value.integer < GRPC_COMPRESS_ALGORITHMS_COUNT);
164
162
  channel->compression_options.default_algorithm.algorithm =
165
- (grpc_compression_algorithm)args->args[i].value.integer;
163
+ (grpc_compression_algorithm)grpc_channel_arg_get_integer(
164
+ &args->args[i],
165
+ (grpc_integer_options){GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE,
166
+ GRPC_COMPRESS_ALGORITHMS_COUNT - 1});
166
167
  } else if (0 ==
167
168
  strcmp(args->args[i].key,
168
169
  GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET)) {
@@ -177,6 +178,55 @@ done:
177
178
  return channel;
178
179
  }
179
180
 
181
+ grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target,
182
+ const grpc_channel_args *input_args,
183
+ grpc_channel_stack_type channel_stack_type,
184
+ grpc_transport *optional_transport) {
185
+ grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create();
186
+ grpc_channel_stack_builder_set_channel_arguments(exec_ctx, builder,
187
+ input_args);
188
+ grpc_channel_stack_builder_set_target(builder, target);
189
+ grpc_channel_stack_builder_set_transport(builder, optional_transport);
190
+ if (!grpc_channel_init_create_stack(exec_ctx, builder, channel_stack_type)) {
191
+ grpc_channel_stack_builder_destroy(exec_ctx, builder);
192
+ return NULL;
193
+ }
194
+ return grpc_channel_create_with_builder(exec_ctx, builder,
195
+ channel_stack_type);
196
+ }
197
+
198
+ size_t grpc_channel_get_call_size_estimate(grpc_channel *channel) {
199
+ #define ROUND_UP_SIZE 256
200
+ /* We round up our current estimate to the NEXT value of ROUND_UP_SIZE.
201
+ This ensures:
202
+ 1. a consistent size allocation when our estimate is drifting slowly
203
+ (which is common) - which tends to help most allocators reuse memory
204
+ 2. a small amount of allowed growth over the estimate without hitting
205
+ the arena size doubling case, reducing overall memory usage */
206
+ return ((size_t)gpr_atm_no_barrier_load(&channel->call_size_estimate) +
207
+ 2 * ROUND_UP_SIZE) &
208
+ ~(size_t)(ROUND_UP_SIZE - 1);
209
+ }
210
+
211
+ void grpc_channel_update_call_size_estimate(grpc_channel *channel,
212
+ size_t size) {
213
+ size_t cur = (size_t)gpr_atm_no_barrier_load(&channel->call_size_estimate);
214
+ if (cur < size) {
215
+ /* size grew: update estimate */
216
+ gpr_atm_no_barrier_cas(&channel->call_size_estimate, (gpr_atm)cur,
217
+ (gpr_atm)size);
218
+ /* if we lose: never mind, something else will likely update soon enough */
219
+ } else if (cur == size) {
220
+ /* no change: holding pattern */
221
+ } else if (cur > 0) {
222
+ /* size shrank: decrease estimate */
223
+ gpr_atm_no_barrier_cas(
224
+ &channel->call_size_estimate, (gpr_atm)cur,
225
+ (gpr_atm)(GPR_MIN(cur - 1, (255 * cur + size) / 256)));
226
+ /* if we lose: never mind, something else will likely update soon enough */
227
+ }
228
+ }
229
+
180
230
  char *grpc_channel_get_target(grpc_channel *channel) {
181
231
  GRPC_API_TRACE("grpc_channel_get_target(channel=%p)", 1, (channel));
182
232
  return gpr_strdup(channel->target);
@@ -348,7 +398,8 @@ void grpc_channel_destroy(grpc_channel *channel) {
348
398
  grpc_channel_element *elem;
349
399
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
350
400
  GRPC_API_TRACE("grpc_channel_destroy(channel=%p)", 1, (channel));
351
- op->disconnect_with_error = GRPC_ERROR_CREATE("Channel Destroyed");
401
+ op->disconnect_with_error =
402
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Destroyed");
352
403
  elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CHANNEL(channel), 0);
353
404
  elem->filter->start_transport_op(&exec_ctx, elem, op);
354
405
 
@@ -35,6 +35,7 @@
35
35
  #define GRPC_CORE_LIB_SURFACE_CHANNEL_H
36
36
 
37
37
  #include "src/core/lib/channel/channel_stack.h"
38
+ #include "src/core/lib/channel/channel_stack_builder.h"
38
39
  #include "src/core/lib/surface/channel_stack_type.h"
39
40
 
40
41
  grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target,
@@ -42,6 +43,10 @@ grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target,
42
43
  grpc_channel_stack_type channel_stack_type,
43
44
  grpc_transport *optional_transport);
44
45
 
46
+ grpc_channel *grpc_channel_create_with_builder(
47
+ grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder,
48
+ grpc_channel_stack_type channel_stack_type);
49
+
45
50
  /** Create a call given a grpc_channel, in order to call \a method.
46
51
  Progress is tied to activity on \a pollset_set. The returned call object is
47
52
  meant to be used with \a grpc_call_start_batch_and_execute, which relies on
@@ -66,6 +71,9 @@ grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_exec_ctx *exec_ctx,
66
71
  grpc_channel *channel,
67
72
  int status_code);
68
73
 
74
+ size_t grpc_channel_get_call_size_estimate(grpc_channel *channel);
75
+ void grpc_channel_update_call_size_estimate(grpc_channel *channel, size_t size);
76
+
69
77
  #ifdef GRPC_STREAM_REFCOUNT_DEBUG
70
78
  void grpc_channel_internal_ref(grpc_channel *channel, const char *reason);
71
79
  void grpc_channel_internal_unref(grpc_exec_ctx *exec_ctx, grpc_channel *channel,
@@ -345,7 +345,6 @@ static void dump_pending_tags(grpc_completion_queue *cc) {}
345
345
  grpc_event grpc_completion_queue_next(grpc_completion_queue *cc,
346
346
  gpr_timespec deadline, void *reserved) {
347
347
  grpc_event ret;
348
- grpc_pollset_worker *worker = NULL;
349
348
  gpr_timespec now;
350
349
 
351
350
  GPR_TIMER_BEGIN("grpc_completion_queue_next", 0);
@@ -426,8 +425,8 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc,
426
425
  gpr_mu_lock(cc->mu);
427
426
  continue;
428
427
  } else {
429
- grpc_error *err = grpc_pollset_work(&exec_ctx, POLLSET_FROM_CQ(cc),
430
- &worker, now, iteration_deadline);
428
+ grpc_error *err = grpc_pollset_work(&exec_ctx, POLLSET_FROM_CQ(cc), NULL,
429
+ now, iteration_deadline);
431
430
  if (err != GRPC_ERROR_NONE) {
432
431
  gpr_mu_unlock(cc->mu);
433
432
  const char *msg = grpc_error_string(err);
@@ -0,0 +1,77 @@
1
+ /*
2
+ *
3
+ * Copyright 2017, Google Inc.
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are
8
+ * met:
9
+ *
10
+ * * Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * * Redistributions in binary form must reproduce the above
13
+ * copyright notice, this list of conditions and the following disclaimer
14
+ * in the documentation and/or other materials provided with the
15
+ * distribution.
16
+ * * Neither the name of Google Inc. nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ */
33
+
34
+ #include "src/core/lib/surface/completion_queue_factory.h"
35
+ #include "src/core/lib/surface/completion_queue.h"
36
+
37
+ #include <grpc/support/log.h>
38
+
39
+ /* TODO (sreek) - Currently this does not use the attributes arg. This will be
40
+ added in a future PR */
41
+ static grpc_completion_queue* default_create(
42
+ const grpc_completion_queue_factory* factory,
43
+ const grpc_completion_queue_attributes* attributes) {
44
+ return grpc_completion_queue_create(NULL);
45
+ }
46
+
47
+ static grpc_completion_queue_factory_vtable default_vtable = {default_create};
48
+
49
+ static const grpc_completion_queue_factory g_default_cq_factory = {
50
+ "Default Factory", NULL, &default_vtable};
51
+
52
+ const grpc_completion_queue_factory* grpc_completion_queue_factory_lookup(
53
+ const grpc_completion_queue_attributes* attributes) {
54
+ /* As we add more fields to grpc_completion_queue_attributes, we may have to
55
+ change this assert to:
56
+ GPR_ASSERT (attributes->version >= 1 &&
57
+ attributes->version <= GRPC_CQ_CURRENT_VERSION) */
58
+ GPR_ASSERT(attributes->version == 1);
59
+
60
+ /* The default factory can handle version 1 of the attributes structure. We
61
+ may have to change this as more fields are added to the structure */
62
+ return &g_default_cq_factory;
63
+ }
64
+
65
+ grpc_completion_queue* grpc_completion_queue_create_for_next(void* reserved) {
66
+ GPR_ASSERT(!reserved);
67
+ grpc_completion_queue_attributes attr = {1, GRPC_CQ_NEXT,
68
+ GRPC_CQ_DEFAULT_POLLING};
69
+ return g_default_cq_factory.vtable->create(&g_default_cq_factory, &attr);
70
+ }
71
+
72
+ grpc_completion_queue* grpc_completion_queue_create_for_pluck(void* reserved) {
73
+ GPR_ASSERT(!reserved);
74
+ grpc_completion_queue_attributes attr = {1, GRPC_CQ_PLUCK,
75
+ GRPC_CQ_DEFAULT_POLLING};
76
+ return g_default_cq_factory.vtable->create(&g_default_cq_factory, &attr);
77
+ }
@@ -0,0 +1,51 @@
1
+ /*
2
+ *
3
+ * Copyright 2017, Google Inc.
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are
8
+ * met:
9
+ *
10
+ * * Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * * Redistributions in binary form must reproduce the above
13
+ * copyright notice, this list of conditions and the following disclaimer
14
+ * in the documentation and/or other materials provided with the
15
+ * distribution.
16
+ * * Neither the name of Google Inc. nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ */
33
+
34
+ #ifndef GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_FACTORY_H
35
+ #define GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_FACTORY_H
36
+
37
+ #include <grpc/grpc.h>
38
+ #include "src/core/lib/surface/completion_queue.h"
39
+
40
+ typedef struct grpc_completion_queue_factory_vtable {
41
+ grpc_completion_queue* (*create)(const grpc_completion_queue_factory*,
42
+ const grpc_completion_queue_attributes*);
43
+ } grpc_completion_queue_factory_vtable;
44
+
45
+ struct grpc_completion_queue_factory {
46
+ const char* name;
47
+ void* data; /* Factory specific data */
48
+ grpc_completion_queue_factory_vtable* vtable;
49
+ };
50
+
51
+ #endif /* GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_FACTORY_H */
@@ -31,6 +31,8 @@
31
31
  *
32
32
  */
33
33
 
34
+ #include <grpc/support/port_platform.h>
35
+
34
36
  #include "src/core/lib/surface/init.h"
35
37
 
36
38
  #include <limits.h>
@@ -43,7 +45,7 @@
43
45
  #include "src/core/lib/security/transport/security_connector.h"
44
46
  #include "src/core/lib/security/transport/security_handshaker.h"
45
47
  #include "src/core/lib/surface/channel_init.h"
46
- #include "src/core/lib/tsi/transport_security_interface.h"
48
+ #include "src/core/tsi/transport_security_interface.h"
47
49
 
48
50
  void grpc_security_pre_init(void) {
49
51
  grpc_register_tracer("secure_endpoint", &grpc_trace_secure_endpoint);
@@ -80,17 +80,20 @@ static void fill_metadata(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
80
80
  mdb->deadline = gpr_inf_future(GPR_CLOCK_REALTIME);
81
81
  }
82
82
 
83
- static void lame_start_transport_stream_op(grpc_exec_ctx *exec_ctx,
84
- grpc_call_element *elem,
85
- grpc_transport_stream_op *op) {
83
+ static void lame_start_transport_stream_op_batch(
84
+ grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
85
+ grpc_transport_stream_op_batch *op) {
86
86
  GRPC_CALL_LOG_OP(GPR_INFO, elem, op);
87
- if (op->recv_initial_metadata != NULL) {
88
- fill_metadata(exec_ctx, elem, op->recv_initial_metadata);
89
- } else if (op->recv_trailing_metadata != NULL) {
90
- fill_metadata(exec_ctx, elem, op->recv_trailing_metadata);
87
+ if (op->recv_initial_metadata) {
88
+ fill_metadata(exec_ctx, elem,
89
+ op->payload->recv_initial_metadata.recv_initial_metadata);
90
+ } else if (op->recv_trailing_metadata) {
91
+ fill_metadata(exec_ctx, elem,
92
+ op->payload->recv_trailing_metadata.recv_trailing_metadata);
91
93
  }
92
- grpc_transport_stream_op_finish_with_failure(
93
- exec_ctx, op, GRPC_ERROR_CREATE("lame client channel"));
94
+ grpc_transport_stream_op_batch_finish_with_failure(
95
+ exec_ctx, op,
96
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("lame client channel"));
94
97
  }
95
98
 
96
99
  static char *lame_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
@@ -111,8 +114,9 @@ static void lame_start_transport_op(grpc_exec_ctx *exec_ctx,
111
114
  GRPC_ERROR_NONE);
112
115
  }
113
116
  if (op->send_ping != NULL) {
114
- grpc_closure_sched(exec_ctx, op->send_ping,
115
- GRPC_ERROR_CREATE("lame client channel"));
117
+ grpc_closure_sched(
118
+ exec_ctx, op->send_ping,
119
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("lame client channel"));
116
120
  }
117
121
  GRPC_ERROR_UNREF(op->disconnect_with_error);
118
122
  if (op->on_consumed != NULL) {
@@ -130,8 +134,8 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
130
134
 
131
135
  static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
132
136
  const grpc_call_final_info *final_info,
133
- void *and_free_memory) {
134
- gpr_free(and_free_memory);
137
+ grpc_closure *then_schedule_closure) {
138
+ grpc_closure_sched(exec_ctx, then_schedule_closure, GRPC_ERROR_NONE);
135
139
  }
136
140
 
137
141
  static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
@@ -146,7 +150,7 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
146
150
  grpc_channel_element *elem) {}
147
151
 
148
152
  const grpc_channel_filter grpc_lame_filter = {
149
- lame_start_transport_stream_op,
153
+ lame_start_transport_stream_op_batch,
150
154
  lame_start_transport_op,
151
155
  sizeof(call_data),
152
156
  init_call_elem,
@@ -154,8 +154,7 @@ struct call_data {
154
154
  grpc_completion_queue *cq_new;
155
155
 
156
156
  grpc_metadata_batch *recv_initial_metadata;
157
- bool recv_idempotent_request;
158
- bool recv_cacheable_request;
157
+ uint32_t recv_initial_metadata_flags;
159
158
  grpc_metadata_array initial_metadata;
160
159
 
161
160
  request_matcher *request_matcher;
@@ -288,10 +287,10 @@ static void send_shutdown(grpc_exec_ctx *exec_ctx, grpc_channel *channel,
288
287
  grpc_channel_element *elem;
289
288
 
290
289
  op->goaway_error =
291
- send_goaway
292
- ? grpc_error_set_int(GRPC_ERROR_CREATE("Server shutdown"),
293
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_OK)
294
- : GRPC_ERROR_NONE;
290
+ send_goaway ? grpc_error_set_int(
291
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server shutdown"),
292
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_OK)
293
+ : GRPC_ERROR_NONE;
295
294
  op->set_accept_stream = true;
296
295
  sc->slice = grpc_slice_from_copied_string("Server shutdown");
297
296
  op->disconnect_with_error = send_disconnect;
@@ -498,13 +497,7 @@ static void publish_call(grpc_exec_ctx *exec_ctx, grpc_server *server,
498
497
  rc->data.batch.details->host = grpc_slice_ref_internal(calld->host);
499
498
  rc->data.batch.details->method = grpc_slice_ref_internal(calld->path);
500
499
  rc->data.batch.details->deadline = calld->deadline;
501
- rc->data.batch.details->flags =
502
- (calld->recv_idempotent_request
503
- ? GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST
504
- : 0) |
505
- (calld->recv_cacheable_request
506
- ? GRPC_INITIAL_METADATA_CACHEABLE_REQUEST
507
- : 0);
500
+ rc->data.batch.details->flags = calld->recv_initial_metadata_flags;
508
501
  break;
509
502
  case REGISTERED_CALL:
510
503
  *rc->data.registered.deadline = calld->deadline;
@@ -632,7 +625,8 @@ static void start_new_rpc(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
632
625
  if (!grpc_slice_eq(rm->host, calld->host)) continue;
633
626
  if (!grpc_slice_eq(rm->method, calld->path)) continue;
634
627
  if ((rm->flags & GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) &&
635
- !calld->recv_idempotent_request) {
628
+ 0 == (calld->recv_initial_metadata_flags &
629
+ GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST)) {
636
630
  continue;
637
631
  }
638
632
  finish_start_new_rpc(exec_ctx, server, elem,
@@ -649,7 +643,8 @@ static void start_new_rpc(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
649
643
  if (rm->has_host) continue;
650
644
  if (!grpc_slice_eq(rm->method, calld->path)) continue;
651
645
  if ((rm->flags & GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) &&
652
- !calld->recv_idempotent_request) {
646
+ 0 == (calld->recv_initial_metadata_flags &
647
+ GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST)) {
653
648
  continue;
654
649
  }
655
650
  finish_start_new_rpc(exec_ctx, server, elem,
@@ -712,8 +707,9 @@ static void maybe_finish_shutdown(grpc_exec_ctx *exec_ctx,
712
707
  return;
713
708
  }
714
709
 
715
- kill_pending_work_locked(exec_ctx, server,
716
- GRPC_ERROR_CREATE("Server Shutdown"));
710
+ kill_pending_work_locked(
711
+ exec_ctx, server,
712
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
717
713
 
718
714
  if (server->root_channel_data.next != &server->root_channel_data ||
719
715
  server->listeners_destroyed < num_listeners(server)) {
@@ -771,8 +767,8 @@ static void server_on_recv_initial_metadata(grpc_exec_ctx *exec_ctx, void *ptr,
771
767
  /* do nothing */
772
768
  } else {
773
769
  grpc_error *src_error = error;
774
- error =
775
- GRPC_ERROR_CREATE_REFERENCING("Missing :authority or :path", &error, 1);
770
+ error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
771
+ "Missing :authority or :path", &error, 1);
776
772
  GRPC_ERROR_UNREF(src_error);
777
773
  }
778
774
 
@@ -780,22 +776,25 @@ static void server_on_recv_initial_metadata(grpc_exec_ctx *exec_ctx, void *ptr,
780
776
  }
781
777
 
782
778
  static void server_mutate_op(grpc_call_element *elem,
783
- grpc_transport_stream_op *op) {
779
+ grpc_transport_stream_op_batch *op) {
784
780
  call_data *calld = elem->call_data;
785
781
 
786
- if (op->recv_initial_metadata != NULL) {
787
- GPR_ASSERT(op->recv_idempotent_request == NULL);
788
- calld->recv_initial_metadata = op->recv_initial_metadata;
789
- calld->on_done_recv_initial_metadata = op->recv_initial_metadata_ready;
790
- op->recv_initial_metadata_ready = &calld->server_on_recv_initial_metadata;
791
- op->recv_idempotent_request = &calld->recv_idempotent_request;
792
- op->recv_cacheable_request = &calld->recv_cacheable_request;
782
+ if (op->recv_initial_metadata) {
783
+ GPR_ASSERT(op->payload->recv_initial_metadata.recv_flags == NULL);
784
+ calld->recv_initial_metadata =
785
+ op->payload->recv_initial_metadata.recv_initial_metadata;
786
+ calld->on_done_recv_initial_metadata =
787
+ op->payload->recv_initial_metadata.recv_initial_metadata_ready;
788
+ op->payload->recv_initial_metadata.recv_initial_metadata_ready =
789
+ &calld->server_on_recv_initial_metadata;
790
+ op->payload->recv_initial_metadata.recv_flags =
791
+ &calld->recv_initial_metadata_flags;
793
792
  }
794
793
  }
795
794
 
796
- static void server_start_transport_stream_op(grpc_exec_ctx *exec_ctx,
797
- grpc_call_element *elem,
798
- grpc_transport_stream_op *op) {
795
+ static void server_start_transport_stream_op_batch(
796
+ grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
797
+ grpc_transport_stream_op_batch *op) {
799
798
  GRPC_CALL_LOG_OP(GPR_INFO, elem, op);
800
799
  server_mutate_op(elem, op);
801
800
  grpc_call_next_op(exec_ctx, elem, op);
@@ -898,7 +897,7 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
898
897
 
899
898
  static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
900
899
  const grpc_call_final_info *final_info,
901
- void *ignored) {
900
+ grpc_closure *ignored) {
902
901
  channel_data *chand = elem->channel_data;
903
902
  call_data *calld = elem->call_data;
904
903
 
@@ -959,7 +958,7 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
959
958
  }
960
959
 
961
960
  const grpc_channel_filter grpc_server_top_filter = {
962
- server_start_transport_stream_op,
961
+ server_start_transport_stream_op_batch,
963
962
  grpc_channel_next_op,
964
963
  sizeof(call_data),
965
964
  init_call_elem,
@@ -1219,7 +1218,8 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
1219
1218
  op->on_connectivity_state_change = &chand->channel_connectivity_changed;
1220
1219
  op->connectivity_state = &chand->connectivity_state;
1221
1220
  if (gpr_atm_acq_load(&s->shutdown_flag) != 0) {
1222
- op->disconnect_with_error = GRPC_ERROR_CREATE("Server shutdown");
1221
+ op->disconnect_with_error =
1222
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server shutdown");
1223
1223
  }
1224
1224
  grpc_transport_perform_op(exec_ctx, transport, op);
1225
1225
  }
@@ -1277,8 +1277,9 @@ void grpc_server_shutdown_and_notify(grpc_server *server,
1277
1277
 
1278
1278
  /* collect all unregistered then registered calls */
1279
1279
  gpr_mu_lock(&server->mu_call);
1280
- kill_pending_work_locked(&exec_ctx, server,
1281
- GRPC_ERROR_CREATE("Server Shutdown"));
1280
+ kill_pending_work_locked(
1281
+ &exec_ctx, server,
1282
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
1282
1283
  gpr_mu_unlock(&server->mu_call);
1283
1284
 
1284
1285
  maybe_finish_shutdown(&exec_ctx, server);
@@ -1308,8 +1309,9 @@ void grpc_server_cancel_all_calls(grpc_server *server) {
1308
1309
  channel_broadcaster_init(server, &broadcaster);
1309
1310
  gpr_mu_unlock(&server->mu_global);
1310
1311
 
1311
- channel_broadcaster_shutdown(&exec_ctx, &broadcaster, false /* send_goaway */,
1312
- GRPC_ERROR_CREATE("Cancelling all calls"));
1312
+ channel_broadcaster_shutdown(
1313
+ &exec_ctx, &broadcaster, false /* send_goaway */,
1314
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Cancelling all calls"));
1313
1315
  grpc_exec_ctx_finish(&exec_ctx);
1314
1316
  }
1315
1317
 
@@ -1357,16 +1359,16 @@ static grpc_call_error queue_call_request(grpc_exec_ctx *exec_ctx,
1357
1359
  int request_id;
1358
1360
  if (gpr_atm_acq_load(&server->shutdown_flag)) {
1359
1361
  fail_call(exec_ctx, server, cq_idx, rc,
1360
- GRPC_ERROR_CREATE("Server Shutdown"));
1362
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
1361
1363
  return GRPC_CALL_OK;
1362
1364
  }
1363
1365
  request_id = gpr_stack_lockfree_pop(server->request_freelist_per_cq[cq_idx]);
1364
1366
  if (request_id == -1) {
1365
1367
  /* out of request ids: just fail this one */
1366
1368
  fail_call(exec_ctx, server, cq_idx, rc,
1367
- grpc_error_set_int(GRPC_ERROR_CREATE("Out of request ids"),
1368
- GRPC_ERROR_INT_LIMIT,
1369
- server->max_requested_calls_per_cq));
1369
+ grpc_error_set_int(
1370
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Out of request ids"),
1371
+ GRPC_ERROR_INT_LIMIT, server->max_requested_calls_per_cq));
1370
1372
  return GRPC_CALL_OK;
1371
1373
  }
1372
1374
  switch (rc->type) {