grpc 1.4.5 → 1.6.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 (928) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1235 -1100
  3. data/etc/roots.pem +0 -412
  4. data/include/grpc/byte_buffer.h +10 -25
  5. data/include/grpc/byte_buffer_reader.h +10 -25
  6. data/include/grpc/census.h +10 -25
  7. data/include/grpc/compression.h +10 -25
  8. data/include/grpc/grpc.h +15 -26
  9. data/include/grpc/grpc_cronet.h +10 -25
  10. data/include/grpc/grpc_posix.h +10 -25
  11. data/include/grpc/grpc_security.h +10 -25
  12. data/include/grpc/grpc_security_constants.h +10 -25
  13. data/include/grpc/impl/codegen/atm.h +11 -25
  14. data/include/grpc/impl/codegen/atm_gcc_atomic.h +10 -25
  15. data/include/grpc/impl/codegen/atm_gcc_sync.h +10 -25
  16. data/include/grpc/impl/codegen/atm_windows.h +10 -25
  17. data/include/grpc/impl/codegen/byte_buffer_reader.h +11 -26
  18. data/include/grpc/impl/codegen/compression_types.h +12 -27
  19. data/include/grpc/impl/codegen/connectivity_state.h +10 -25
  20. data/include/grpc/impl/codegen/exec_ctx_fwd.h +10 -25
  21. data/include/grpc/impl/codegen/gpr_slice.h +10 -25
  22. data/include/grpc/impl/codegen/gpr_types.h +10 -25
  23. data/include/grpc/impl/codegen/grpc_types.h +42 -43
  24. data/include/grpc/impl/codegen/port_platform.h +10 -25
  25. data/include/grpc/impl/codegen/propagation_bits.h +10 -25
  26. data/include/grpc/impl/codegen/slice.h +13 -28
  27. data/include/grpc/impl/codegen/status.h +10 -25
  28. data/include/grpc/impl/codegen/sync.h +10 -25
  29. data/include/grpc/impl/codegen/sync_generic.h +10 -25
  30. data/include/grpc/impl/codegen/sync_posix.h +10 -25
  31. data/include/grpc/impl/codegen/sync_windows.h +10 -25
  32. data/include/grpc/load_reporting.h +10 -25
  33. data/include/grpc/slice.h +10 -25
  34. data/include/grpc/slice_buffer.h +10 -25
  35. data/include/grpc/status.h +10 -25
  36. data/include/grpc/support/alloc.h +10 -25
  37. data/include/grpc/support/atm.h +10 -25
  38. data/include/grpc/support/atm_gcc_atomic.h +10 -25
  39. data/include/grpc/support/atm_gcc_sync.h +10 -25
  40. data/include/grpc/support/atm_windows.h +10 -25
  41. data/include/grpc/support/avl.h +46 -49
  42. data/include/grpc/support/cmdline.h +10 -25
  43. data/include/grpc/support/cpu.h +10 -25
  44. data/include/grpc/support/histogram.h +10 -25
  45. data/include/grpc/support/host_port.h +10 -25
  46. data/include/grpc/support/log.h +10 -25
  47. data/include/grpc/support/log_windows.h +10 -25
  48. data/include/grpc/support/port_platform.h +10 -25
  49. data/include/grpc/support/string_util.h +10 -25
  50. data/include/grpc/support/subprocess.h +10 -25
  51. data/include/grpc/support/sync.h +10 -25
  52. data/include/grpc/support/sync_generic.h +10 -25
  53. data/include/grpc/support/sync_posix.h +10 -25
  54. data/include/grpc/support/sync_windows.h +10 -25
  55. data/include/grpc/support/thd.h +10 -25
  56. data/include/grpc/support/time.h +10 -25
  57. data/include/grpc/support/tls.h +10 -25
  58. data/include/grpc/support/tls_gcc.h +10 -25
  59. data/include/grpc/support/tls_msvc.h +10 -25
  60. data/include/grpc/support/tls_pthread.h +10 -25
  61. data/include/grpc/support/useful.h +10 -25
  62. data/include/grpc/support/workaround_list.h +11 -26
  63. data/src/boringssl/err_data.c +277 -259
  64. data/src/core/ext/census/aggregation.h +10 -25
  65. data/src/core/ext/census/base_resources.c +10 -25
  66. data/src/core/ext/census/base_resources.h +10 -25
  67. data/src/core/ext/census/census_interface.h +10 -25
  68. data/src/core/ext/census/census_rpc_stats.h +10 -25
  69. data/src/core/ext/census/context.c +10 -25
  70. data/src/core/ext/census/gen/census.pb.c +10 -25
  71. data/src/core/ext/census/gen/census.pb.h +10 -25
  72. data/src/core/ext/census/gen/trace_context.pb.c +10 -25
  73. data/src/core/ext/census/gen/trace_context.pb.h +10 -25
  74. data/src/core/ext/census/grpc_context.c +10 -25
  75. data/src/core/ext/census/grpc_filter.c +11 -26
  76. data/src/core/ext/census/grpc_filter.h +10 -25
  77. data/src/core/ext/census/grpc_plugin.c +10 -25
  78. data/src/core/ext/census/initialize.c +10 -25
  79. data/src/core/ext/census/intrusive_hash_map.c +10 -25
  80. data/src/core/ext/census/intrusive_hash_map.h +10 -25
  81. data/src/core/ext/census/intrusive_hash_map_internal.h +10 -25
  82. data/src/core/ext/census/mlog.c +10 -25
  83. data/src/core/ext/census/mlog.h +10 -25
  84. data/src/core/ext/census/operation.c +10 -25
  85. data/src/core/ext/census/placeholders.c +10 -25
  86. data/src/core/ext/census/resource.c +10 -25
  87. data/src/core/ext/census/resource.h +10 -25
  88. data/src/core/ext/census/rpc_metric_id.h +10 -25
  89. data/src/core/ext/census/trace_context.c +10 -25
  90. data/src/core/ext/census/trace_context.h +10 -25
  91. data/src/core/ext/census/trace_label.h +10 -25
  92. data/src/core/ext/census/trace_propagation.h +10 -25
  93. data/src/core/ext/census/trace_status.h +10 -25
  94. data/src/core/ext/census/trace_string.h +10 -25
  95. data/src/core/ext/census/tracing.c +10 -26
  96. data/src/core/ext/census/tracing.h +10 -25
  97. data/src/core/ext/filters/client_channel/channel_connectivity.c +20 -33
  98. data/src/core/ext/filters/client_channel/client_channel.c +617 -520
  99. data/src/core/ext/filters/client_channel/client_channel.h +15 -28
  100. data/src/core/ext/filters/client_channel/client_channel_factory.c +13 -31
  101. data/src/core/ext/filters/client_channel/client_channel_factory.h +10 -25
  102. data/src/core/ext/filters/client_channel/client_channel_plugin.c +16 -29
  103. data/src/core/ext/filters/client_channel/connector.c +10 -25
  104. data/src/core/ext/filters/client_channel/connector.h +10 -25
  105. data/src/core/ext/filters/client_channel/http_connect_handshaker.c +15 -30
  106. data/src/core/ext/filters/client_channel/http_connect_handshaker.h +10 -25
  107. data/src/core/ext/filters/client_channel/http_proxy.c +112 -38
  108. data/src/core/ext/filters/client_channel/http_proxy.h +10 -25
  109. data/src/core/ext/filters/client_channel/lb_policy.c +32 -36
  110. data/src/core/ext/filters/client_channel/lb_policy.h +24 -27
  111. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +14 -30
  112. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +10 -25
  113. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +464 -279
  114. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +10 -25
  115. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +15 -28
  116. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c +40 -48
  117. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +65 -49
  118. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +31 -31
  119. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +47 -32
  120. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +11 -26
  121. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +13 -9
  122. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +27 -21
  123. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +373 -136
  124. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +504 -279
  125. data/src/core/ext/filters/client_channel/lb_policy_factory.c +12 -31
  126. data/src/core/ext/filters/client_channel/lb_policy_factory.h +12 -27
  127. data/src/core/ext/filters/client_channel/lb_policy_registry.c +10 -25
  128. data/src/core/ext/filters/client_channel/lb_policy_registry.h +10 -25
  129. data/src/core/ext/filters/client_channel/parse_address.c +10 -25
  130. data/src/core/ext/filters/client_channel/parse_address.h +10 -25
  131. data/src/core/ext/filters/client_channel/proxy_mapper.c +10 -25
  132. data/src/core/ext/filters/client_channel/proxy_mapper.h +10 -25
  133. data/src/core/ext/filters/client_channel/proxy_mapper_registry.c +10 -25
  134. data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +10 -25
  135. data/src/core/ext/filters/client_channel/resolver.c +33 -38
  136. data/src/core/ext/filters/client_channel/resolver.h +19 -30
  137. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +153 -50
  138. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +14 -27
  139. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +33 -30
  140. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +326 -116
  141. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +35 -36
  142. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c +60 -0
  143. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c +19 -34
  144. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c +254 -0
  145. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +60 -0
  146. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c +16 -28
  147. data/src/core/ext/filters/client_channel/resolver_factory.c +10 -25
  148. data/src/core/ext/filters/client_channel/resolver_factory.h +10 -25
  149. data/src/core/ext/filters/client_channel/resolver_registry.c +10 -25
  150. data/src/core/ext/filters/client_channel/resolver_registry.h +10 -25
  151. data/src/core/ext/filters/client_channel/retry_throttle.c +23 -34
  152. data/src/core/ext/filters/client_channel/retry_throttle.h +10 -25
  153. data/src/core/ext/filters/client_channel/subchannel.c +33 -55
  154. data/src/core/ext/filters/client_channel/subchannel.h +16 -26
  155. data/src/core/ext/filters/client_channel/subchannel_index.c +55 -92
  156. data/src/core/ext/filters/client_channel/subchannel_index.h +26 -29
  157. data/src/core/ext/filters/client_channel/uri_parser.c +10 -25
  158. data/src/core/ext/filters/client_channel/uri_parser.h +10 -25
  159. data/src/core/ext/filters/deadline/deadline_filter.c +30 -45
  160. data/src/core/ext/filters/deadline/deadline_filter.h +10 -25
  161. data/src/core/ext/filters/http/client/http_client_filter.c +255 -294
  162. data/src/core/ext/filters/http/client/http_client_filter.h +10 -25
  163. data/src/core/ext/filters/http/http_filters_plugin.c +11 -26
  164. data/src/core/ext/filters/http/message_compress/message_compress_filter.c +133 -105
  165. data/src/core/ext/filters/http/message_compress/message_compress_filter.h +10 -25
  166. data/src/core/ext/filters/http/server/http_server_filter.c +17 -32
  167. data/src/core/ext/filters/http/server/http_server_filter.h +10 -25
  168. data/src/core/ext/filters/load_reporting/load_reporting.c +11 -30
  169. data/src/core/ext/filters/load_reporting/load_reporting.h +10 -25
  170. data/src/core/ext/filters/load_reporting/load_reporting_filter.c +11 -26
  171. data/src/core/ext/filters/load_reporting/load_reporting_filter.h +10 -25
  172. data/src/core/ext/filters/max_age/max_age_filter.c +28 -43
  173. data/src/core/ext/filters/max_age/max_age_filter.h +10 -25
  174. data/src/core/ext/filters/message_size/message_size_filter.c +24 -37
  175. data/src/core/ext/filters/message_size/message_size_filter.h +10 -25
  176. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c +16 -31
  177. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +10 -25
  178. data/src/core/ext/filters/workarounds/workaround_utils.c +12 -26
  179. data/src/core/ext/filters/workarounds/workaround_utils.h +11 -26
  180. data/src/core/ext/transport/chttp2/alpn/alpn.c +10 -25
  181. data/src/core/ext/transport/chttp2/alpn/alpn.h +10 -25
  182. data/src/core/ext/transport/chttp2/client/chttp2_connector.c +13 -28
  183. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +10 -25
  184. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +13 -30
  185. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +12 -29
  186. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +13 -30
  187. data/src/core/ext/transport/chttp2/server/chttp2_server.c +11 -26
  188. data/src/core/ext/transport/chttp2/server/chttp2_server.h +10 -25
  189. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +10 -25
  190. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +10 -25
  191. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +10 -25
  192. data/src/core/ext/transport/chttp2/transport/bin_decoder.c +11 -25
  193. data/src/core/ext/transport/chttp2/transport/bin_decoder.h +10 -25
  194. data/src/core/ext/transport/chttp2/transport/bin_encoder.c +10 -25
  195. data/src/core/ext/transport/chttp2/transport/bin_encoder.h +10 -25
  196. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +15 -27
  197. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +421 -443
  198. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +14 -25
  199. data/src/core/ext/transport/chttp2/transport/flow_control.c +500 -0
  200. data/src/core/ext/transport/chttp2/transport/frame.h +10 -25
  201. data/src/core/ext/transport/chttp2/transport/frame_data.c +20 -28
  202. data/src/core/ext/transport/chttp2/transport/frame_data.h +10 -25
  203. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +10 -25
  204. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +10 -25
  205. data/src/core/ext/transport/chttp2/transport/frame_ping.c +11 -26
  206. data/src/core/ext/transport/chttp2/transport/frame_ping.h +10 -25
  207. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +11 -26
  208. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +10 -25
  209. data/src/core/ext/transport/chttp2/transport/frame_settings.c +16 -29
  210. data/src/core/ext/transport/chttp2/transport/frame_settings.h +10 -25
  211. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +17 -33
  212. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +10 -25
  213. data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +18 -31
  214. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +12 -25
  215. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +15 -30
  216. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +10 -25
  217. data/src/core/ext/transport/chttp2/transport/hpack_table.c +10 -25
  218. data/src/core/ext/transport/chttp2/transport/hpack_table.h +10 -25
  219. data/src/core/ext/transport/chttp2/transport/http2_settings.c +10 -25
  220. data/src/core/ext/transport/chttp2/transport/http2_settings.h +10 -25
  221. data/src/core/ext/transport/chttp2/transport/huffsyms.c +10 -25
  222. data/src/core/ext/transport/chttp2/transport/huffsyms.h +10 -25
  223. data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +10 -25
  224. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +10 -25
  225. data/src/core/ext/transport/chttp2/transport/internal.h +191 -179
  226. data/src/core/ext/transport/chttp2/transport/parsing.c +33 -102
  227. data/src/core/ext/transport/chttp2/transport/stream_lists.c +26 -28
  228. data/src/core/ext/transport/chttp2/transport/stream_map.c +10 -25
  229. data/src/core/ext/transport/chttp2/transport/stream_map.h +10 -25
  230. data/src/core/ext/transport/chttp2/transport/varint.c +14 -25
  231. data/src/core/ext/transport/chttp2/transport/varint.h +10 -25
  232. data/src/core/ext/transport/chttp2/transport/writing.c +164 -106
  233. data/src/core/ext/transport/inproc/inproc_plugin.c +29 -0
  234. data/src/core/ext/transport/inproc/inproc_transport.c +1303 -0
  235. data/src/core/ext/transport/inproc/inproc_transport.h +41 -0
  236. data/src/core/lib/channel/channel_args.c +52 -27
  237. data/src/core/lib/channel/channel_args.h +18 -27
  238. data/src/core/lib/channel/channel_stack.c +11 -26
  239. data/src/core/lib/channel/channel_stack.h +12 -27
  240. data/src/core/lib/channel/channel_stack_builder.c +11 -26
  241. data/src/core/lib/channel/channel_stack_builder.h +10 -25
  242. data/src/core/lib/channel/connected_channel.c +10 -25
  243. data/src/core/lib/channel/connected_channel.h +10 -25
  244. data/src/core/lib/channel/context.h +10 -25
  245. data/src/core/lib/channel/handshaker.c +14 -29
  246. data/src/core/lib/channel/handshaker.h +10 -25
  247. data/src/core/lib/channel/handshaker_factory.c +10 -25
  248. data/src/core/lib/channel/handshaker_factory.h +10 -25
  249. data/src/core/lib/channel/handshaker_registry.c +10 -25
  250. data/src/core/lib/channel/handshaker_registry.h +10 -25
  251. data/src/core/lib/compression/algorithm_metadata.h +10 -25
  252. data/src/core/lib/compression/compression.c +10 -25
  253. data/src/core/lib/compression/message_compress.c +10 -25
  254. data/src/core/lib/compression/message_compress.h +10 -25
  255. data/src/core/lib/compression/stream_compression.c +191 -0
  256. data/src/core/lib/compression/stream_compression.h +90 -0
  257. data/src/core/lib/debug/trace.c +28 -29
  258. data/src/core/lib/debug/trace.h +16 -30
  259. data/src/core/lib/http/format_request.c +10 -25
  260. data/src/core/lib/http/format_request.h +10 -25
  261. data/src/core/lib/http/httpcli.c +19 -35
  262. data/src/core/lib/http/httpcli.h +10 -25
  263. data/src/core/lib/http/httpcli_security_connector.c +17 -30
  264. data/src/core/lib/http/parser.c +11 -26
  265. data/src/core/lib/http/parser.h +10 -25
  266. data/src/core/lib/iomgr/closure.c +62 -25
  267. data/src/core/lib/iomgr/closure.h +81 -26
  268. data/src/core/lib/iomgr/combiner.c +103 -200
  269. data/src/core/lib/iomgr/combiner.h +14 -32
  270. data/src/core/lib/iomgr/endpoint.c +10 -29
  271. data/src/core/lib/iomgr/endpoint.h +10 -29
  272. data/src/core/lib/iomgr/endpoint_pair.h +10 -25
  273. data/src/core/lib/iomgr/endpoint_pair_posix.c +10 -25
  274. data/src/core/lib/iomgr/endpoint_pair_uv.c +10 -25
  275. data/src/core/lib/iomgr/endpoint_pair_windows.c +10 -25
  276. data/src/core/lib/iomgr/error.c +45 -46
  277. data/src/core/lib/iomgr/error.h +21 -34
  278. data/src/core/lib/iomgr/error_internal.h +10 -25
  279. data/src/core/lib/iomgr/ev_epoll1_linux.c +279 -179
  280. data/src/core/lib/iomgr/ev_epoll1_linux.h +10 -25
  281. data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +75 -264
  282. data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.h +10 -25
  283. data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +44 -199
  284. data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.h +10 -25
  285. data/src/core/lib/iomgr/ev_epollex_linux.c +184 -247
  286. data/src/core/lib/iomgr/ev_epollex_linux.h +10 -25
  287. data/src/core/lib/iomgr/ev_epollsig_linux.c +116 -323
  288. data/src/core/lib/iomgr/ev_epollsig_linux.h +10 -25
  289. data/src/core/lib/iomgr/ev_poll_posix.c +328 -184
  290. data/src/core/lib/iomgr/ev_poll_posix.h +10 -25
  291. data/src/core/lib/iomgr/ev_posix.c +25 -56
  292. data/src/core/lib/iomgr/ev_posix.h +15 -44
  293. data/src/core/lib/iomgr/ev_windows.c +11 -26
  294. data/src/core/lib/iomgr/exec_ctx.c +36 -45
  295. data/src/core/lib/iomgr/exec_ctx.h +10 -25
  296. data/src/core/lib/iomgr/executor.c +152 -127
  297. data/src/core/lib/iomgr/executor.h +18 -26
  298. data/src/core/lib/iomgr/gethostname.h +26 -0
  299. data/src/core/lib/iomgr/gethostname_fallback.c +27 -0
  300. data/src/core/lib/iomgr/gethostname_host_name_max.c +37 -0
  301. data/src/core/lib/iomgr/gethostname_sysconf.c +37 -0
  302. data/src/core/lib/iomgr/iocp_windows.c +10 -25
  303. data/src/core/lib/iomgr/iocp_windows.h +10 -25
  304. data/src/core/lib/iomgr/iomgr.c +17 -28
  305. data/src/core/lib/iomgr/iomgr.h +12 -27
  306. data/src/core/lib/iomgr/iomgr_internal.h +10 -25
  307. data/src/core/lib/iomgr/iomgr_posix.c +11 -26
  308. data/src/core/lib/iomgr/iomgr_posix.h +10 -25
  309. data/src/core/lib/iomgr/iomgr_uv.c +19 -26
  310. data/src/core/lib/iomgr/iomgr_uv.h +37 -0
  311. data/src/core/lib/iomgr/iomgr_windows.c +10 -25
  312. data/src/core/lib/iomgr/is_epollexclusive_available.c +10 -25
  313. data/src/core/lib/iomgr/is_epollexclusive_available.h +10 -25
  314. data/src/core/lib/iomgr/load_file.c +10 -25
  315. data/src/core/lib/iomgr/load_file.h +10 -25
  316. data/src/core/lib/iomgr/lockfree_event.c +22 -35
  317. data/src/core/lib/iomgr/lockfree_event.h +13 -27
  318. data/src/core/lib/iomgr/nameser.h +104 -0
  319. data/src/core/lib/iomgr/network_status_tracker.c +10 -25
  320. data/src/core/lib/iomgr/network_status_tracker.h +10 -25
  321. data/src/core/lib/iomgr/polling_entity.c +10 -25
  322. data/src/core/lib/iomgr/polling_entity.h +14 -34
  323. data/src/core/lib/iomgr/pollset.h +14 -25
  324. data/src/core/lib/iomgr/pollset_set.h +10 -25
  325. data/src/core/lib/iomgr/pollset_set_uv.c +10 -25
  326. data/src/core/lib/iomgr/pollset_set_windows.c +10 -25
  327. data/src/core/lib/iomgr/pollset_set_windows.h +10 -25
  328. data/src/core/lib/iomgr/pollset_uv.c +25 -26
  329. data/src/core/lib/iomgr/pollset_uv.h +10 -25
  330. data/src/core/lib/iomgr/pollset_windows.c +17 -27
  331. data/src/core/lib/iomgr/pollset_windows.h +10 -25
  332. data/src/core/lib/iomgr/port.h +24 -25
  333. data/src/core/lib/iomgr/resolve_address.h +10 -25
  334. data/src/core/lib/iomgr/resolve_address_posix.c +13 -28
  335. data/src/core/lib/iomgr/resolve_address_uv.c +31 -35
  336. data/src/core/lib/iomgr/resolve_address_windows.c +13 -28
  337. data/src/core/lib/iomgr/resource_quota.c +52 -67
  338. data/src/core/lib/iomgr/resource_quota.h +10 -25
  339. data/src/core/lib/iomgr/sockaddr.h +10 -25
  340. data/src/core/lib/iomgr/sockaddr_posix.h +10 -25
  341. data/src/core/lib/iomgr/sockaddr_utils.c +15 -25
  342. data/src/core/lib/iomgr/sockaddr_utils.h +12 -25
  343. data/src/core/lib/iomgr/sockaddr_windows.h +10 -25
  344. data/src/core/lib/iomgr/socket_factory_posix.c +13 -31
  345. data/src/core/lib/iomgr/socket_factory_posix.h +10 -25
  346. data/src/core/lib/iomgr/socket_mutator.c +14 -31
  347. data/src/core/lib/iomgr/socket_mutator.h +10 -25
  348. data/src/core/lib/iomgr/socket_utils.h +10 -25
  349. data/src/core/lib/iomgr/socket_utils_common_posix.c +10 -25
  350. data/src/core/lib/iomgr/socket_utils_linux.c +10 -25
  351. data/src/core/lib/iomgr/socket_utils_posix.c +10 -25
  352. data/src/core/lib/iomgr/socket_utils_posix.h +10 -25
  353. data/src/core/lib/iomgr/socket_utils_uv.c +10 -25
  354. data/src/core/lib/iomgr/socket_utils_windows.c +10 -25
  355. data/src/core/lib/iomgr/socket_windows.c +12 -27
  356. data/src/core/lib/iomgr/socket_windows.h +10 -25
  357. data/src/core/lib/iomgr/sys_epoll_wrapper.h +10 -25
  358. data/src/core/lib/iomgr/tcp_client.h +10 -25
  359. data/src/core/lib/iomgr/tcp_client_posix.c +21 -34
  360. data/src/core/lib/iomgr/tcp_client_posix.h +10 -25
  361. data/src/core/lib/iomgr/tcp_client_uv.c +18 -27
  362. data/src/core/lib/iomgr/tcp_client_windows.c +14 -29
  363. data/src/core/lib/iomgr/tcp_posix.c +36 -55
  364. data/src/core/lib/iomgr/tcp_posix.h +10 -25
  365. data/src/core/lib/iomgr/tcp_server.h +10 -25
  366. data/src/core/lib/iomgr/tcp_server_posix.c +16 -31
  367. data/src/core/lib/iomgr/tcp_server_utils_posix.h +10 -25
  368. data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +11 -26
  369. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c +10 -25
  370. data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c +10 -25
  371. data/src/core/lib/iomgr/tcp_server_uv.c +103 -64
  372. data/src/core/lib/iomgr/tcp_server_windows.c +14 -29
  373. data/src/core/lib/iomgr/tcp_uv.c +41 -45
  374. data/src/core/lib/iomgr/tcp_uv.h +10 -25
  375. data/src/core/lib/iomgr/tcp_windows.c +39 -53
  376. data/src/core/lib/iomgr/tcp_windows.h +10 -25
  377. data/src/core/lib/iomgr/time_averaged_stats.c +10 -25
  378. data/src/core/lib/iomgr/time_averaged_stats.h +10 -25
  379. data/src/core/lib/iomgr/timer.h +18 -27
  380. data/src/core/lib/iomgr/timer_generic.c +91 -87
  381. data/src/core/lib/iomgr/timer_generic.h +10 -25
  382. data/src/core/lib/iomgr/timer_heap.c +10 -25
  383. data/src/core/lib/iomgr/timer_heap.h +10 -25
  384. data/src/core/lib/iomgr/timer_manager.c +178 -100
  385. data/src/core/lib/iomgr/timer_manager.h +10 -25
  386. data/src/core/lib/iomgr/timer_uv.c +23 -33
  387. data/src/core/lib/iomgr/timer_uv.h +10 -25
  388. data/src/core/lib/iomgr/udp_server.c +17 -32
  389. data/src/core/lib/iomgr/udp_server.h +10 -25
  390. data/src/core/lib/iomgr/unix_sockets_posix.c +10 -25
  391. data/src/core/lib/iomgr/unix_sockets_posix.h +10 -25
  392. data/src/core/lib/iomgr/unix_sockets_posix_noop.c +10 -25
  393. data/src/core/lib/iomgr/wakeup_fd_cv.c +10 -25
  394. data/src/core/lib/iomgr/wakeup_fd_cv.h +13 -28
  395. data/src/core/lib/iomgr/wakeup_fd_eventfd.c +10 -25
  396. data/src/core/lib/iomgr/wakeup_fd_nospecial.c +10 -25
  397. data/src/core/lib/iomgr/wakeup_fd_pipe.c +10 -25
  398. data/src/core/lib/iomgr/wakeup_fd_pipe.h +10 -25
  399. data/src/core/lib/iomgr/wakeup_fd_posix.c +10 -25
  400. data/src/core/lib/iomgr/wakeup_fd_posix.h +10 -25
  401. data/src/core/lib/json/json.c +10 -25
  402. data/src/core/lib/json/json.h +10 -25
  403. data/src/core/lib/json/json_common.h +10 -25
  404. data/src/core/lib/json/json_reader.c +11 -25
  405. data/src/core/lib/json/json_reader.h +10 -25
  406. data/src/core/lib/json/json_string.c +10 -25
  407. data/src/core/lib/json/json_writer.c +10 -25
  408. data/src/core/lib/json/json_writer.h +10 -25
  409. data/src/core/lib/profiling/basic_timers.c +10 -25
  410. data/src/core/lib/profiling/stap_timers.c +10 -25
  411. data/src/core/lib/profiling/timers.h +10 -25
  412. data/src/core/lib/security/context/security_context.c +32 -40
  413. data/src/core/lib/security/context/security_context.h +15 -26
  414. data/src/core/lib/security/credentials/composite/composite_credentials.c +76 -81
  415. data/src/core/lib/security/credentials/composite/composite_credentials.h +10 -25
  416. data/src/core/lib/security/credentials/credentials.c +29 -49
  417. data/src/core/lib/security/credentials/credentials.h +48 -61
  418. data/src/core/lib/security/credentials/credentials_metadata.c +34 -78
  419. data/src/core/lib/security/credentials/fake/fake_credentials.c +33 -56
  420. data/src/core/lib/security/credentials/fake/fake_credentials.h +12 -27
  421. data/src/core/lib/security/credentials/google_default/credentials_generic.c +10 -25
  422. data/src/core/lib/security/credentials/google_default/google_default_credentials.c +12 -27
  423. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +10 -25
  424. data/src/core/lib/security/credentials/iam/iam_credentials.c +40 -40
  425. data/src/core/lib/security/credentials/iam/iam_credentials.h +11 -26
  426. data/src/core/lib/security/credentials/jwt/json_token.c +10 -25
  427. data/src/core/lib/security/credentials/jwt/json_token.h +10 -25
  428. data/src/core/lib/security/credentials/jwt/jwt_credentials.c +45 -48
  429. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +11 -26
  430. data/src/core/lib/security/credentials/jwt/jwt_verifier.c +53 -33
  431. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +10 -25
  432. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +155 -87
  433. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +24 -28
  434. data/src/core/lib/security/credentials/plugin/plugin_credentials.c +118 -82
  435. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +24 -27
  436. data/src/core/lib/security/credentials/ssl/ssl_credentials.c +13 -32
  437. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +10 -25
  438. data/src/core/lib/security/transport/auth_filters.h +10 -25
  439. data/src/core/lib/security/transport/client_auth_filter.c +217 -112
  440. data/src/core/lib/security/transport/lb_targets_info.c +16 -32
  441. data/src/core/lib/security/transport/lb_targets_info.h +10 -25
  442. data/src/core/lib/security/transport/secure_endpoint.c +29 -43
  443. data/src/core/lib/security/transport/secure_endpoint.h +10 -25
  444. data/src/core/lib/security/transport/security_connector.c +80 -61
  445. data/src/core/lib/security/transport/security_connector.h +35 -35
  446. data/src/core/lib/security/transport/security_handshaker.c +18 -33
  447. data/src/core/lib/security/transport/security_handshaker.h +10 -25
  448. data/src/core/lib/security/transport/server_auth_filter.c +62 -116
  449. data/src/core/lib/security/transport/tsi_error.c +10 -25
  450. data/src/core/lib/security/transport/tsi_error.h +10 -25
  451. data/src/core/lib/security/util/json_util.c +10 -25
  452. data/src/core/lib/security/util/json_util.h +10 -25
  453. data/src/core/lib/slice/b64.c +10 -25
  454. data/src/core/lib/slice/b64.h +10 -25
  455. data/src/core/lib/slice/percent_encoding.c +10 -25
  456. data/src/core/lib/slice/percent_encoding.h +10 -25
  457. data/src/core/lib/slice/slice.c +10 -25
  458. data/src/core/lib/slice/slice_buffer.c +10 -25
  459. data/src/core/lib/slice/slice_hash_table.c +48 -26
  460. data/src/core/lib/slice/slice_hash_table.h +26 -28
  461. data/src/core/lib/slice/slice_intern.c +10 -25
  462. data/src/core/lib/slice/slice_internal.h +10 -25
  463. data/src/core/lib/slice/slice_string_helpers.c +10 -25
  464. data/src/core/lib/slice/slice_string_helpers.h +10 -25
  465. data/src/core/lib/support/alloc.c +10 -25
  466. data/src/core/lib/support/arena.c +12 -27
  467. data/src/core/lib/support/arena.h +10 -25
  468. data/src/core/lib/support/atm.c +17 -32
  469. data/src/core/lib/support/atomic.h +10 -25
  470. data/src/core/lib/support/atomic_with_atm.h +10 -25
  471. data/src/core/lib/support/atomic_with_std.h +10 -25
  472. data/src/core/lib/support/avl.c +101 -101
  473. data/src/core/lib/support/backoff.c +10 -25
  474. data/src/core/lib/support/backoff.h +10 -25
  475. data/src/core/lib/support/block_annotate.h +10 -25
  476. data/src/core/lib/support/cmdline.c +10 -25
  477. data/src/core/lib/support/cpu_iphone.c +10 -25
  478. data/src/core/lib/support/cpu_linux.c +10 -25
  479. data/src/core/lib/support/cpu_posix.c +10 -25
  480. data/src/core/lib/support/cpu_windows.c +10 -25
  481. data/src/core/lib/support/env.h +16 -25
  482. data/src/core/lib/support/env_linux.c +30 -37
  483. data/src/core/lib/support/env_posix.c +15 -25
  484. data/src/core/lib/support/env_windows.c +15 -25
  485. data/src/core/lib/support/histogram.c +10 -25
  486. data/src/core/lib/support/host_port.c +10 -25
  487. data/src/core/lib/support/log.c +20 -29
  488. data/src/core/lib/support/log_android.c +10 -25
  489. data/src/core/lib/support/log_linux.c +13 -26
  490. data/src/core/lib/support/log_posix.c +10 -25
  491. data/src/core/lib/support/log_windows.c +10 -25
  492. data/src/core/lib/support/memory.h +10 -25
  493. data/src/core/lib/support/mpscq.c +11 -49
  494. data/src/core/lib/support/mpscq.h +11 -50
  495. data/src/core/lib/support/murmur_hash.c +12 -25
  496. data/src/core/lib/support/murmur_hash.h +10 -25
  497. data/src/core/lib/support/spinlock.h +10 -25
  498. data/src/core/lib/support/stack_lockfree.c +10 -25
  499. data/src/core/lib/support/stack_lockfree.h +10 -25
  500. data/src/core/lib/support/string.c +10 -25
  501. data/src/core/lib/support/string.h +10 -25
  502. data/src/core/lib/support/string_posix.c +10 -25
  503. data/src/core/lib/support/string_util_windows.c +10 -25
  504. data/src/core/lib/support/string_windows.c +10 -25
  505. data/src/core/lib/support/string_windows.h +10 -25
  506. data/src/core/lib/support/subprocess_posix.c +10 -25
  507. data/src/core/lib/support/subprocess_windows.c +10 -25
  508. data/src/core/lib/support/sync.c +10 -25
  509. data/src/core/lib/support/sync_posix.c +10 -25
  510. data/src/core/lib/support/sync_windows.c +10 -25
  511. data/src/core/lib/support/thd.c +10 -25
  512. data/src/core/lib/support/thd_internal.h +10 -25
  513. data/src/core/lib/support/thd_posix.c +10 -25
  514. data/src/core/lib/support/thd_windows.c +10 -25
  515. data/src/core/lib/support/time.c +10 -25
  516. data/src/core/lib/support/time_posix.c +10 -25
  517. data/src/core/lib/support/time_precise.c +18 -33
  518. data/src/core/lib/support/time_precise.h +10 -25
  519. data/src/core/lib/support/time_windows.c +10 -25
  520. data/src/core/lib/support/tls_pthread.c +10 -25
  521. data/src/core/lib/support/tmpfile.h +10 -25
  522. data/src/core/lib/support/tmpfile_msys.c +10 -25
  523. data/src/core/lib/support/tmpfile_posix.c +10 -25
  524. data/src/core/lib/support/tmpfile_windows.c +10 -25
  525. data/src/core/lib/support/wrap_memcpy.c +10 -25
  526. data/src/core/lib/surface/alarm.c +78 -35
  527. data/src/core/lib/surface/alarm_internal.h +40 -0
  528. data/src/core/lib/surface/api_trace.c +11 -26
  529. data/src/core/lib/surface/api_trace.h +10 -25
  530. data/src/core/lib/surface/byte_buffer.c +10 -25
  531. data/src/core/lib/surface/byte_buffer_reader.c +10 -25
  532. data/src/core/lib/surface/call.c +64 -84
  533. data/src/core/lib/surface/call.h +11 -26
  534. data/src/core/lib/surface/call_details.c +10 -25
  535. data/src/core/lib/surface/call_log_batch.c +10 -25
  536. data/src/core/lib/surface/call_test_only.h +10 -25
  537. data/src/core/lib/surface/channel.c +11 -26
  538. data/src/core/lib/surface/channel.h +11 -26
  539. data/src/core/lib/surface/channel_init.c +10 -25
  540. data/src/core/lib/surface/channel_init.h +10 -25
  541. data/src/core/lib/surface/channel_ping.c +12 -27
  542. data/src/core/lib/surface/channel_stack_type.c +10 -25
  543. data/src/core/lib/surface/channel_stack_type.h +10 -25
  544. data/src/core/lib/surface/completion_queue.c +442 -331
  545. data/src/core/lib/surface/completion_queue.h +16 -33
  546. data/src/core/lib/surface/completion_queue_factory.c +10 -25
  547. data/src/core/lib/surface/completion_queue_factory.h +10 -25
  548. data/src/core/lib/surface/event_string.c +10 -25
  549. data/src/core/lib/surface/event_string.h +10 -25
  550. data/src/core/lib/surface/init.c +38 -47
  551. data/src/core/lib/surface/init.h +10 -25
  552. data/src/core/lib/surface/init_secure.c +20 -27
  553. data/src/core/lib/surface/lame_client.cc +14 -29
  554. data/src/core/lib/surface/lame_client.h +10 -25
  555. data/src/core/lib/surface/metadata_array.c +10 -25
  556. data/src/core/lib/surface/server.c +128 -81
  557. data/src/core/lib/surface/server.h +10 -25
  558. data/src/core/lib/surface/validate_metadata.c +10 -25
  559. data/src/core/lib/surface/validate_metadata.h +10 -25
  560. data/src/core/lib/surface/version.c +11 -26
  561. data/src/core/lib/transport/bdp_estimator.c +19 -29
  562. data/src/core/lib/transport/bdp_estimator.h +16 -29
  563. data/src/core/lib/transport/byte_stream.c +127 -36
  564. data/src/core/lib/transport/byte_stream.h +88 -46
  565. data/src/core/lib/transport/connectivity_state.c +17 -31
  566. data/src/core/lib/transport/connectivity_state.h +10 -25
  567. data/src/core/lib/transport/error_utils.c +10 -25
  568. data/src/core/lib/transport/error_utils.h +10 -25
  569. data/src/core/lib/transport/http2_errors.h +10 -25
  570. data/src/core/lib/transport/metadata.c +87 -85
  571. data/src/core/lib/transport/metadata.h +15 -28
  572. data/src/core/lib/transport/metadata_batch.c +10 -25
  573. data/src/core/lib/transport/metadata_batch.h +10 -25
  574. data/src/core/lib/transport/pid_controller.c +10 -25
  575. data/src/core/lib/transport/pid_controller.h +10 -25
  576. data/src/core/lib/transport/service_config.c +11 -26
  577. data/src/core/lib/transport/service_config.h +10 -25
  578. data/src/core/lib/transport/static_metadata.c +12 -26
  579. data/src/core/lib/transport/static_metadata.h +10 -25
  580. data/src/core/lib/transport/status_conversion.c +10 -25
  581. data/src/core/lib/transport/status_conversion.h +10 -25
  582. data/src/core/lib/transport/timeout_encoding.c +10 -25
  583. data/src/core/lib/transport/timeout_encoding.h +10 -25
  584. data/src/core/lib/transport/transport.c +60 -53
  585. data/src/core/lib/transport/transport.h +36 -34
  586. data/src/core/lib/transport/transport_impl.h +10 -25
  587. data/src/core/lib/transport/transport_op_string.c +10 -28
  588. data/src/core/plugin_registry/grpc_plugin_registry.c +22 -25
  589. data/src/core/tsi/fake_transport_security.c +199 -94
  590. data/src/core/tsi/fake_transport_security.h +11 -26
  591. data/src/core/tsi/gts_transport_security.c +40 -0
  592. data/src/core/tsi/gts_transport_security.h +37 -0
  593. data/src/core/tsi/ssl_transport_security.c +13 -32
  594. data/src/core/tsi/ssl_transport_security.h +10 -25
  595. data/src/core/tsi/ssl_types.h +10 -25
  596. data/src/core/tsi/transport_security.c +48 -78
  597. data/src/core/tsi/transport_security.h +18 -27
  598. data/src/core/tsi/transport_security_adapter.c +17 -29
  599. data/src/core/tsi/transport_security_adapter.h +10 -25
  600. data/src/core/tsi/transport_security_grpc.c +64 -0
  601. data/src/core/tsi/transport_security_grpc.h +80 -0
  602. data/src/core/tsi/transport_security_interface.h +21 -27
  603. data/src/ruby/bin/apis/google/protobuf/empty.rb +10 -25
  604. data/src/ruby/bin/apis/pubsub_demo.rb +10 -25
  605. data/src/ruby/bin/apis/tech/pubsub/proto/pubsub.rb +10 -25
  606. data/src/ruby/bin/apis/tech/pubsub/proto/pubsub_services.rb +10 -25
  607. data/src/ruby/bin/math_client.rb +10 -25
  608. data/src/ruby/bin/math_server.rb +10 -25
  609. data/src/ruby/bin/math_services_pb.rb +10 -25
  610. data/src/ruby/bin/noproto_client.rb +10 -25
  611. data/src/ruby/bin/noproto_server.rb +10 -25
  612. data/src/ruby/ext/grpc/extconf.rb +10 -25
  613. data/src/ruby/ext/grpc/rb_byte_buffer.c +10 -25
  614. data/src/ruby/ext/grpc/rb_byte_buffer.h +10 -25
  615. data/src/ruby/ext/grpc/rb_call.c +44 -25
  616. data/src/ruby/ext/grpc/rb_call.h +10 -25
  617. data/src/ruby/ext/grpc/rb_call_credentials.c +10 -25
  618. data/src/ruby/ext/grpc/rb_call_credentials.h +10 -25
  619. data/src/ruby/ext/grpc/rb_channel.c +10 -25
  620. data/src/ruby/ext/grpc/rb_channel.h +10 -25
  621. data/src/ruby/ext/grpc/rb_channel_args.c +10 -25
  622. data/src/ruby/ext/grpc/rb_channel_args.h +10 -25
  623. data/src/ruby/ext/grpc/rb_channel_credentials.c +10 -25
  624. data/src/ruby/ext/grpc/rb_channel_credentials.h +10 -25
  625. data/src/ruby/ext/grpc/rb_completion_queue.c +10 -25
  626. data/src/ruby/ext/grpc/rb_completion_queue.h +10 -25
  627. data/src/ruby/ext/grpc/rb_compression_options.c +10 -25
  628. data/src/ruby/ext/grpc/rb_compression_options.h +10 -25
  629. data/src/ruby/ext/grpc/rb_event_thread.c +10 -25
  630. data/src/ruby/ext/grpc/rb_event_thread.h +10 -25
  631. data/src/ruby/ext/grpc/rb_grpc.c +10 -25
  632. data/src/ruby/ext/grpc/rb_grpc.h +10 -25
  633. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -25
  634. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +16 -31
  635. data/src/ruby/ext/grpc/rb_loader.c +10 -25
  636. data/src/ruby/ext/grpc/rb_loader.h +10 -25
  637. data/src/ruby/ext/grpc/rb_server.c +10 -25
  638. data/src/ruby/ext/grpc/rb_server.h +10 -25
  639. data/src/ruby/ext/grpc/rb_server_credentials.c +10 -25
  640. data/src/ruby/ext/grpc/rb_server_credentials.h +10 -25
  641. data/src/ruby/lib/grpc.rb +10 -25
  642. data/src/ruby/lib/grpc/core/time_consts.rb +10 -25
  643. data/src/ruby/lib/grpc/errors.rb +16 -30
  644. data/src/ruby/lib/grpc/generic/active_call.rb +25 -27
  645. data/src/ruby/lib/grpc/generic/bidi_call.rb +17 -27
  646. data/src/ruby/lib/grpc/generic/client_stub.rb +10 -25
  647. data/src/ruby/lib/grpc/generic/rpc_desc.rb +10 -25
  648. data/src/ruby/lib/grpc/generic/rpc_server.rb +10 -25
  649. data/src/ruby/lib/grpc/generic/service.rb +10 -25
  650. data/src/ruby/lib/grpc/grpc.rb +10 -25
  651. data/src/ruby/lib/grpc/logconfig.rb +10 -25
  652. data/src/ruby/lib/grpc/notifier.rb +10 -25
  653. data/src/ruby/lib/grpc/version.rb +11 -26
  654. data/src/ruby/pb/generate_proto_ruby.sh +10 -25
  655. data/src/ruby/pb/grpc/health/checker.rb +10 -25
  656. data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +10 -25
  657. data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +10 -25
  658. data/src/ruby/pb/grpc/testing/metrics_services_pb.rb +10 -25
  659. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +10 -25
  660. data/src/ruby/pb/test/client.rb +10 -25
  661. data/src/ruby/pb/test/server.rb +10 -25
  662. data/src/ruby/spec/call_credentials_spec.rb +10 -25
  663. data/src/ruby/spec/call_spec.rb +43 -25
  664. data/src/ruby/spec/channel_connection_spec.rb +10 -25
  665. data/src/ruby/spec/channel_credentials_spec.rb +11 -26
  666. data/src/ruby/spec/channel_spec.rb +10 -25
  667. data/src/ruby/spec/client_auth_spec.rb +10 -25
  668. data/src/ruby/spec/client_server_spec.rb +66 -25
  669. data/src/ruby/spec/compression_options_spec.rb +10 -25
  670. data/src/ruby/spec/error_sanity_spec.rb +10 -25
  671. data/src/ruby/spec/generic/active_call_spec.rb +10 -25
  672. data/src/ruby/spec/generic/client_stub_spec.rb +146 -35
  673. data/src/ruby/spec/generic/rpc_desc_spec.rb +10 -25
  674. data/src/ruby/spec/generic/rpc_server_pool_spec.rb +10 -25
  675. data/src/ruby/spec/generic/rpc_server_spec.rb +124 -34
  676. data/src/ruby/spec/generic/service_spec.rb +10 -25
  677. data/src/ruby/spec/pb/duplicate/codegen_spec.rb +10 -25
  678. data/src/ruby/spec/pb/health/checker_spec.rb +10 -25
  679. data/src/ruby/spec/server_credentials_spec.rb +10 -25
  680. data/src/ruby/spec/server_spec.rb +10 -25
  681. data/src/ruby/spec/spec_helper.rb +10 -25
  682. data/src/ruby/spec/time_consts_spec.rb +10 -25
  683. data/third_party/boringssl/crypto/aes/key_wrap.c +138 -0
  684. data/third_party/boringssl/crypto/asn1/a_bitstr.c +6 -3
  685. data/third_party/boringssl/crypto/asn1/a_enum.c +4 -1
  686. data/third_party/boringssl/crypto/asn1/a_gentm.c +20 -15
  687. data/third_party/boringssl/crypto/asn1/a_int.c +7 -4
  688. data/third_party/boringssl/crypto/asn1/a_object.c +5 -2
  689. data/third_party/boringssl/crypto/asn1/a_time.c +0 -1
  690. data/third_party/boringssl/crypto/asn1/a_utctm.c +1 -2
  691. data/third_party/boringssl/crypto/asn1/asn1_lib.c +5 -2
  692. data/third_party/boringssl/crypto/asn1/asn1_locl.h +35 -0
  693. data/third_party/boringssl/crypto/asn1/tasn_dec.c +3 -1
  694. data/third_party/boringssl/crypto/asn1/tasn_enc.c +6 -3
  695. data/third_party/boringssl/crypto/asn1/tasn_new.c +12 -7
  696. data/third_party/boringssl/crypto/asn1/tasn_utl.c +22 -8
  697. data/third_party/boringssl/crypto/{time_support.c → asn1/time_support.c} +1 -1
  698. data/third_party/boringssl/crypto/asn1/x_long.c +5 -2
  699. data/third_party/boringssl/crypto/base64/base64.c +7 -5
  700. data/third_party/boringssl/crypto/bio/bio.c +24 -10
  701. data/third_party/boringssl/crypto/bio/bio_mem.c +12 -10
  702. data/third_party/boringssl/crypto/bio/connect.c +7 -18
  703. data/third_party/boringssl/crypto/bio/fd.c +3 -6
  704. data/third_party/boringssl/crypto/bio/file.c +6 -6
  705. data/third_party/boringssl/crypto/bio/hexdump.c +4 -2
  706. data/third_party/boringssl/crypto/bio/pair.c +30 -344
  707. data/third_party/boringssl/crypto/bio/socket.c +6 -7
  708. data/third_party/boringssl/crypto/bio/socket_helper.c +4 -3
  709. data/third_party/boringssl/crypto/bn/add.c +1 -1
  710. data/third_party/boringssl/crypto/bn/asm/x86_64-gcc.c +11 -10
  711. data/third_party/boringssl/crypto/bn/bn.c +6 -20
  712. data/third_party/boringssl/crypto/bn/cmp.c +14 -0
  713. data/third_party/boringssl/crypto/bn/convert.c +73 -2
  714. data/third_party/boringssl/crypto/bn/ctx.c +3 -1
  715. data/third_party/boringssl/crypto/bn/div.c +108 -51
  716. data/third_party/boringssl/crypto/bn/exponentiation.c +15 -33
  717. data/third_party/boringssl/crypto/bn/gcd.c +29 -22
  718. data/third_party/boringssl/crypto/bn/generic.c +71 -67
  719. data/third_party/boringssl/crypto/bn/internal.h +19 -6
  720. data/third_party/boringssl/crypto/bn/kronecker.c +1 -0
  721. data/third_party/boringssl/crypto/bn/montgomery.c +9 -10
  722. data/third_party/boringssl/crypto/bn/montgomery_inv.c +47 -0
  723. data/third_party/boringssl/crypto/bn/mul.c +11 -9
  724. data/third_party/boringssl/crypto/bn/random.c +6 -3
  725. data/third_party/boringssl/crypto/bn/rsaz_exp.c +0 -65
  726. data/third_party/boringssl/crypto/bn/rsaz_exp.h +0 -3
  727. data/third_party/boringssl/crypto/bn/shift.c +9 -1
  728. data/third_party/boringssl/crypto/bn/sqrt.c +3 -1
  729. data/third_party/boringssl/crypto/buf/buf.c +6 -4
  730. data/third_party/boringssl/crypto/bytestring/asn1_compat.c +2 -1
  731. data/third_party/boringssl/crypto/bytestring/ber.c +2 -1
  732. data/third_party/boringssl/crypto/bytestring/cbb.c +9 -7
  733. data/third_party/boringssl/crypto/bytestring/cbs.c +54 -2
  734. data/third_party/boringssl/crypto/chacha/chacha.c +1 -1
  735. data/third_party/boringssl/crypto/cipher/aead.c +3 -3
  736. data/third_party/boringssl/crypto/cipher/cipher.c +18 -13
  737. data/third_party/boringssl/crypto/cipher/e_aes.c +335 -281
  738. data/third_party/boringssl/crypto/cipher/e_chacha20poly1305.c +113 -137
  739. data/third_party/boringssl/crypto/cipher/e_null.c +2 -1
  740. data/third_party/boringssl/crypto/cipher/e_rc2.c +54 -49
  741. data/third_party/boringssl/crypto/cipher/e_ssl3.c +4 -3
  742. data/third_party/boringssl/crypto/cipher/e_tls.c +5 -5
  743. data/third_party/boringssl/crypto/cipher/tls_cbc.c +41 -112
  744. data/third_party/boringssl/crypto/cmac/cmac.c +6 -4
  745. data/third_party/boringssl/crypto/conf/conf.c +6 -3
  746. data/third_party/boringssl/crypto/cpu-arm-linux.c +2 -2
  747. data/third_party/boringssl/crypto/curve25519/curve25519.c +28 -34
  748. data/third_party/boringssl/crypto/curve25519/spake25519.c +7 -6
  749. data/third_party/boringssl/crypto/curve25519/x25519-x86_64.c +2 -1
  750. data/third_party/boringssl/crypto/des/des.c +1 -1
  751. data/third_party/boringssl/crypto/des/internal.h +58 -46
  752. data/third_party/boringssl/crypto/dh/dh.c +4 -8
  753. data/third_party/boringssl/crypto/digest/digest.c +5 -2
  754. data/third_party/boringssl/crypto/digest/digests.c +70 -33
  755. data/third_party/boringssl/crypto/digest/md32_common.h +39 -27
  756. data/third_party/boringssl/crypto/dsa/dsa.c +11 -19
  757. data/third_party/boringssl/crypto/ec/ec.c +1 -1
  758. data/third_party/boringssl/crypto/ec/ec_asn1.c +3 -2
  759. data/third_party/boringssl/crypto/ec/ec_key.c +1 -1
  760. data/third_party/boringssl/crypto/ec/ec_montgomery.c +6 -11
  761. data/third_party/boringssl/crypto/ec/oct.c +2 -14
  762. data/third_party/boringssl/crypto/ec/p224-64.c +78 -122
  763. data/third_party/boringssl/crypto/ec/p256-64.c +93 -133
  764. data/third_party/boringssl/crypto/ec/p256-x86_64.c +48 -61
  765. data/third_party/boringssl/crypto/ec/p256-x86_64.h +113 -0
  766. data/third_party/boringssl/crypto/ec/simple.c +2 -1
  767. data/third_party/boringssl/crypto/ec/wnaf.c +52 -43
  768. data/third_party/boringssl/crypto/ecdh/ecdh.c +4 -2
  769. data/third_party/boringssl/crypto/ecdsa/ecdsa.c +17 -16
  770. data/third_party/boringssl/crypto/engine/engine.c +3 -1
  771. data/third_party/boringssl/crypto/err/err.c +5 -5
  772. data/third_party/boringssl/crypto/evp/evp.c +1 -1
  773. data/third_party/boringssl/crypto/evp/evp_asn1.c +1 -1
  774. data/third_party/boringssl/crypto/evp/evp_ctx.c +23 -29
  775. data/third_party/boringssl/crypto/evp/p_ec.c +2 -1
  776. data/third_party/boringssl/crypto/evp/p_rsa.c +9 -3
  777. data/third_party/boringssl/crypto/evp/pbkdf.c +3 -1
  778. data/third_party/boringssl/crypto/hkdf/hkdf.c +3 -1
  779. data/third_party/boringssl/crypto/hmac/hmac.c +4 -2
  780. data/third_party/boringssl/crypto/internal.h +81 -0
  781. data/third_party/boringssl/crypto/lhash/lhash.c +7 -13
  782. data/third_party/boringssl/crypto/md4/md4.c +20 -18
  783. data/third_party/boringssl/crypto/md5/md5.c +31 -21
  784. data/third_party/boringssl/crypto/mem.c +4 -10
  785. data/third_party/boringssl/crypto/modes/cbc.c +2 -6
  786. data/third_party/boringssl/crypto/modes/cfb.c +2 -2
  787. data/third_party/boringssl/crypto/modes/ctr.c +1 -1
  788. data/third_party/boringssl/crypto/modes/gcm.c +117 -334
  789. data/third_party/boringssl/crypto/modes/internal.h +107 -84
  790. data/third_party/boringssl/crypto/modes/ofb.c +3 -3
  791. data/third_party/boringssl/crypto/modes/polyval.c +94 -0
  792. data/third_party/boringssl/crypto/obj/obj.c +13 -8
  793. data/third_party/boringssl/crypto/obj/obj_dat.h +6109 -5187
  794. data/third_party/boringssl/crypto/obj/obj_xref.c +55 -57
  795. data/third_party/boringssl/crypto/pem/pem_lib.c +6 -3
  796. data/third_party/boringssl/crypto/pkcs8/internal.h +27 -8
  797. data/third_party/boringssl/crypto/pkcs8/p5_pbev2.c +137 -352
  798. data/third_party/boringssl/crypto/pkcs8/pkcs8.c +371 -364
  799. data/third_party/boringssl/crypto/poly1305/poly1305.c +12 -18
  800. data/third_party/boringssl/crypto/poly1305/poly1305_arm.c +2 -2
  801. data/third_party/boringssl/crypto/{newhope/reduce.c → pool/internal.h} +24 -21
  802. data/third_party/boringssl/crypto/pool/pool.c +200 -0
  803. data/third_party/boringssl/crypto/rand/deterministic.c +6 -5
  804. data/third_party/boringssl/crypto/rand/fuchsia.c +43 -0
  805. data/third_party/boringssl/crypto/rand/rand.c +7 -7
  806. data/third_party/boringssl/crypto/rand/urandom.c +136 -22
  807. data/third_party/boringssl/crypto/rand/windows.c +2 -2
  808. data/third_party/boringssl/crypto/rsa/blinding.c +2 -1
  809. data/third_party/boringssl/crypto/rsa/padding.c +11 -11
  810. data/third_party/boringssl/crypto/rsa/rsa.c +4 -4
  811. data/third_party/boringssl/crypto/rsa/rsa_asn1.c +7 -1
  812. data/third_party/boringssl/crypto/rsa/rsa_impl.c +41 -80
  813. data/third_party/boringssl/crypto/sha/sha1-altivec.c +346 -0
  814. data/third_party/boringssl/crypto/sha/sha1.c +60 -42
  815. data/third_party/boringssl/crypto/sha/sha256.c +4 -2
  816. data/third_party/boringssl/crypto/sha/sha512.c +9 -7
  817. data/third_party/boringssl/crypto/stack/stack.c +10 -7
  818. data/third_party/boringssl/crypto/thread_pthread.c +2 -2
  819. data/third_party/boringssl/crypto/thread_win.c +2 -2
  820. data/third_party/boringssl/crypto/x509/a_verify.c +1 -1
  821. data/third_party/boringssl/crypto/x509/asn1_gen.c +1 -1
  822. data/third_party/boringssl/crypto/x509/by_dir.c +1 -1
  823. data/third_party/boringssl/crypto/x509/t_x509.c +78 -38
  824. data/third_party/boringssl/crypto/x509/x509_cmp.c +8 -5
  825. data/third_party/boringssl/crypto/x509/x509_lu.c +6 -1
  826. data/third_party/boringssl/crypto/x509/x509_obj.c +4 -1
  827. data/third_party/boringssl/crypto/x509/x509_vfy.c +42 -8
  828. data/third_party/boringssl/crypto/x509/x509_vpm.c +8 -6
  829. data/third_party/boringssl/crypto/x509/x509name.c +4 -1
  830. data/third_party/boringssl/crypto/x509/x_crl.c +4 -2
  831. data/third_party/boringssl/crypto/x509/x_name.c +23 -13
  832. data/third_party/boringssl/crypto/x509/x_pkey.c +4 -1
  833. data/third_party/boringssl/crypto/x509/x_x509.c +42 -3
  834. data/third_party/boringssl/crypto/x509v3/pcy_int.h +2 -2
  835. data/third_party/boringssl/crypto/x509v3/pcy_tree.c +2 -1
  836. data/third_party/boringssl/crypto/x509v3/v3_cpols.c +1 -1
  837. data/third_party/boringssl/crypto/x509v3/v3_ia5.c +4 -1
  838. data/third_party/boringssl/crypto/x509v3/v3_ncons.c +4 -1
  839. data/third_party/boringssl/crypto/x509v3/v3_pci.c +6 -3
  840. data/third_party/boringssl/crypto/x509v3/v3_purp.c +13 -21
  841. data/third_party/boringssl/crypto/x509v3/v3_utl.c +19 -33
  842. data/third_party/boringssl/include/openssl/aead.h +9 -20
  843. data/third_party/boringssl/include/openssl/aes.h +21 -9
  844. data/third_party/boringssl/include/openssl/asn1.h +9 -1
  845. data/third_party/boringssl/include/openssl/base.h +33 -6
  846. data/third_party/boringssl/include/openssl/bio.h +10 -103
  847. data/third_party/boringssl/include/openssl/bn.h +58 -42
  848. data/third_party/boringssl/include/openssl/bytestring.h +17 -0
  849. data/third_party/boringssl/include/openssl/cipher.h +4 -3
  850. data/third_party/boringssl/include/openssl/conf.h +4 -1
  851. data/third_party/boringssl/include/openssl/curve25519.h +13 -0
  852. data/third_party/boringssl/include/openssl/digest.h +5 -3
  853. data/third_party/boringssl/include/openssl/dsa.h +5 -5
  854. data/third_party/boringssl/include/openssl/ec.h +2 -2
  855. data/third_party/boringssl/include/openssl/ecdh.h +3 -4
  856. data/third_party/boringssl/include/openssl/ecdsa.h +10 -10
  857. data/third_party/boringssl/include/openssl/err.h +5 -5
  858. data/third_party/boringssl/include/openssl/evp.h +11 -7
  859. data/third_party/boringssl/include/openssl/lhash.h +2 -3
  860. data/third_party/boringssl/include/openssl/lhash_macros.h +56 -14
  861. data/third_party/boringssl/include/openssl/nid.h +2949 -2916
  862. data/third_party/boringssl/include/openssl/obj.h +1 -1
  863. data/third_party/boringssl/include/openssl/pkcs8.h +21 -42
  864. data/third_party/boringssl/include/openssl/pool.h +87 -0
  865. data/third_party/boringssl/include/openssl/rand.h +1 -1
  866. data/third_party/boringssl/include/openssl/rsa.h +4 -2
  867. data/third_party/boringssl/include/openssl/sha.h +0 -4
  868. data/third_party/boringssl/include/openssl/ssl.h +327 -662
  869. data/third_party/boringssl/include/openssl/ssl3.h +1 -21
  870. data/third_party/boringssl/include/openssl/stack.h +1 -0
  871. data/third_party/boringssl/include/openssl/stack_macros.h +85 -0
  872. data/third_party/boringssl/include/openssl/tls1.h +23 -52
  873. data/third_party/boringssl/include/openssl/type_check.h +4 -0
  874. data/third_party/boringssl/include/openssl/x509.h +10 -59
  875. data/third_party/boringssl/include/openssl/x509_vfy.h +7 -1
  876. data/third_party/boringssl/include/openssl/x509v3.h +4 -4
  877. data/third_party/boringssl/ssl/bio_ssl.c +175 -0
  878. data/third_party/boringssl/ssl/custom_extensions.c +24 -21
  879. data/third_party/boringssl/ssl/d1_both.c +259 -289
  880. data/third_party/boringssl/ssl/d1_lib.c +8 -20
  881. data/third_party/boringssl/ssl/d1_pkt.c +6 -15
  882. data/third_party/boringssl/ssl/dtls_method.c +22 -8
  883. data/third_party/boringssl/ssl/dtls_record.c +27 -2
  884. data/third_party/boringssl/ssl/handshake_client.c +460 -579
  885. data/third_party/boringssl/ssl/handshake_server.c +662 -644
  886. data/third_party/boringssl/ssl/internal.h +1009 -375
  887. data/third_party/boringssl/ssl/s3_both.c +312 -162
  888. data/third_party/boringssl/ssl/s3_lib.c +12 -128
  889. data/third_party/boringssl/ssl/s3_pkt.c +22 -30
  890. data/third_party/boringssl/ssl/ssl_aead_ctx.c +28 -22
  891. data/third_party/boringssl/ssl/ssl_asn1.c +210 -114
  892. data/third_party/boringssl/ssl/ssl_buffer.c +2 -1
  893. data/third_party/boringssl/ssl/ssl_cert.c +417 -219
  894. data/third_party/boringssl/ssl/ssl_cipher.c +191 -393
  895. data/third_party/boringssl/ssl/ssl_ecdh.c +19 -164
  896. data/third_party/boringssl/ssl/ssl_file.c +0 -11
  897. data/third_party/boringssl/ssl/ssl_lib.c +325 -652
  898. data/third_party/boringssl/ssl/{ssl_rsa.c → ssl_privkey.c} +21 -131
  899. data/third_party/boringssl/ssl/ssl_privkey_cc.cc +76 -0
  900. data/third_party/boringssl/ssl/ssl_session.c +206 -95
  901. data/third_party/boringssl/ssl/ssl_stat.c +18 -84
  902. data/third_party/boringssl/ssl/{s3_enc.c → ssl_transcript.c} +150 -157
  903. data/third_party/boringssl/ssl/ssl_x509.c +815 -0
  904. data/third_party/boringssl/ssl/t1_enc.c +188 -174
  905. data/third_party/boringssl/ssl/t1_lib.c +1064 -764
  906. data/third_party/boringssl/ssl/tls13_both.c +290 -96
  907. data/third_party/boringssl/ssl/tls13_client.c +344 -314
  908. data/third_party/boringssl/ssl/tls13_enc.c +239 -200
  909. data/third_party/boringssl/ssl/tls13_server.c +374 -366
  910. data/third_party/boringssl/ssl/tls_method.c +40 -5
  911. data/third_party/boringssl/ssl/tls_record.c +166 -71
  912. metadata +39 -25
  913. data/src/core/lib/iomgr/workqueue.h +0 -87
  914. data/src/core/lib/iomgr/workqueue_uv.c +0 -65
  915. data/src/core/lib/iomgr/workqueue_uv.h +0 -37
  916. data/src/core/lib/iomgr/workqueue_windows.c +0 -63
  917. data/src/core/lib/iomgr/workqueue_windows.h +0 -37
  918. data/third_party/boringssl/crypto/bio/buffer.c +0 -496
  919. data/third_party/boringssl/crypto/newhope/error_correction.c +0 -131
  920. data/third_party/boringssl/crypto/newhope/internal.h +0 -71
  921. data/third_party/boringssl/crypto/newhope/newhope.c +0 -174
  922. data/third_party/boringssl/crypto/newhope/ntt.c +0 -148
  923. data/third_party/boringssl/crypto/newhope/poly.c +0 -183
  924. data/third_party/boringssl/crypto/newhope/precomp.c +0 -306
  925. data/third_party/boringssl/crypto/obj/obj_xref.h +0 -96
  926. data/third_party/boringssl/crypto/pkcs8/p5_pbe.c +0 -151
  927. data/third_party/boringssl/include/openssl/newhope.h +0 -158
  928. data/third_party/boringssl/include/openssl/time_support.h +0 -91
@@ -1,33 +1,18 @@
1
1
  /*
2
2
  *
3
- * Copyright 2015-2016, Google Inc.
4
- * All rights reserved.
3
+ * Copyright 2015-2016 gRPC authors.
5
4
  *
6
- * Redistribution and use in source and binary forms, with or without
7
- * modification, are permitted provided that the following conditions are
8
- * met:
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
9
8
  *
10
- * * Redistributions of source code must retain the above copyright
11
- * notice, this list of conditions and the following disclaimer.
12
- * * Redistributions in binary form must reproduce the above
13
- * copyright notice, this list of conditions and the following disclaimer
14
- * in the documentation and/or other materials provided with the
15
- * distribution.
16
- * * Neither the name of Google Inc. nor the names of its
17
- * contributors may be used to endorse or promote products derived from
18
- * this software without specific prior written permission.
9
+ * http://www.apache.org/licenses/LICENSE-2.0
19
10
  *
20
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
31
16
  *
32
17
  */
33
18
  #include "src/core/lib/surface/completion_queue.h"
@@ -50,9 +35,13 @@
50
35
  #include "src/core/lib/surface/call.h"
51
36
  #include "src/core/lib/surface/event_string.h"
52
37
 
53
- grpc_tracer_flag grpc_trace_operation_failures = GRPC_TRACER_INITIALIZER(false);
38
+ grpc_tracer_flag grpc_trace_operation_failures =
39
+ GRPC_TRACER_INITIALIZER(false, "op_failure");
54
40
  #ifndef NDEBUG
55
- grpc_tracer_flag grpc_trace_pending_tags = GRPC_TRACER_INITIALIZER(false);
41
+ grpc_tracer_flag grpc_trace_pending_tags =
42
+ GRPC_TRACER_INITIALIZER(false, "pending_tags");
43
+ grpc_tracer_flag grpc_trace_cq_refcount =
44
+ GRPC_TRACER_INITIALIZER(false, "cq_refcount");
56
45
  #endif
57
46
 
58
47
  typedef struct {
@@ -128,7 +117,7 @@ static grpc_error *non_polling_poller_work(grpc_exec_ctx *exec_ctx,
128
117
  npp->root = w.next;
129
118
  if (&w == npp->root) {
130
119
  if (npp->shutdown) {
131
- grpc_closure_sched(exec_ctx, npp->shutdown, GRPC_ERROR_NONE);
120
+ GRPC_CLOSURE_SCHED(exec_ctx, npp->shutdown, GRPC_ERROR_NONE);
132
121
  }
133
122
  npp->root = NULL;
134
123
  }
@@ -161,7 +150,7 @@ static void non_polling_poller_shutdown(grpc_exec_ctx *exec_ctx,
161
150
  GPR_ASSERT(closure != NULL);
162
151
  p->shutdown = closure;
163
152
  if (p->root == NULL) {
164
- grpc_closure_sched(exec_ctx, closure, GRPC_ERROR_NONE);
153
+ GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
165
154
  } else {
166
155
  non_polling_worker *w = p->root;
167
156
  do {
@@ -203,16 +192,19 @@ static const cq_poller_vtable g_poller_vtable_by_poller_type[] = {
203
192
 
204
193
  typedef struct cq_vtable {
205
194
  grpc_cq_completion_type cq_completion_type;
206
- size_t (*size)();
207
- void (*begin_op)(grpc_completion_queue *cc, void *tag);
208
- void (*end_op)(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cc, void *tag,
195
+ size_t data_size;
196
+ void (*init)(void *data);
197
+ void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cq);
198
+ void (*destroy)(void *data);
199
+ bool (*begin_op)(grpc_completion_queue *cq, void *tag);
200
+ void (*end_op)(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cq, void *tag,
209
201
  grpc_error *error,
210
202
  void (*done)(grpc_exec_ctx *exec_ctx, void *done_arg,
211
203
  grpc_cq_completion *storage),
212
204
  void *done_arg, grpc_cq_completion *storage);
213
- grpc_event (*next)(grpc_completion_queue *cc, gpr_timespec deadline,
205
+ grpc_event (*next)(grpc_completion_queue *cq, gpr_timespec deadline,
214
206
  void *reserved);
215
- grpc_event (*pluck)(grpc_completion_queue *cc, void *tag,
207
+ grpc_event (*pluck)(grpc_completion_queue *cq, void *tag,
216
208
  gpr_timespec deadline, void *reserved);
217
209
  } cq_vtable;
218
210
 
@@ -232,64 +224,81 @@ typedef struct grpc_cq_event_queue {
232
224
  gpr_atm num_queue_items;
233
225
  } grpc_cq_event_queue;
234
226
 
235
- /* TODO: sreek Refactor this based on the completion_type. Put completion-type
236
- * specific data in a different structure (and co-allocate memory for it along
237
- * with completion queue + pollset )*/
238
- typedef struct cq_data {
239
- gpr_mu *mu;
227
+ typedef struct cq_next_data {
228
+ /** Completed events for completion-queues of type GRPC_CQ_NEXT */
229
+ grpc_cq_event_queue queue;
230
+
231
+ /** Counter of how many things have ever been queued on this completion queue
232
+ useful for avoiding locks to check the queue */
233
+ gpr_atm things_queued_ever;
234
+
235
+ /* Number of outstanding events (+1 if not shut down) */
236
+ gpr_atm pending_events;
240
237
 
238
+ /** 0 initially. 1 once we initiated shutdown */
239
+ bool shutdown_called;
240
+ } cq_next_data;
241
+
242
+ typedef struct cq_pluck_data {
241
243
  /** Completed events for completion-queues of type GRPC_CQ_PLUCK */
242
244
  grpc_cq_completion completed_head;
243
245
  grpc_cq_completion *completed_tail;
244
246
 
245
- /** Completed events for completion-queues of type GRPC_CQ_NEXT */
246
- grpc_cq_event_queue queue;
247
-
248
247
  /** Number of pending events (+1 if we're not shutdown) */
249
- gpr_refcount pending_events;
250
-
251
- /** Once owning_refs drops to zero, we will destroy the cq */
252
- gpr_refcount owning_refs;
248
+ gpr_atm pending_events;
253
249
 
254
250
  /** Counter of how many things have ever been queued on this completion queue
255
251
  useful for avoiding locks to check the queue */
256
252
  gpr_atm things_queued_ever;
257
253
 
258
- /** 0 initially, 1 once we've begun shutting down */
254
+ /** 0 initially. 1 once we completed shutting */
255
+ /* TODO: (sreek) This is not needed since (shutdown == 1) if and only if
256
+ * (pending_events == 0). So consider removing this in future and use
257
+ * pending_events */
259
258
  gpr_atm shutdown;
260
- int shutdown_called;
261
259
 
262
- int is_server_cq;
260
+ /** 0 initially. 1 once we initiated shutdown */
261
+ bool shutdown_called;
263
262
 
264
263
  int num_pluckers;
265
- int num_polls;
266
264
  plucker pluckers[GRPC_MAX_COMPLETION_QUEUE_PLUCKERS];
267
- grpc_closure pollset_shutdown_done;
265
+ } cq_pluck_data;
266
+
267
+ /* Completion queue structure */
268
+ struct grpc_completion_queue {
269
+ /** Once owning_refs drops to zero, we will destroy the cq */
270
+ gpr_refcount owning_refs;
271
+
272
+ gpr_mu *mu;
273
+
274
+ const cq_vtable *vtable;
275
+ const cq_poller_vtable *poller_vtable;
268
276
 
269
277
  #ifndef NDEBUG
270
278
  void **outstanding_tags;
271
279
  size_t outstanding_tag_count;
272
280
  size_t outstanding_tag_capacity;
273
281
  #endif
274
- } cq_data;
275
282
 
276
- /* Completion queue structure */
277
- struct grpc_completion_queue {
278
- cq_data data;
279
- const cq_vtable *vtable;
280
- const cq_poller_vtable *poller_vtable;
283
+ grpc_closure pollset_shutdown_done;
284
+ int num_polls;
281
285
  };
282
286
 
283
287
  /* Forward declarations */
284
- static void cq_finish_shutdown(grpc_exec_ctx *exec_ctx,
285
- grpc_completion_queue *cc);
286
-
287
- static size_t cq_size(grpc_completion_queue *cc);
288
-
289
- static void cq_begin_op(grpc_completion_queue *cc, void *tag);
288
+ static void cq_finish_shutdown_next(grpc_exec_ctx *exec_ctx,
289
+ grpc_completion_queue *cq);
290
+ static void cq_finish_shutdown_pluck(grpc_exec_ctx *exec_ctx,
291
+ grpc_completion_queue *cq);
292
+ static void cq_shutdown_next(grpc_exec_ctx *exec_ctx,
293
+ grpc_completion_queue *cq);
294
+ static void cq_shutdown_pluck(grpc_exec_ctx *exec_ctx,
295
+ grpc_completion_queue *cq);
296
+
297
+ static bool cq_begin_op_for_next(grpc_completion_queue *cq, void *tag);
298
+ static bool cq_begin_op_for_pluck(grpc_completion_queue *cq, void *tag);
290
299
 
291
300
  static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
292
- grpc_completion_queue *cc, void *tag,
301
+ grpc_completion_queue *cq, void *tag,
293
302
  grpc_error *error,
294
303
  void (*done)(grpc_exec_ctx *exec_ctx,
295
304
  void *done_arg,
@@ -297,42 +306,56 @@ static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
297
306
  void *done_arg, grpc_cq_completion *storage);
298
307
 
299
308
  static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
300
- grpc_completion_queue *cc, void *tag,
309
+ grpc_completion_queue *cq, void *tag,
301
310
  grpc_error *error,
302
311
  void (*done)(grpc_exec_ctx *exec_ctx,
303
312
  void *done_arg,
304
313
  grpc_cq_completion *storage),
305
314
  void *done_arg, grpc_cq_completion *storage);
306
315
 
307
- static grpc_event cq_next(grpc_completion_queue *cc, gpr_timespec deadline,
316
+ static grpc_event cq_next(grpc_completion_queue *cq, gpr_timespec deadline,
308
317
  void *reserved);
309
318
 
310
- static grpc_event cq_pluck(grpc_completion_queue *cc, void *tag,
319
+ static grpc_event cq_pluck(grpc_completion_queue *cq, void *tag,
311
320
  gpr_timespec deadline, void *reserved);
312
321
 
322
+ static void cq_init_next(void *data);
323
+ static void cq_init_pluck(void *data);
324
+ static void cq_destroy_next(void *data);
325
+ static void cq_destroy_pluck(void *data);
326
+
313
327
  /* Completion queue vtables based on the completion-type */
314
328
  static const cq_vtable g_cq_vtable[] = {
315
329
  /* GRPC_CQ_NEXT */
316
- {.cq_completion_type = GRPC_CQ_NEXT,
317
- .size = cq_size,
318
- .begin_op = cq_begin_op,
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,
319
336
  .end_op = cq_end_op_for_next,
320
337
  .next = cq_next,
321
338
  .pluck = NULL},
322
339
  /* GRPC_CQ_PLUCK */
323
- {.cq_completion_type = GRPC_CQ_PLUCK,
324
- .size = cq_size,
325
- .begin_op = cq_begin_op,
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,
326
346
  .end_op = cq_end_op_for_pluck,
327
347
  .next = NULL,
328
348
  .pluck = cq_pluck},
329
349
  };
330
350
 
331
- #define POLLSET_FROM_CQ(cq) ((grpc_pollset *)(cq + 1))
332
- #define CQ_FROM_POLLSET(ps) (((grpc_completion_queue *)ps) - 1)
351
+ #define DATA_FROM_CQ(cq) ((void *)(cq + 1))
352
+ #define POLLSET_FROM_CQ(cq) \
353
+ ((grpc_pollset *)(cq->vtable->data_size + (char *)DATA_FROM_CQ(cq)))
333
354
 
334
- grpc_tracer_flag grpc_cq_pluck_trace = GRPC_TRACER_INITIALIZER(true);
335
- grpc_tracer_flag grpc_cq_event_timeout_trace = GRPC_TRACER_INITIALIZER(true);
355
+ grpc_tracer_flag grpc_cq_pluck_trace =
356
+ GRPC_TRACER_INITIALIZER(true, "queue_pluck");
357
+ grpc_tracer_flag grpc_cq_event_timeout_trace =
358
+ GRPC_TRACER_INITIALIZER(true, "queue_timeout");
336
359
 
337
360
  #define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \
338
361
  if (GRPC_TRACER_ON(grpc_api_trace) && \
@@ -343,7 +366,7 @@ grpc_tracer_flag grpc_cq_event_timeout_trace = GRPC_TRACER_INITIALIZER(true);
343
366
  gpr_free(_ev); \
344
367
  }
345
368
 
346
- static void on_pollset_shutdown_done(grpc_exec_ctx *exec_ctx, void *cc,
369
+ static void on_pollset_shutdown_done(grpc_exec_ctx *exec_ctx, void *cq,
347
370
  grpc_error *error);
348
371
 
349
372
  static void cq_event_queue_init(grpc_cq_event_queue *q) {
@@ -356,9 +379,9 @@ static void cq_event_queue_destroy(grpc_cq_event_queue *q) {
356
379
  gpr_mpscq_destroy(&q->queue);
357
380
  }
358
381
 
359
- static void cq_event_queue_push(grpc_cq_event_queue *q, grpc_cq_completion *c) {
382
+ static bool cq_event_queue_push(grpc_cq_event_queue *q, grpc_cq_completion *c) {
360
383
  gpr_mpscq_push(&q->queue, (gpr_mpscq_node *)c);
361
- gpr_atm_no_barrier_fetch_add(&q->num_queue_items, 1);
384
+ return gpr_atm_no_barrier_fetch_add(&q->num_queue_items, 1) == 0;
362
385
  }
363
386
 
364
387
  static grpc_cq_completion *cq_event_queue_pop(grpc_cq_event_queue *q) {
@@ -381,16 +404,10 @@ static long cq_event_queue_num_items(grpc_cq_event_queue *q) {
381
404
  return (long)gpr_atm_no_barrier_load(&q->num_queue_items);
382
405
  }
383
406
 
384
- static size_t cq_size(grpc_completion_queue *cc) {
385
- /* Size of the completion queue and the size of the pollset whose memory is
386
- allocated right after that of completion queue */
387
- return sizeof(grpc_completion_queue) + cc->poller_vtable->size();
388
- }
389
-
390
407
  grpc_completion_queue *grpc_completion_queue_create_internal(
391
408
  grpc_cq_completion_type completion_type,
392
409
  grpc_cq_polling_type polling_type) {
393
- grpc_completion_queue *cc;
410
+ grpc_completion_queue *cq;
394
411
 
395
412
  GPR_TIMER_BEGIN("grpc_completion_queue_create_internal", 0);
396
413
 
@@ -403,150 +420,189 @@ grpc_completion_queue *grpc_completion_queue_create_internal(
403
420
  const cq_poller_vtable *poller_vtable =
404
421
  &g_poller_vtable_by_poller_type[polling_type];
405
422
 
406
- cc = gpr_zalloc(sizeof(grpc_completion_queue) + poller_vtable->size());
407
- cq_data *cqd = &cc->data;
423
+ cq = gpr_zalloc(sizeof(grpc_completion_queue) + vtable->data_size +
424
+ poller_vtable->size());
408
425
 
409
- cc->vtable = vtable;
410
- cc->poller_vtable = poller_vtable;
426
+ cq->vtable = vtable;
427
+ cq->poller_vtable = poller_vtable;
411
428
 
412
- poller_vtable->init(POLLSET_FROM_CQ(cc), &cc->data.mu);
429
+ /* One for destroy(), one for pollset_shutdown */
430
+ gpr_ref_init(&cq->owning_refs, 2);
413
431
 
414
- #ifndef NDEBUG
415
- cqd->outstanding_tags = NULL;
416
- cqd->outstanding_tag_capacity = 0;
417
- #endif
432
+ poller_vtable->init(POLLSET_FROM_CQ(cq), &cq->mu);
433
+ vtable->init(DATA_FROM_CQ(cq));
418
434
 
419
- /* Initial ref is dropped by grpc_completion_queue_shutdown */
420
- gpr_ref_init(&cqd->pending_events, 1);
421
- /* One for destroy(), one for pollset_shutdown */
422
- gpr_ref_init(&cqd->owning_refs, 2);
435
+ GRPC_CLOSURE_INIT(&cq->pollset_shutdown_done, on_pollset_shutdown_done, cq,
436
+ grpc_schedule_on_exec_ctx);
437
+
438
+ GPR_TIMER_END("grpc_completion_queue_create_internal", 0);
439
+
440
+ return cq;
441
+ }
442
+
443
+ static void cq_init_next(void *ptr) {
444
+ cq_next_data *cqd = ptr;
445
+ /* Initial count is dropped by grpc_completion_queue_shutdown */
446
+ gpr_atm_no_barrier_store(&cqd->pending_events, 1);
447
+ cqd->shutdown_called = false;
448
+ gpr_atm_no_barrier_store(&cqd->things_queued_ever, 0);
449
+ cq_event_queue_init(&cqd->queue);
450
+ }
451
+
452
+ static void cq_destroy_next(void *ptr) {
453
+ cq_next_data *cqd = ptr;
454
+ GPR_ASSERT(cq_event_queue_num_items(&cqd->queue) == 0);
455
+ cq_event_queue_destroy(&cqd->queue);
456
+ }
457
+
458
+ static void cq_init_pluck(void *ptr) {
459
+ cq_pluck_data *cqd = ptr;
460
+ /* Initial count is dropped by grpc_completion_queue_shutdown */
461
+ gpr_atm_no_barrier_store(&cqd->pending_events, 1);
423
462
  cqd->completed_tail = &cqd->completed_head;
424
463
  cqd->completed_head.next = (uintptr_t)cqd->completed_tail;
425
464
  gpr_atm_no_barrier_store(&cqd->shutdown, 0);
426
- cqd->shutdown_called = 0;
427
- cqd->is_server_cq = 0;
465
+ cqd->shutdown_called = false;
428
466
  cqd->num_pluckers = 0;
429
- cqd->num_polls = 0;
430
467
  gpr_atm_no_barrier_store(&cqd->things_queued_ever, 0);
431
- #ifndef NDEBUG
432
- cqd->outstanding_tag_count = 0;
433
- #endif
434
- cq_event_queue_init(&cqd->queue);
435
- grpc_closure_init(&cqd->pollset_shutdown_done, on_pollset_shutdown_done, cc,
436
- grpc_schedule_on_exec_ctx);
437
-
438
- GPR_TIMER_END("grpc_completion_queue_create_internal", 0);
468
+ }
439
469
 
440
- return cc;
470
+ static void cq_destroy_pluck(void *ptr) {
471
+ cq_pluck_data *cqd = ptr;
472
+ GPR_ASSERT(cqd->completed_head.next == (uintptr_t)&cqd->completed_head);
441
473
  }
442
474
 
443
- grpc_cq_completion_type grpc_get_cq_completion_type(grpc_completion_queue *cc) {
444
- return cc->vtable->cq_completion_type;
475
+ grpc_cq_completion_type grpc_get_cq_completion_type(grpc_completion_queue *cq) {
476
+ return cq->vtable->cq_completion_type;
445
477
  }
446
478
 
447
- int grpc_get_cq_poll_num(grpc_completion_queue *cc) {
479
+ int grpc_get_cq_poll_num(grpc_completion_queue *cq) {
448
480
  int cur_num_polls;
449
- gpr_mu_lock(cc->data.mu);
450
- cur_num_polls = cc->data.num_polls;
451
- gpr_mu_unlock(cc->data.mu);
481
+ gpr_mu_lock(cq->mu);
482
+ cur_num_polls = cq->num_polls;
483
+ gpr_mu_unlock(cq->mu);
452
484
  return cur_num_polls;
453
485
  }
454
486
 
455
- #ifdef GRPC_CQ_REF_COUNT_DEBUG
456
- void grpc_cq_internal_ref(grpc_completion_queue *cc, const char *reason,
487
+ #ifndef NDEBUG
488
+ void grpc_cq_internal_ref(grpc_completion_queue *cq, const char *reason,
457
489
  const char *file, int line) {
458
- cq_data *cqd = &cc->data;
459
- gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "CQ:%p ref %d -> %d %s", cc,
460
- (int)cqd->owning_refs.count, (int)cqd->owning_refs.count + 1, reason);
490
+ if (GRPC_TRACER_ON(grpc_trace_cq_refcount)) {
491
+ gpr_atm val = gpr_atm_no_barrier_load(&cq->owning_refs.count);
492
+ gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
493
+ "CQ:%p ref %" PRIdPTR " -> %" PRIdPTR " %s", cq, val, val + 1,
494
+ reason);
495
+ }
461
496
  #else
462
- void grpc_cq_internal_ref(grpc_completion_queue *cc) {
463
- cq_data *cqd = &cc->data;
497
+ void grpc_cq_internal_ref(grpc_completion_queue *cq) {
464
498
  #endif
465
- gpr_ref(&cqd->owning_refs);
499
+ gpr_ref(&cq->owning_refs);
466
500
  }
467
501
 
468
502
  static void on_pollset_shutdown_done(grpc_exec_ctx *exec_ctx, void *arg,
469
503
  grpc_error *error) {
470
- grpc_completion_queue *cc = arg;
471
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, cc, "pollset_destroy");
504
+ grpc_completion_queue *cq = arg;
505
+ GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "pollset_destroy");
472
506
  }
473
507
 
474
- #ifdef GRPC_CQ_REF_COUNT_DEBUG
475
- void grpc_cq_internal_unref(grpc_completion_queue *cc, const char *reason,
476
- const char *file, int line) {
477
- cq_data *cqd = &cc->data;
478
- gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "CQ:%p unref %d -> %d %s", cc,
479
- (int)cqd->owning_refs.count, (int)cqd->owning_refs.count - 1, reason);
508
+ #ifndef NDEBUG
509
+ void grpc_cq_internal_unref(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cq,
510
+ const char *reason, const char *file, int line) {
511
+ if (GRPC_TRACER_ON(grpc_trace_cq_refcount)) {
512
+ gpr_atm val = gpr_atm_no_barrier_load(&cq->owning_refs.count);
513
+ gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
514
+ "CQ:%p unref %" PRIdPTR " -> %" PRIdPTR " %s", cq, val, val - 1,
515
+ reason);
516
+ }
480
517
  #else
481
518
  void grpc_cq_internal_unref(grpc_exec_ctx *exec_ctx,
482
- grpc_completion_queue *cc) {
483
- cq_data *cqd = &cc->data;
519
+ grpc_completion_queue *cq) {
484
520
  #endif
485
- if (gpr_unref(&cqd->owning_refs)) {
486
- GPR_ASSERT(cqd->completed_head.next == (uintptr_t)&cqd->completed_head);
487
- cc->poller_vtable->destroy(exec_ctx, POLLSET_FROM_CQ(cc));
488
- cq_event_queue_destroy(&cqd->queue);
521
+ if (gpr_unref(&cq->owning_refs)) {
522
+ cq->vtable->destroy(DATA_FROM_CQ(cq));
523
+ cq->poller_vtable->destroy(exec_ctx, POLLSET_FROM_CQ(cq));
489
524
  #ifndef NDEBUG
490
- gpr_free(cqd->outstanding_tags);
525
+ gpr_free(cq->outstanding_tags);
491
526
  #endif
492
- gpr_free(cc);
527
+ gpr_free(cq);
493
528
  }
494
529
  }
495
530
 
496
- static void cq_begin_op(grpc_completion_queue *cc, void *tag) {
497
- cq_data *cqd = &cc->data;
498
531
  #ifndef NDEBUG
499
- gpr_mu_lock(cqd->mu);
500
- GPR_ASSERT(!cqd->shutdown_called);
501
- if (cqd->outstanding_tag_count == cqd->outstanding_tag_capacity) {
502
- cqd->outstanding_tag_capacity =
503
- GPR_MAX(4, 2 * cqd->outstanding_tag_capacity);
504
- cqd->outstanding_tags =
505
- gpr_realloc(cqd->outstanding_tags, sizeof(*cqd->outstanding_tags) *
506
- cqd->outstanding_tag_capacity);
507
- }
508
- cqd->outstanding_tags[cqd->outstanding_tag_count++] = tag;
509
- gpr_mu_unlock(cqd->mu);
510
- #endif
511
- gpr_ref(&cqd->pending_events);
512
- }
513
-
514
- void grpc_cq_begin_op(grpc_completion_queue *cc, void *tag) {
515
- cc->vtable->begin_op(cc, tag);
516
- }
517
-
518
- #ifndef NDEBUG
519
- static void cq_check_tag(grpc_completion_queue *cc, void *tag, bool lock_cq) {
520
- cq_data *cqd = &cc->data;
532
+ static void cq_check_tag(grpc_completion_queue *cq, void *tag, bool lock_cq) {
521
533
  int found = 0;
522
534
  if (lock_cq) {
523
- gpr_mu_lock(cqd->mu);
535
+ gpr_mu_lock(cq->mu);
524
536
  }
525
537
 
526
- for (int i = 0; i < (int)cqd->outstanding_tag_count; i++) {
527
- if (cqd->outstanding_tags[i] == tag) {
528
- cqd->outstanding_tag_count--;
529
- GPR_SWAP(void *, cqd->outstanding_tags[i],
530
- cqd->outstanding_tags[cqd->outstanding_tag_count]);
538
+ for (int i = 0; i < (int)cq->outstanding_tag_count; i++) {
539
+ if (cq->outstanding_tags[i] == tag) {
540
+ cq->outstanding_tag_count--;
541
+ GPR_SWAP(void *, cq->outstanding_tags[i],
542
+ cq->outstanding_tags[cq->outstanding_tag_count]);
531
543
  found = 1;
532
544
  break;
533
545
  }
534
546
  }
535
547
 
536
548
  if (lock_cq) {
537
- gpr_mu_unlock(cqd->mu);
549
+ gpr_mu_unlock(cq->mu);
538
550
  }
539
551
 
540
552
  GPR_ASSERT(found);
541
553
  }
542
554
  #else
543
- static void cq_check_tag(grpc_completion_queue *cc, void *tag, bool lock_cq) {}
555
+ static void cq_check_tag(grpc_completion_queue *cq, void *tag, bool lock_cq) {}
544
556
  #endif
545
557
 
546
- /* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a completion
558
+ /* Atomically increments a counter only if the counter is not zero. Returns
559
+ * true if the increment was successful; false if the counter is zero */
560
+ static bool atm_inc_if_nonzero(gpr_atm *counter) {
561
+ while (true) {
562
+ gpr_atm count = gpr_atm_no_barrier_load(counter);
563
+ /* If zero, we are done. If not, we must to a CAS (instead of an atomic
564
+ * increment) to maintain the contract: do not increment the counter if it
565
+ * is zero. */
566
+ if (count == 0) {
567
+ return false;
568
+ } else if (gpr_atm_no_barrier_cas(counter, count, count + 1)) {
569
+ break;
570
+ }
571
+ }
572
+
573
+ return true;
574
+ }
575
+
576
+ static bool cq_begin_op_for_next(grpc_completion_queue *cq, void *tag) {
577
+ cq_next_data *cqd = DATA_FROM_CQ(cq);
578
+ return atm_inc_if_nonzero(&cqd->pending_events);
579
+ }
580
+
581
+ static bool cq_begin_op_for_pluck(grpc_completion_queue *cq, void *tag) {
582
+ cq_pluck_data *cqd = DATA_FROM_CQ(cq);
583
+ return atm_inc_if_nonzero(&cqd->pending_events);
584
+ }
585
+
586
+ bool grpc_cq_begin_op(grpc_completion_queue *cq, void *tag) {
587
+ #ifndef NDEBUG
588
+ gpr_mu_lock(cq->mu);
589
+ if (cq->outstanding_tag_count == cq->outstanding_tag_capacity) {
590
+ 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);
594
+ }
595
+ cq->outstanding_tags[cq->outstanding_tag_count++] = tag;
596
+ gpr_mu_unlock(cq->mu);
597
+ #endif
598
+ return cq->vtable->begin_op(cq, tag);
599
+ }
600
+
601
+ /* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a
602
+ * completion
547
603
  * type of GRPC_CQ_NEXT) */
548
604
  static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
549
- grpc_completion_queue *cc, void *tag,
605
+ grpc_completion_queue *cq, void *tag,
550
606
  grpc_error *error,
551
607
  void (*done)(grpc_exec_ctx *exec_ctx,
552
608
  void *done_arg,
@@ -559,16 +615,16 @@ static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
559
615
  error != GRPC_ERROR_NONE)) {
560
616
  const char *errmsg = grpc_error_string(error);
561
617
  GRPC_API_TRACE(
562
- "cq_end_op_for_next(exec_ctx=%p, cc=%p, tag=%p, error=%s, "
618
+ "cq_end_op_for_next(exec_ctx=%p, cq=%p, tag=%p, error=%s, "
563
619
  "done=%p, done_arg=%p, storage=%p)",
564
- 7, (exec_ctx, cc, tag, errmsg, done, done_arg, storage));
620
+ 7, (exec_ctx, cq, tag, errmsg, done, done_arg, storage));
565
621
  if (GRPC_TRACER_ON(grpc_trace_operation_failures) &&
566
622
  error != GRPC_ERROR_NONE) {
567
623
  gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
568
624
  }
569
625
  }
570
626
 
571
- cq_data *cqd = &cc->data;
627
+ cq_next_data *cqd = DATA_FROM_CQ(cq);
572
628
  int is_success = (error == GRPC_ERROR_NONE);
573
629
 
574
630
  storage->tag = tag;
@@ -576,28 +632,42 @@ static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
576
632
  storage->done_arg = done_arg;
577
633
  storage->next = (uintptr_t)(is_success);
578
634
 
579
- cq_check_tag(cc, tag, true); /* Used in debug builds only */
635
+ cq_check_tag(cq, tag, true); /* Used in debug builds only */
580
636
 
581
637
  /* Add the completion to the queue */
582
- cq_event_queue_push(&cqd->queue, storage);
638
+ bool is_first = cq_event_queue_push(&cqd->queue, storage);
583
639
  gpr_atm_no_barrier_fetch_add(&cqd->things_queued_ever, 1);
584
-
585
- gpr_mu_lock(cqd->mu);
586
-
587
- int shutdown = gpr_unref(&cqd->pending_events);
588
- if (!shutdown) {
589
- grpc_error *kick_error = cc->poller_vtable->kick(POLLSET_FROM_CQ(cc), NULL);
590
- gpr_mu_unlock(cqd->mu);
591
-
592
- if (kick_error != GRPC_ERROR_NONE) {
593
- const char *msg = grpc_error_string(kick_error);
594
- gpr_log(GPR_ERROR, "Kick failed: %s", msg);
595
-
596
- GRPC_ERROR_UNREF(kick_error);
640
+ bool will_definitely_shutdown =
641
+ gpr_atm_no_barrier_load(&cqd->pending_events) == 1;
642
+
643
+ if (!will_definitely_shutdown) {
644
+ /* Only kick if this is the first item queued */
645
+ if (is_first) {
646
+ gpr_mu_lock(cq->mu);
647
+ grpc_error *kick_error =
648
+ cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), NULL);
649
+ gpr_mu_unlock(cq->mu);
650
+
651
+ if (kick_error != GRPC_ERROR_NONE) {
652
+ const char *msg = grpc_error_string(kick_error);
653
+ gpr_log(GPR_ERROR, "Kick failed: %s", msg);
654
+ GRPC_ERROR_UNREF(kick_error);
655
+ }
656
+ }
657
+ if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
658
+ GRPC_CQ_INTERNAL_REF(cq, "shutting_down");
659
+ gpr_mu_lock(cq->mu);
660
+ cq_finish_shutdown_next(exec_ctx, cq);
661
+ gpr_mu_unlock(cq->mu);
662
+ GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
597
663
  }
598
664
  } else {
599
- cq_finish_shutdown(exec_ctx, cc);
600
- gpr_mu_unlock(cqd->mu);
665
+ GRPC_CQ_INTERNAL_REF(cq, "shutting_down");
666
+ gpr_atm_rel_store(&cqd->pending_events, 0);
667
+ gpr_mu_lock(cq->mu);
668
+ cq_finish_shutdown_next(exec_ctx, cq);
669
+ gpr_mu_unlock(cq->mu);
670
+ GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
601
671
  }
602
672
 
603
673
  GPR_TIMER_END("cq_end_op_for_next", 0);
@@ -605,16 +675,17 @@ static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
605
675
  GRPC_ERROR_UNREF(error);
606
676
  }
607
677
 
608
- /* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a completion
678
+ /* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a
679
+ * completion
609
680
  * type of GRPC_CQ_PLUCK) */
610
681
  static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
611
- grpc_completion_queue *cc, void *tag,
682
+ grpc_completion_queue *cq, void *tag,
612
683
  grpc_error *error,
613
684
  void (*done)(grpc_exec_ctx *exec_ctx,
614
685
  void *done_arg,
615
686
  grpc_cq_completion *storage),
616
687
  void *done_arg, grpc_cq_completion *storage) {
617
- cq_data *cqd = &cc->data;
688
+ cq_pluck_data *cqd = DATA_FROM_CQ(cq);
618
689
  int is_success = (error == GRPC_ERROR_NONE);
619
690
 
620
691
  GPR_TIMER_BEGIN("cq_end_op_for_pluck", 0);
@@ -624,9 +695,9 @@ static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
624
695
  error != GRPC_ERROR_NONE)) {
625
696
  const char *errmsg = grpc_error_string(error);
626
697
  GRPC_API_TRACE(
627
- "cq_end_op_for_pluck(exec_ctx=%p, cc=%p, tag=%p, error=%s, "
698
+ "cq_end_op_for_pluck(exec_ctx=%p, cq=%p, tag=%p, error=%s, "
628
699
  "done=%p, done_arg=%p, storage=%p)",
629
- 7, (exec_ctx, cc, tag, errmsg, done, done_arg, storage));
700
+ 7, (exec_ctx, cq, tag, errmsg, done, done_arg, storage));
630
701
  if (GRPC_TRACER_ON(grpc_trace_operation_failures) &&
631
702
  error != GRPC_ERROR_NONE) {
632
703
  gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
@@ -638,8 +709,8 @@ static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
638
709
  storage->done_arg = done_arg;
639
710
  storage->next = ((uintptr_t)&cqd->completed_head) | ((uintptr_t)(is_success));
640
711
 
641
- gpr_mu_lock(cqd->mu);
642
- cq_check_tag(cc, tag, false); /* Used in debug builds only */
712
+ gpr_mu_lock(cq->mu);
713
+ cq_check_tag(cq, tag, false); /* Used in debug builds only */
643
714
 
644
715
  /* Add to the list of completions */
645
716
  gpr_atm_no_barrier_fetch_add(&cqd->things_queued_ever, 1);
@@ -647,8 +718,10 @@ static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
647
718
  ((uintptr_t)storage) | (1u & (uintptr_t)cqd->completed_tail->next);
648
719
  cqd->completed_tail = storage;
649
720
 
650
- int shutdown = gpr_unref(&cqd->pending_events);
651
- if (!shutdown) {
721
+ if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
722
+ cq_finish_shutdown_pluck(exec_ctx, cq);
723
+ gpr_mu_unlock(cq->mu);
724
+ } else {
652
725
  grpc_pollset_worker *pluck_worker = NULL;
653
726
  for (int i = 0; i < cqd->num_pluckers; i++) {
654
727
  if (cqd->pluckers[i].tag == tag) {
@@ -658,9 +731,9 @@ static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
658
731
  }
659
732
 
660
733
  grpc_error *kick_error =
661
- cc->poller_vtable->kick(POLLSET_FROM_CQ(cc), pluck_worker);
734
+ cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), pluck_worker);
662
735
 
663
- gpr_mu_unlock(cqd->mu);
736
+ gpr_mu_unlock(cq->mu);
664
737
 
665
738
  if (kick_error != GRPC_ERROR_NONE) {
666
739
  const char *msg = grpc_error_string(kick_error);
@@ -668,9 +741,6 @@ static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
668
741
 
669
742
  GRPC_ERROR_UNREF(kick_error);
670
743
  }
671
- } else {
672
- cq_finish_shutdown(exec_ctx, cc);
673
- gpr_mu_unlock(cqd->mu);
674
744
  }
675
745
 
676
746
  GPR_TIMER_END("cq_end_op_for_pluck", 0);
@@ -678,12 +748,12 @@ static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
678
748
  GRPC_ERROR_UNREF(error);
679
749
  }
680
750
 
681
- void grpc_cq_end_op(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cc,
751
+ void grpc_cq_end_op(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cq,
682
752
  void *tag, grpc_error *error,
683
753
  void (*done)(grpc_exec_ctx *exec_ctx, void *done_arg,
684
754
  grpc_cq_completion *storage),
685
755
  void *done_arg, grpc_cq_completion *storage) {
686
- cc->vtable->end_op(exec_ctx, cc, tag, error, done, done_arg, storage);
756
+ cq->vtable->end_op(exec_ctx, cq, tag, error, done, done_arg, storage);
687
757
  }
688
758
 
689
759
  typedef struct {
@@ -698,7 +768,7 @@ typedef struct {
698
768
  static bool cq_is_next_finished(grpc_exec_ctx *exec_ctx, void *arg) {
699
769
  cq_is_finished_arg *a = arg;
700
770
  grpc_completion_queue *cq = a->cq;
701
- cq_data *cqd = &cq->data;
771
+ cq_next_data *cqd = DATA_FROM_CQ(cq);
702
772
  GPR_ASSERT(a->stolen_completion == NULL);
703
773
 
704
774
  gpr_atm current_last_seen_things_queued_ever =
@@ -709,7 +779,8 @@ static bool cq_is_next_finished(grpc_exec_ctx *exec_ctx, void *arg) {
709
779
  gpr_atm_no_barrier_load(&cqd->things_queued_ever);
710
780
 
711
781
  /* Pop a cq_completion from the queue. Returns NULL if the queue is empty
712
- * might return NULL in some cases even if the queue is not empty; but that
782
+ * might return NULL in some cases even if the queue is not empty; but
783
+ * that
713
784
  * is ok and doesn't affect correctness. Might effect the tail latencies a
714
785
  * bit) */
715
786
  a->stolen_completion = cq_event_queue_pop(&cqd->queue);
@@ -722,58 +793,56 @@ static bool cq_is_next_finished(grpc_exec_ctx *exec_ctx, void *arg) {
722
793
  }
723
794
 
724
795
  #ifndef NDEBUG
725
- static void dump_pending_tags(grpc_completion_queue *cc) {
796
+ static void dump_pending_tags(grpc_completion_queue *cq) {
726
797
  if (!GRPC_TRACER_ON(grpc_trace_pending_tags)) return;
727
798
 
728
- cq_data *cqd = &cc->data;
729
-
730
799
  gpr_strvec v;
731
800
  gpr_strvec_init(&v);
732
801
  gpr_strvec_add(&v, gpr_strdup("PENDING TAGS:"));
733
- gpr_mu_lock(cqd->mu);
734
- for (size_t i = 0; i < cqd->outstanding_tag_count; i++) {
802
+ gpr_mu_lock(cq->mu);
803
+ for (size_t i = 0; i < cq->outstanding_tag_count; i++) {
735
804
  char *s;
736
- gpr_asprintf(&s, " %p", cqd->outstanding_tags[i]);
805
+ gpr_asprintf(&s, " %p", cq->outstanding_tags[i]);
737
806
  gpr_strvec_add(&v, s);
738
807
  }
739
- gpr_mu_unlock(cqd->mu);
808
+ gpr_mu_unlock(cq->mu);
740
809
  char *out = gpr_strvec_flatten(&v, NULL);
741
810
  gpr_strvec_destroy(&v);
742
811
  gpr_log(GPR_DEBUG, "%s", out);
743
812
  gpr_free(out);
744
813
  }
745
814
  #else
746
- static void dump_pending_tags(grpc_completion_queue *cc) {}
815
+ static void dump_pending_tags(grpc_completion_queue *cq) {}
747
816
  #endif
748
817
 
749
- static grpc_event cq_next(grpc_completion_queue *cc, gpr_timespec deadline,
818
+ static grpc_event cq_next(grpc_completion_queue *cq, gpr_timespec deadline,
750
819
  void *reserved) {
751
820
  grpc_event ret;
752
821
  gpr_timespec now;
753
- cq_data *cqd = &cc->data;
822
+ cq_next_data *cqd = DATA_FROM_CQ(cq);
754
823
 
755
824
  GPR_TIMER_BEGIN("grpc_completion_queue_next", 0);
756
825
 
757
826
  GRPC_API_TRACE(
758
827
  "grpc_completion_queue_next("
759
- "cc=%p, "
828
+ "cq=%p, "
760
829
  "deadline=gpr_timespec { tv_sec: %" PRId64
761
830
  ", tv_nsec: %d, clock_type: %d }, "
762
831
  "reserved=%p)",
763
- 5, (cc, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type,
832
+ 5, (cq, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type,
764
833
  reserved));
765
834
  GPR_ASSERT(!reserved);
766
835
 
767
- dump_pending_tags(cc);
836
+ dump_pending_tags(cq);
768
837
 
769
838
  deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC);
770
839
 
771
- GRPC_CQ_INTERNAL_REF(cc, "next");
840
+ GRPC_CQ_INTERNAL_REF(cq, "next");
772
841
 
773
842
  cq_is_finished_arg is_finished_arg = {
774
843
  .last_seen_things_queued_ever =
775
844
  gpr_atm_no_barrier_load(&cqd->things_queued_ever),
776
- .cq = cc,
845
+ .cq = cq,
777
846
  .deadline = deadline,
778
847
  .stolen_completion = NULL,
779
848
  .tag = NULL,
@@ -806,22 +875,22 @@ static grpc_event cq_next(grpc_completion_queue *cc, gpr_timespec deadline,
806
875
  /* If c == NULL it means either the queue is empty OR in an transient
807
876
  inconsistent state. If it is the latter, we shold do a 0-timeout poll
808
877
  so that the thread comes back quickly from poll to make a second
809
- attempt at popping. Not doing this can potentially deadlock this thread
810
- forever (if the deadline is infinity) */
878
+ attempt at popping. Not doing this can potentially deadlock this
879
+ thread forever (if the deadline is infinity) */
811
880
  if (cq_event_queue_num_items(&cqd->queue) > 0) {
812
881
  iteration_deadline = gpr_time_0(GPR_CLOCK_MONOTONIC);
813
882
  }
814
883
  }
815
884
 
816
- if (gpr_atm_no_barrier_load(&cqd->shutdown)) {
885
+ if (gpr_atm_no_barrier_load(&cqd->pending_events) == 0) {
817
886
  /* Before returning, check if the queue has any items left over (since
818
887
  gpr_mpscq_pop() can sometimes return NULL even if the queue is not
819
888
  empty. If so, keep retrying but do not return GRPC_QUEUE_SHUTDOWN */
820
889
  if (cq_event_queue_num_items(&cqd->queue) > 0) {
821
890
  /* Go to the beginning of the loop. No point doing a poll because
822
- (cc->shutdown == true) is only possible when there is no pending work
823
- (i.e cc->pending_events == 0) and any outstanding grpc_cq_completion
824
- events are already queued on this cq */
891
+ (cq->shutdown == true) is only possible when there is no pending
892
+ work (i.e cq->pending_events == 0) and any outstanding completion
893
+ events should have already been queued on this cq */
825
894
  continue;
826
895
  }
827
896
 
@@ -834,16 +903,16 @@ static grpc_event cq_next(grpc_completion_queue *cc, gpr_timespec deadline,
834
903
  if (!is_finished_arg.first_loop && gpr_time_cmp(now, deadline) >= 0) {
835
904
  memset(&ret, 0, sizeof(ret));
836
905
  ret.type = GRPC_QUEUE_TIMEOUT;
837
- dump_pending_tags(cc);
906
+ dump_pending_tags(cq);
838
907
  break;
839
908
  }
840
909
 
841
910
  /* The main polling work happens in grpc_pollset_work */
842
- gpr_mu_lock(cqd->mu);
843
- cqd->num_polls++;
844
- grpc_error *err = cc->poller_vtable->work(&exec_ctx, POLLSET_FROM_CQ(cc),
911
+ gpr_mu_lock(cq->mu);
912
+ cq->num_polls++;
913
+ grpc_error *err = cq->poller_vtable->work(&exec_ctx, POLLSET_FROM_CQ(cq),
845
914
  NULL, now, iteration_deadline);
846
- gpr_mu_unlock(cqd->mu);
915
+ gpr_mu_unlock(cq->mu);
847
916
 
848
917
  if (err != GRPC_ERROR_NONE) {
849
918
  const char *msg = grpc_error_string(err);
@@ -852,14 +921,21 @@ static grpc_event cq_next(grpc_completion_queue *cc, gpr_timespec deadline,
852
921
  GRPC_ERROR_UNREF(err);
853
922
  memset(&ret, 0, sizeof(ret));
854
923
  ret.type = GRPC_QUEUE_TIMEOUT;
855
- dump_pending_tags(cc);
924
+ dump_pending_tags(cq);
856
925
  break;
857
926
  }
858
927
  is_finished_arg.first_loop = false;
859
928
  }
860
929
 
861
- GRPC_SURFACE_TRACE_RETURNED_EVENT(cc, &ret);
862
- GRPC_CQ_INTERNAL_UNREF(&exec_ctx, cc, "next");
930
+ if (cq_event_queue_num_items(&cqd->queue) > 0 &&
931
+ gpr_atm_no_barrier_load(&cqd->pending_events) > 0) {
932
+ gpr_mu_lock(cq->mu);
933
+ cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), NULL);
934
+ gpr_mu_unlock(cq->mu);
935
+ }
936
+
937
+ GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret);
938
+ GRPC_CQ_INTERNAL_UNREF(&exec_ctx, cq, "next");
863
939
  grpc_exec_ctx_finish(&exec_ctx);
864
940
  GPR_ASSERT(is_finished_arg.stolen_completion == NULL);
865
941
 
@@ -868,14 +944,57 @@ static grpc_event cq_next(grpc_completion_queue *cc, gpr_timespec deadline,
868
944
  return ret;
869
945
  }
870
946
 
871
- grpc_event grpc_completion_queue_next(grpc_completion_queue *cc,
947
+ /* Finishes the completion queue shutdown. This means that there are no more
948
+ completion events / tags expected from the completion queue
949
+ - Must be called under completion queue lock
950
+ - Must be called only once in completion queue's lifetime
951
+ - grpc_completion_queue_shutdown() MUST have been called before calling
952
+ this function */
953
+ static void cq_finish_shutdown_next(grpc_exec_ctx *exec_ctx,
954
+ grpc_completion_queue *cq) {
955
+ cq_next_data *cqd = DATA_FROM_CQ(cq);
956
+
957
+ GPR_ASSERT(cqd->shutdown_called);
958
+ GPR_ASSERT(gpr_atm_no_barrier_load(&cqd->pending_events) == 0);
959
+
960
+ cq->poller_vtable->shutdown(exec_ctx, POLLSET_FROM_CQ(cq),
961
+ &cq->pollset_shutdown_done);
962
+ }
963
+
964
+ static void cq_shutdown_next(grpc_exec_ctx *exec_ctx,
965
+ grpc_completion_queue *cq) {
966
+ cq_next_data *cqd = DATA_FROM_CQ(cq);
967
+
968
+ /* Need an extra ref for cq here because:
969
+ * We call cq_finish_shutdown_next() below, that would call pollset shutdown.
970
+ * Pollset shutdown decrements the cq ref count which can potentially destroy
971
+ * the cq (if that happens to be the last ref).
972
+ * Creating an extra ref here prevents the cq from getting destroyed while
973
+ * this function is still active */
974
+ GRPC_CQ_INTERNAL_REF(cq, "shutting_down");
975
+ gpr_mu_lock(cq->mu);
976
+ if (cqd->shutdown_called) {
977
+ gpr_mu_unlock(cq->mu);
978
+ GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
979
+ GPR_TIMER_END("grpc_completion_queue_shutdown", 0);
980
+ return;
981
+ }
982
+ cqd->shutdown_called = true;
983
+ if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
984
+ cq_finish_shutdown_next(exec_ctx, cq);
985
+ }
986
+ gpr_mu_unlock(cq->mu);
987
+ GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
988
+ }
989
+
990
+ grpc_event grpc_completion_queue_next(grpc_completion_queue *cq,
872
991
  gpr_timespec deadline, void *reserved) {
873
- return cc->vtable->next(cc, deadline, reserved);
992
+ return cq->vtable->next(cq, deadline, reserved);
874
993
  }
875
994
 
876
- static int add_plucker(grpc_completion_queue *cc, void *tag,
995
+ static int add_plucker(grpc_completion_queue *cq, void *tag,
877
996
  grpc_pollset_worker **worker) {
878
- cq_data *cqd = &cc->data;
997
+ cq_pluck_data *cqd = DATA_FROM_CQ(cq);
879
998
  if (cqd->num_pluckers == GRPC_MAX_COMPLETION_QUEUE_PLUCKERS) {
880
999
  return 0;
881
1000
  }
@@ -885,9 +1004,9 @@ static int add_plucker(grpc_completion_queue *cc, void *tag,
885
1004
  return 1;
886
1005
  }
887
1006
 
888
- static void del_plucker(grpc_completion_queue *cc, void *tag,
1007
+ static void del_plucker(grpc_completion_queue *cq, void *tag,
889
1008
  grpc_pollset_worker **worker) {
890
- cq_data *cqd = &cc->data;
1009
+ cq_pluck_data *cqd = DATA_FROM_CQ(cq);
891
1010
  for (int i = 0; i < cqd->num_pluckers; i++) {
892
1011
  if (cqd->pluckers[i].tag == tag && cqd->pluckers[i].worker == worker) {
893
1012
  cqd->num_pluckers--;
@@ -901,13 +1020,13 @@ static void del_plucker(grpc_completion_queue *cc, void *tag,
901
1020
  static bool cq_is_pluck_finished(grpc_exec_ctx *exec_ctx, void *arg) {
902
1021
  cq_is_finished_arg *a = arg;
903
1022
  grpc_completion_queue *cq = a->cq;
904
- cq_data *cqd = &cq->data;
1023
+ cq_pluck_data *cqd = DATA_FROM_CQ(cq);
905
1024
 
906
1025
  GPR_ASSERT(a->stolen_completion == NULL);
907
1026
  gpr_atm current_last_seen_things_queued_ever =
908
1027
  gpr_atm_no_barrier_load(&cqd->things_queued_ever);
909
1028
  if (current_last_seen_things_queued_ever != a->last_seen_things_queued_ever) {
910
- gpr_mu_lock(cqd->mu);
1029
+ gpr_mu_lock(cq->mu);
911
1030
  a->last_seen_things_queued_ever =
912
1031
  gpr_atm_no_barrier_load(&cqd->things_queued_ever);
913
1032
  grpc_cq_completion *c;
@@ -919,51 +1038,51 @@ static bool cq_is_pluck_finished(grpc_exec_ctx *exec_ctx, void *arg) {
919
1038
  if (c == cqd->completed_tail) {
920
1039
  cqd->completed_tail = prev;
921
1040
  }
922
- gpr_mu_unlock(cqd->mu);
1041
+ gpr_mu_unlock(cq->mu);
923
1042
  a->stolen_completion = c;
924
1043
  return true;
925
1044
  }
926
1045
  prev = c;
927
1046
  }
928
- gpr_mu_unlock(cqd->mu);
1047
+ gpr_mu_unlock(cq->mu);
929
1048
  }
930
1049
  return !a->first_loop &&
931
1050
  gpr_time_cmp(a->deadline, gpr_now(a->deadline.clock_type)) < 0;
932
1051
  }
933
1052
 
934
- static grpc_event cq_pluck(grpc_completion_queue *cc, void *tag,
1053
+ static grpc_event cq_pluck(grpc_completion_queue *cq, void *tag,
935
1054
  gpr_timespec deadline, void *reserved) {
936
1055
  grpc_event ret;
937
1056
  grpc_cq_completion *c;
938
1057
  grpc_cq_completion *prev;
939
1058
  grpc_pollset_worker *worker = NULL;
940
1059
  gpr_timespec now;
941
- cq_data *cqd = &cc->data;
1060
+ cq_pluck_data *cqd = DATA_FROM_CQ(cq);
942
1061
 
943
1062
  GPR_TIMER_BEGIN("grpc_completion_queue_pluck", 0);
944
1063
 
945
1064
  if (GRPC_TRACER_ON(grpc_cq_pluck_trace)) {
946
1065
  GRPC_API_TRACE(
947
1066
  "grpc_completion_queue_pluck("
948
- "cc=%p, tag=%p, "
1067
+ "cq=%p, tag=%p, "
949
1068
  "deadline=gpr_timespec { tv_sec: %" PRId64
950
1069
  ", tv_nsec: %d, clock_type: %d }, "
951
1070
  "reserved=%p)",
952
- 6, (cc, tag, deadline.tv_sec, deadline.tv_nsec,
1071
+ 6, (cq, tag, deadline.tv_sec, deadline.tv_nsec,
953
1072
  (int)deadline.clock_type, reserved));
954
1073
  }
955
1074
  GPR_ASSERT(!reserved);
956
1075
 
957
- dump_pending_tags(cc);
1076
+ dump_pending_tags(cq);
958
1077
 
959
1078
  deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC);
960
1079
 
961
- GRPC_CQ_INTERNAL_REF(cc, "pluck");
962
- gpr_mu_lock(cqd->mu);
1080
+ GRPC_CQ_INTERNAL_REF(cq, "pluck");
1081
+ gpr_mu_lock(cq->mu);
963
1082
  cq_is_finished_arg is_finished_arg = {
964
1083
  .last_seen_things_queued_ever =
965
1084
  gpr_atm_no_barrier_load(&cqd->things_queued_ever),
966
- .cq = cc,
1085
+ .cq = cq,
967
1086
  .deadline = deadline,
968
1087
  .stolen_completion = NULL,
969
1088
  .tag = tag,
@@ -972,7 +1091,7 @@ static grpc_event cq_pluck(grpc_completion_queue *cc, void *tag,
972
1091
  GRPC_EXEC_CTX_INITIALIZER(0, cq_is_pluck_finished, &is_finished_arg);
973
1092
  for (;;) {
974
1093
  if (is_finished_arg.stolen_completion != NULL) {
975
- gpr_mu_unlock(cqd->mu);
1094
+ gpr_mu_unlock(cq->mu);
976
1095
  c = is_finished_arg.stolen_completion;
977
1096
  is_finished_arg.stolen_completion = NULL;
978
1097
  ret.type = GRPC_OP_COMPLETE;
@@ -989,7 +1108,7 @@ static grpc_event cq_pluck(grpc_completion_queue *cc, void *tag,
989
1108
  if (c == cqd->completed_tail) {
990
1109
  cqd->completed_tail = prev;
991
1110
  }
992
- gpr_mu_unlock(cqd->mu);
1111
+ gpr_mu_unlock(cq->mu);
993
1112
  ret.type = GRPC_OP_COMPLETE;
994
1113
  ret.success = c->next & 1u;
995
1114
  ret.tag = c->tag;
@@ -999,54 +1118,54 @@ static grpc_event cq_pluck(grpc_completion_queue *cc, void *tag,
999
1118
  prev = c;
1000
1119
  }
1001
1120
  if (gpr_atm_no_barrier_load(&cqd->shutdown)) {
1002
- gpr_mu_unlock(cqd->mu);
1121
+ gpr_mu_unlock(cq->mu);
1003
1122
  memset(&ret, 0, sizeof(ret));
1004
1123
  ret.type = GRPC_QUEUE_SHUTDOWN;
1005
1124
  break;
1006
1125
  }
1007
- if (!add_plucker(cc, tag, &worker)) {
1126
+ if (!add_plucker(cq, tag, &worker)) {
1008
1127
  gpr_log(GPR_DEBUG,
1009
1128
  "Too many outstanding grpc_completion_queue_pluck calls: maximum "
1010
1129
  "is %d",
1011
1130
  GRPC_MAX_COMPLETION_QUEUE_PLUCKERS);
1012
- gpr_mu_unlock(cqd->mu);
1131
+ gpr_mu_unlock(cq->mu);
1013
1132
  memset(&ret, 0, sizeof(ret));
1014
1133
  /* TODO(ctiller): should we use a different result here */
1015
1134
  ret.type = GRPC_QUEUE_TIMEOUT;
1016
- dump_pending_tags(cc);
1135
+ dump_pending_tags(cq);
1017
1136
  break;
1018
1137
  }
1019
1138
  now = gpr_now(GPR_CLOCK_MONOTONIC);
1020
1139
  if (!is_finished_arg.first_loop && gpr_time_cmp(now, deadline) >= 0) {
1021
- del_plucker(cc, tag, &worker);
1022
- gpr_mu_unlock(cqd->mu);
1140
+ del_plucker(cq, tag, &worker);
1141
+ gpr_mu_unlock(cq->mu);
1023
1142
  memset(&ret, 0, sizeof(ret));
1024
1143
  ret.type = GRPC_QUEUE_TIMEOUT;
1025
- dump_pending_tags(cc);
1144
+ dump_pending_tags(cq);
1026
1145
  break;
1027
1146
  }
1028
1147
 
1029
- cqd->num_polls++;
1030
- grpc_error *err = cc->poller_vtable->work(&exec_ctx, POLLSET_FROM_CQ(cc),
1148
+ cq->num_polls++;
1149
+ grpc_error *err = cq->poller_vtable->work(&exec_ctx, POLLSET_FROM_CQ(cq),
1031
1150
  &worker, now, deadline);
1032
1151
  if (err != GRPC_ERROR_NONE) {
1033
- del_plucker(cc, tag, &worker);
1034
- gpr_mu_unlock(cqd->mu);
1152
+ del_plucker(cq, tag, &worker);
1153
+ gpr_mu_unlock(cq->mu);
1035
1154
  const char *msg = grpc_error_string(err);
1036
1155
  gpr_log(GPR_ERROR, "Completion queue pluck failed: %s", msg);
1037
1156
 
1038
1157
  GRPC_ERROR_UNREF(err);
1039
1158
  memset(&ret, 0, sizeof(ret));
1040
1159
  ret.type = GRPC_QUEUE_TIMEOUT;
1041
- dump_pending_tags(cc);
1160
+ dump_pending_tags(cq);
1042
1161
  break;
1043
1162
  }
1044
1163
  is_finished_arg.first_loop = false;
1045
- del_plucker(cc, tag, &worker);
1164
+ del_plucker(cq, tag, &worker);
1046
1165
  }
1047
1166
  done:
1048
- GRPC_SURFACE_TRACE_RETURNED_EVENT(cc, &ret);
1049
- GRPC_CQ_INTERNAL_UNREF(&exec_ctx, cc, "pluck");
1167
+ GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret);
1168
+ GRPC_CQ_INTERNAL_UNREF(&exec_ctx, cq, "pluck");
1050
1169
  grpc_exec_ctx_finish(&exec_ctx);
1051
1170
  GPR_ASSERT(is_finished_arg.stolen_completion == NULL);
1052
1171
 
@@ -1055,85 +1174,77 @@ done:
1055
1174
  return ret;
1056
1175
  }
1057
1176
 
1058
- grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag,
1177
+ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, void *tag,
1059
1178
  gpr_timespec deadline, void *reserved) {
1060
- return cc->vtable->pluck(cc, tag, deadline, reserved);
1179
+ return cq->vtable->pluck(cq, tag, deadline, reserved);
1061
1180
  }
1062
1181
 
1063
- /* Finishes the completion queue shutdown. This means that there are no more
1064
- completion events / tags expected from the completion queue
1065
- - Must be called under completion queue lock
1066
- - Must be called only once in completion queue's lifetime
1067
- - grpc_completion_queue_shutdown() MUST have been called before calling
1068
- this function */
1069
- static void cq_finish_shutdown(grpc_exec_ctx *exec_ctx,
1070
- grpc_completion_queue *cc) {
1071
- cq_data *cqd = &cc->data;
1182
+ static void cq_finish_shutdown_pluck(grpc_exec_ctx *exec_ctx,
1183
+ grpc_completion_queue *cq) {
1184
+ cq_pluck_data *cqd = DATA_FROM_CQ(cq);
1072
1185
 
1073
1186
  GPR_ASSERT(cqd->shutdown_called);
1074
1187
  GPR_ASSERT(!gpr_atm_no_barrier_load(&cqd->shutdown));
1075
1188
  gpr_atm_no_barrier_store(&cqd->shutdown, 1);
1076
1189
 
1077
- cc->poller_vtable->shutdown(exec_ctx, POLLSET_FROM_CQ(cc),
1078
- &cqd->pollset_shutdown_done);
1190
+ cq->poller_vtable->shutdown(exec_ctx, POLLSET_FROM_CQ(cq),
1191
+ &cq->pollset_shutdown_done);
1079
1192
  }
1080
1193
 
1081
- /* Shutdown simply drops a ref that we reserved at creation time; if we drop
1082
- to zero here, then enter shutdown mode and wake up any waiters */
1083
- void grpc_completion_queue_shutdown(grpc_completion_queue *cc) {
1084
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
1085
- GPR_TIMER_BEGIN("grpc_completion_queue_shutdown", 0);
1086
- GRPC_API_TRACE("grpc_completion_queue_shutdown(cc=%p)", 1, (cc));
1087
- cq_data *cqd = &cc->data;
1088
-
1089
- gpr_mu_lock(cqd->mu);
1194
+ /* NOTE: This function is almost exactly identical to cq_shutdown_next() but
1195
+ * merging them is a bit tricky and probably not worth it */
1196
+ static void cq_shutdown_pluck(grpc_exec_ctx *exec_ctx,
1197
+ grpc_completion_queue *cq) {
1198
+ cq_pluck_data *cqd = DATA_FROM_CQ(cq);
1199
+
1200
+ /* Need an extra ref for cq here because:
1201
+ * We call cq_finish_shutdown_pluck() below, that would call pollset shutdown.
1202
+ * Pollset shutdown decrements the cq ref count which can potentially destroy
1203
+ * the cq (if that happens to be the last ref).
1204
+ * Creating an extra ref here prevents the cq from getting destroyed while
1205
+ * this function is still active */
1206
+ GRPC_CQ_INTERNAL_REF(cq, "shutting_down (pluck cq)");
1207
+ gpr_mu_lock(cq->mu);
1090
1208
  if (cqd->shutdown_called) {
1091
- gpr_mu_unlock(cqd->mu);
1209
+ gpr_mu_unlock(cq->mu);
1210
+ GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down (pluck cq)");
1092
1211
  GPR_TIMER_END("grpc_completion_queue_shutdown", 0);
1093
1212
  return;
1094
1213
  }
1095
- cqd->shutdown_called = 1;
1096
- if (gpr_unref(&cqd->pending_events)) {
1097
- cq_finish_shutdown(&exec_ctx, cc);
1214
+ cqd->shutdown_called = true;
1215
+ if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
1216
+ cq_finish_shutdown_pluck(exec_ctx, cq);
1098
1217
  }
1099
- gpr_mu_unlock(cqd->mu);
1218
+ gpr_mu_unlock(cq->mu);
1219
+ GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down (pluck cq)");
1220
+ }
1221
+
1222
+ /* Shutdown simply drops a ref that we reserved at creation time; if we drop
1223
+ to zero here, then enter shutdown mode and wake up any waiters */
1224
+ void grpc_completion_queue_shutdown(grpc_completion_queue *cq) {
1225
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
1226
+ GPR_TIMER_BEGIN("grpc_completion_queue_shutdown", 0);
1227
+ GRPC_API_TRACE("grpc_completion_queue_shutdown(cq=%p)", 1, (cq));
1228
+ cq->vtable->shutdown(&exec_ctx, cq);
1100
1229
  grpc_exec_ctx_finish(&exec_ctx);
1101
1230
  GPR_TIMER_END("grpc_completion_queue_shutdown", 0);
1102
1231
  }
1103
1232
 
1104
- void grpc_completion_queue_destroy(grpc_completion_queue *cc) {
1105
- GRPC_API_TRACE("grpc_completion_queue_destroy(cc=%p)", 1, (cc));
1233
+ void grpc_completion_queue_destroy(grpc_completion_queue *cq) {
1234
+ GRPC_API_TRACE("grpc_completion_queue_destroy(cq=%p)", 1, (cq));
1106
1235
  GPR_TIMER_BEGIN("grpc_completion_queue_destroy", 0);
1107
- grpc_completion_queue_shutdown(cc);
1108
-
1109
- /* TODO (sreek): This should not ideally be here. Refactor it into the
1110
- * cq_vtable (perhaps have a create/destroy methods in the cq vtable) */
1111
- if (cc->vtable->cq_completion_type == GRPC_CQ_NEXT) {
1112
- GPR_ASSERT(cq_event_queue_num_items(&cc->data.queue) == 0);
1113
- }
1236
+ grpc_completion_queue_shutdown(cq);
1114
1237
 
1115
1238
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
1116
- GRPC_CQ_INTERNAL_UNREF(&exec_ctx, cc, "destroy");
1239
+ GRPC_CQ_INTERNAL_UNREF(&exec_ctx, cq, "destroy");
1117
1240
  grpc_exec_ctx_finish(&exec_ctx);
1118
1241
  GPR_TIMER_END("grpc_completion_queue_destroy", 0);
1119
1242
  }
1120
1243
 
1121
- grpc_pollset *grpc_cq_pollset(grpc_completion_queue *cc) {
1122
- return cc->poller_vtable->can_get_pollset ? POLLSET_FROM_CQ(cc) : NULL;
1123
- }
1124
-
1125
- grpc_completion_queue *grpc_cq_from_pollset(grpc_pollset *ps) {
1126
- return CQ_FROM_POLLSET(ps);
1127
- }
1128
-
1129
- void grpc_cq_mark_server_cq(grpc_completion_queue *cc) {
1130
- cc->data.is_server_cq = 1;
1131
- }
1132
-
1133
- bool grpc_cq_is_server_cq(grpc_completion_queue *cc) {
1134
- return cc->data.is_server_cq;
1244
+ grpc_pollset *grpc_cq_pollset(grpc_completion_queue *cq) {
1245
+ return cq->poller_vtable->can_get_pollset ? POLLSET_FROM_CQ(cq) : NULL;
1135
1246
  }
1136
1247
 
1137
- bool grpc_cq_can_listen(grpc_completion_queue *cc) {
1138
- return cc->poller_vtable->can_listen;
1248
+ bool grpc_cq_can_listen(grpc_completion_queue *cq) {
1249
+ return cq->poller_vtable->can_listen;
1139
1250
  }