grpc 1.6.7 → 1.7.0.pre1

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 (277) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +579 -77
  3. data/include/grpc/byte_buffer.h +1 -63
  4. data/include/grpc/compression.h +27 -5
  5. data/include/grpc/fork.h +24 -0
  6. data/include/grpc/grpc.h +12 -6
  7. data/include/grpc/grpc_security.h +28 -7
  8. data/include/grpc/impl/codegen/atm.h +1 -0
  9. data/include/grpc/impl/codegen/byte_buffer.h +86 -0
  10. data/include/grpc/impl/codegen/compression_types.h +63 -5
  11. data/include/grpc/impl/codegen/fork.h +48 -0
  12. data/include/grpc/impl/codegen/grpc_types.h +26 -9
  13. data/include/grpc/impl/codegen/port_platform.h +11 -4
  14. data/include/grpc/impl/codegen/slice.h +6 -1
  15. data/include/grpc/impl/codegen/sync.h +3 -1
  16. data/include/grpc/impl/codegen/sync_custom.h +36 -0
  17. data/include/grpc/module.modulemap +75 -3
  18. data/include/grpc/slice.h +1 -5
  19. data/include/grpc/support/sync_custom.h +24 -0
  20. data/src/core/ext/census/base_resources.c +14 -14
  21. data/src/core/ext/census/context.c +7 -5
  22. data/src/core/ext/census/grpc_filter.c +12 -14
  23. data/src/core/ext/census/mlog.c +2 -1
  24. data/src/core/ext/census/resource.c +13 -9
  25. data/src/core/ext/filters/client_channel/channel_connectivity.c +15 -8
  26. data/src/core/ext/filters/client_channel/client_channel.c +418 -439
  27. data/src/core/ext/filters/client_channel/client_channel_factory.c +4 -5
  28. data/src/core/ext/filters/client_channel/client_channel_plugin.c +2 -2
  29. data/src/core/ext/filters/client_channel/http_connect_handshaker.c +7 -5
  30. data/src/core/ext/filters/client_channel/http_proxy.c +17 -21
  31. data/src/core/ext/filters/client_channel/lb_policy.c +1 -1
  32. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +7 -7
  33. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +371 -257
  34. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +7 -5
  35. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +25 -14
  36. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +16 -16
  37. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +33 -28
  38. data/src/core/ext/filters/client_channel/lb_policy_factory.c +10 -8
  39. data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -1
  40. data/src/core/ext/filters/client_channel/proxy_mapper_registry.c +1 -1
  41. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +7 -6
  42. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +62 -28
  43. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +29 -23
  44. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c +25 -14
  45. data/src/core/ext/filters/client_channel/retry_throttle.c +9 -6
  46. data/src/core/ext/filters/client_channel/subchannel.c +30 -30
  47. data/src/core/ext/filters/client_channel/subchannel.h +1 -4
  48. data/src/core/ext/filters/client_channel/subchannel_index.c +31 -15
  49. data/src/core/ext/filters/client_channel/subchannel_index.h +7 -0
  50. data/src/core/ext/filters/client_channel/uri_parser.c +4 -3
  51. data/src/core/ext/filters/deadline/deadline_filter.c +78 -39
  52. data/src/core/ext/filters/deadline/deadline_filter.h +7 -1
  53. data/src/core/ext/filters/http/client/http_client_filter.c +14 -14
  54. data/src/core/ext/filters/http/http_filters_plugin.c +1 -1
  55. data/src/core/ext/filters/http/message_compress/message_compress_filter.c +240 -175
  56. data/src/core/ext/filters/http/server/http_server_filter.c +48 -36
  57. data/src/core/ext/filters/load_reporting/{load_reporting_filter.c → server_load_reporting_filter.c} +11 -12
  58. data/src/core/ext/filters/load_reporting/{load_reporting_filter.h → server_load_reporting_filter.h} +6 -5
  59. data/src/core/ext/filters/load_reporting/{load_reporting.c → server_load_reporting_plugin.c} +19 -13
  60. data/src/core/ext/filters/load_reporting/{load_reporting.h → server_load_reporting_plugin.h} +4 -3
  61. data/src/core/ext/filters/max_age/max_age_filter.c +2 -3
  62. data/src/core/ext/filters/message_size/message_size_filter.c +4 -2
  63. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c +0 -1
  64. data/src/core/ext/transport/chttp2/client/chttp2_connector.c +5 -5
  65. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +1 -1
  66. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +1 -1
  67. data/src/core/ext/transport/chttp2/server/chttp2_server.c +20 -18
  68. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +1 -0
  69. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +493 -210
  70. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -0
  71. data/src/core/ext/transport/chttp2/transport/flow_control.c +9 -8
  72. data/src/core/ext/transport/chttp2/transport/frame_data.c +2 -2
  73. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +2 -2
  74. data/src/core/ext/transport/chttp2/transport/frame_ping.c +5 -4
  75. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +1 -1
  76. data/src/core/ext/transport/chttp2/transport/frame_settings.c +10 -9
  77. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +9 -5
  78. data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +62 -41
  79. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +52 -8
  80. data/src/core/ext/transport/chttp2/transport/hpack_table.c +2 -2
  81. data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +3 -2
  82. data/src/core/ext/transport/chttp2/transport/internal.h +60 -30
  83. data/src/core/ext/transport/chttp2/transport/parsing.c +16 -5
  84. data/src/core/ext/transport/chttp2/transport/stream_lists.c +36 -16
  85. data/src/core/ext/transport/chttp2/transport/stream_map.c +6 -4
  86. data/src/core/ext/transport/chttp2/transport/writing.c +133 -105
  87. data/src/core/ext/transport/inproc/inproc_transport.c +61 -65
  88. data/src/core/lib/channel/channel_args.c +112 -12
  89. data/src/core/lib/channel/channel_args.h +31 -0
  90. data/src/core/lib/channel/channel_stack.c +1 -15
  91. data/src/core/lib/channel/channel_stack.h +3 -10
  92. data/src/core/lib/channel/channel_stack_builder.c +41 -10
  93. data/src/core/lib/channel/channel_stack_builder.h +10 -0
  94. data/src/core/lib/channel/connected_channel.c +94 -23
  95. data/src/core/lib/channel/handshaker.c +8 -6
  96. data/src/core/lib/channel/handshaker_registry.c +1 -1
  97. data/src/core/lib/compression/algorithm_metadata.h +14 -0
  98. data/src/core/lib/compression/compression.c +101 -1
  99. data/src/core/lib/compression/stream_compression.c +32 -146
  100. data/src/core/lib/compression/stream_compression.h +28 -4
  101. data/src/core/lib/compression/stream_compression_gzip.c +228 -0
  102. data/src/core/lib/{iomgr/ev_epoll_thread_pool_linux.h → compression/stream_compression_gzip.h} +5 -7
  103. data/src/core/lib/compression/stream_compression_identity.c +94 -0
  104. data/src/core/lib/{iomgr/ev_epoll_limited_pollers_linux.h → compression/stream_compression_identity.h} +7 -8
  105. data/src/core/lib/debug/stats.c +174 -0
  106. data/src/core/lib/debug/stats.h +61 -0
  107. data/src/core/lib/debug/stats_data.c +687 -0
  108. data/src/core/lib/debug/stats_data.h +470 -0
  109. data/src/core/lib/debug/trace.c +3 -3
  110. data/src/core/lib/debug/trace.h +1 -1
  111. data/src/core/lib/http/format_request.c +1 -1
  112. data/src/core/lib/http/httpcli.c +8 -7
  113. data/src/core/lib/http/httpcli_security_connector.c +2 -1
  114. data/src/core/lib/http/parser.c +4 -3
  115. data/src/core/lib/iomgr/call_combiner.c +202 -0
  116. data/src/core/lib/iomgr/call_combiner.h +121 -0
  117. data/src/core/lib/iomgr/closure.c +18 -4
  118. data/src/core/lib/iomgr/combiner.c +11 -4
  119. data/src/core/lib/iomgr/error.c +26 -24
  120. data/src/core/lib/iomgr/ev_epoll1_linux.c +395 -212
  121. data/src/core/lib/iomgr/ev_epollex_linux.c +141 -128
  122. data/src/core/lib/iomgr/ev_epollsig_linux.c +44 -41
  123. data/src/core/lib/iomgr/ev_poll_posix.c +99 -75
  124. data/src/core/lib/iomgr/ev_posix.c +5 -9
  125. data/src/core/lib/iomgr/ev_posix.h +1 -1
  126. data/src/core/lib/iomgr/exec_ctx.h +6 -1
  127. data/src/core/lib/iomgr/executor.c +142 -36
  128. data/src/core/lib/iomgr/executor.h +6 -1
  129. data/src/core/lib/iomgr/fork_posix.c +88 -0
  130. data/src/core/lib/iomgr/fork_windows.c +39 -0
  131. data/src/core/lib/iomgr/iocp_windows.c +2 -0
  132. data/src/core/lib/iomgr/iomgr.c +2 -8
  133. data/src/core/lib/iomgr/is_epollexclusive_available.c +6 -6
  134. data/src/core/lib/iomgr/load_file.c +2 -1
  135. data/src/core/lib/iomgr/polling_entity.c +9 -9
  136. data/src/core/lib/iomgr/polling_entity.h +7 -1
  137. data/src/core/lib/iomgr/pollset.h +1 -1
  138. data/src/core/lib/iomgr/pollset_uv.c +1 -1
  139. data/src/core/lib/iomgr/pollset_windows.c +3 -3
  140. data/src/core/lib/iomgr/port.h +4 -0
  141. data/src/core/lib/iomgr/resolve_address_posix.c +8 -7
  142. data/src/core/lib/iomgr/resolve_address_windows.c +1 -1
  143. data/src/core/lib/iomgr/resource_quota.c +24 -19
  144. data/src/core/lib/iomgr/socket_factory_posix.c +4 -4
  145. data/src/core/lib/iomgr/socket_mutator.c +4 -4
  146. data/src/core/lib/iomgr/socket_utils_windows.c +0 -4
  147. data/src/core/lib/iomgr/tcp_client_posix.c +5 -4
  148. data/src/core/lib/iomgr/tcp_posix.c +181 -20
  149. data/src/core/lib/iomgr/tcp_server_posix.c +8 -7
  150. data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +1 -1
  151. data/src/core/lib/iomgr/timer.h +4 -0
  152. data/src/core/lib/iomgr/timer_generic.c +138 -3
  153. data/src/core/lib/iomgr/timer_generic.h +3 -0
  154. data/src/core/lib/iomgr/timer_heap.c +4 -4
  155. data/src/core/lib/iomgr/timer_manager.c +2 -2
  156. data/src/core/lib/iomgr/timer_uv.c +2 -0
  157. data/src/core/lib/iomgr/udp_server.c +10 -8
  158. data/src/core/lib/iomgr/unix_sockets_posix.c +4 -2
  159. data/src/core/lib/iomgr/wakeup_fd_cv.c +9 -8
  160. data/src/core/lib/iomgr/wakeup_fd_cv.h +2 -2
  161. data/src/core/lib/json/json.c +1 -1
  162. data/src/core/lib/json/json_string.c +13 -13
  163. data/src/core/lib/profiling/timers.h +18 -8
  164. data/src/core/lib/security/credentials/composite/composite_credentials.c +4 -10
  165. data/src/core/lib/security/credentials/google_default/google_default_credentials.c +2 -1
  166. data/src/core/lib/security/credentials/jwt/jwt_verifier.c +11 -6
  167. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +4 -4
  168. data/src/core/lib/security/credentials/plugin/plugin_credentials.c +132 -50
  169. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -0
  170. data/src/core/lib/security/transport/client_auth_filter.c +68 -135
  171. data/src/core/lib/security/transport/secure_endpoint.c +110 -90
  172. data/src/core/lib/security/transport/secure_endpoint.h +8 -3
  173. data/src/core/lib/security/transport/security_connector.c +10 -12
  174. data/src/core/lib/security/transport/security_handshaker.c +45 -24
  175. data/src/core/lib/security/transport/server_auth_filter.c +71 -20
  176. data/src/core/lib/slice/b64.c +2 -2
  177. data/src/core/lib/slice/slice.c +16 -14
  178. data/src/core/lib/slice/slice_buffer.c +5 -4
  179. data/src/core/lib/slice/slice_hash_table.c +3 -2
  180. data/src/core/lib/slice/slice_intern.c +8 -5
  181. data/src/core/lib/support/block_annotate.h +22 -0
  182. data/src/core/lib/support/fork.c +62 -0
  183. data/src/core/lib/support/fork.h +35 -0
  184. data/src/core/lib/support/log_linux.c +1 -1
  185. data/src/core/lib/support/string.c +15 -1
  186. data/src/core/lib/support/string.h +3 -0
  187. data/src/core/lib/support/thd_internal.h +6 -0
  188. data/src/core/lib/support/thd_posix.c +56 -0
  189. data/src/core/lib/support/thd_windows.c +2 -0
  190. data/src/core/lib/surface/alarm.c +22 -15
  191. data/src/core/lib/surface/byte_buffer.c +4 -2
  192. data/src/core/lib/surface/call.c +442 -141
  193. data/src/core/lib/surface/call.h +6 -6
  194. data/src/core/lib/surface/call_log_batch.c +1 -1
  195. data/src/core/lib/surface/call_test_only.h +12 -0
  196. data/src/core/lib/surface/channel.c +39 -4
  197. data/src/core/lib/surface/channel_init.c +6 -6
  198. data/src/core/lib/surface/channel_ping.c +2 -2
  199. data/src/core/lib/surface/completion_queue.c +56 -57
  200. data/src/core/lib/surface/init.c +17 -3
  201. data/src/core/lib/surface/init_secure.c +5 -1
  202. data/src/core/lib/surface/lame_client.cc +9 -10
  203. data/src/core/lib/surface/server.c +81 -72
  204. data/src/core/lib/surface/version.c +2 -2
  205. data/src/core/lib/transport/byte_stream.c +1 -0
  206. data/src/core/lib/transport/byte_stream.h +3 -1
  207. data/src/core/lib/transport/connectivity_state.c +2 -1
  208. data/src/core/lib/transport/metadata.c +7 -4
  209. data/src/core/lib/transport/metadata_batch.c +18 -16
  210. data/src/core/lib/transport/metadata_batch.h +1 -0
  211. data/src/core/lib/transport/service_config.c +5 -3
  212. data/src/core/lib/transport/static_metadata.c +395 -614
  213. data/src/core/lib/transport/static_metadata.h +165 -133
  214. data/src/core/lib/transport/status_conversion.c +1 -1
  215. data/src/core/lib/transport/transport.c +20 -20
  216. data/src/core/lib/transport/transport.h +8 -5
  217. data/src/core/lib/transport/transport_impl.h +0 -3
  218. data/src/core/lib/transport/transport_op_string.c +8 -1
  219. data/src/core/plugin_registry/grpc_plugin_registry.c +4 -4
  220. data/src/core/tsi/fake_transport_security.c +133 -2
  221. data/src/core/tsi/fake_transport_security.h +5 -0
  222. data/src/core/tsi/ssl_transport_security.c +105 -8
  223. data/src/core/tsi/ssl_transport_security.h +30 -7
  224. data/src/core/tsi/transport_security.h +8 -2
  225. data/src/core/tsi/transport_security_grpc.c +20 -13
  226. data/src/core/tsi/transport_security_grpc.h +13 -9
  227. data/src/ruby/ext/grpc/rb_call_credentials.c +6 -2
  228. data/src/ruby/ext/grpc/rb_grpc.c +1 -1
  229. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +30 -20
  230. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +50 -35
  231. data/src/ruby/lib/grpc.rb +1 -0
  232. data/src/ruby/lib/grpc/generic/active_call.rb +34 -9
  233. data/src/ruby/lib/grpc/generic/bidi_call.rb +19 -10
  234. data/src/ruby/lib/grpc/generic/client_stub.rb +95 -38
  235. data/src/ruby/lib/grpc/generic/interceptor_registry.rb +53 -0
  236. data/src/ruby/lib/grpc/generic/interceptors.rb +186 -0
  237. data/src/ruby/lib/grpc/generic/rpc_desc.rb +66 -20
  238. data/src/ruby/lib/grpc/generic/rpc_server.rb +15 -3
  239. data/src/ruby/lib/grpc/google_rpc_status_utils.rb +1 -2
  240. data/src/ruby/lib/grpc/version.rb +1 -1
  241. data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +1 -0
  242. data/src/ruby/spec/channel_connection_spec.rb +1 -34
  243. data/src/ruby/spec/client_server_spec.rb +188 -82
  244. data/src/ruby/spec/generic/active_call_spec.rb +65 -11
  245. data/src/ruby/spec/generic/client_interceptors_spec.rb +153 -0
  246. data/src/ruby/spec/generic/interceptor_registry_spec.rb +65 -0
  247. data/src/ruby/spec/generic/rpc_desc_spec.rb +38 -0
  248. data/src/ruby/spec/generic/rpc_server_spec.rb +1 -34
  249. data/src/ruby/spec/generic/server_interceptors_spec.rb +218 -0
  250. data/src/ruby/spec/spec_helper.rb +4 -0
  251. data/src/ruby/spec/support/helpers.rb +73 -0
  252. data/src/ruby/spec/support/services.rb +147 -0
  253. data/third_party/cares/ares_build.h +21 -62
  254. data/third_party/cares/cares/ares.h +23 -1
  255. data/third_party/cares/cares/ares__close_sockets.c +2 -2
  256. data/third_party/cares/cares/ares_create_query.c +3 -3
  257. data/third_party/cares/cares/ares_expand_name.c +6 -2
  258. data/third_party/cares/cares/ares_expand_string.c +1 -1
  259. data/third_party/cares/cares/ares_getnameinfo.c +27 -7
  260. data/third_party/cares/cares/ares_init.c +407 -39
  261. data/third_party/cares/cares/ares_library_init.c +10 -0
  262. data/third_party/cares/cares/ares_library_init.h +2 -1
  263. data/third_party/cares/cares/ares_nowarn.c +6 -6
  264. data/third_party/cares/cares/ares_nowarn.h +2 -2
  265. data/third_party/cares/cares/ares_parse_naptr_reply.c +6 -1
  266. data/third_party/cares/cares/ares_private.h +11 -0
  267. data/third_party/cares/cares/ares_process.c +126 -37
  268. data/third_party/cares/cares/ares_version.h +2 -2
  269. data/third_party/cares/cares/ares_writev.c +2 -2
  270. data/third_party/cares/cares/config-win32.h +8 -34
  271. data/third_party/cares/cares/inet_net_pton.c +2 -2
  272. data/third_party/cares/cares/setup_once.h +5 -5
  273. data/third_party/cares/config_darwin/ares_config.h +98 -196
  274. data/third_party/cares/config_linux/ares_config.h +103 -203
  275. metadata +47 -20
  276. data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +0 -1957
  277. data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +0 -1182
@@ -233,15 +233,10 @@ void grpc_call_stack_destroy(grpc_exec_ctx *exec_ctx, grpc_call_stack *stack,
233
233
  void grpc_call_next_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
234
234
  grpc_transport_stream_op_batch *op) {
235
235
  grpc_call_element *next_elem = elem + 1;
236
+ GRPC_CALL_LOG_OP(GPR_INFO, next_elem, op);
236
237
  next_elem->filter->start_transport_stream_op_batch(exec_ctx, next_elem, op);
237
238
  }
238
239
 
239
- char *grpc_call_next_get_peer(grpc_exec_ctx *exec_ctx,
240
- grpc_call_element *elem) {
241
- grpc_call_element *next_elem = elem + 1;
242
- return next_elem->filter->get_peer(exec_ctx, next_elem);
243
- }
244
-
245
240
  void grpc_channel_next_get_info(grpc_exec_ctx *exec_ctx,
246
241
  grpc_channel_element *elem,
247
242
  const grpc_channel_info *channel_info) {
@@ -265,12 +260,3 @@ grpc_call_stack *grpc_call_stack_from_top_element(grpc_call_element *elem) {
265
260
  return (grpc_call_stack *)((char *)(elem)-ROUND_UP_TO_ALIGNMENT_SIZE(
266
261
  sizeof(grpc_call_stack)));
267
262
  }
268
-
269
- void grpc_call_element_signal_error(grpc_exec_ctx *exec_ctx,
270
- grpc_call_element *elem,
271
- grpc_error *error) {
272
- grpc_transport_stream_op_batch *op = grpc_make_transport_stream_op(NULL);
273
- op->cancel_stream = true;
274
- op->payload->cancel_stream.cancel_error = error;
275
- elem->filter->start_transport_stream_op_batch(exec_ctx, elem, op);
276
- }
@@ -40,6 +40,7 @@
40
40
  #include <grpc/support/time.h>
41
41
 
42
42
  #include "src/core/lib/debug/trace.h"
43
+ #include "src/core/lib/iomgr/call_combiner.h"
43
44
  #include "src/core/lib/iomgr/polling_entity.h"
44
45
  #include "src/core/lib/support/arena.h"
45
46
  #include "src/core/lib/transport/transport.h"
@@ -71,6 +72,7 @@ typedef struct {
71
72
  gpr_timespec start_time;
72
73
  gpr_timespec deadline;
73
74
  gpr_arena *arena;
75
+ grpc_call_combiner *call_combiner;
74
76
  } grpc_call_element_args;
75
77
 
76
78
  typedef struct {
@@ -150,9 +152,6 @@ typedef struct {
150
152
  void (*destroy_channel_elem)(grpc_exec_ctx *exec_ctx,
151
153
  grpc_channel_element *elem);
152
154
 
153
- /* Implement grpc_call_get_peer() */
154
- char *(*get_peer)(grpc_exec_ctx *exec_ctx, grpc_call_element *elem);
155
-
156
155
  /* Implement grpc_channel_get_info() */
157
156
  void (*get_channel_info)(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
158
157
  const grpc_channel_info *channel_info);
@@ -271,8 +270,6 @@ void grpc_call_next_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
271
270
  stack */
272
271
  void grpc_channel_next_op(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem,
273
272
  grpc_transport_op *op);
274
- /* Pass through a request to get_peer to the next child element */
275
- char *grpc_call_next_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem);
276
273
  /* Pass through a request to get_channel_info() to the next child element */
277
274
  void grpc_channel_next_get_info(grpc_exec_ctx *exec_ctx,
278
275
  grpc_channel_element *elem,
@@ -284,14 +281,10 @@ grpc_channel_stack *grpc_channel_stack_from_top_element(
284
281
  /* Given the top element of a call stack, get the call stack itself */
285
282
  grpc_call_stack *grpc_call_stack_from_top_element(grpc_call_element *elem);
286
283
 
287
- void grpc_call_log_op(char *file, int line, gpr_log_severity severity,
284
+ void grpc_call_log_op(const char *file, int line, gpr_log_severity severity,
288
285
  grpc_call_element *elem,
289
286
  grpc_transport_stream_op_batch *op);
290
287
 
291
- void grpc_call_element_signal_error(grpc_exec_ctx *exec_ctx,
292
- grpc_call_element *cur_elem,
293
- grpc_error *error);
294
-
295
288
  extern grpc_tracer_flag grpc_trace_channel;
296
289
 
297
290
  #define GRPC_CALL_LOG_OP(sev, elem, op) \
@@ -51,7 +51,8 @@ struct grpc_channel_stack_builder_iterator {
51
51
  };
52
52
 
53
53
  grpc_channel_stack_builder *grpc_channel_stack_builder_create(void) {
54
- grpc_channel_stack_builder *b = gpr_zalloc(sizeof(*b));
54
+ grpc_channel_stack_builder *b =
55
+ (grpc_channel_stack_builder *)gpr_zalloc(sizeof(*b));
55
56
 
56
57
  b->begin.filter = NULL;
57
58
  b->end.filter = NULL;
@@ -76,7 +77,8 @@ const char *grpc_channel_stack_builder_get_target(
76
77
 
77
78
  static grpc_channel_stack_builder_iterator *create_iterator_at_filter_node(
78
79
  grpc_channel_stack_builder *builder, filter_node *node) {
79
- grpc_channel_stack_builder_iterator *it = gpr_malloc(sizeof(*it));
80
+ grpc_channel_stack_builder_iterator *it =
81
+ (grpc_channel_stack_builder_iterator *)gpr_malloc(sizeof(*it));
80
82
  it->builder = builder;
81
83
  it->node = node;
82
84
  return it;
@@ -124,6 +126,20 @@ bool grpc_channel_stack_builder_move_prev(
124
126
  return true;
125
127
  }
126
128
 
129
+ grpc_channel_stack_builder_iterator *grpc_channel_stack_builder_iterator_find(
130
+ grpc_channel_stack_builder *builder, const char *filter_name) {
131
+ GPR_ASSERT(filter_name != NULL);
132
+ grpc_channel_stack_builder_iterator *it =
133
+ grpc_channel_stack_builder_create_iterator_at_first(builder);
134
+ while (grpc_channel_stack_builder_move_next(it)) {
135
+ if (grpc_channel_stack_builder_iterator_is_end(it)) break;
136
+ const char *filter_name_at_it =
137
+ grpc_channel_stack_builder_iterator_filter_name(it);
138
+ if (strcmp(filter_name, filter_name_at_it) == 0) break;
139
+ }
140
+ return it;
141
+ }
142
+
127
143
  bool grpc_channel_stack_builder_move_prev(
128
144
  grpc_channel_stack_builder_iterator *iterator);
129
145
 
@@ -169,6 +185,21 @@ bool grpc_channel_stack_builder_append_filter(
169
185
  return ok;
170
186
  }
171
187
 
188
+ bool grpc_channel_stack_builder_remove_filter(
189
+ grpc_channel_stack_builder *builder, const char *filter_name) {
190
+ grpc_channel_stack_builder_iterator *it =
191
+ grpc_channel_stack_builder_iterator_find(builder, filter_name);
192
+ if (grpc_channel_stack_builder_iterator_is_end(it)) {
193
+ grpc_channel_stack_builder_iterator_destroy(it);
194
+ return false;
195
+ }
196
+ it->node->prev->next = it->node->next;
197
+ it->node->next->prev = it->node->prev;
198
+ gpr_free(it->node);
199
+ grpc_channel_stack_builder_iterator_destroy(it);
200
+ return true;
201
+ }
202
+
172
203
  bool grpc_channel_stack_builder_prepend_filter(
173
204
  grpc_channel_stack_builder *builder, const grpc_channel_filter *filter,
174
205
  grpc_post_filter_create_init_func post_init_func, void *user_data) {
@@ -183,13 +214,13 @@ bool grpc_channel_stack_builder_prepend_filter(
183
214
  static void add_after(filter_node *before, const grpc_channel_filter *filter,
184
215
  grpc_post_filter_create_init_func post_init_func,
185
216
  void *user_data) {
186
- filter_node *new = gpr_malloc(sizeof(*new));
187
- new->next = before->next;
188
- new->prev = before;
189
- new->next->prev = new->prev->next = new;
190
- new->filter = filter;
191
- new->init = post_init_func;
192
- new->init_arg = user_data;
217
+ filter_node *new_node = (filter_node *)gpr_malloc(sizeof(*new_node));
218
+ new_node->next = before->next;
219
+ new_node->prev = before;
220
+ new_node->next->prev = new_node->prev->next = new_node;
221
+ new_node->filter = filter;
222
+ new_node->init = post_init_func;
223
+ new_node->init_arg = user_data;
193
224
  }
194
225
 
195
226
  bool grpc_channel_stack_builder_add_filter_before(
@@ -237,7 +268,7 @@ grpc_error *grpc_channel_stack_builder_finish(
237
268
 
238
269
  // create an array of filters
239
270
  const grpc_channel_filter **filters =
240
- gpr_malloc(sizeof(*filters) * num_filters);
271
+ (const grpc_channel_filter **)gpr_malloc(sizeof(*filters) * num_filters);
241
272
  size_t i = 0;
242
273
  for (filter_node *p = builder->begin.next; p != &builder->end; p = p->next) {
243
274
  filters[i++] = p->filter;
@@ -95,6 +95,11 @@ bool grpc_channel_stack_builder_move_next(
95
95
  bool grpc_channel_stack_builder_move_prev(
96
96
  grpc_channel_stack_builder_iterator *iterator);
97
97
 
98
+ /// Return an iterator at \a filter_name, or at the end of the list if not
99
+ /// found.
100
+ grpc_channel_stack_builder_iterator *grpc_channel_stack_builder_iterator_find(
101
+ grpc_channel_stack_builder *builder, const char *filter_name);
102
+
98
103
  typedef void (*grpc_post_filter_create_init_func)(
99
104
  grpc_channel_stack *channel_stack, grpc_channel_element *elem, void *arg);
100
105
 
@@ -132,6 +137,11 @@ bool grpc_channel_stack_builder_append_filter(
132
137
  grpc_post_filter_create_init_func post_init_func,
133
138
  void *user_data) GRPC_MUST_USE_RESULT;
134
139
 
140
+ /// Remove any filter whose name is \a filter_name from \a builder. Returns true
141
+ /// if \a filter_name was not found.
142
+ bool grpc_channel_stack_builder_remove_filter(
143
+ grpc_channel_stack_builder *builder, const char *filter_name);
144
+
135
145
  /// Terminate iteration and destroy \a iterator
136
146
  void grpc_channel_stack_builder_iterator_destroy(
137
147
  grpc_channel_stack_builder_iterator *iterator);
@@ -36,7 +36,57 @@ typedef struct connected_channel_channel_data {
36
36
  grpc_transport *transport;
37
37
  } channel_data;
38
38
 
39
- typedef struct connected_channel_call_data { void *unused; } call_data;
39
+ typedef struct {
40
+ grpc_closure closure;
41
+ grpc_closure *original_closure;
42
+ grpc_call_combiner *call_combiner;
43
+ const char *reason;
44
+ } callback_state;
45
+
46
+ typedef struct connected_channel_call_data {
47
+ grpc_call_combiner *call_combiner;
48
+ // Closures used for returning results on the call combiner.
49
+ callback_state on_complete[6]; // Max number of pending batches.
50
+ callback_state recv_initial_metadata_ready;
51
+ callback_state recv_message_ready;
52
+ } call_data;
53
+
54
+ static void run_in_call_combiner(grpc_exec_ctx *exec_ctx, void *arg,
55
+ grpc_error *error) {
56
+ callback_state *state = (callback_state *)arg;
57
+ GRPC_CALL_COMBINER_START(exec_ctx, state->call_combiner,
58
+ state->original_closure, GRPC_ERROR_REF(error),
59
+ state->reason);
60
+ }
61
+
62
+ static void run_cancel_in_call_combiner(grpc_exec_ctx *exec_ctx, void *arg,
63
+ grpc_error *error) {
64
+ run_in_call_combiner(exec_ctx, arg, error);
65
+ gpr_free(arg);
66
+ }
67
+
68
+ static void intercept_callback(call_data *calld, callback_state *state,
69
+ bool free_when_done, const char *reason,
70
+ grpc_closure **original_closure) {
71
+ state->original_closure = *original_closure;
72
+ state->call_combiner = calld->call_combiner;
73
+ state->reason = reason;
74
+ *original_closure = GRPC_CLOSURE_INIT(
75
+ &state->closure,
76
+ free_when_done ? run_cancel_in_call_combiner : run_in_call_combiner,
77
+ state, grpc_schedule_on_exec_ctx);
78
+ }
79
+
80
+ static callback_state *get_state_for_batch(
81
+ call_data *calld, grpc_transport_stream_op_batch *batch) {
82
+ if (batch->send_initial_metadata) return &calld->on_complete[0];
83
+ if (batch->send_message) return &calld->on_complete[1];
84
+ if (batch->send_trailing_metadata) return &calld->on_complete[2];
85
+ if (batch->recv_initial_metadata) return &calld->on_complete[3];
86
+ if (batch->recv_message) return &calld->on_complete[4];
87
+ if (batch->recv_trailing_metadata) return &calld->on_complete[5];
88
+ GPR_UNREACHABLE_CODE(return NULL);
89
+ }
40
90
 
41
91
  /* We perform a small hack to locate transport data alongside the connected
42
92
  channel data in call allocations, to allow everything to be pulled in minimal
@@ -49,19 +99,44 @@ typedef struct connected_channel_call_data { void *unused; } call_data;
49
99
  into transport stream operations */
50
100
  static void con_start_transport_stream_op_batch(
51
101
  grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
52
- grpc_transport_stream_op_batch *op) {
53
- call_data *calld = elem->call_data;
54
- channel_data *chand = elem->channel_data;
55
- GRPC_CALL_LOG_OP(GPR_INFO, elem, op);
56
-
102
+ grpc_transport_stream_op_batch *batch) {
103
+ call_data *calld = (call_data *)elem->call_data;
104
+ channel_data *chand = (channel_data *)elem->channel_data;
105
+ if (batch->recv_initial_metadata) {
106
+ callback_state *state = &calld->recv_initial_metadata_ready;
107
+ intercept_callback(
108
+ calld, state, false, "recv_initial_metadata_ready",
109
+ &batch->payload->recv_initial_metadata.recv_initial_metadata_ready);
110
+ }
111
+ if (batch->recv_message) {
112
+ callback_state *state = &calld->recv_message_ready;
113
+ intercept_callback(calld, state, false, "recv_message_ready",
114
+ &batch->payload->recv_message.recv_message_ready);
115
+ }
116
+ if (batch->cancel_stream) {
117
+ // There can be more than one cancellation batch in flight at any
118
+ // given time, so we can't just pick out a fixed index into
119
+ // calld->on_complete like we can for the other ops. However,
120
+ // cancellation isn't in the fast path, so we just allocate a new
121
+ // closure for each one.
122
+ callback_state *state = (callback_state *)gpr_malloc(sizeof(*state));
123
+ intercept_callback(calld, state, true, "on_complete (cancel_stream)",
124
+ &batch->on_complete);
125
+ } else {
126
+ callback_state *state = get_state_for_batch(calld, batch);
127
+ intercept_callback(calld, state, false, "on_complete", &batch->on_complete);
128
+ }
57
129
  grpc_transport_perform_stream_op(exec_ctx, chand->transport,
58
- TRANSPORT_STREAM_FROM_CALL_DATA(calld), op);
130
+ TRANSPORT_STREAM_FROM_CALL_DATA(calld),
131
+ batch);
132
+ GRPC_CALL_COMBINER_STOP(exec_ctx, calld->call_combiner,
133
+ "passed batch to transport");
59
134
  }
60
135
 
61
136
  static void con_start_transport_op(grpc_exec_ctx *exec_ctx,
62
137
  grpc_channel_element *elem,
63
138
  grpc_transport_op *op) {
64
- channel_data *chand = elem->channel_data;
139
+ channel_data *chand = (channel_data *)elem->channel_data;
65
140
  grpc_transport_perform_op(exec_ctx, chand->transport, op);
66
141
  }
67
142
 
@@ -69,8 +144,9 @@ static void con_start_transport_op(grpc_exec_ctx *exec_ctx,
69
144
  static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
70
145
  grpc_call_element *elem,
71
146
  const grpc_call_element_args *args) {
72
- call_data *calld = elem->call_data;
73
- channel_data *chand = elem->channel_data;
147
+ call_data *calld = (call_data *)elem->call_data;
148
+ channel_data *chand = (channel_data *)elem->channel_data;
149
+ calld->call_combiner = args->call_combiner;
74
150
  int r = grpc_transport_init_stream(
75
151
  exec_ctx, chand->transport, TRANSPORT_STREAM_FROM_CALL_DATA(calld),
76
152
  &args->call_stack->refcount, args->server_transport_data, args->arena);
@@ -82,8 +158,8 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
82
158
  static void set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
83
159
  grpc_call_element *elem,
84
160
  grpc_polling_entity *pollent) {
85
- call_data *calld = elem->call_data;
86
- channel_data *chand = elem->channel_data;
161
+ call_data *calld = (call_data *)elem->call_data;
162
+ channel_data *chand = (channel_data *)elem->channel_data;
87
163
  grpc_transport_set_pops(exec_ctx, chand->transport,
88
164
  TRANSPORT_STREAM_FROM_CALL_DATA(calld), pollent);
89
165
  }
@@ -92,8 +168,8 @@ static void set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
92
168
  static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
93
169
  const grpc_call_final_info *final_info,
94
170
  grpc_closure *then_schedule_closure) {
95
- call_data *calld = elem->call_data;
96
- channel_data *chand = elem->channel_data;
171
+ call_data *calld = (call_data *)elem->call_data;
172
+ channel_data *chand = (channel_data *)elem->channel_data;
97
173
  grpc_transport_destroy_stream(exec_ctx, chand->transport,
98
174
  TRANSPORT_STREAM_FROM_CALL_DATA(calld),
99
175
  then_schedule_closure);
@@ -118,11 +194,6 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
118
194
  }
119
195
  }
120
196
 
121
- static char *con_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
122
- channel_data *chand = elem->channel_data;
123
- return grpc_transport_get_peer(exec_ctx, chand->transport);
124
- }
125
-
126
197
  /* No-op. */
127
198
  static void con_get_channel_info(grpc_exec_ctx *exec_ctx,
128
199
  grpc_channel_element *elem,
@@ -138,7 +209,6 @@ const grpc_channel_filter grpc_connected_filter = {
138
209
  sizeof(channel_data),
139
210
  init_channel_elem,
140
211
  destroy_channel_elem,
141
- con_get_peer,
142
212
  con_get_channel_info,
143
213
  "connected",
144
214
  };
@@ -148,7 +218,7 @@ static void bind_transport(grpc_channel_stack *channel_stack,
148
218
  channel_data *cd = (channel_data *)elem->channel_data;
149
219
  GPR_ASSERT(elem->filter == &grpc_connected_filter);
150
220
  GPR_ASSERT(cd->transport == NULL);
151
- cd->transport = t;
221
+ cd->transport = (grpc_transport *)t;
152
222
 
153
223
  /* HACK(ctiller): increase call stack size for the channel to make space
154
224
  for channel data. We need a cleaner (but performant) way to do this,
@@ -156,7 +226,8 @@ static void bind_transport(grpc_channel_stack *channel_stack,
156
226
  This is only "safe" because call stacks place no additional data after
157
227
  the last call element, and the last call element MUST be the connected
158
228
  channel. */
159
- channel_stack->call_stack_size += grpc_transport_stream_size(t);
229
+ channel_stack->call_stack_size +=
230
+ grpc_transport_stream_size((grpc_transport *)t);
160
231
  }
161
232
 
162
233
  bool grpc_add_connected_filter(grpc_exec_ctx *exec_ctx,
@@ -170,6 +241,6 @@ bool grpc_add_connected_filter(grpc_exec_ctx *exec_ctx,
170
241
  }
171
242
 
172
243
  grpc_stream *grpc_connected_channel_get_stream(grpc_call_element *elem) {
173
- call_data *calld = elem->call_data;
244
+ call_data *calld = (call_data *)elem->call_data;
174
245
  return TRANSPORT_STREAM_FROM_CALL_DATA(calld);
175
246
  }
@@ -84,7 +84,8 @@ struct grpc_handshake_manager {
84
84
  };
85
85
 
86
86
  grpc_handshake_manager* grpc_handshake_manager_create() {
87
- grpc_handshake_manager* mgr = gpr_zalloc(sizeof(grpc_handshake_manager));
87
+ grpc_handshake_manager* mgr =
88
+ (grpc_handshake_manager*)gpr_zalloc(sizeof(grpc_handshake_manager));
88
89
  gpr_mu_init(&mgr->mu);
89
90
  gpr_ref_init(&mgr->refs, 1);
90
91
  return mgr;
@@ -137,8 +138,8 @@ void grpc_handshake_manager_add(grpc_handshake_manager* mgr,
137
138
  realloc_count = mgr->count * 2;
138
139
  }
139
140
  if (realloc_count > 0) {
140
- mgr->handshakers =
141
- gpr_realloc(mgr->handshakers, realloc_count * sizeof(grpc_handshaker*));
141
+ mgr->handshakers = (grpc_handshaker**)gpr_realloc(
142
+ mgr->handshakers, realloc_count * sizeof(grpc_handshaker*));
142
143
  }
143
144
  mgr->handshakers[mgr->count++] = handshaker;
144
145
  gpr_mu_unlock(&mgr->mu);
@@ -205,7 +206,7 @@ static bool call_next_handshaker_locked(grpc_exec_ctx* exec_ctx,
205
206
  // handshakers together.
206
207
  static void call_next_handshaker(grpc_exec_ctx* exec_ctx, void* arg,
207
208
  grpc_error* error) {
208
- grpc_handshake_manager* mgr = arg;
209
+ grpc_handshake_manager* mgr = (grpc_handshake_manager*)arg;
209
210
  gpr_mu_lock(&mgr->mu);
210
211
  bool done = call_next_handshaker_locked(exec_ctx, mgr, GRPC_ERROR_REF(error));
211
212
  gpr_mu_unlock(&mgr->mu);
@@ -219,7 +220,7 @@ static void call_next_handshaker(grpc_exec_ctx* exec_ctx, void* arg,
219
220
 
220
221
  // Callback invoked when deadline is exceeded.
221
222
  static void on_timeout(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
222
- grpc_handshake_manager* mgr = arg;
223
+ grpc_handshake_manager* mgr = (grpc_handshake_manager*)arg;
223
224
  if (error == GRPC_ERROR_NONE) { // Timer fired, rather than being cancelled.
224
225
  grpc_handshake_manager_shutdown(
225
226
  exec_ctx, mgr,
@@ -241,7 +242,8 @@ void grpc_handshake_manager_do_handshake(
241
242
  mgr->args.endpoint = endpoint;
242
243
  mgr->args.args = grpc_channel_args_copy(channel_args);
243
244
  mgr->args.user_data = user_data;
244
- mgr->args.read_buffer = gpr_malloc(sizeof(*mgr->args.read_buffer));
245
+ mgr->args.read_buffer =
246
+ (grpc_slice_buffer*)gpr_malloc(sizeof(*mgr->args.read_buffer));
245
247
  grpc_slice_buffer_init(mgr->args.read_buffer);
246
248
  // Initialize state needed for calling handshakers.
247
249
  mgr->acceptor = acceptor;
@@ -34,7 +34,7 @@ typedef struct {
34
34
  static void grpc_handshaker_factory_list_register(
35
35
  grpc_handshaker_factory_list* list, bool at_start,
36
36
  grpc_handshaker_factory* factory) {
37
- list->list = gpr_realloc(
37
+ list->list = (grpc_handshaker_factory**)gpr_realloc(
38
38
  list->list, (list->num_factories + 1) * sizeof(grpc_handshaker_factory*));
39
39
  if (at_start) {
40
40
  memmove(list->list + 1, list->list,
@@ -26,13 +26,27 @@
26
26
  grpc_slice grpc_compression_algorithm_slice(
27
27
  grpc_compression_algorithm algorithm);
28
28
 
29
+ /** Return stream compression algorithm based metadata value */
30
+ grpc_slice grpc_stream_compression_algorithm_slice(
31
+ grpc_stream_compression_algorithm algorithm);
32
+
29
33
  /** Return compression algorithm based metadata element (grpc-encoding: xxx) */
30
34
  grpc_mdelem grpc_compression_encoding_mdelem(
31
35
  grpc_compression_algorithm algorithm);
32
36
 
37
+ /** Return stream compression algorithm based metadata element
38
+ * (content-encoding: xxx) */
39
+ grpc_mdelem grpc_stream_compression_encoding_mdelem(
40
+ grpc_stream_compression_algorithm algorithm);
41
+
33
42
  /** Find compression algorithm based on passed in mdstr - returns
34
43
  * GRPC_COMPRESS_ALGORITHM_COUNT on failure */
35
44
  grpc_compression_algorithm grpc_compression_algorithm_from_slice(
36
45
  grpc_slice str);
37
46
 
47
+ /** Find stream compression algorithm based on passed in mdstr - returns
48
+ * GRPC_STREAM_COMPRESS_ALGORITHM_COUNT on failure */
49
+ grpc_stream_compression_algorithm grpc_stream_compression_algorithm_from_slice(
50
+ grpc_slice str);
51
+
38
52
  #endif /* GRPC_CORE_LIB_COMPRESSION_ALGORITHM_METADATA_H */