grpc 1.6.7 → 1.7.0.pre1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +579 -77
  3. data/include/grpc/byte_buffer.h +1 -63
  4. data/include/grpc/compression.h +27 -5
  5. data/include/grpc/fork.h +24 -0
  6. data/include/grpc/grpc.h +12 -6
  7. data/include/grpc/grpc_security.h +28 -7
  8. data/include/grpc/impl/codegen/atm.h +1 -0
  9. data/include/grpc/impl/codegen/byte_buffer.h +86 -0
  10. data/include/grpc/impl/codegen/compression_types.h +63 -5
  11. data/include/grpc/impl/codegen/fork.h +48 -0
  12. data/include/grpc/impl/codegen/grpc_types.h +26 -9
  13. data/include/grpc/impl/codegen/port_platform.h +11 -4
  14. data/include/grpc/impl/codegen/slice.h +6 -1
  15. data/include/grpc/impl/codegen/sync.h +3 -1
  16. data/include/grpc/impl/codegen/sync_custom.h +36 -0
  17. data/include/grpc/module.modulemap +75 -3
  18. data/include/grpc/slice.h +1 -5
  19. data/include/grpc/support/sync_custom.h +24 -0
  20. data/src/core/ext/census/base_resources.c +14 -14
  21. data/src/core/ext/census/context.c +7 -5
  22. data/src/core/ext/census/grpc_filter.c +12 -14
  23. data/src/core/ext/census/mlog.c +2 -1
  24. data/src/core/ext/census/resource.c +13 -9
  25. data/src/core/ext/filters/client_channel/channel_connectivity.c +15 -8
  26. data/src/core/ext/filters/client_channel/client_channel.c +418 -439
  27. data/src/core/ext/filters/client_channel/client_channel_factory.c +4 -5
  28. data/src/core/ext/filters/client_channel/client_channel_plugin.c +2 -2
  29. data/src/core/ext/filters/client_channel/http_connect_handshaker.c +7 -5
  30. data/src/core/ext/filters/client_channel/http_proxy.c +17 -21
  31. data/src/core/ext/filters/client_channel/lb_policy.c +1 -1
  32. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +7 -7
  33. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +371 -257
  34. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +7 -5
  35. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +25 -14
  36. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +16 -16
  37. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +33 -28
  38. data/src/core/ext/filters/client_channel/lb_policy_factory.c +10 -8
  39. data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -1
  40. data/src/core/ext/filters/client_channel/proxy_mapper_registry.c +1 -1
  41. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +7 -6
  42. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +62 -28
  43. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +29 -23
  44. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c +25 -14
  45. data/src/core/ext/filters/client_channel/retry_throttle.c +9 -6
  46. data/src/core/ext/filters/client_channel/subchannel.c +30 -30
  47. data/src/core/ext/filters/client_channel/subchannel.h +1 -4
  48. data/src/core/ext/filters/client_channel/subchannel_index.c +31 -15
  49. data/src/core/ext/filters/client_channel/subchannel_index.h +7 -0
  50. data/src/core/ext/filters/client_channel/uri_parser.c +4 -3
  51. data/src/core/ext/filters/deadline/deadline_filter.c +78 -39
  52. data/src/core/ext/filters/deadline/deadline_filter.h +7 -1
  53. data/src/core/ext/filters/http/client/http_client_filter.c +14 -14
  54. data/src/core/ext/filters/http/http_filters_plugin.c +1 -1
  55. data/src/core/ext/filters/http/message_compress/message_compress_filter.c +240 -175
  56. data/src/core/ext/filters/http/server/http_server_filter.c +48 -36
  57. data/src/core/ext/filters/load_reporting/{load_reporting_filter.c → server_load_reporting_filter.c} +11 -12
  58. data/src/core/ext/filters/load_reporting/{load_reporting_filter.h → server_load_reporting_filter.h} +6 -5
  59. data/src/core/ext/filters/load_reporting/{load_reporting.c → server_load_reporting_plugin.c} +19 -13
  60. data/src/core/ext/filters/load_reporting/{load_reporting.h → server_load_reporting_plugin.h} +4 -3
  61. data/src/core/ext/filters/max_age/max_age_filter.c +2 -3
  62. data/src/core/ext/filters/message_size/message_size_filter.c +4 -2
  63. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c +0 -1
  64. data/src/core/ext/transport/chttp2/client/chttp2_connector.c +5 -5
  65. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +1 -1
  66. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +1 -1
  67. data/src/core/ext/transport/chttp2/server/chttp2_server.c +20 -18
  68. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +1 -0
  69. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +493 -210
  70. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -0
  71. data/src/core/ext/transport/chttp2/transport/flow_control.c +9 -8
  72. data/src/core/ext/transport/chttp2/transport/frame_data.c +2 -2
  73. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +2 -2
  74. data/src/core/ext/transport/chttp2/transport/frame_ping.c +5 -4
  75. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +1 -1
  76. data/src/core/ext/transport/chttp2/transport/frame_settings.c +10 -9
  77. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +9 -5
  78. data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +62 -41
  79. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +52 -8
  80. data/src/core/ext/transport/chttp2/transport/hpack_table.c +2 -2
  81. data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +3 -2
  82. data/src/core/ext/transport/chttp2/transport/internal.h +60 -30
  83. data/src/core/ext/transport/chttp2/transport/parsing.c +16 -5
  84. data/src/core/ext/transport/chttp2/transport/stream_lists.c +36 -16
  85. data/src/core/ext/transport/chttp2/transport/stream_map.c +6 -4
  86. data/src/core/ext/transport/chttp2/transport/writing.c +133 -105
  87. data/src/core/ext/transport/inproc/inproc_transport.c +61 -65
  88. data/src/core/lib/channel/channel_args.c +112 -12
  89. data/src/core/lib/channel/channel_args.h +31 -0
  90. data/src/core/lib/channel/channel_stack.c +1 -15
  91. data/src/core/lib/channel/channel_stack.h +3 -10
  92. data/src/core/lib/channel/channel_stack_builder.c +41 -10
  93. data/src/core/lib/channel/channel_stack_builder.h +10 -0
  94. data/src/core/lib/channel/connected_channel.c +94 -23
  95. data/src/core/lib/channel/handshaker.c +8 -6
  96. data/src/core/lib/channel/handshaker_registry.c +1 -1
  97. data/src/core/lib/compression/algorithm_metadata.h +14 -0
  98. data/src/core/lib/compression/compression.c +101 -1
  99. data/src/core/lib/compression/stream_compression.c +32 -146
  100. data/src/core/lib/compression/stream_compression.h +28 -4
  101. data/src/core/lib/compression/stream_compression_gzip.c +228 -0
  102. data/src/core/lib/{iomgr/ev_epoll_thread_pool_linux.h → compression/stream_compression_gzip.h} +5 -7
  103. data/src/core/lib/compression/stream_compression_identity.c +94 -0
  104. data/src/core/lib/{iomgr/ev_epoll_limited_pollers_linux.h → compression/stream_compression_identity.h} +7 -8
  105. data/src/core/lib/debug/stats.c +174 -0
  106. data/src/core/lib/debug/stats.h +61 -0
  107. data/src/core/lib/debug/stats_data.c +687 -0
  108. data/src/core/lib/debug/stats_data.h +470 -0
  109. data/src/core/lib/debug/trace.c +3 -3
  110. data/src/core/lib/debug/trace.h +1 -1
  111. data/src/core/lib/http/format_request.c +1 -1
  112. data/src/core/lib/http/httpcli.c +8 -7
  113. data/src/core/lib/http/httpcli_security_connector.c +2 -1
  114. data/src/core/lib/http/parser.c +4 -3
  115. data/src/core/lib/iomgr/call_combiner.c +202 -0
  116. data/src/core/lib/iomgr/call_combiner.h +121 -0
  117. data/src/core/lib/iomgr/closure.c +18 -4
  118. data/src/core/lib/iomgr/combiner.c +11 -4
  119. data/src/core/lib/iomgr/error.c +26 -24
  120. data/src/core/lib/iomgr/ev_epoll1_linux.c +395 -212
  121. data/src/core/lib/iomgr/ev_epollex_linux.c +141 -128
  122. data/src/core/lib/iomgr/ev_epollsig_linux.c +44 -41
  123. data/src/core/lib/iomgr/ev_poll_posix.c +99 -75
  124. data/src/core/lib/iomgr/ev_posix.c +5 -9
  125. data/src/core/lib/iomgr/ev_posix.h +1 -1
  126. data/src/core/lib/iomgr/exec_ctx.h +6 -1
  127. data/src/core/lib/iomgr/executor.c +142 -36
  128. data/src/core/lib/iomgr/executor.h +6 -1
  129. data/src/core/lib/iomgr/fork_posix.c +88 -0
  130. data/src/core/lib/iomgr/fork_windows.c +39 -0
  131. data/src/core/lib/iomgr/iocp_windows.c +2 -0
  132. data/src/core/lib/iomgr/iomgr.c +2 -8
  133. data/src/core/lib/iomgr/is_epollexclusive_available.c +6 -6
  134. data/src/core/lib/iomgr/load_file.c +2 -1
  135. data/src/core/lib/iomgr/polling_entity.c +9 -9
  136. data/src/core/lib/iomgr/polling_entity.h +7 -1
  137. data/src/core/lib/iomgr/pollset.h +1 -1
  138. data/src/core/lib/iomgr/pollset_uv.c +1 -1
  139. data/src/core/lib/iomgr/pollset_windows.c +3 -3
  140. data/src/core/lib/iomgr/port.h +4 -0
  141. data/src/core/lib/iomgr/resolve_address_posix.c +8 -7
  142. data/src/core/lib/iomgr/resolve_address_windows.c +1 -1
  143. data/src/core/lib/iomgr/resource_quota.c +24 -19
  144. data/src/core/lib/iomgr/socket_factory_posix.c +4 -4
  145. data/src/core/lib/iomgr/socket_mutator.c +4 -4
  146. data/src/core/lib/iomgr/socket_utils_windows.c +0 -4
  147. data/src/core/lib/iomgr/tcp_client_posix.c +5 -4
  148. data/src/core/lib/iomgr/tcp_posix.c +181 -20
  149. data/src/core/lib/iomgr/tcp_server_posix.c +8 -7
  150. data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +1 -1
  151. data/src/core/lib/iomgr/timer.h +4 -0
  152. data/src/core/lib/iomgr/timer_generic.c +138 -3
  153. data/src/core/lib/iomgr/timer_generic.h +3 -0
  154. data/src/core/lib/iomgr/timer_heap.c +4 -4
  155. data/src/core/lib/iomgr/timer_manager.c +2 -2
  156. data/src/core/lib/iomgr/timer_uv.c +2 -0
  157. data/src/core/lib/iomgr/udp_server.c +10 -8
  158. data/src/core/lib/iomgr/unix_sockets_posix.c +4 -2
  159. data/src/core/lib/iomgr/wakeup_fd_cv.c +9 -8
  160. data/src/core/lib/iomgr/wakeup_fd_cv.h +2 -2
  161. data/src/core/lib/json/json.c +1 -1
  162. data/src/core/lib/json/json_string.c +13 -13
  163. data/src/core/lib/profiling/timers.h +18 -8
  164. data/src/core/lib/security/credentials/composite/composite_credentials.c +4 -10
  165. data/src/core/lib/security/credentials/google_default/google_default_credentials.c +2 -1
  166. data/src/core/lib/security/credentials/jwt/jwt_verifier.c +11 -6
  167. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +4 -4
  168. data/src/core/lib/security/credentials/plugin/plugin_credentials.c +132 -50
  169. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -0
  170. data/src/core/lib/security/transport/client_auth_filter.c +68 -135
  171. data/src/core/lib/security/transport/secure_endpoint.c +110 -90
  172. data/src/core/lib/security/transport/secure_endpoint.h +8 -3
  173. data/src/core/lib/security/transport/security_connector.c +10 -12
  174. data/src/core/lib/security/transport/security_handshaker.c +45 -24
  175. data/src/core/lib/security/transport/server_auth_filter.c +71 -20
  176. data/src/core/lib/slice/b64.c +2 -2
  177. data/src/core/lib/slice/slice.c +16 -14
  178. data/src/core/lib/slice/slice_buffer.c +5 -4
  179. data/src/core/lib/slice/slice_hash_table.c +3 -2
  180. data/src/core/lib/slice/slice_intern.c +8 -5
  181. data/src/core/lib/support/block_annotate.h +22 -0
  182. data/src/core/lib/support/fork.c +62 -0
  183. data/src/core/lib/support/fork.h +35 -0
  184. data/src/core/lib/support/log_linux.c +1 -1
  185. data/src/core/lib/support/string.c +15 -1
  186. data/src/core/lib/support/string.h +3 -0
  187. data/src/core/lib/support/thd_internal.h +6 -0
  188. data/src/core/lib/support/thd_posix.c +56 -0
  189. data/src/core/lib/support/thd_windows.c +2 -0
  190. data/src/core/lib/surface/alarm.c +22 -15
  191. data/src/core/lib/surface/byte_buffer.c +4 -2
  192. data/src/core/lib/surface/call.c +442 -141
  193. data/src/core/lib/surface/call.h +6 -6
  194. data/src/core/lib/surface/call_log_batch.c +1 -1
  195. data/src/core/lib/surface/call_test_only.h +12 -0
  196. data/src/core/lib/surface/channel.c +39 -4
  197. data/src/core/lib/surface/channel_init.c +6 -6
  198. data/src/core/lib/surface/channel_ping.c +2 -2
  199. data/src/core/lib/surface/completion_queue.c +56 -57
  200. data/src/core/lib/surface/init.c +17 -3
  201. data/src/core/lib/surface/init_secure.c +5 -1
  202. data/src/core/lib/surface/lame_client.cc +9 -10
  203. data/src/core/lib/surface/server.c +81 -72
  204. data/src/core/lib/surface/version.c +2 -2
  205. data/src/core/lib/transport/byte_stream.c +1 -0
  206. data/src/core/lib/transport/byte_stream.h +3 -1
  207. data/src/core/lib/transport/connectivity_state.c +2 -1
  208. data/src/core/lib/transport/metadata.c +7 -4
  209. data/src/core/lib/transport/metadata_batch.c +18 -16
  210. data/src/core/lib/transport/metadata_batch.h +1 -0
  211. data/src/core/lib/transport/service_config.c +5 -3
  212. data/src/core/lib/transport/static_metadata.c +395 -614
  213. data/src/core/lib/transport/static_metadata.h +165 -133
  214. data/src/core/lib/transport/status_conversion.c +1 -1
  215. data/src/core/lib/transport/transport.c +20 -20
  216. data/src/core/lib/transport/transport.h +8 -5
  217. data/src/core/lib/transport/transport_impl.h +0 -3
  218. data/src/core/lib/transport/transport_op_string.c +8 -1
  219. data/src/core/plugin_registry/grpc_plugin_registry.c +4 -4
  220. data/src/core/tsi/fake_transport_security.c +133 -2
  221. data/src/core/tsi/fake_transport_security.h +5 -0
  222. data/src/core/tsi/ssl_transport_security.c +105 -8
  223. data/src/core/tsi/ssl_transport_security.h +30 -7
  224. data/src/core/tsi/transport_security.h +8 -2
  225. data/src/core/tsi/transport_security_grpc.c +20 -13
  226. data/src/core/tsi/transport_security_grpc.h +13 -9
  227. data/src/ruby/ext/grpc/rb_call_credentials.c +6 -2
  228. data/src/ruby/ext/grpc/rb_grpc.c +1 -1
  229. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +30 -20
  230. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +50 -35
  231. data/src/ruby/lib/grpc.rb +1 -0
  232. data/src/ruby/lib/grpc/generic/active_call.rb +34 -9
  233. data/src/ruby/lib/grpc/generic/bidi_call.rb +19 -10
  234. data/src/ruby/lib/grpc/generic/client_stub.rb +95 -38
  235. data/src/ruby/lib/grpc/generic/interceptor_registry.rb +53 -0
  236. data/src/ruby/lib/grpc/generic/interceptors.rb +186 -0
  237. data/src/ruby/lib/grpc/generic/rpc_desc.rb +66 -20
  238. data/src/ruby/lib/grpc/generic/rpc_server.rb +15 -3
  239. data/src/ruby/lib/grpc/google_rpc_status_utils.rb +1 -2
  240. data/src/ruby/lib/grpc/version.rb +1 -1
  241. data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +1 -0
  242. data/src/ruby/spec/channel_connection_spec.rb +1 -34
  243. data/src/ruby/spec/client_server_spec.rb +188 -82
  244. data/src/ruby/spec/generic/active_call_spec.rb +65 -11
  245. data/src/ruby/spec/generic/client_interceptors_spec.rb +153 -0
  246. data/src/ruby/spec/generic/interceptor_registry_spec.rb +65 -0
  247. data/src/ruby/spec/generic/rpc_desc_spec.rb +38 -0
  248. data/src/ruby/spec/generic/rpc_server_spec.rb +1 -34
  249. data/src/ruby/spec/generic/server_interceptors_spec.rb +218 -0
  250. data/src/ruby/spec/spec_helper.rb +4 -0
  251. data/src/ruby/spec/support/helpers.rb +73 -0
  252. data/src/ruby/spec/support/services.rb +147 -0
  253. data/third_party/cares/ares_build.h +21 -62
  254. data/third_party/cares/cares/ares.h +23 -1
  255. data/third_party/cares/cares/ares__close_sockets.c +2 -2
  256. data/third_party/cares/cares/ares_create_query.c +3 -3
  257. data/third_party/cares/cares/ares_expand_name.c +6 -2
  258. data/third_party/cares/cares/ares_expand_string.c +1 -1
  259. data/third_party/cares/cares/ares_getnameinfo.c +27 -7
  260. data/third_party/cares/cares/ares_init.c +407 -39
  261. data/third_party/cares/cares/ares_library_init.c +10 -0
  262. data/third_party/cares/cares/ares_library_init.h +2 -1
  263. data/third_party/cares/cares/ares_nowarn.c +6 -6
  264. data/third_party/cares/cares/ares_nowarn.h +2 -2
  265. data/third_party/cares/cares/ares_parse_naptr_reply.c +6 -1
  266. data/third_party/cares/cares/ares_private.h +11 -0
  267. data/third_party/cares/cares/ares_process.c +126 -37
  268. data/third_party/cares/cares/ares_version.h +2 -2
  269. data/third_party/cares/cares/ares_writev.c +2 -2
  270. data/third_party/cares/cares/config-win32.h +8 -34
  271. data/third_party/cares/cares/inet_net_pton.c +2 -2
  272. data/third_party/cares/cares/setup_once.h +5 -5
  273. data/third_party/cares/config_darwin/ares_config.h +98 -196
  274. data/third_party/cares/config_linux/ares_config.h +103 -203
  275. metadata +47 -20
  276. data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +0 -1957
  277. data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +0 -1182
@@ -21,6 +21,7 @@
21
21
  #include <limits.h>
22
22
  #include <memory.h>
23
23
 
24
+ #include <grpc/fork.h>
24
25
  #include <grpc/grpc.h>
25
26
  #include <grpc/support/alloc.h>
26
27
  #include <grpc/support/log.h>
@@ -28,14 +29,19 @@
28
29
  #include "src/core/lib/channel/channel_stack.h"
29
30
  #include "src/core/lib/channel/connected_channel.h"
30
31
  #include "src/core/lib/channel/handshaker_registry.h"
32
+ #include "src/core/lib/debug/stats.h"
31
33
  #include "src/core/lib/debug/trace.h"
32
34
  #include "src/core/lib/http/parser.h"
35
+ #include "src/core/lib/iomgr/call_combiner.h"
33
36
  #include "src/core/lib/iomgr/combiner.h"
34
37
  #include "src/core/lib/iomgr/executor.h"
35
38
  #include "src/core/lib/iomgr/iomgr.h"
36
39
  #include "src/core/lib/iomgr/resource_quota.h"
40
+ #include "src/core/lib/iomgr/timer_manager.h"
37
41
  #include "src/core/lib/profiling/timers.h"
38
42
  #include "src/core/lib/slice/slice_internal.h"
43
+ #include "src/core/lib/support/fork.h"
44
+ #include "src/core/lib/support/thd_internal.h"
39
45
  #include "src/core/lib/surface/alarm_internal.h"
40
46
  #include "src/core/lib/surface/api_trace.h"
41
47
  #include "src/core/lib/surface/call.h"
@@ -59,9 +65,11 @@ static int g_initializations;
59
65
 
60
66
  static void do_basic_init(void) {
61
67
  gpr_log_verbosity_init();
68
+ grpc_fork_support_init();
62
69
  gpr_mu_init(&g_init_mu);
63
70
  grpc_register_built_in_plugins();
64
71
  g_initializations = 0;
72
+ grpc_fork_handlers_auto_register();
65
73
  }
66
74
 
67
75
  static bool append_filter(grpc_exec_ctx *exec_ctx,
@@ -118,6 +126,8 @@ void grpc_init(void) {
118
126
  gpr_mu_lock(&g_init_mu);
119
127
  if (++g_initializations == 1) {
120
128
  gpr_time_init();
129
+ gpr_thd_init();
130
+ grpc_stats_init();
121
131
  grpc_slice_intern_init();
122
132
  grpc_mdctx_global_init();
123
133
  grpc_channel_init_init();
@@ -127,6 +137,7 @@ void grpc_init(void) {
127
137
  grpc_register_tracer(&grpc_trace_channel_stack_builder);
128
138
  grpc_register_tracer(&grpc_http1_trace);
129
139
  grpc_register_tracer(&grpc_cq_pluck_trace); // default on
140
+ grpc_register_tracer(&grpc_call_combiner_trace);
130
141
  grpc_register_tracer(&grpc_combiner_trace);
131
142
  grpc_register_tracer(&grpc_server_channel_trace);
132
143
  grpc_register_tracer(&grpc_bdp_estimator_trace);
@@ -175,17 +186,20 @@ void grpc_shutdown(void) {
175
186
  GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, NULL);
176
187
  gpr_mu_lock(&g_init_mu);
177
188
  if (--g_initializations == 0) {
178
- grpc_iomgr_shutdown(&exec_ctx);
179
- gpr_timers_global_destroy();
180
- grpc_tracer_shutdown();
189
+ grpc_executor_shutdown(&exec_ctx);
190
+ grpc_timer_manager_set_threading(false); // shutdown timer_manager thread
181
191
  for (i = g_number_of_plugins; i >= 0; i--) {
182
192
  if (g_all_of_the_plugins[i].destroy != NULL) {
183
193
  g_all_of_the_plugins[i].destroy();
184
194
  }
185
195
  }
196
+ grpc_iomgr_shutdown(&exec_ctx);
197
+ gpr_timers_global_destroy();
198
+ grpc_tracer_shutdown();
186
199
  grpc_mdctx_global_shutdown(&exec_ctx);
187
200
  grpc_handshaker_factory_registry_shutdown(&exec_ctx);
188
201
  grpc_slice_intern_shutdown();
202
+ grpc_stats_shutdown();
189
203
  }
190
204
  gpr_mu_unlock(&g_init_mu);
191
205
  grpc_exec_ctx_finish(&exec_ctx);
@@ -25,6 +25,7 @@
25
25
 
26
26
  #include "src/core/lib/debug/trace.h"
27
27
  #include "src/core/lib/security/credentials/credentials.h"
28
+ #include "src/core/lib/security/credentials/plugin/plugin_credentials.h"
28
29
  #include "src/core/lib/security/transport/auth_filters.h"
29
30
  #include "src/core/lib/security/transport/secure_endpoint.h"
30
31
  #include "src/core/lib/security/transport/security_connector.h"
@@ -84,4 +85,7 @@ void grpc_register_security_filters(void) {
84
85
  maybe_prepend_server_auth_filter, NULL);
85
86
  }
86
87
 
87
- void grpc_security_init() { grpc_security_register_handshaker_factories(); }
88
+ void grpc_security_init() {
89
+ grpc_security_register_handshaker_factories();
90
+ grpc_register_tracer(&grpc_plugin_credentials_trace);
91
+ }
@@ -40,6 +40,7 @@ namespace grpc_core {
40
40
  namespace {
41
41
 
42
42
  struct CallData {
43
+ grpc_call_combiner *call_combiner;
43
44
  grpc_linked_mdelem status;
44
45
  grpc_linked_mdelem details;
45
46
  grpc_core::atomic<bool> filled_metadata;
@@ -52,14 +53,14 @@ struct ChannelData {
52
53
 
53
54
  static void fill_metadata(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
54
55
  grpc_metadata_batch *mdb) {
55
- CallData *calld = static_cast<CallData *>(elem->call_data);
56
+ CallData *calld = reinterpret_cast<CallData *>(elem->call_data);
56
57
  bool expected = false;
57
58
  if (!calld->filled_metadata.compare_exchange_strong(
58
59
  expected, true, grpc_core::memory_order_relaxed,
59
60
  grpc_core::memory_order_relaxed)) {
60
61
  return;
61
62
  }
62
- ChannelData *chand = static_cast<ChannelData *>(elem->channel_data);
63
+ ChannelData *chand = reinterpret_cast<ChannelData *>(elem->channel_data);
63
64
  char tmp[GPR_LTOA_MIN_BUFSIZE];
64
65
  gpr_ltoa(chand->error_code, tmp);
65
66
  calld->status.md = grpc_mdelem_from_slices(
@@ -79,6 +80,7 @@ static void fill_metadata(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
79
80
  static void lame_start_transport_stream_op_batch(
80
81
  grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
81
82
  grpc_transport_stream_op_batch *op) {
83
+ CallData *calld = reinterpret_cast<CallData *>(elem->call_data);
82
84
  if (op->recv_initial_metadata) {
83
85
  fill_metadata(exec_ctx, elem,
84
86
  op->payload->recv_initial_metadata.recv_initial_metadata);
@@ -87,12 +89,8 @@ static void lame_start_transport_stream_op_batch(
87
89
  op->payload->recv_trailing_metadata.recv_trailing_metadata);
88
90
  }
89
91
  grpc_transport_stream_op_batch_finish_with_failure(
90
- exec_ctx, op,
91
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("lame client channel"));
92
- }
93
-
94
- static char *lame_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
95
- return NULL;
92
+ exec_ctx, op, GRPC_ERROR_CREATE_FROM_STATIC_STRING("lame client channel"),
93
+ calld->call_combiner);
96
94
  }
97
95
 
98
96
  static void lame_get_channel_info(grpc_exec_ctx *exec_ctx,
@@ -122,6 +120,8 @@ static void lame_start_transport_op(grpc_exec_ctx *exec_ctx,
122
120
  static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
123
121
  grpc_call_element *elem,
124
122
  const grpc_call_element_args *args) {
123
+ CallData *calld = reinterpret_cast<CallData *>(elem->call_data);
124
+ calld->call_combiner = args->call_combiner;
125
125
  return GRPC_ERROR_NONE;
126
126
  }
127
127
 
@@ -156,7 +156,6 @@ extern "C" const grpc_channel_filter grpc_lame_filter = {
156
156
  sizeof(grpc_core::ChannelData),
157
157
  grpc_core::init_channel_elem,
158
158
  grpc_core::destroy_channel_elem,
159
- grpc_core::lame_get_peer,
160
159
  grpc_core::lame_get_channel_info,
161
160
  "lame-client",
162
161
  };
@@ -176,7 +175,7 @@ grpc_channel *grpc_lame_client_channel_create(const char *target,
176
175
  "error_message=%s)",
177
176
  3, (target, (int)error_code, error_message));
178
177
  GPR_ASSERT(elem->filter == &grpc_lame_filter);
179
- auto chand = static_cast<grpc_core::ChannelData *>(elem->channel_data);
178
+ auto chand = reinterpret_cast<grpc_core::ChannelData *>(elem->channel_data);
180
179
  chand->error_code = error_code;
181
180
  chand->error_message = error_message;
182
181
  grpc_exec_ctx_finish(&exec_ctx);
@@ -29,6 +29,7 @@
29
29
 
30
30
  #include "src/core/lib/channel/channel_args.h"
31
31
  #include "src/core/lib/channel/connected_channel.h"
32
+ #include "src/core/lib/debug/stats.h"
32
33
  #include "src/core/lib/iomgr/executor.h"
33
34
  #include "src/core/lib/iomgr/iomgr.h"
34
35
  #include "src/core/lib/slice/slice_internal.h"
@@ -75,7 +76,7 @@ typedef struct requested_call {
75
76
  grpc_call_details *details;
76
77
  } batch;
77
78
  struct {
78
- registered_method *registered_method;
79
+ registered_method *method;
79
80
  gpr_timespec *deadline;
80
81
  grpc_byte_buffer **optional_payload;
81
82
  } registered;
@@ -144,7 +145,7 @@ struct call_data {
144
145
  uint32_t recv_initial_metadata_flags;
145
146
  grpc_metadata_array initial_metadata;
146
147
 
147
- request_matcher *request_matcher;
148
+ request_matcher *matcher;
148
149
  grpc_byte_buffer *payload;
149
150
 
150
151
  grpc_closure got_initial_metadata;
@@ -170,7 +171,7 @@ struct registered_method {
170
171
  grpc_server_register_method_payload_handling payload_handling;
171
172
  uint32_t flags;
172
173
  /* one request matcher per method */
173
- request_matcher request_matcher;
174
+ request_matcher matcher;
174
175
  registered_method *next;
175
176
  };
176
177
 
@@ -250,7 +251,8 @@ static void channel_broadcaster_init(grpc_server *s, channel_broadcaster *cb) {
250
251
  count++;
251
252
  }
252
253
  cb->num_channels = count;
253
- cb->channels = gpr_malloc(sizeof(*cb->channels) * cb->num_channels);
254
+ cb->channels =
255
+ (grpc_channel **)gpr_malloc(sizeof(*cb->channels) * cb->num_channels);
254
256
  count = 0;
255
257
  for (c = s->root_channel_data.next; c != &s->root_channel_data; c = c->next) {
256
258
  cb->channels[count++] = c->channel;
@@ -265,14 +267,15 @@ struct shutdown_cleanup_args {
265
267
 
266
268
  static void shutdown_cleanup(grpc_exec_ctx *exec_ctx, void *arg,
267
269
  grpc_error *error) {
268
- struct shutdown_cleanup_args *a = arg;
270
+ struct shutdown_cleanup_args *a = (struct shutdown_cleanup_args *)arg;
269
271
  grpc_slice_unref_internal(exec_ctx, a->slice);
270
272
  gpr_free(a);
271
273
  }
272
274
 
273
275
  static void send_shutdown(grpc_exec_ctx *exec_ctx, grpc_channel *channel,
274
276
  bool send_goaway, grpc_error *send_disconnect) {
275
- struct shutdown_cleanup_args *sc = gpr_malloc(sizeof(*sc));
277
+ struct shutdown_cleanup_args *sc =
278
+ (struct shutdown_cleanup_args *)gpr_malloc(sizeof(*sc));
276
279
  GRPC_CLOSURE_INIT(&sc->closure, shutdown_cleanup, sc,
277
280
  grpc_schedule_on_exec_ctx);
278
281
  grpc_transport_op *op = grpc_make_transport_op(&sc->closure);
@@ -314,8 +317,8 @@ static void request_matcher_init(request_matcher *rm, size_t entries,
314
317
  grpc_server *server) {
315
318
  memset(rm, 0, sizeof(*rm));
316
319
  rm->server = server;
317
- rm->requests_per_cq =
318
- gpr_malloc(sizeof(*rm->requests_per_cq) * server->cq_count);
320
+ rm->requests_per_cq = (gpr_stack_lockfree **)gpr_malloc(
321
+ sizeof(*rm->requests_per_cq) * server->cq_count);
319
322
  for (size_t i = 0; i < server->cq_count; i++) {
320
323
  rm->requests_per_cq[i] = gpr_stack_lockfree_create(entries);
321
324
  }
@@ -331,7 +334,7 @@ static void request_matcher_destroy(request_matcher *rm) {
331
334
 
332
335
  static void kill_zombie(grpc_exec_ctx *exec_ctx, void *elem,
333
336
  grpc_error *error) {
334
- grpc_call_unref(grpc_call_from_top_element(elem));
337
+ grpc_call_unref(grpc_call_from_top_element((grpc_call_element *)elem));
335
338
  }
336
339
 
337
340
  static void request_matcher_zombify_all_pending_calls(grpc_exec_ctx *exec_ctx,
@@ -384,7 +387,7 @@ static void server_delete(grpc_exec_ctx *exec_ctx, grpc_server *server) {
384
387
  while ((rm = server->registered_methods) != NULL) {
385
388
  server->registered_methods = rm->next;
386
389
  if (server->started) {
387
- request_matcher_destroy(&rm->request_matcher);
390
+ request_matcher_destroy(&rm->matcher);
388
391
  }
389
392
  gpr_free(rm->method);
390
393
  gpr_free(rm->host);
@@ -426,7 +429,7 @@ static void orphan_channel(channel_data *chand) {
426
429
 
427
430
  static void finish_destroy_channel(grpc_exec_ctx *exec_ctx, void *cd,
428
431
  grpc_error *error) {
429
- channel_data *chand = cd;
432
+ channel_data *chand = (channel_data *)cd;
430
433
  grpc_server *server = chand->server;
431
434
  GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, chand->channel, "server");
432
435
  server_unref(exec_ctx, server);
@@ -459,7 +462,7 @@ static void destroy_channel(grpc_exec_ctx *exec_ctx, channel_data *chand,
459
462
 
460
463
  static void done_request_event(grpc_exec_ctx *exec_ctx, void *req,
461
464
  grpc_cq_completion *c) {
462
- requested_call *rc = req;
465
+ requested_call *rc = (requested_call *)req;
463
466
  grpc_server *server = rc->server;
464
467
 
465
468
  if (rc >= server->requested_calls_per_cq[rc->cq_idx] &&
@@ -505,7 +508,7 @@ static void publish_call(grpc_exec_ctx *exec_ctx, grpc_server *server,
505
508
 
506
509
  grpc_call_element *elem =
507
510
  grpc_call_stack_element(grpc_call_get_call_stack(call), 0);
508
- channel_data *chand = elem->channel_data;
511
+ channel_data *chand = (channel_data *)elem->channel_data;
509
512
  server_ref(chand->server);
510
513
  grpc_cq_end_op(exec_ctx, calld->cq_new, rc->tag, GRPC_ERROR_NONE,
511
514
  done_request_event, rc, &rc->completion);
@@ -513,10 +516,10 @@ static void publish_call(grpc_exec_ctx *exec_ctx, grpc_server *server,
513
516
 
514
517
  static void publish_new_rpc(grpc_exec_ctx *exec_ctx, void *arg,
515
518
  grpc_error *error) {
516
- grpc_call_element *call_elem = arg;
517
- call_data *calld = call_elem->call_data;
518
- channel_data *chand = call_elem->channel_data;
519
- request_matcher *rm = calld->request_matcher;
519
+ grpc_call_element *call_elem = (grpc_call_element *)arg;
520
+ call_data *calld = (call_data *)call_elem->call_data;
521
+ channel_data *chand = (channel_data *)call_elem->channel_data;
522
+ request_matcher *rm = calld->matcher;
520
523
  grpc_server *server = rm->server;
521
524
 
522
525
  if (error != GRPC_ERROR_NONE || gpr_atm_acq_load(&server->shutdown_flag)) {
@@ -538,6 +541,7 @@ static void publish_new_rpc(grpc_exec_ctx *exec_ctx, void *arg,
538
541
  if (request_id == -1) {
539
542
  continue;
540
543
  } else {
544
+ GRPC_STATS_INC_SERVER_CQS_CHECKED(exec_ctx, i);
541
545
  gpr_mu_lock(&calld->mu_state);
542
546
  calld->state = ACTIVATED;
543
547
  gpr_mu_unlock(&calld->mu_state);
@@ -548,6 +552,7 @@ static void publish_new_rpc(grpc_exec_ctx *exec_ctx, void *arg,
548
552
  }
549
553
 
550
554
  /* no cq to take the request found: queue it on the slow list */
555
+ GRPC_STATS_INC_SERVER_SLOWPATH_REQUESTS_QUEUED(exec_ctx);
551
556
  gpr_mu_lock(&server->mu_call);
552
557
  gpr_mu_lock(&calld->mu_state);
553
558
  calld->state = PENDING;
@@ -566,7 +571,7 @@ static void finish_start_new_rpc(
566
571
  grpc_exec_ctx *exec_ctx, grpc_server *server, grpc_call_element *elem,
567
572
  request_matcher *rm,
568
573
  grpc_server_register_method_payload_handling payload_handling) {
569
- call_data *calld = elem->call_data;
574
+ call_data *calld = (call_data *)elem->call_data;
570
575
 
571
576
  if (gpr_atm_acq_load(&server->shutdown_flag)) {
572
577
  gpr_mu_lock(&calld->mu_state);
@@ -578,7 +583,7 @@ static void finish_start_new_rpc(
578
583
  return;
579
584
  }
580
585
 
581
- calld->request_matcher = rm;
586
+ calld->matcher = rm;
582
587
 
583
588
  switch (payload_handling) {
584
589
  case GRPC_SRM_PAYLOAD_NONE:
@@ -599,8 +604,8 @@ static void finish_start_new_rpc(
599
604
  }
600
605
 
601
606
  static void start_new_rpc(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
602
- channel_data *chand = elem->channel_data;
603
- call_data *calld = elem->call_data;
607
+ channel_data *chand = (channel_data *)elem->channel_data;
608
+ call_data *calld = (call_data *)elem->call_data;
604
609
  grpc_server *server = chand->server;
605
610
  uint32_t i;
606
611
  uint32_t hash;
@@ -624,7 +629,7 @@ static void start_new_rpc(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
624
629
  continue;
625
630
  }
626
631
  finish_start_new_rpc(exec_ctx, server, elem,
627
- &rm->server_registered_method->request_matcher,
632
+ &rm->server_registered_method->matcher,
628
633
  rm->server_registered_method->payload_handling);
629
634
  return;
630
635
  }
@@ -642,7 +647,7 @@ static void start_new_rpc(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
642
647
  continue;
643
648
  }
644
649
  finish_start_new_rpc(exec_ctx, server, elem,
645
- &rm->server_registered_method->request_matcher,
650
+ &rm->server_registered_method->matcher,
646
651
  rm->server_registered_method->payload_handling);
647
652
  return;
648
653
  }
@@ -663,7 +668,7 @@ static int num_listeners(grpc_server *server) {
663
668
 
664
669
  static void done_shutdown_event(grpc_exec_ctx *exec_ctx, void *server,
665
670
  grpc_cq_completion *completion) {
666
- server_unref(exec_ctx, server);
671
+ server_unref(exec_ctx, (grpc_server *)server);
667
672
  }
668
673
 
669
674
  static int num_channels(grpc_server *server) {
@@ -686,9 +691,9 @@ static void kill_pending_work_locked(grpc_exec_ctx *exec_ctx,
686
691
  exec_ctx, &server->unregistered_request_matcher);
687
692
  for (registered_method *rm = server->registered_methods; rm;
688
693
  rm = rm->next) {
689
- request_matcher_kill_requests(exec_ctx, server, &rm->request_matcher,
694
+ request_matcher_kill_requests(exec_ctx, server, &rm->matcher,
690
695
  GRPC_ERROR_REF(error));
691
- request_matcher_zombify_all_pending_calls(exec_ctx, &rm->request_matcher);
696
+ request_matcher_zombify_all_pending_calls(exec_ctx, &rm->matcher);
692
697
  }
693
698
  }
694
699
  GRPC_ERROR_UNREF(error);
@@ -732,8 +737,8 @@ static void maybe_finish_shutdown(grpc_exec_ctx *exec_ctx,
732
737
 
733
738
  static void server_on_recv_initial_metadata(grpc_exec_ctx *exec_ctx, void *ptr,
734
739
  grpc_error *error) {
735
- grpc_call_element *elem = ptr;
736
- call_data *calld = elem->call_data;
740
+ grpc_call_element *elem = (grpc_call_element *)ptr;
741
+ call_data *calld = (call_data *)elem->call_data;
737
742
  gpr_timespec op_deadline;
738
743
 
739
744
  if (error == GRPC_ERROR_NONE) {
@@ -771,7 +776,7 @@ static void server_on_recv_initial_metadata(grpc_exec_ctx *exec_ctx, void *ptr,
771
776
 
772
777
  static void server_mutate_op(grpc_call_element *elem,
773
778
  grpc_transport_stream_op_batch *op) {
774
- call_data *calld = elem->call_data;
779
+ call_data *calld = (call_data *)elem->call_data;
775
780
 
776
781
  if (op->recv_initial_metadata) {
777
782
  GPR_ASSERT(op->payload->recv_initial_metadata.recv_flags == NULL);
@@ -789,15 +794,14 @@ static void server_mutate_op(grpc_call_element *elem,
789
794
  static void server_start_transport_stream_op_batch(
790
795
  grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
791
796
  grpc_transport_stream_op_batch *op) {
792
- GRPC_CALL_LOG_OP(GPR_INFO, elem, op);
793
797
  server_mutate_op(elem, op);
794
798
  grpc_call_next_op(exec_ctx, elem, op);
795
799
  }
796
800
 
797
801
  static void got_initial_metadata(grpc_exec_ctx *exec_ctx, void *ptr,
798
802
  grpc_error *error) {
799
- grpc_call_element *elem = ptr;
800
- call_data *calld = elem->call_data;
803
+ grpc_call_element *elem = (grpc_call_element *)ptr;
804
+ call_data *calld = (call_data *)elem->call_data;
801
805
  if (error == GRPC_ERROR_NONE) {
802
806
  start_new_rpc(exec_ctx, elem);
803
807
  } else {
@@ -823,7 +827,7 @@ static void got_initial_metadata(grpc_exec_ctx *exec_ctx, void *ptr,
823
827
  static void accept_stream(grpc_exec_ctx *exec_ctx, void *cd,
824
828
  grpc_transport *transport,
825
829
  const void *transport_server_data) {
826
- channel_data *chand = cd;
830
+ channel_data *chand = (channel_data *)cd;
827
831
  /* create a call */
828
832
  grpc_call_create_args args;
829
833
  memset(&args, 0, sizeof(args));
@@ -839,7 +843,7 @@ static void accept_stream(grpc_exec_ctx *exec_ctx, void *cd,
839
843
  GRPC_ERROR_UNREF(error);
840
844
  return;
841
845
  }
842
- call_data *calld = elem->call_data;
846
+ call_data *calld = (call_data *)elem->call_data;
843
847
  grpc_op op;
844
848
  memset(&op, 0, sizeof(op));
845
849
  op.op = GRPC_OP_RECV_INITIAL_METADATA;
@@ -853,7 +857,7 @@ static void accept_stream(grpc_exec_ctx *exec_ctx, void *cd,
853
857
 
854
858
  static void channel_connectivity_changed(grpc_exec_ctx *exec_ctx, void *cd,
855
859
  grpc_error *error) {
856
- channel_data *chand = cd;
860
+ channel_data *chand = (channel_data *)cd;
857
861
  grpc_server *server = chand->server;
858
862
  if (chand->connectivity_state != GRPC_CHANNEL_SHUTDOWN) {
859
863
  grpc_transport_op *op = grpc_make_transport_op(NULL);
@@ -874,8 +878,8 @@ static void channel_connectivity_changed(grpc_exec_ctx *exec_ctx, void *cd,
874
878
  static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
875
879
  grpc_call_element *elem,
876
880
  const grpc_call_element_args *args) {
877
- call_data *calld = elem->call_data;
878
- channel_data *chand = elem->channel_data;
881
+ call_data *calld = (call_data *)elem->call_data;
882
+ channel_data *chand = (channel_data *)elem->channel_data;
879
883
  memset(calld, 0, sizeof(call_data));
880
884
  calld->deadline = gpr_inf_future(GPR_CLOCK_REALTIME);
881
885
  calld->call = grpc_call_from_top_element(elem);
@@ -892,8 +896,8 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
892
896
  static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
893
897
  const grpc_call_final_info *final_info,
894
898
  grpc_closure *ignored) {
895
- channel_data *chand = elem->channel_data;
896
- call_data *calld = elem->call_data;
899
+ channel_data *chand = (channel_data *)elem->channel_data;
900
+ call_data *calld = (call_data *)elem->call_data;
897
901
 
898
902
  GPR_ASSERT(calld->state != PENDING);
899
903
 
@@ -914,7 +918,7 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
914
918
  static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
915
919
  grpc_channel_element *elem,
916
920
  grpc_channel_element_args *args) {
917
- channel_data *chand = elem->channel_data;
921
+ channel_data *chand = (channel_data *)elem->channel_data;
918
922
  GPR_ASSERT(args->is_first);
919
923
  GPR_ASSERT(!args->is_last);
920
924
  chand->server = NULL;
@@ -931,7 +935,7 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
931
935
  static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
932
936
  grpc_channel_element *elem) {
933
937
  size_t i;
934
- channel_data *chand = elem->channel_data;
938
+ channel_data *chand = (channel_data *)elem->channel_data;
935
939
  if (chand->registered_methods) {
936
940
  for (i = 0; i < chand->registered_method_slots; i++) {
937
941
  grpc_slice_unref_internal(exec_ctx, chand->registered_methods[i].method);
@@ -962,7 +966,6 @@ const grpc_channel_filter grpc_server_top_filter = {
962
966
  sizeof(channel_data),
963
967
  init_channel_elem,
964
968
  destroy_channel_elem,
965
- grpc_call_next_get_peer,
966
969
  grpc_channel_next_get_info,
967
970
  "server",
968
971
  };
@@ -978,8 +981,8 @@ static void register_completion_queue(grpc_server *server,
978
981
 
979
982
  GRPC_CQ_INTERNAL_REF(cq, "server");
980
983
  n = server->cq_count++;
981
- server->cqs = gpr_realloc(server->cqs,
982
- server->cq_count * sizeof(grpc_completion_queue *));
984
+ server->cqs = (grpc_completion_queue **)gpr_realloc(
985
+ server->cqs, server->cq_count * sizeof(grpc_completion_queue *));
983
986
  server->cqs[n] = cq;
984
987
  }
985
988
 
@@ -1004,7 +1007,7 @@ void grpc_server_register_completion_queue(grpc_server *server,
1004
1007
  grpc_server *grpc_server_create(const grpc_channel_args *args, void *reserved) {
1005
1008
  GRPC_API_TRACE("grpc_server_create(%p, %p)", 2, (args, reserved));
1006
1009
 
1007
- grpc_server *server = gpr_zalloc(sizeof(grpc_server));
1010
+ grpc_server *server = (grpc_server *)gpr_zalloc(sizeof(grpc_server));
1008
1011
 
1009
1012
  gpr_mu_init(&server->mu_global);
1010
1013
  gpr_mu_init(&server->mu_call);
@@ -1055,7 +1058,7 @@ void *grpc_server_register_method(
1055
1058
  flags);
1056
1059
  return NULL;
1057
1060
  }
1058
- m = gpr_zalloc(sizeof(registered_method));
1061
+ m = (registered_method *)gpr_zalloc(sizeof(registered_method));
1059
1062
  m->method = gpr_strdup(method);
1060
1063
  m->host = gpr_strdup(host);
1061
1064
  m->next = server->registered_methods;
@@ -1067,7 +1070,7 @@ void *grpc_server_register_method(
1067
1070
 
1068
1071
  static void start_listeners(grpc_exec_ctx *exec_ctx, void *s,
1069
1072
  grpc_error *error) {
1070
- grpc_server *server = s;
1073
+ grpc_server *server = (grpc_server *)s;
1071
1074
  for (listener *l = server->listeners; l; l = l->next) {
1072
1075
  l->start(exec_ctx, server, l->arg, server->pollsets, server->pollset_count);
1073
1076
  }
@@ -1088,11 +1091,12 @@ void grpc_server_start(grpc_server *server) {
1088
1091
 
1089
1092
  server->started = true;
1090
1093
  server->pollset_count = 0;
1091
- server->pollsets = gpr_malloc(sizeof(grpc_pollset *) * server->cq_count);
1092
- server->request_freelist_per_cq =
1093
- gpr_malloc(sizeof(*server->request_freelist_per_cq) * server->cq_count);
1094
- server->requested_calls_per_cq =
1095
- gpr_malloc(sizeof(*server->requested_calls_per_cq) * server->cq_count);
1094
+ server->pollsets =
1095
+ (grpc_pollset **)gpr_malloc(sizeof(grpc_pollset *) * server->cq_count);
1096
+ server->request_freelist_per_cq = (gpr_stack_lockfree **)gpr_malloc(
1097
+ sizeof(*server->request_freelist_per_cq) * server->cq_count);
1098
+ server->requested_calls_per_cq = (requested_call **)gpr_malloc(
1099
+ sizeof(*server->requested_calls_per_cq) * server->cq_count);
1096
1100
  for (i = 0; i < server->cq_count; i++) {
1097
1101
  if (grpc_cq_can_listen(server->cqs[i])) {
1098
1102
  server->pollsets[server->pollset_count++] =
@@ -1103,22 +1107,24 @@ void grpc_server_start(grpc_server *server) {
1103
1107
  for (int j = 0; j < server->max_requested_calls_per_cq; j++) {
1104
1108
  gpr_stack_lockfree_push(server->request_freelist_per_cq[i], j);
1105
1109
  }
1106
- server->requested_calls_per_cq[i] =
1107
- gpr_malloc((size_t)server->max_requested_calls_per_cq *
1108
- sizeof(*server->requested_calls_per_cq[i]));
1110
+ server->requested_calls_per_cq[i] = (requested_call *)gpr_malloc(
1111
+ (size_t)server->max_requested_calls_per_cq *
1112
+ sizeof(*server->requested_calls_per_cq[i]));
1109
1113
  }
1110
1114
  request_matcher_init(&server->unregistered_request_matcher,
1111
1115
  (size_t)server->max_requested_calls_per_cq, server);
1112
1116
  for (registered_method *rm = server->registered_methods; rm; rm = rm->next) {
1113
- request_matcher_init(&rm->request_matcher,
1117
+ request_matcher_init(&rm->matcher,
1114
1118
  (size_t)server->max_requested_calls_per_cq, server);
1115
1119
  }
1116
1120
 
1117
1121
  server_ref(server);
1118
1122
  server->starting = true;
1119
- GRPC_CLOSURE_SCHED(&exec_ctx, GRPC_CLOSURE_CREATE(start_listeners, server,
1120
- grpc_executor_scheduler),
1121
- GRPC_ERROR_NONE);
1123
+ GRPC_CLOSURE_SCHED(
1124
+ &exec_ctx,
1125
+ GRPC_CLOSURE_CREATE(start_listeners, server,
1126
+ grpc_executor_scheduler(GRPC_EXECUTOR_SHORT)),
1127
+ GRPC_ERROR_NONE);
1122
1128
 
1123
1129
  grpc_exec_ctx_finish(&exec_ctx);
1124
1130
  }
@@ -1173,7 +1179,7 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
1173
1179
  if (num_registered_methods > 0) {
1174
1180
  slots = 2 * num_registered_methods;
1175
1181
  alloc = sizeof(channel_registered_method) * slots;
1176
- chand->registered_methods = gpr_zalloc(alloc);
1182
+ chand->registered_methods = (channel_registered_method *)gpr_zalloc(alloc);
1177
1183
  for (rm = s->registered_methods; rm; rm = rm->next) {
1178
1184
  grpc_slice host;
1179
1185
  bool has_host;
@@ -1234,7 +1240,7 @@ void done_published_shutdown(grpc_exec_ctx *exec_ctx, void *done_arg,
1234
1240
 
1235
1241
  static void listener_destroy_done(grpc_exec_ctx *exec_ctx, void *s,
1236
1242
  grpc_error *error) {
1237
- grpc_server *server = s;
1243
+ grpc_server *server = (grpc_server *)s;
1238
1244
  gpr_mu_lock(&server->mu_global);
1239
1245
  server->listeners_destroyed++;
1240
1246
  maybe_finish_shutdown(exec_ctx, server);
@@ -1261,14 +1267,15 @@ void grpc_server_shutdown_and_notify(grpc_server *server,
1261
1267
  /* stay locked, and gather up some stuff to do */
1262
1268
  GPR_ASSERT(grpc_cq_begin_op(cq, tag));
1263
1269
  if (server->shutdown_published) {
1264
- grpc_cq_end_op(&exec_ctx, cq, tag, GRPC_ERROR_NONE, done_published_shutdown,
1265
- NULL, gpr_malloc(sizeof(grpc_cq_completion)));
1270
+ grpc_cq_end_op(
1271
+ &exec_ctx, cq, tag, GRPC_ERROR_NONE, done_published_shutdown, NULL,
1272
+ (grpc_cq_completion *)gpr_malloc(sizeof(grpc_cq_completion)));
1266
1273
  gpr_mu_unlock(&server->mu_global);
1267
1274
  goto done;
1268
1275
  }
1269
- server->shutdown_tags =
1270
- gpr_realloc(server->shutdown_tags,
1271
- sizeof(shutdown_tag) * (server->num_shutdown_tags + 1));
1276
+ server->shutdown_tags = (shutdown_tag *)gpr_realloc(
1277
+ server->shutdown_tags,
1278
+ sizeof(shutdown_tag) * (server->num_shutdown_tags + 1));
1272
1279
  sdt = &server->shutdown_tags[server->num_shutdown_tags++];
1273
1280
  sdt->tag = tag;
1274
1281
  sdt->cq = cq;
@@ -1351,7 +1358,7 @@ void grpc_server_add_listener(
1351
1358
  grpc_pollset **pollsets, size_t pollset_count),
1352
1359
  void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_server *server, void *arg,
1353
1360
  grpc_closure *on_done)) {
1354
- listener *l = gpr_malloc(sizeof(listener));
1361
+ listener *l = (listener *)gpr_malloc(sizeof(listener));
1355
1362
  l->arg = arg;
1356
1363
  l->start = start;
1357
1364
  l->destroy = destroy;
@@ -1384,7 +1391,7 @@ static grpc_call_error queue_call_request(grpc_exec_ctx *exec_ctx,
1384
1391
  rm = &server->unregistered_request_matcher;
1385
1392
  break;
1386
1393
  case REGISTERED_CALL:
1387
- rm = &rc->data.registered.registered_method->request_matcher;
1394
+ rm = &rc->data.registered.method->matcher;
1388
1395
  break;
1389
1396
  }
1390
1397
  server->requested_calls_per_cq[cq_idx][request_id] = *rc;
@@ -1428,7 +1435,8 @@ grpc_call_error grpc_server_request_call(
1428
1435
  grpc_completion_queue *cq_for_notification, void *tag) {
1429
1436
  grpc_call_error error;
1430
1437
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
1431
- requested_call *rc = gpr_malloc(sizeof(*rc));
1438
+ requested_call *rc = (requested_call *)gpr_malloc(sizeof(*rc));
1439
+ GRPC_STATS_INC_SERVER_REQUESTED_CALLS(&exec_ctx);
1432
1440
  GRPC_API_TRACE(
1433
1441
  "grpc_server_request_call("
1434
1442
  "server=%p, call=%p, details=%p, initial_metadata=%p, "
@@ -1473,8 +1481,9 @@ grpc_call_error grpc_server_request_registered_call(
1473
1481
  grpc_completion_queue *cq_for_notification, void *tag) {
1474
1482
  grpc_call_error error;
1475
1483
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
1476
- requested_call *rc = gpr_malloc(sizeof(*rc));
1477
- registered_method *rm = rmp;
1484
+ requested_call *rc = (requested_call *)gpr_malloc(sizeof(*rc));
1485
+ registered_method *rm = (registered_method *)rmp;
1486
+ GRPC_STATS_INC_SERVER_REQUESTED_CALLS(&exec_ctx);
1478
1487
  GRPC_API_TRACE(
1479
1488
  "grpc_server_request_registered_call("
1480
1489
  "server=%p, rmp=%p, call=%p, deadline=%p, initial_metadata=%p, "
@@ -1511,7 +1520,7 @@ grpc_call_error grpc_server_request_registered_call(
1511
1520
  rc->tag = tag;
1512
1521
  rc->cq_bound_to_call = cq_bound_to_call;
1513
1522
  rc->call = call;
1514
- rc->data.registered.registered_method = rm;
1523
+ rc->data.registered.method = rm;
1515
1524
  rc->data.registered.deadline = deadline;
1516
1525
  rc->initial_metadata = initial_metadata;
1517
1526
  rc->data.registered.optional_payload = optional_payload;