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
@@ -32,6 +32,8 @@
32
32
  #define EXPECTED_CONTENT_TYPE_LENGTH sizeof(EXPECTED_CONTENT_TYPE) - 1
33
33
 
34
34
  typedef struct call_data {
35
+ grpc_call_combiner *call_combiner;
36
+
35
37
  grpc_linked_mdelem status;
36
38
  grpc_linked_mdelem content_type;
37
39
 
@@ -81,18 +83,18 @@ static grpc_error *server_filter_outgoing_metadata(grpc_exec_ctx *exec_ctx,
81
83
  }
82
84
 
83
85
  static void add_error(const char *error_name, grpc_error **cumulative,
84
- grpc_error *new) {
85
- if (new == GRPC_ERROR_NONE) return;
86
+ grpc_error *new_err) {
87
+ if (new_err == GRPC_ERROR_NONE) return;
86
88
  if (*cumulative == GRPC_ERROR_NONE) {
87
89
  *cumulative = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_name);
88
90
  }
89
- *cumulative = grpc_error_add_child(*cumulative, new);
91
+ *cumulative = grpc_error_add_child(*cumulative, new_err);
90
92
  }
91
93
 
92
94
  static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
93
95
  grpc_call_element *elem,
94
96
  grpc_metadata_batch *b) {
95
- call_data *calld = elem->call_data;
97
+ call_data *calld = (call_data *)elem->call_data;
96
98
  grpc_error *error = GRPC_ERROR_NONE;
97
99
  static const char *error_name = "Failed processing incoming headers";
98
100
 
@@ -261,8 +263,8 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
261
263
 
262
264
  static void hs_on_recv(grpc_exec_ctx *exec_ctx, void *user_data,
263
265
  grpc_error *err) {
264
- grpc_call_element *elem = user_data;
265
- call_data *calld = elem->call_data;
266
+ grpc_call_element *elem = (grpc_call_element *)user_data;
267
+ call_data *calld = (call_data *)elem->call_data;
266
268
  if (err == GRPC_ERROR_NONE) {
267
269
  err = server_filter_incoming_metadata(exec_ctx, elem,
268
270
  calld->recv_initial_metadata);
@@ -274,14 +276,18 @@ static void hs_on_recv(grpc_exec_ctx *exec_ctx, void *user_data,
274
276
 
275
277
  static void hs_on_complete(grpc_exec_ctx *exec_ctx, void *user_data,
276
278
  grpc_error *err) {
277
- grpc_call_element *elem = user_data;
278
- call_data *calld = elem->call_data;
279
+ grpc_call_element *elem = (grpc_call_element *)user_data;
280
+ call_data *calld = (call_data *)elem->call_data;
279
281
  /* Call recv_message_ready if we got the payload via the path field */
280
282
  if (calld->seen_path_with_query && calld->recv_message_ready != NULL) {
281
283
  *calld->pp_recv_message = calld->payload_bin_delivered
282
284
  ? NULL
283
285
  : (grpc_byte_stream *)&calld->read_stream;
284
- GRPC_CLOSURE_RUN(exec_ctx, calld->recv_message_ready, GRPC_ERROR_REF(err));
286
+ // Re-enter call combiner for recv_message_ready, since the surface
287
+ // code will release the call combiner for each callback it receives.
288
+ GRPC_CALL_COMBINER_START(exec_ctx, calld->call_combiner,
289
+ calld->recv_message_ready, GRPC_ERROR_REF(err),
290
+ "resuming recv_message_ready from on_complete");
285
291
  calld->recv_message_ready = NULL;
286
292
  calld->payload_bin_delivered = true;
287
293
  }
@@ -290,20 +296,25 @@ static void hs_on_complete(grpc_exec_ctx *exec_ctx, void *user_data,
290
296
 
291
297
  static void hs_recv_message_ready(grpc_exec_ctx *exec_ctx, void *user_data,
292
298
  grpc_error *err) {
293
- grpc_call_element *elem = user_data;
294
- call_data *calld = elem->call_data;
299
+ grpc_call_element *elem = (grpc_call_element *)user_data;
300
+ call_data *calld = (call_data *)elem->call_data;
295
301
  if (calld->seen_path_with_query) {
296
- /* do nothing. This is probably a GET request, and payload will be returned
297
- in hs_on_complete callback. */
302
+ // Do nothing. This is probably a GET request, and payload will be
303
+ // returned in hs_on_complete callback.
304
+ // Note that we release the call combiner here, so that other
305
+ // callbacks can run.
306
+ GRPC_CALL_COMBINER_STOP(exec_ctx, calld->call_combiner,
307
+ "pausing recv_message_ready until on_complete");
298
308
  } else {
299
309
  GRPC_CLOSURE_RUN(exec_ctx, calld->recv_message_ready, GRPC_ERROR_REF(err));
300
310
  }
301
311
  }
302
312
 
303
- static void hs_mutate_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
304
- grpc_transport_stream_op_batch *op) {
313
+ static grpc_error *hs_mutate_op(grpc_exec_ctx *exec_ctx,
314
+ grpc_call_element *elem,
315
+ grpc_transport_stream_op_batch *op) {
305
316
  /* grab pointers to our data from the call element */
306
- call_data *calld = elem->call_data;
317
+ call_data *calld = (call_data *)elem->call_data;
307
318
 
308
319
  if (op->send_initial_metadata) {
309
320
  grpc_error *error = GRPC_ERROR_NONE;
@@ -323,10 +334,7 @@ static void hs_mutate_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
323
334
  server_filter_outgoing_metadata(
324
335
  exec_ctx, elem,
325
336
  op->payload->send_initial_metadata.send_initial_metadata));
326
- if (error != GRPC_ERROR_NONE) {
327
- grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, op, error);
328
- return;
329
- }
337
+ if (error != GRPC_ERROR_NONE) return error;
330
338
  }
331
339
 
332
340
  if (op->recv_initial_metadata) {
@@ -359,21 +367,25 @@ static void hs_mutate_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
359
367
  grpc_error *error = server_filter_outgoing_metadata(
360
368
  exec_ctx, elem,
361
369
  op->payload->send_trailing_metadata.send_trailing_metadata);
362
- if (error != GRPC_ERROR_NONE) {
363
- grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, op, error);
364
- return;
365
- }
370
+ if (error != GRPC_ERROR_NONE) return error;
366
371
  }
372
+
373
+ return GRPC_ERROR_NONE;
367
374
  }
368
375
 
369
- static void hs_start_transport_op(grpc_exec_ctx *exec_ctx,
370
- grpc_call_element *elem,
371
- grpc_transport_stream_op_batch *op) {
372
- GRPC_CALL_LOG_OP(GPR_INFO, elem, op);
373
- GPR_TIMER_BEGIN("hs_start_transport_op", 0);
374
- hs_mutate_op(exec_ctx, elem, op);
375
- grpc_call_next_op(exec_ctx, elem, op);
376
- GPR_TIMER_END("hs_start_transport_op", 0);
376
+ static void hs_start_transport_stream_op_batch(
377
+ grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
378
+ grpc_transport_stream_op_batch *op) {
379
+ call_data *calld = (call_data *)elem->call_data;
380
+ GPR_TIMER_BEGIN("hs_start_transport_stream_op_batch", 0);
381
+ grpc_error *error = hs_mutate_op(exec_ctx, elem, op);
382
+ if (error != GRPC_ERROR_NONE) {
383
+ grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, op, error,
384
+ calld->call_combiner);
385
+ } else {
386
+ grpc_call_next_op(exec_ctx, elem, op);
387
+ }
388
+ GPR_TIMER_END("hs_start_transport_stream_op_batch", 0);
377
389
  }
378
390
 
379
391
  /* Constructor for call_data */
@@ -381,8 +393,9 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
381
393
  grpc_call_element *elem,
382
394
  const grpc_call_element_args *args) {
383
395
  /* grab pointers to our data from the call element */
384
- call_data *calld = elem->call_data;
396
+ call_data *calld = (call_data *)elem->call_data;
385
397
  /* initialize members */
398
+ calld->call_combiner = args->call_combiner;
386
399
  GRPC_CLOSURE_INIT(&calld->hs_on_recv, hs_on_recv, elem,
387
400
  grpc_schedule_on_exec_ctx);
388
401
  GRPC_CLOSURE_INIT(&calld->hs_on_complete, hs_on_complete, elem,
@@ -397,7 +410,7 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
397
410
  static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
398
411
  const grpc_call_final_info *final_info,
399
412
  grpc_closure *ignored) {
400
- call_data *calld = elem->call_data;
413
+ call_data *calld = (call_data *)elem->call_data;
401
414
  grpc_slice_buffer_destroy_internal(exec_ctx, &calld->read_slice_buffer);
402
415
  }
403
416
 
@@ -414,7 +427,7 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
414
427
  grpc_channel_element *elem) {}
415
428
 
416
429
  const grpc_channel_filter grpc_http_server_filter = {
417
- hs_start_transport_op,
430
+ hs_start_transport_stream_op_batch,
418
431
  grpc_channel_next_op,
419
432
  sizeof(call_data),
420
433
  init_call_elem,
@@ -423,6 +436,5 @@ const grpc_channel_filter grpc_http_server_filter = {
423
436
  sizeof(channel_data),
424
437
  init_channel_elem,
425
438
  destroy_channel_elem,
426
- grpc_call_next_get_peer,
427
439
  grpc_channel_next_get_info,
428
440
  "http-server"};
@@ -24,8 +24,8 @@
24
24
  #include <grpc/support/string_util.h>
25
25
  #include <grpc/support/sync.h>
26
26
 
27
- #include "src/core/ext/filters/load_reporting/load_reporting.h"
28
- #include "src/core/ext/filters/load_reporting/load_reporting_filter.h"
27
+ #include "src/core/ext/filters/load_reporting/server_load_reporting_filter.h"
28
+ #include "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h"
29
29
  #include "src/core/lib/channel/channel_args.h"
30
30
  #include "src/core/lib/profiling/timers.h"
31
31
  #include "src/core/lib/slice/slice_internal.h"
@@ -56,8 +56,8 @@ typedef struct channel_data {
56
56
 
57
57
  static void on_initial_md_ready(grpc_exec_ctx *exec_ctx, void *user_data,
58
58
  grpc_error *err) {
59
- grpc_call_element *elem = user_data;
60
- call_data *calld = elem->call_data;
59
+ grpc_call_element *elem = (grpc_call_element *)user_data;
60
+ call_data *calld = (call_data *)elem->call_data;
61
61
 
62
62
  if (err == GRPC_ERROR_NONE) {
63
63
  if (calld->recv_initial_metadata->idx.named.path != NULL) {
@@ -88,7 +88,7 @@ static void on_initial_md_ready(grpc_exec_ctx *exec_ctx, void *user_data,
88
88
  static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
89
89
  grpc_call_element *elem,
90
90
  const grpc_call_element_args *args) {
91
- call_data *calld = elem->call_data;
91
+ call_data *calld = (call_data *)elem->call_data;
92
92
  calld->id = (intptr_t)args->call_stack;
93
93
  GRPC_CLOSURE_INIT(&calld->on_initial_md_ready, on_initial_md_ready, elem,
94
94
  grpc_schedule_on_exec_ctx);
@@ -111,7 +111,7 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
111
111
  static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
112
112
  const grpc_call_final_info *final_info,
113
113
  grpc_closure *ignored) {
114
- call_data *calld = elem->call_data;
114
+ call_data *calld = (call_data *)elem->call_data;
115
115
 
116
116
  /* TODO(dgq): do something with the data
117
117
  channel_data *chand = elem->channel_data;
@@ -141,7 +141,7 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
141
141
  grpc_channel_element_args *args) {
142
142
  GPR_ASSERT(!args->is_last);
143
143
 
144
- channel_data *chand = elem->channel_data;
144
+ channel_data *chand = (channel_data *)elem->channel_data;
145
145
  chand->id = (intptr_t)args->channel_stack;
146
146
 
147
147
  /* TODO(dgq): do something with the data
@@ -176,8 +176,8 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
176
176
  static grpc_filtered_mdelem lr_trailing_md_filter(grpc_exec_ctx *exec_ctx,
177
177
  void *user_data,
178
178
  grpc_mdelem md) {
179
- grpc_call_element *elem = user_data;
180
- call_data *calld = elem->call_data;
179
+ grpc_call_element *elem = (grpc_call_element *)user_data;
180
+ call_data *calld = (call_data *)elem->call_data;
181
181
  if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_LB_COST_BIN)) {
182
182
  calld->trailing_md_string = GRPC_MDVALUE(md);
183
183
  return GRPC_FILTERED_REMOVE();
@@ -189,7 +189,7 @@ static void lr_start_transport_stream_op_batch(
189
189
  grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
190
190
  grpc_transport_stream_op_batch *op) {
191
191
  GPR_TIMER_BEGIN("lr_start_transport_stream_op_batch", 0);
192
- call_data *calld = elem->call_data;
192
+ call_data *calld = (call_data *)elem->call_data;
193
193
 
194
194
  if (op->recv_initial_metadata) {
195
195
  /* substitute our callback for the higher callback */
@@ -213,7 +213,7 @@ static void lr_start_transport_stream_op_batch(
213
213
  GPR_TIMER_END("lr_start_transport_stream_op_batch", 0);
214
214
  }
215
215
 
216
- const grpc_channel_filter grpc_load_reporting_filter = {
216
+ const grpc_channel_filter grpc_server_load_reporting_filter = {
217
217
  lr_start_transport_stream_op_batch,
218
218
  grpc_channel_next_op,
219
219
  sizeof(call_data),
@@ -223,6 +223,5 @@ const grpc_channel_filter grpc_load_reporting_filter = {
223
223
  sizeof(channel_data),
224
224
  init_channel_elem,
225
225
  destroy_channel_elem,
226
- grpc_call_next_get_peer,
227
226
  grpc_channel_next_get_info,
228
227
  "load_reporting"};
@@ -16,12 +16,13 @@
16
16
  *
17
17
  */
18
18
 
19
- #ifndef GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_LOAD_REPORTING_FILTER_H
20
- #define GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_LOAD_REPORTING_FILTER_H
19
+ #ifndef GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_SERVER_LOAD_REPORTING_FILTER_H
20
+ #define GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_SERVER_LOAD_REPORTING_FILTER_H
21
21
 
22
- #include "src/core/ext/filters/load_reporting/load_reporting.h"
22
+ #include "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h"
23
23
  #include "src/core/lib/channel/channel_stack.h"
24
24
 
25
- extern const grpc_channel_filter grpc_load_reporting_filter;
25
+ extern const grpc_channel_filter grpc_server_load_reporting_filter;
26
26
 
27
- #endif /* GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_LOAD_REPORTING_FILTER_H */
27
+ #endif /* GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_SERVER_LOAD_REPORTING_FILTER_H \
28
+ */
@@ -25,8 +25,8 @@
25
25
  #include <grpc/support/alloc.h>
26
26
  #include <grpc/support/sync.h>
27
27
 
28
- #include "src/core/ext/filters/load_reporting/load_reporting.h"
29
- #include "src/core/ext/filters/load_reporting/load_reporting_filter.h"
28
+ #include "src/core/ext/filters/load_reporting/server_load_reporting_filter.h"
29
+ #include "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h"
30
30
  #include "src/core/lib/channel/channel_stack_builder.h"
31
31
  #include "src/core/lib/slice/slice_internal.h"
32
32
  #include "src/core/lib/surface/call.h"
@@ -37,28 +37,34 @@ static bool is_load_reporting_enabled(const grpc_channel_args *a) {
37
37
  grpc_channel_args_find(a, GRPC_ARG_ENABLE_LOAD_REPORTING), false);
38
38
  }
39
39
 
40
- static bool maybe_add_load_reporting_filter(grpc_exec_ctx *exec_ctx,
41
- grpc_channel_stack_builder *builder,
42
- void *arg) {
40
+ static bool maybe_add_server_load_reporting_filter(
41
+ grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder, void *arg) {
43
42
  const grpc_channel_args *args =
44
43
  grpc_channel_stack_builder_get_channel_arguments(builder);
45
- if (is_load_reporting_enabled(args)) {
46
- return grpc_channel_stack_builder_prepend_filter(
47
- builder, (const grpc_channel_filter *)arg, NULL, NULL);
44
+ const grpc_channel_filter *filter = (const grpc_channel_filter *)arg;
45
+ grpc_channel_stack_builder_iterator *it =
46
+ grpc_channel_stack_builder_iterator_find(builder, filter->name);
47
+ const bool already_has_load_reporting_filter =
48
+ !grpc_channel_stack_builder_iterator_is_end(it);
49
+ grpc_channel_stack_builder_iterator_destroy(it);
50
+ if (is_load_reporting_enabled(args) && !already_has_load_reporting_filter) {
51
+ return grpc_channel_stack_builder_prepend_filter(builder, filter, NULL,
52
+ NULL);
48
53
  }
49
54
  return true;
50
55
  }
51
56
 
52
57
  grpc_arg grpc_load_reporting_enable_arg() {
53
- return grpc_channel_arg_integer_create(GRPC_ARG_ENABLE_LOAD_REPORTING, 1);
58
+ return grpc_channel_arg_integer_create((char *)GRPC_ARG_ENABLE_LOAD_REPORTING,
59
+ 1);
54
60
  }
55
61
 
56
62
  /* Plugin registration */
57
63
 
58
- void grpc_load_reporting_plugin_init(void) {
64
+ void grpc_server_load_reporting_plugin_init(void) {
59
65
  grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
60
- maybe_add_load_reporting_filter,
61
- (void *)&grpc_load_reporting_filter);
66
+ maybe_add_server_load_reporting_filter,
67
+ (void *)&grpc_server_load_reporting_filter);
62
68
  }
63
69
 
64
- void grpc_load_reporting_plugin_shutdown() {}
70
+ void grpc_server_load_reporting_plugin_shutdown() {}
@@ -16,8 +16,8 @@
16
16
  *
17
17
  */
18
18
 
19
- #ifndef GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_LOAD_REPORTING_H
20
- #define GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_LOAD_REPORTING_H
19
+ #ifndef GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_SERVER_LOAD_REPORTING_PLUGIN_H
20
+ #define GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_SERVER_LOAD_REPORTING_PLUGIN_H
21
21
 
22
22
  #include <grpc/impl/codegen/grpc_types.h>
23
23
 
@@ -55,4 +55,5 @@ typedef struct grpc_load_reporting_call_data {
55
55
  /** Return a \a grpc_arg enabling load reporting */
56
56
  grpc_arg grpc_load_reporting_enable_arg();
57
57
 
58
- #endif /* GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_LOAD_REPORTING_H */
58
+ #endif /* GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_SERVER_LOAD_REPORTING_PLUGIN_H \
59
+ */
@@ -273,7 +273,7 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
273
273
  static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
274
274
  const grpc_call_final_info* final_info,
275
275
  grpc_closure* ignored) {
276
- channel_data* chand = elem->channel_data;
276
+ channel_data* chand = (channel_data*)elem->channel_data;
277
277
  decrease_call_count(exec_ctx, chand);
278
278
  }
279
279
 
@@ -391,7 +391,6 @@ const grpc_channel_filter grpc_max_age_filter = {
391
391
  sizeof(channel_data),
392
392
  init_channel_elem,
393
393
  destroy_channel_elem,
394
- grpc_call_next_get_peer,
395
394
  grpc_channel_next_get_info,
396
395
  "max_age"};
397
396
 
@@ -403,7 +402,7 @@ static bool maybe_add_max_age_filter(grpc_exec_ctx* exec_ctx,
403
402
  bool enable =
404
403
  grpc_channel_arg_get_integer(
405
404
  grpc_channel_args_find(channel_args, GRPC_ARG_MAX_CONNECTION_AGE_MS),
406
- MAX_CONNECTION_AGE_INTEGER_OPTIONS) != INT_MAX &&
405
+ MAX_CONNECTION_AGE_INTEGER_OPTIONS) != INT_MAX ||
407
406
  grpc_channel_arg_get_integer(
408
407
  grpc_channel_args_find(channel_args, GRPC_ARG_MAX_CONNECTION_IDLE_MS),
409
408
  MAX_CONNECTION_IDLE_INTEGER_OPTIONS) != INT_MAX;
@@ -68,6 +68,7 @@ static void* message_size_limits_create_from_json(const grpc_json* json) {
68
68
  }
69
69
 
70
70
  typedef struct call_data {
71
+ grpc_call_combiner* call_combiner;
71
72
  message_size_limits limits;
72
73
  // Receive closures are chained: we inject this closure as the
73
74
  // recv_message_ready up-call on transport_stream_op, and remember to
@@ -131,7 +132,8 @@ static void start_transport_stream_op_batch(
131
132
  exec_ctx, op,
132
133
  grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(message_string),
133
134
  GRPC_ERROR_INT_GRPC_STATUS,
134
- GRPC_STATUS_RESOURCE_EXHAUSTED));
135
+ GRPC_STATUS_RESOURCE_EXHAUSTED),
136
+ calld->call_combiner);
135
137
  gpr_free(message_string);
136
138
  return;
137
139
  }
@@ -152,6 +154,7 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
152
154
  const grpc_call_element_args* args) {
153
155
  channel_data* chand = (channel_data*)elem->channel_data;
154
156
  call_data* calld = (call_data*)elem->call_data;
157
+ calld->call_combiner = args->call_combiner;
155
158
  calld->next_recv_message_ready = NULL;
156
159
  GRPC_CLOSURE_INIT(&calld->recv_message_ready, recv_message_ready, elem,
157
160
  grpc_schedule_on_exec_ctx);
@@ -259,7 +262,6 @@ const grpc_channel_filter grpc_message_size_filter = {
259
262
  sizeof(channel_data),
260
263
  init_channel_elem,
261
264
  destroy_channel_elem,
262
- grpc_call_next_get_peer,
263
265
  grpc_channel_next_get_info,
264
266
  "message_size"};
265
267
 
@@ -177,7 +177,6 @@ const grpc_channel_filter grpc_workaround_cronet_compression_filter = {
177
177
  0,
178
178
  init_channel_elem,
179
179
  destroy_channel_elem,
180
- grpc_call_next_get_peer,
181
180
  grpc_channel_next_get_info,
182
181
  "workaround_cronet_compression"};
183
182
 
@@ -93,8 +93,8 @@ static void chttp2_connector_shutdown(grpc_exec_ctx *exec_ctx,
93
93
 
94
94
  static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
95
95
  grpc_error *error) {
96
- grpc_handshaker_args *args = arg;
97
- chttp2_connector *c = args->user_data;
96
+ grpc_handshaker_args *args = (grpc_handshaker_args *)arg;
97
+ chttp2_connector *c = (chttp2_connector *)args->user_data;
98
98
  gpr_mu_lock(&c->mu);
99
99
  if (error != GRPC_ERROR_NONE || c->shutdown) {
100
100
  if (error == GRPC_ERROR_NONE) {
@@ -143,7 +143,7 @@ static void start_handshake_locked(grpc_exec_ctx *exec_ctx,
143
143
  }
144
144
 
145
145
  static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
146
- chttp2_connector *c = arg;
146
+ chttp2_connector *c = (chttp2_connector *)arg;
147
147
  gpr_mu_lock(&c->mu);
148
148
  GPR_ASSERT(c->connecting);
149
149
  c->connecting = false;
@@ -161,7 +161,7 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
161
161
  grpc_endpoint_shutdown(exec_ctx, c->endpoint, GRPC_ERROR_REF(error));
162
162
  }
163
163
  gpr_mu_unlock(&c->mu);
164
- chttp2_connector_unref(exec_ctx, arg);
164
+ chttp2_connector_unref(exec_ctx, (grpc_connector *)arg);
165
165
  } else {
166
166
  GPR_ASSERT(c->endpoint != NULL);
167
167
  start_handshake_locked(exec_ctx, c);
@@ -198,7 +198,7 @@ static const grpc_connector_vtable chttp2_connector_vtable = {
198
198
  chttp2_connector_connect};
199
199
 
200
200
  grpc_connector *grpc_chttp2_connector_create() {
201
- chttp2_connector *c = gpr_zalloc(sizeof(*c));
201
+ chttp2_connector *c = (chttp2_connector *)gpr_zalloc(sizeof(*c));
202
202
  c->base.vtable = &chttp2_connector_vtable;
203
203
  gpr_mu_init(&c->mu);
204
204
  gpr_ref_init(&c->refs, 1);