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
@@ -19,6 +19,10 @@
19
19
  #ifndef GRPC_CORE_LIB_SURFACE_CALL_H
20
20
  #define GRPC_CORE_LIB_SURFACE_CALL_H
21
21
 
22
+ #ifdef __cplusplus
23
+ extern "C" {
24
+ #endif
25
+
22
26
  #include "src/core/lib/channel/channel_stack.h"
23
27
  #include "src/core/lib/channel/context.h"
24
28
  #include "src/core/lib/surface/api_trace.h"
@@ -26,10 +30,6 @@
26
30
  #include <grpc/grpc.h>
27
31
  #include <grpc/impl/codegen/compression_types.h>
28
32
 
29
- #ifdef __cplusplus
30
- extern "C" {
31
- #endif
32
-
33
33
  typedef void (*grpc_ioreq_completion_func)(grpc_exec_ctx *exec_ctx,
34
34
  grpc_call *call, int success,
35
35
  void *user_data);
@@ -37,7 +37,7 @@ typedef void (*grpc_ioreq_completion_func)(grpc_exec_ctx *exec_ctx,
37
37
  typedef struct grpc_call_create_args {
38
38
  grpc_channel *channel;
39
39
 
40
- grpc_call *parent_call;
40
+ grpc_call *parent;
41
41
  uint32_t propagation_mask;
42
42
 
43
43
  grpc_completion_queue *cq;
@@ -89,7 +89,7 @@ grpc_call_error grpc_call_start_batch_and_execute(grpc_exec_ctx *exec_ctx,
89
89
  /* Given the top call_element, get the call object. */
90
90
  grpc_call *grpc_call_from_top_element(grpc_call_element *surface_element);
91
91
 
92
- void grpc_call_log_batch(char *file, int line, gpr_log_severity severity,
92
+ void grpc_call_log_batch(const char *file, int line, gpr_log_severity severity,
93
93
  grpc_call *call, const grpc_op *ops, size_t nops,
94
94
  void *tag);
95
95
 
@@ -103,7 +103,7 @@ char *grpc_op_string(const grpc_op *op) {
103
103
  return out;
104
104
  }
105
105
 
106
- void grpc_call_log_batch(char *file, int line, gpr_log_severity severity,
106
+ void grpc_call_log_batch(const char *file, int line, gpr_log_severity severity,
107
107
  grpc_call *call, const grpc_op *ops, size_t nops,
108
108
  void *tag) {
109
109
  char *tmp;
@@ -42,6 +42,18 @@ uint32_t grpc_call_test_only_get_message_flags(grpc_call *call);
42
42
  * To be indexed by grpc_compression_algorithm enum values. */
43
43
  uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call *call);
44
44
 
45
+ /** Returns a bitset for the stream encodings (stream compression algorithms)
46
+ * supported by \a call's peer.
47
+ *
48
+ * To be indexed by grpc_stream_compression_algorithm enum values. */
49
+ uint32_t grpc_call_test_only_get_stream_encodings_accepted_by_peer(
50
+ grpc_call *call);
51
+
52
+ /** Returns the incoming stream compression algorithm (content-encoding header)
53
+ * received by a call. */
54
+ grpc_stream_compression_algorithm
55
+ grpc_call_test_only_get_incoming_stream_encodings(grpc_call *call);
56
+
45
57
  #ifdef __cplusplus
46
58
  }
47
59
  #endif
@@ -27,6 +27,7 @@
27
27
  #include <grpc/support/string_util.h>
28
28
 
29
29
  #include "src/core/lib/channel/channel_args.h"
30
+ #include "src/core/lib/debug/stats.h"
30
31
  #include "src/core/lib/iomgr/iomgr.h"
31
32
  #include "src/core/lib/slice/slice_internal.h"
32
33
  #include "src/core/lib/support/string.h"
@@ -77,6 +78,11 @@ grpc_channel *grpc_channel_create_with_builder(
77
78
  grpc_channel_args *args = grpc_channel_args_copy(
78
79
  grpc_channel_stack_builder_get_channel_arguments(builder));
79
80
  grpc_channel *channel;
81
+ if (channel_stack_type == GRPC_SERVER_CHANNEL) {
82
+ GRPC_STATS_INC_SERVER_CHANNELS_CREATED(exec_ctx);
83
+ } else {
84
+ GRPC_STATS_INC_CLIENT_CHANNELS_CREATED(exec_ctx);
85
+ }
80
86
  grpc_error *error = grpc_channel_stack_builder_finish(
81
87
  exec_ctx, builder, sizeof(grpc_channel), 1, destroy_channel, NULL,
82
88
  (void **)&channel);
@@ -141,6 +147,16 @@ grpc_channel *grpc_channel_create_with_builder(
141
147
  (grpc_integer_options){GRPC_COMPRESS_LEVEL_NONE,
142
148
  GRPC_COMPRESS_LEVEL_NONE,
143
149
  GRPC_COMPRESS_LEVEL_COUNT - 1});
150
+ } else if (0 == strcmp(args->args[i].key,
151
+ GRPC_STREAM_COMPRESSION_CHANNEL_DEFAULT_LEVEL)) {
152
+ channel->compression_options.default_stream_compression_level.is_set =
153
+ true;
154
+ channel->compression_options.default_stream_compression_level.level =
155
+ (grpc_stream_compression_level)grpc_channel_arg_get_integer(
156
+ &args->args[i],
157
+ (grpc_integer_options){GRPC_STREAM_COMPRESS_LEVEL_NONE,
158
+ GRPC_STREAM_COMPRESS_LEVEL_NONE,
159
+ GRPC_STREAM_COMPRESS_LEVEL_COUNT - 1});
144
160
  } else if (0 == strcmp(args->args[i].key,
145
161
  GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM)) {
146
162
  channel->compression_options.default_algorithm.is_set = true;
@@ -149,12 +165,31 @@ grpc_channel *grpc_channel_create_with_builder(
149
165
  &args->args[i],
150
166
  (grpc_integer_options){GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE,
151
167
  GRPC_COMPRESS_ALGORITHMS_COUNT - 1});
168
+ } else if (0 == strcmp(args->args[i].key,
169
+ GRPC_STREAM_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM)) {
170
+ channel->compression_options.default_stream_compression_algorithm.is_set =
171
+ true;
172
+ channel->compression_options.default_stream_compression_algorithm
173
+ .algorithm =
174
+ (grpc_stream_compression_algorithm)grpc_channel_arg_get_integer(
175
+ &args->args[i],
176
+ (grpc_integer_options){
177
+ GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_NONE,
178
+ GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT - 1});
152
179
  } else if (0 ==
153
180
  strcmp(args->args[i].key,
154
181
  GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET)) {
155
182
  channel->compression_options.enabled_algorithms_bitset =
156
183
  (uint32_t)args->args[i].value.integer |
157
184
  0x1; /* always support no compression */
185
+ } else if (0 ==
186
+ strcmp(
187
+ args->args[i].key,
188
+ GRPC_STREAM_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET)) {
189
+ channel->compression_options
190
+ .enabled_stream_compression_algorithms_bitset =
191
+ (uint32_t)args->args[i].value.integer |
192
+ 0x1; /* always support no compression */
158
193
  }
159
194
  }
160
195
 
@@ -247,7 +282,7 @@ static grpc_call *grpc_channel_create_call_internal(
247
282
  grpc_call_create_args args;
248
283
  memset(&args, 0, sizeof(args));
249
284
  args.channel = channel;
250
- args.parent_call = parent_call;
285
+ args.parent = parent_call;
251
286
  args.propagation_mask = propagation_mask;
252
287
  args.cq = cq;
253
288
  args.pollset_set_alternative = pollset_set_alternative;
@@ -298,7 +333,7 @@ grpc_call *grpc_channel_create_pollset_set_call(
298
333
 
299
334
  void *grpc_channel_register_call(grpc_channel *channel, const char *method,
300
335
  const char *host, void *reserved) {
301
- registered_call *rc = gpr_malloc(sizeof(registered_call));
336
+ registered_call *rc = (registered_call *)gpr_malloc(sizeof(registered_call));
302
337
  GRPC_API_TRACE(
303
338
  "grpc_channel_register_call(channel=%p, method=%s, host=%s, reserved=%p)",
304
339
  4, (channel, method, host, reserved));
@@ -325,7 +360,7 @@ grpc_call *grpc_channel_create_registered_call(
325
360
  grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask,
326
361
  grpc_completion_queue *completion_queue, void *registered_call_handle,
327
362
  gpr_timespec deadline, void *reserved) {
328
- registered_call *rc = registered_call_handle;
363
+ registered_call *rc = (registered_call *)registered_call_handle;
329
364
  GRPC_API_TRACE(
330
365
  "grpc_channel_create_registered_call("
331
366
  "channel=%p, parent_call=%p, propagation_mask=%x, completion_queue=%p, "
@@ -363,7 +398,7 @@ void grpc_channel_internal_unref(grpc_exec_ctx *exec_ctx,
363
398
 
364
399
  static void destroy_channel(grpc_exec_ctx *exec_ctx, void *arg,
365
400
  grpc_error *error) {
366
- grpc_channel *channel = arg;
401
+ grpc_channel *channel = (grpc_channel *)arg;
367
402
  grpc_channel_stack_destroy(exec_ctx, CHANNEL_STACK_FROM_CHANNEL(channel));
368
403
  while (channel->registered_calls) {
369
404
  registered_call *rc = channel->registered_calls;
@@ -53,9 +53,9 @@ void grpc_channel_init_register_stage(grpc_channel_stack_type type,
53
53
  GPR_ASSERT(!g_finalized);
54
54
  if (g_slots[type].cap_slots == g_slots[type].num_slots) {
55
55
  g_slots[type].cap_slots = GPR_MAX(8, 3 * g_slots[type].cap_slots / 2);
56
- g_slots[type].slots =
57
- gpr_realloc(g_slots[type].slots,
58
- g_slots[type].cap_slots * sizeof(*g_slots[type].slots));
56
+ g_slots[type].slots = (stage_slot *)gpr_realloc(
57
+ g_slots[type].slots,
58
+ g_slots[type].cap_slots * sizeof(*g_slots[type].slots));
59
59
  }
60
60
  stage_slot *s = &g_slots[type].slots[g_slots[type].num_slots++];
61
61
  s->insertion_order = g_slots[type].num_slots;
@@ -65,8 +65,8 @@ void grpc_channel_init_register_stage(grpc_channel_stack_type type,
65
65
  }
66
66
 
67
67
  static int compare_slots(const void *a, const void *b) {
68
- const stage_slot *sa = a;
69
- const stage_slot *sb = b;
68
+ const stage_slot *sa = (const stage_slot *)a;
69
+ const stage_slot *sb = (const stage_slot *)b;
70
70
 
71
71
  int c = GPR_ICMP(sa->priority, sb->priority);
72
72
  if (c != 0) return c;
@@ -85,7 +85,7 @@ void grpc_channel_init_finalize(void) {
85
85
  void grpc_channel_init_shutdown(void) {
86
86
  for (int i = 0; i < GRPC_NUM_CHANNEL_STACK_TYPES; i++) {
87
87
  gpr_free(g_slots[i].slots);
88
- g_slots[i].slots = (void *)(uintptr_t)0xdeadbeef;
88
+ g_slots[i].slots = (stage_slot *)(void *)(uintptr_t)0xdeadbeef;
89
89
  }
90
90
  }
91
91
 
@@ -39,7 +39,7 @@ static void ping_destroy(grpc_exec_ctx *exec_ctx, void *arg,
39
39
  }
40
40
 
41
41
  static void ping_done(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
42
- ping_result *pr = arg;
42
+ ping_result *pr = (ping_result *)arg;
43
43
  grpc_cq_end_op(exec_ctx, pr->cq, pr->tag, GRPC_ERROR_REF(error), ping_destroy,
44
44
  pr, &pr->completion_storage);
45
45
  }
@@ -49,7 +49,7 @@ void grpc_channel_ping(grpc_channel *channel, grpc_completion_queue *cq,
49
49
  GRPC_API_TRACE("grpc_channel_ping(channel=%p, cq=%p, tag=%p, reserved=%p)", 4,
50
50
  (channel, cq, tag, reserved));
51
51
  grpc_transport_op *op = grpc_make_transport_op(NULL);
52
- ping_result *pr = gpr_malloc(sizeof(*pr));
52
+ ping_result *pr = (ping_result *)gpr_malloc(sizeof(*pr));
53
53
  grpc_channel_element *top_elem =
54
54
  grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
55
55
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
@@ -26,6 +26,7 @@
26
26
  #include <grpc/support/string_util.h>
27
27
  #include <grpc/support/time.h>
28
28
 
29
+ #include "src/core/lib/debug/stats.h"
29
30
  #include "src/core/lib/iomgr/pollset.h"
30
31
  #include "src/core/lib/iomgr/timer.h"
31
32
  #include "src/core/lib/profiling/timers.h"
@@ -54,7 +55,7 @@ typedef struct {
54
55
  bool can_listen;
55
56
  size_t (*size)(void);
56
57
  void (*init)(grpc_pollset *pollset, gpr_mu **mu);
57
- grpc_error *(*kick)(grpc_pollset *pollset,
58
+ grpc_error *(*kick)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
58
59
  grpc_pollset_worker *specific_worker);
59
60
  grpc_error *(*work)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
60
61
  grpc_pollset_worker **worker, gpr_timespec now,
@@ -130,7 +131,8 @@ static grpc_error *non_polling_poller_work(grpc_exec_ctx *exec_ctx,
130
131
  }
131
132
 
132
133
  static grpc_error *non_polling_poller_kick(
133
- grpc_pollset *pollset, grpc_pollset_worker *specific_worker) {
134
+ grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
135
+ grpc_pollset_worker *specific_worker) {
134
136
  non_polling_poller *p = (non_polling_poller *)pollset;
135
137
  if (specific_worker == NULL) specific_worker = (grpc_pollset_worker *)p->root;
136
138
  if (specific_worker != NULL) {
@@ -327,25 +329,12 @@ static void cq_destroy_pluck(void *data);
327
329
  /* Completion queue vtables based on the completion-type */
328
330
  static const cq_vtable g_cq_vtable[] = {
329
331
  /* GRPC_CQ_NEXT */
330
- {.data_size = sizeof(cq_next_data),
331
- .cq_completion_type = GRPC_CQ_NEXT,
332
- .init = cq_init_next,
333
- .shutdown = cq_shutdown_next,
334
- .destroy = cq_destroy_next,
335
- .begin_op = cq_begin_op_for_next,
336
- .end_op = cq_end_op_for_next,
337
- .next = cq_next,
338
- .pluck = NULL},
332
+ {GRPC_CQ_NEXT, sizeof(cq_next_data), cq_init_next, cq_shutdown_next,
333
+ cq_destroy_next, cq_begin_op_for_next, cq_end_op_for_next, cq_next, NULL},
339
334
  /* GRPC_CQ_PLUCK */
340
- {.data_size = sizeof(cq_pluck_data),
341
- .cq_completion_type = GRPC_CQ_PLUCK,
342
- .init = cq_init_pluck,
343
- .shutdown = cq_shutdown_pluck,
344
- .destroy = cq_destroy_pluck,
345
- .begin_op = cq_begin_op_for_pluck,
346
- .end_op = cq_end_op_for_pluck,
347
- .next = NULL,
348
- .pluck = cq_pluck},
335
+ {GRPC_CQ_PLUCK, sizeof(cq_pluck_data), cq_init_pluck, cq_shutdown_pluck,
336
+ cq_destroy_pluck, cq_begin_op_for_pluck, cq_end_op_for_pluck, NULL,
337
+ cq_pluck},
349
338
  };
350
339
 
351
340
  #define DATA_FROM_CQ(cq) ((void *)(cq + 1))
@@ -420,8 +409,13 @@ grpc_completion_queue *grpc_completion_queue_create_internal(
420
409
  const cq_poller_vtable *poller_vtable =
421
410
  &g_poller_vtable_by_poller_type[polling_type];
422
411
 
423
- cq = gpr_zalloc(sizeof(grpc_completion_queue) + vtable->data_size +
424
- poller_vtable->size());
412
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
413
+ GRPC_STATS_INC_CQS_CREATED(&exec_ctx);
414
+ grpc_exec_ctx_finish(&exec_ctx);
415
+
416
+ cq = (grpc_completion_queue *)gpr_zalloc(sizeof(grpc_completion_queue) +
417
+ vtable->data_size +
418
+ poller_vtable->size());
425
419
 
426
420
  cq->vtable = vtable;
427
421
  cq->poller_vtable = poller_vtable;
@@ -441,7 +435,7 @@ grpc_completion_queue *grpc_completion_queue_create_internal(
441
435
  }
442
436
 
443
437
  static void cq_init_next(void *ptr) {
444
- cq_next_data *cqd = ptr;
438
+ cq_next_data *cqd = (cq_next_data *)ptr;
445
439
  /* Initial count is dropped by grpc_completion_queue_shutdown */
446
440
  gpr_atm_no_barrier_store(&cqd->pending_events, 1);
447
441
  cqd->shutdown_called = false;
@@ -450,13 +444,13 @@ static void cq_init_next(void *ptr) {
450
444
  }
451
445
 
452
446
  static void cq_destroy_next(void *ptr) {
453
- cq_next_data *cqd = ptr;
447
+ cq_next_data *cqd = (cq_next_data *)ptr;
454
448
  GPR_ASSERT(cq_event_queue_num_items(&cqd->queue) == 0);
455
449
  cq_event_queue_destroy(&cqd->queue);
456
450
  }
457
451
 
458
452
  static void cq_init_pluck(void *ptr) {
459
- cq_pluck_data *cqd = ptr;
453
+ cq_pluck_data *cqd = (cq_pluck_data *)ptr;
460
454
  /* Initial count is dropped by grpc_completion_queue_shutdown */
461
455
  gpr_atm_no_barrier_store(&cqd->pending_events, 1);
462
456
  cqd->completed_tail = &cqd->completed_head;
@@ -468,7 +462,7 @@ static void cq_init_pluck(void *ptr) {
468
462
  }
469
463
 
470
464
  static void cq_destroy_pluck(void *ptr) {
471
- cq_pluck_data *cqd = ptr;
465
+ cq_pluck_data *cqd = (cq_pluck_data *)ptr;
472
466
  GPR_ASSERT(cqd->completed_head.next == (uintptr_t)&cqd->completed_head);
473
467
  }
474
468
 
@@ -501,7 +495,7 @@ void grpc_cq_internal_ref(grpc_completion_queue *cq) {
501
495
 
502
496
  static void on_pollset_shutdown_done(grpc_exec_ctx *exec_ctx, void *arg,
503
497
  grpc_error *error) {
504
- grpc_completion_queue *cq = arg;
498
+ grpc_completion_queue *cq = (grpc_completion_queue *)arg;
505
499
  GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "pollset_destroy");
506
500
  }
507
501
 
@@ -559,13 +553,13 @@ static void cq_check_tag(grpc_completion_queue *cq, void *tag, bool lock_cq) {}
559
553
  * true if the increment was successful; false if the counter is zero */
560
554
  static bool atm_inc_if_nonzero(gpr_atm *counter) {
561
555
  while (true) {
562
- gpr_atm count = gpr_atm_no_barrier_load(counter);
556
+ gpr_atm count = gpr_atm_acq_load(counter);
563
557
  /* If zero, we are done. If not, we must to a CAS (instead of an atomic
564
558
  * increment) to maintain the contract: do not increment the counter if it
565
559
  * is zero. */
566
560
  if (count == 0) {
567
561
  return false;
568
- } else if (gpr_atm_no_barrier_cas(counter, count, count + 1)) {
562
+ } else if (gpr_atm_full_cas(counter, count, count + 1)) {
569
563
  break;
570
564
  }
571
565
  }
@@ -574,12 +568,12 @@ static bool atm_inc_if_nonzero(gpr_atm *counter) {
574
568
  }
575
569
 
576
570
  static bool cq_begin_op_for_next(grpc_completion_queue *cq, void *tag) {
577
- cq_next_data *cqd = DATA_FROM_CQ(cq);
571
+ cq_next_data *cqd = (cq_next_data *)DATA_FROM_CQ(cq);
578
572
  return atm_inc_if_nonzero(&cqd->pending_events);
579
573
  }
580
574
 
581
575
  static bool cq_begin_op_for_pluck(grpc_completion_queue *cq, void *tag) {
582
- cq_pluck_data *cqd = DATA_FROM_CQ(cq);
576
+ cq_pluck_data *cqd = (cq_pluck_data *)DATA_FROM_CQ(cq);
583
577
  return atm_inc_if_nonzero(&cqd->pending_events);
584
578
  }
585
579
 
@@ -588,9 +582,9 @@ bool grpc_cq_begin_op(grpc_completion_queue *cq, void *tag) {
588
582
  gpr_mu_lock(cq->mu);
589
583
  if (cq->outstanding_tag_count == cq->outstanding_tag_capacity) {
590
584
  cq->outstanding_tag_capacity = GPR_MAX(4, 2 * cq->outstanding_tag_capacity);
591
- cq->outstanding_tags =
592
- gpr_realloc(cq->outstanding_tags, sizeof(*cq->outstanding_tags) *
593
- cq->outstanding_tag_capacity);
585
+ cq->outstanding_tags = (void **)gpr_realloc(
586
+ cq->outstanding_tags,
587
+ sizeof(*cq->outstanding_tags) * cq->outstanding_tag_capacity);
594
588
  }
595
589
  cq->outstanding_tags[cq->outstanding_tag_count++] = tag;
596
590
  gpr_mu_unlock(cq->mu);
@@ -624,7 +618,7 @@ static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
624
618
  }
625
619
  }
626
620
 
627
- cq_next_data *cqd = DATA_FROM_CQ(cq);
621
+ cq_next_data *cqd = (cq_next_data *)DATA_FROM_CQ(cq);
628
622
  int is_success = (error == GRPC_ERROR_NONE);
629
623
 
630
624
  storage->tag = tag;
@@ -637,15 +631,19 @@ static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
637
631
  /* Add the completion to the queue */
638
632
  bool is_first = cq_event_queue_push(&cqd->queue, storage);
639
633
  gpr_atm_no_barrier_fetch_add(&cqd->things_queued_ever, 1);
640
- bool will_definitely_shutdown =
641
- gpr_atm_no_barrier_load(&cqd->pending_events) == 1;
634
+
635
+ /* Since we do not hold the cq lock here, it is important to do an 'acquire'
636
+ load here (instead of a 'no_barrier' load) to match with the release store
637
+ (done via gpr_atm_full_fetch_add(pending_events, -1)) in cq_shutdown_next
638
+ */
639
+ bool will_definitely_shutdown = gpr_atm_acq_load(&cqd->pending_events) == 1;
642
640
 
643
641
  if (!will_definitely_shutdown) {
644
642
  /* Only kick if this is the first item queued */
645
643
  if (is_first) {
646
644
  gpr_mu_lock(cq->mu);
647
645
  grpc_error *kick_error =
648
- cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), NULL);
646
+ cq->poller_vtable->kick(exec_ctx, POLLSET_FROM_CQ(cq), NULL);
649
647
  gpr_mu_unlock(cq->mu);
650
648
 
651
649
  if (kick_error != GRPC_ERROR_NONE) {
@@ -685,7 +683,7 @@ static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
685
683
  void *done_arg,
686
684
  grpc_cq_completion *storage),
687
685
  void *done_arg, grpc_cq_completion *storage) {
688
- cq_pluck_data *cqd = DATA_FROM_CQ(cq);
686
+ cq_pluck_data *cqd = (cq_pluck_data *)DATA_FROM_CQ(cq);
689
687
  int is_success = (error == GRPC_ERROR_NONE);
690
688
 
691
689
  GPR_TIMER_BEGIN("cq_end_op_for_pluck", 0);
@@ -731,7 +729,7 @@ static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
731
729
  }
732
730
 
733
731
  grpc_error *kick_error =
734
- cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), pluck_worker);
732
+ cq->poller_vtable->kick(exec_ctx, POLLSET_FROM_CQ(cq), pluck_worker);
735
733
 
736
734
  gpr_mu_unlock(cq->mu);
737
735
 
@@ -766,9 +764,9 @@ typedef struct {
766
764
  } cq_is_finished_arg;
767
765
 
768
766
  static bool cq_is_next_finished(grpc_exec_ctx *exec_ctx, void *arg) {
769
- cq_is_finished_arg *a = arg;
767
+ cq_is_finished_arg *a = (cq_is_finished_arg *)arg;
770
768
  grpc_completion_queue *cq = a->cq;
771
- cq_next_data *cqd = DATA_FROM_CQ(cq);
769
+ cq_next_data *cqd = (cq_next_data *)DATA_FROM_CQ(cq);
772
770
  GPR_ASSERT(a->stolen_completion == NULL);
773
771
 
774
772
  gpr_atm current_last_seen_things_queued_ever =
@@ -819,7 +817,7 @@ static grpc_event cq_next(grpc_completion_queue *cq, gpr_timespec deadline,
819
817
  void *reserved) {
820
818
  grpc_event ret;
821
819
  gpr_timespec now;
822
- cq_next_data *cqd = DATA_FROM_CQ(cq);
820
+ cq_next_data *cqd = (cq_next_data *)DATA_FROM_CQ(cq);
823
821
 
824
822
  GPR_TIMER_BEGIN("grpc_completion_queue_next", 0);
825
823
 
@@ -882,7 +880,7 @@ static grpc_event cq_next(grpc_completion_queue *cq, gpr_timespec deadline,
882
880
  }
883
881
  }
884
882
 
885
- if (gpr_atm_no_barrier_load(&cqd->pending_events) == 0) {
883
+ if (gpr_atm_acq_load(&cqd->pending_events) == 0) {
886
884
  /* Before returning, check if the queue has any items left over (since
887
885
  gpr_mpscq_pop() can sometimes return NULL even if the queue is not
888
886
  empty. If so, keep retrying but do not return GRPC_QUEUE_SHUTDOWN */
@@ -928,9 +926,9 @@ static grpc_event cq_next(grpc_completion_queue *cq, gpr_timespec deadline,
928
926
  }
929
927
 
930
928
  if (cq_event_queue_num_items(&cqd->queue) > 0 &&
931
- gpr_atm_no_barrier_load(&cqd->pending_events) > 0) {
929
+ gpr_atm_acq_load(&cqd->pending_events) > 0) {
932
930
  gpr_mu_lock(cq->mu);
933
- cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), NULL);
931
+ cq->poller_vtable->kick(&exec_ctx, POLLSET_FROM_CQ(cq), NULL);
934
932
  gpr_mu_unlock(cq->mu);
935
933
  }
936
934
 
@@ -952,7 +950,7 @@ static grpc_event cq_next(grpc_completion_queue *cq, gpr_timespec deadline,
952
950
  this function */
953
951
  static void cq_finish_shutdown_next(grpc_exec_ctx *exec_ctx,
954
952
  grpc_completion_queue *cq) {
955
- cq_next_data *cqd = DATA_FROM_CQ(cq);
953
+ cq_next_data *cqd = (cq_next_data *)DATA_FROM_CQ(cq);
956
954
 
957
955
  GPR_ASSERT(cqd->shutdown_called);
958
956
  GPR_ASSERT(gpr_atm_no_barrier_load(&cqd->pending_events) == 0);
@@ -963,7 +961,7 @@ static void cq_finish_shutdown_next(grpc_exec_ctx *exec_ctx,
963
961
 
964
962
  static void cq_shutdown_next(grpc_exec_ctx *exec_ctx,
965
963
  grpc_completion_queue *cq) {
966
- cq_next_data *cqd = DATA_FROM_CQ(cq);
964
+ cq_next_data *cqd = (cq_next_data *)DATA_FROM_CQ(cq);
967
965
 
968
966
  /* Need an extra ref for cq here because:
969
967
  * We call cq_finish_shutdown_next() below, that would call pollset shutdown.
@@ -976,10 +974,12 @@ static void cq_shutdown_next(grpc_exec_ctx *exec_ctx,
976
974
  if (cqd->shutdown_called) {
977
975
  gpr_mu_unlock(cq->mu);
978
976
  GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
979
- GPR_TIMER_END("grpc_completion_queue_shutdown", 0);
980
977
  return;
981
978
  }
982
979
  cqd->shutdown_called = true;
980
+ /* Doing a full_fetch_add (i.e acq/release) here to match with
981
+ * cq_begin_op_for_next and and cq_end_op_for_next functions which read/write
982
+ * on this counter without necessarily holding a lock on cq */
983
983
  if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
984
984
  cq_finish_shutdown_next(exec_ctx, cq);
985
985
  }
@@ -994,7 +994,7 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cq,
994
994
 
995
995
  static int add_plucker(grpc_completion_queue *cq, void *tag,
996
996
  grpc_pollset_worker **worker) {
997
- cq_pluck_data *cqd = DATA_FROM_CQ(cq);
997
+ cq_pluck_data *cqd = (cq_pluck_data *)DATA_FROM_CQ(cq);
998
998
  if (cqd->num_pluckers == GRPC_MAX_COMPLETION_QUEUE_PLUCKERS) {
999
999
  return 0;
1000
1000
  }
@@ -1006,7 +1006,7 @@ static int add_plucker(grpc_completion_queue *cq, void *tag,
1006
1006
 
1007
1007
  static void del_plucker(grpc_completion_queue *cq, void *tag,
1008
1008
  grpc_pollset_worker **worker) {
1009
- cq_pluck_data *cqd = DATA_FROM_CQ(cq);
1009
+ cq_pluck_data *cqd = (cq_pluck_data *)DATA_FROM_CQ(cq);
1010
1010
  for (int i = 0; i < cqd->num_pluckers; i++) {
1011
1011
  if (cqd->pluckers[i].tag == tag && cqd->pluckers[i].worker == worker) {
1012
1012
  cqd->num_pluckers--;
@@ -1018,9 +1018,9 @@ static void del_plucker(grpc_completion_queue *cq, void *tag,
1018
1018
  }
1019
1019
 
1020
1020
  static bool cq_is_pluck_finished(grpc_exec_ctx *exec_ctx, void *arg) {
1021
- cq_is_finished_arg *a = arg;
1021
+ cq_is_finished_arg *a = (cq_is_finished_arg *)arg;
1022
1022
  grpc_completion_queue *cq = a->cq;
1023
- cq_pluck_data *cqd = DATA_FROM_CQ(cq);
1023
+ cq_pluck_data *cqd = (cq_pluck_data *)DATA_FROM_CQ(cq);
1024
1024
 
1025
1025
  GPR_ASSERT(a->stolen_completion == NULL);
1026
1026
  gpr_atm current_last_seen_things_queued_ever =
@@ -1057,7 +1057,7 @@ static grpc_event cq_pluck(grpc_completion_queue *cq, void *tag,
1057
1057
  grpc_cq_completion *prev;
1058
1058
  grpc_pollset_worker *worker = NULL;
1059
1059
  gpr_timespec now;
1060
- cq_pluck_data *cqd = DATA_FROM_CQ(cq);
1060
+ cq_pluck_data *cqd = (cq_pluck_data *)DATA_FROM_CQ(cq);
1061
1061
 
1062
1062
  GPR_TIMER_BEGIN("grpc_completion_queue_pluck", 0);
1063
1063
 
@@ -1181,7 +1181,7 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, void *tag,
1181
1181
 
1182
1182
  static void cq_finish_shutdown_pluck(grpc_exec_ctx *exec_ctx,
1183
1183
  grpc_completion_queue *cq) {
1184
- cq_pluck_data *cqd = DATA_FROM_CQ(cq);
1184
+ cq_pluck_data *cqd = (cq_pluck_data *)DATA_FROM_CQ(cq);
1185
1185
 
1186
1186
  GPR_ASSERT(cqd->shutdown_called);
1187
1187
  GPR_ASSERT(!gpr_atm_no_barrier_load(&cqd->shutdown));
@@ -1195,7 +1195,7 @@ static void cq_finish_shutdown_pluck(grpc_exec_ctx *exec_ctx,
1195
1195
  * merging them is a bit tricky and probably not worth it */
1196
1196
  static void cq_shutdown_pluck(grpc_exec_ctx *exec_ctx,
1197
1197
  grpc_completion_queue *cq) {
1198
- cq_pluck_data *cqd = DATA_FROM_CQ(cq);
1198
+ cq_pluck_data *cqd = (cq_pluck_data *)DATA_FROM_CQ(cq);
1199
1199
 
1200
1200
  /* Need an extra ref for cq here because:
1201
1201
  * We call cq_finish_shutdown_pluck() below, that would call pollset shutdown.
@@ -1208,7 +1208,6 @@ static void cq_shutdown_pluck(grpc_exec_ctx *exec_ctx,
1208
1208
  if (cqd->shutdown_called) {
1209
1209
  gpr_mu_unlock(cq->mu);
1210
1210
  GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down (pluck cq)");
1211
- GPR_TIMER_END("grpc_completion_queue_shutdown", 0);
1212
1211
  return;
1213
1212
  }
1214
1213
  cqd->shutdown_called = true;