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
@@ -39,6 +39,7 @@
39
39
  #include <grpc/support/tls.h>
40
40
  #include <grpc/support/useful.h>
41
41
 
42
+ #include "src/core/lib/debug/stats.h"
42
43
  #include "src/core/lib/iomgr/ev_posix.h"
43
44
  #include "src/core/lib/iomgr/iomgr_internal.h"
44
45
  #include "src/core/lib/iomgr/lockfree_event.h"
@@ -362,7 +363,8 @@ static void polling_island_add_fds_locked(polling_island *pi, grpc_fd **fds,
362
363
 
363
364
  if (pi->fd_cnt == pi->fd_capacity) {
364
365
  pi->fd_capacity = GPR_MAX(pi->fd_capacity + 8, pi->fd_cnt * 3 / 2);
365
- pi->fds = gpr_realloc(pi->fds, sizeof(grpc_fd *) * pi->fd_capacity);
366
+ pi->fds =
367
+ (grpc_fd **)gpr_realloc(pi->fds, sizeof(grpc_fd *) * pi->fd_capacity);
366
368
  }
367
369
 
368
370
  pi->fds[pi->fd_cnt++] = fds[i];
@@ -465,7 +467,7 @@ static polling_island *polling_island_create(grpc_exec_ctx *exec_ctx,
465
467
 
466
468
  *error = GRPC_ERROR_NONE;
467
469
 
468
- pi = gpr_malloc(sizeof(*pi));
470
+ pi = (polling_island *)gpr_malloc(sizeof(*pi));
469
471
  gpr_mu_init(&pi->mu);
470
472
  pi->fd_cnt = 0;
471
473
  pi->fd_capacity = 0;
@@ -809,7 +811,7 @@ static grpc_fd *fd_create(int fd, const char *name) {
809
811
  gpr_mu_unlock(&fd_freelist_mu);
810
812
 
811
813
  if (new_fd == NULL) {
812
- new_fd = gpr_malloc(sizeof(grpc_fd));
814
+ new_fd = (grpc_fd *)gpr_malloc(sizeof(grpc_fd));
813
815
  gpr_mu_init(&new_fd->po.mu);
814
816
  }
815
817
 
@@ -1019,10 +1021,11 @@ static void push_front_worker(grpc_pollset *p, grpc_pollset_worker *worker) {
1019
1021
  }
1020
1022
 
1021
1023
  /* p->mu must be held before calling this function */
1022
- static grpc_error *pollset_kick(grpc_pollset *p,
1024
+ static grpc_error *pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
1023
1025
  grpc_pollset_worker *specific_worker) {
1024
1026
  GPR_TIMER_BEGIN("pollset_kick", 0);
1025
1027
  grpc_error *error = GRPC_ERROR_NONE;
1028
+ GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
1026
1029
  const char *err_desc = "Kick Failure";
1027
1030
  grpc_pollset_worker *worker = specific_worker;
1028
1031
  if (worker != NULL) {
@@ -1130,7 +1133,8 @@ static void fd_become_writable(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
1130
1133
  }
1131
1134
 
1132
1135
  static void pollset_release_polling_island(grpc_exec_ctx *exec_ctx,
1133
- grpc_pollset *ps, char *reason) {
1136
+ grpc_pollset *ps,
1137
+ const char *reason) {
1134
1138
  if (ps->po.pi != NULL) {
1135
1139
  PI_UNREF(exec_ctx, ps->po.pi, reason);
1136
1140
  }
@@ -1156,7 +1160,7 @@ static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
1156
1160
  GPR_ASSERT(!pollset->shutting_down);
1157
1161
  pollset->shutting_down = true;
1158
1162
  pollset->shutdown_done = closure;
1159
- pollset_kick(pollset, GRPC_POLLSET_KICK_BROADCAST);
1163
+ pollset_kick(exec_ctx, pollset, GRPC_POLLSET_KICK_BROADCAST);
1160
1164
 
1161
1165
  /* If the pollset has any workers, we cannot call finish_shutdown_locked()
1162
1166
  because it would release the underlying polling island. In such a case, we
@@ -1236,6 +1240,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
1236
1240
  g_current_thread_polling_island = pi;
1237
1241
 
1238
1242
  GRPC_SCHEDULING_START_BLOCKING_REGION;
1243
+ GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
1239
1244
  ep_rv =
1240
1245
  epoll_pwait(epoll_fd, ep_ev, GRPC_EPOLL_MAX_EVENTS, timeout_ms, sig_mask);
1241
1246
  GRPC_SCHEDULING_END_BLOCKING_REGION;
@@ -1271,7 +1276,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
1271
1276
  to the function pollset_work_and_unlock() will pick up the correct
1272
1277
  epoll_fd */
1273
1278
  } else {
1274
- grpc_fd *fd = data_ptr;
1279
+ grpc_fd *fd = (grpc_fd *)data_ptr;
1275
1280
  int cancel = ep_ev[i].events & (EPOLLERR | EPOLLHUP);
1276
1281
  int read_ev = ep_ev[i].events & (EPOLLIN | EPOLLPRI);
1277
1282
  int write_ev = ep_ev[i].events & EPOLLOUT;
@@ -1567,7 +1572,7 @@ static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
1567
1572
  */
1568
1573
 
1569
1574
  static grpc_pollset_set *pollset_set_create(void) {
1570
- grpc_pollset_set *pss = gpr_malloc(sizeof(*pss));
1575
+ grpc_pollset_set *pss = (grpc_pollset_set *)gpr_malloc(sizeof(*pss));
1571
1576
  gpr_mu_init(&pss->po.mu);
1572
1577
  pss->po.pi = NULL;
1573
1578
  #ifndef NDEBUG
@@ -1645,8 +1650,8 @@ void *grpc_pollset_get_polling_island(grpc_pollset *ps) {
1645
1650
  }
1646
1651
 
1647
1652
  bool grpc_are_polling_islands_equal(void *p, void *q) {
1648
- polling_island *p1 = p;
1649
- polling_island *p2 = q;
1653
+ polling_island *p1 = (polling_island *)p;
1654
+ polling_island *p2 = (polling_island *)q;
1650
1655
 
1651
1656
  /* Note: polling_island_lock_pair() may change p1 and p2 to point to the
1652
1657
  latest polling islands in their respective linked lists */
@@ -1667,34 +1672,34 @@ static void shutdown_engine(void) {
1667
1672
  }
1668
1673
 
1669
1674
  static const grpc_event_engine_vtable vtable = {
1670
- .pollset_size = sizeof(grpc_pollset),
1671
-
1672
- .fd_create = fd_create,
1673
- .fd_wrapped_fd = fd_wrapped_fd,
1674
- .fd_orphan = fd_orphan,
1675
- .fd_shutdown = fd_shutdown,
1676
- .fd_is_shutdown = fd_is_shutdown,
1677
- .fd_notify_on_read = fd_notify_on_read,
1678
- .fd_notify_on_write = fd_notify_on_write,
1679
- .fd_get_read_notifier_pollset = fd_get_read_notifier_pollset,
1680
-
1681
- .pollset_init = pollset_init,
1682
- .pollset_shutdown = pollset_shutdown,
1683
- .pollset_destroy = pollset_destroy,
1684
- .pollset_work = pollset_work,
1685
- .pollset_kick = pollset_kick,
1686
- .pollset_add_fd = pollset_add_fd,
1687
-
1688
- .pollset_set_create = pollset_set_create,
1689
- .pollset_set_destroy = pollset_set_destroy,
1690
- .pollset_set_add_pollset = pollset_set_add_pollset,
1691
- .pollset_set_del_pollset = pollset_set_del_pollset,
1692
- .pollset_set_add_pollset_set = pollset_set_add_pollset_set,
1693
- .pollset_set_del_pollset_set = pollset_set_del_pollset_set,
1694
- .pollset_set_add_fd = pollset_set_add_fd,
1695
- .pollset_set_del_fd = pollset_set_del_fd,
1696
-
1697
- .shutdown_engine = shutdown_engine,
1675
+ sizeof(grpc_pollset),
1676
+
1677
+ fd_create,
1678
+ fd_wrapped_fd,
1679
+ fd_orphan,
1680
+ fd_shutdown,
1681
+ fd_notify_on_read,
1682
+ fd_notify_on_write,
1683
+ fd_is_shutdown,
1684
+ fd_get_read_notifier_pollset,
1685
+
1686
+ pollset_init,
1687
+ pollset_shutdown,
1688
+ pollset_destroy,
1689
+ pollset_work,
1690
+ pollset_kick,
1691
+ pollset_add_fd,
1692
+
1693
+ pollset_set_create,
1694
+ pollset_set_destroy,
1695
+ pollset_set_add_pollset,
1696
+ pollset_set_del_pollset,
1697
+ pollset_set_add_pollset_set,
1698
+ pollset_set_del_pollset_set,
1699
+ pollset_set_add_fd,
1700
+ pollset_set_del_fd,
1701
+
1702
+ shutdown_engine,
1698
1703
  };
1699
1704
 
1700
1705
  /* It is possible that GLIBC has epoll but the underlying kernel doesn't.
@@ -1728,9 +1733,7 @@ const grpc_event_engine_vtable *grpc_init_epollsig_linux(
1728
1733
  }
1729
1734
 
1730
1735
  if (!is_grpc_wakeup_signal_initialized) {
1731
- /* TODO(ctiller): when other epoll engines are ready, remove the true || to
1732
- * force this to be explitly chosen if needed */
1733
- if (true || explicit_request) {
1736
+ if (explicit_request) {
1734
1737
  grpc_use_signal(SIGRTMIN + 6);
1735
1738
  } else {
1736
1739
  return NULL;
@@ -36,6 +36,7 @@
36
36
  #include <grpc/support/tls.h>
37
37
  #include <grpc/support/useful.h>
38
38
 
39
+ #include "src/core/lib/debug/stats.h"
39
40
  #include "src/core/lib/iomgr/iomgr_internal.h"
40
41
  #include "src/core/lib/iomgr/timer.h"
41
42
  #include "src/core/lib/iomgr/wakeup_fd_cv.h"
@@ -208,7 +209,7 @@ static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
208
209
  #define GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP 2
209
210
  /* As per pollset_kick, with an extended set of flags (defined above)
210
211
  -- mostly for fd_posix's use. */
211
- static grpc_error *pollset_kick_ext(grpc_pollset *p,
212
+ static grpc_error *pollset_kick_ext(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
212
213
  grpc_pollset_worker *specific_worker,
213
214
  uint32_t flags) GRPC_MUST_USE_RESULT;
214
215
 
@@ -326,7 +327,7 @@ static void unref_by(grpc_fd *fd, int n) {
326
327
  }
327
328
 
328
329
  static grpc_fd *fd_create(int fd, const char *name) {
329
- grpc_fd *r = gpr_malloc(sizeof(*r));
330
+ grpc_fd *r = (grpc_fd *)gpr_malloc(sizeof(*r));
330
331
  gpr_mu_init(&r->mu);
331
332
  gpr_atm_rel_store(&r->refst, 1);
332
333
  r->shutdown = 0;
@@ -364,36 +365,39 @@ static grpc_pollset *fd_get_read_notifier_pollset(grpc_exec_ctx *exec_ctx,
364
365
  return notifier;
365
366
  }
366
367
 
367
- static grpc_error *pollset_kick_locked(grpc_fd_watcher *watcher) {
368
+ static grpc_error *pollset_kick_locked(grpc_exec_ctx *exec_ctx,
369
+ grpc_fd_watcher *watcher) {
368
370
  gpr_mu_lock(&watcher->pollset->mu);
369
371
  GPR_ASSERT(watcher->worker);
370
- grpc_error *err = pollset_kick_ext(watcher->pollset, watcher->worker,
371
- GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP);
372
+ grpc_error *err =
373
+ pollset_kick_ext(exec_ctx, watcher->pollset, watcher->worker,
374
+ GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP);
372
375
  gpr_mu_unlock(&watcher->pollset->mu);
373
376
  return err;
374
377
  }
375
378
 
376
- static void maybe_wake_one_watcher_locked(grpc_fd *fd) {
379
+ static void maybe_wake_one_watcher_locked(grpc_exec_ctx *exec_ctx,
380
+ grpc_fd *fd) {
377
381
  if (fd->inactive_watcher_root.next != &fd->inactive_watcher_root) {
378
- pollset_kick_locked(fd->inactive_watcher_root.next);
382
+ pollset_kick_locked(exec_ctx, fd->inactive_watcher_root.next);
379
383
  } else if (fd->read_watcher) {
380
- pollset_kick_locked(fd->read_watcher);
384
+ pollset_kick_locked(exec_ctx, fd->read_watcher);
381
385
  } else if (fd->write_watcher) {
382
- pollset_kick_locked(fd->write_watcher);
386
+ pollset_kick_locked(exec_ctx, fd->write_watcher);
383
387
  }
384
388
  }
385
389
 
386
- static void wake_all_watchers_locked(grpc_fd *fd) {
390
+ static void wake_all_watchers_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
387
391
  grpc_fd_watcher *watcher;
388
392
  for (watcher = fd->inactive_watcher_root.next;
389
393
  watcher != &fd->inactive_watcher_root; watcher = watcher->next) {
390
- pollset_kick_locked(watcher);
394
+ pollset_kick_locked(exec_ctx, watcher);
391
395
  }
392
396
  if (fd->read_watcher) {
393
- pollset_kick_locked(fd->read_watcher);
397
+ pollset_kick_locked(exec_ctx, fd->read_watcher);
394
398
  }
395
399
  if (fd->write_watcher && fd->write_watcher != fd->read_watcher) {
396
- pollset_kick_locked(fd->write_watcher);
400
+ pollset_kick_locked(exec_ctx, fd->write_watcher);
397
401
  }
398
402
  }
399
403
 
@@ -434,7 +438,7 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
434
438
  if (!has_watchers(fd)) {
435
439
  close_fd_locked(exec_ctx, fd);
436
440
  } else {
437
- wake_all_watchers_locked(fd);
441
+ wake_all_watchers_locked(exec_ctx, fd);
438
442
  }
439
443
  gpr_mu_unlock(&fd->mu);
440
444
  UNREF_BY(fd, 2, reason); /* drop the reference */
@@ -478,7 +482,7 @@ static void notify_on_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
478
482
  /* already ready ==> queue the closure to run immediately */
479
483
  *st = CLOSURE_NOT_READY;
480
484
  GRPC_CLOSURE_SCHED(exec_ctx, closure, fd_shutdown_error(fd));
481
- maybe_wake_one_watcher_locked(fd);
485
+ maybe_wake_one_watcher_locked(exec_ctx, fd);
482
486
  } else {
483
487
  /* upcallptr was set to a different closure. This is an error! */
484
488
  gpr_log(GPR_ERROR,
@@ -647,7 +651,7 @@ static void fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *watcher,
647
651
  }
648
652
  }
649
653
  if (kick) {
650
- maybe_wake_one_watcher_locked(fd);
654
+ maybe_wake_one_watcher_locked(exec_ctx, fd);
651
655
  }
652
656
  if (fd_is_orphaned(fd) && !has_watchers(fd) && !fd->closed) {
653
657
  close_fd_locked(exec_ctx, fd);
@@ -711,11 +715,12 @@ static void kick_append_error(grpc_error **composite, grpc_error *error) {
711
715
  *composite = grpc_error_add_child(*composite, error);
712
716
  }
713
717
 
714
- static grpc_error *pollset_kick_ext(grpc_pollset *p,
718
+ static grpc_error *pollset_kick_ext(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
715
719
  grpc_pollset_worker *specific_worker,
716
720
  uint32_t flags) {
717
721
  GPR_TIMER_BEGIN("pollset_kick_ext", 0);
718
722
  grpc_error *error = GRPC_ERROR_NONE;
723
+ GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
719
724
 
720
725
  /* pollset->mu already held */
721
726
  if (specific_worker != NULL) {
@@ -781,9 +786,9 @@ static grpc_error *pollset_kick_ext(grpc_pollset *p,
781
786
  return error;
782
787
  }
783
788
 
784
- static grpc_error *pollset_kick(grpc_pollset *p,
789
+ static grpc_error *pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
785
790
  grpc_pollset_worker *specific_worker) {
786
- return pollset_kick_ext(p, specific_worker, 0);
791
+ return pollset_kick_ext(exec_ctx, p, specific_worker, 0);
787
792
  }
788
793
 
789
794
  /* global state management */
@@ -841,12 +846,12 @@ static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
841
846
  if (pollset->fd_count == pollset->fd_capacity) {
842
847
  pollset->fd_capacity =
843
848
  GPR_MAX(pollset->fd_capacity + 8, pollset->fd_count * 3 / 2);
844
- pollset->fds =
845
- gpr_realloc(pollset->fds, sizeof(grpc_fd *) * pollset->fd_capacity);
849
+ pollset->fds = (grpc_fd **)gpr_realloc(
850
+ pollset->fds, sizeof(grpc_fd *) * pollset->fd_capacity);
846
851
  }
847
852
  pollset->fds[pollset->fd_count++] = fd;
848
853
  GRPC_FD_REF(fd, "multipoller");
849
- pollset_kick(pollset, NULL);
854
+ pollset_kick(exec_ctx, pollset, NULL);
850
855
  exit:
851
856
  gpr_mu_unlock(&pollset->mu);
852
857
  }
@@ -894,7 +899,8 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
894
899
  worker.wakeup_fd = pollset->local_wakeup_cache;
895
900
  pollset->local_wakeup_cache = worker.wakeup_fd->next;
896
901
  } else {
897
- worker.wakeup_fd = gpr_malloc(sizeof(*worker.wakeup_fd));
902
+ worker.wakeup_fd =
903
+ (grpc_cached_wakeup_fd *)gpr_malloc(sizeof(*worker.wakeup_fd));
898
904
  error = grpc_wakeup_fd_init(&worker.wakeup_fd->fd);
899
905
  if (error != GRPC_ERROR_NONE) {
900
906
  GRPC_LOG_IF_ERROR("pollset_work", GRPC_ERROR_REF(error));
@@ -949,8 +955,8 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
949
955
  const size_t pfd_size = sizeof(*pfds) * (pollset->fd_count + 2);
950
956
  const size_t watch_size = sizeof(*watchers) * (pollset->fd_count + 2);
951
957
  void *buf = gpr_malloc(pfd_size + watch_size);
952
- pfds = buf;
953
- watchers = (void *)((char *)buf + pfd_size);
958
+ pfds = (struct pollfd *)buf;
959
+ watchers = (grpc_fd_watcher *)(void *)((char *)buf + pfd_size);
954
960
  }
955
961
 
956
962
  fd_count = 0;
@@ -983,9 +989,14 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
983
989
  /* TODO(vpai): Consider first doing a 0 timeout poll here to avoid
984
990
  even going into the blocking annotation if possible */
985
991
  GRPC_SCHEDULING_START_BLOCKING_REGION;
992
+ GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
986
993
  r = grpc_poll_function(pfds, pfd_count, timeout);
987
994
  GRPC_SCHEDULING_END_BLOCKING_REGION;
988
995
 
996
+ if (GRPC_TRACER_ON(grpc_polling_trace)) {
997
+ gpr_log(GPR_DEBUG, "%p poll=%d", pollset, r);
998
+ }
999
+
989
1000
  if (r < 0) {
990
1001
  if (errno != EINTR) {
991
1002
  work_combine_error(&error, GRPC_OS_ERROR(errno, "poll"));
@@ -1006,6 +1017,9 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
1006
1017
  }
1007
1018
  } else {
1008
1019
  if (pfds[0].revents & POLLIN_CHECK) {
1020
+ if (GRPC_TRACER_ON(grpc_polling_trace)) {
1021
+ gpr_log(GPR_DEBUG, "%p: got_wakeup", pollset);
1022
+ }
1009
1023
  work_combine_error(
1010
1024
  &error, grpc_wakeup_fd_consume_wakeup(&worker.wakeup_fd->fd));
1011
1025
  }
@@ -1013,6 +1027,11 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
1013
1027
  if (watchers[i].fd == NULL) {
1014
1028
  fd_end_poll(exec_ctx, &watchers[i], 0, 0, NULL);
1015
1029
  } else {
1030
+ if (GRPC_TRACER_ON(grpc_polling_trace)) {
1031
+ gpr_log(GPR_DEBUG, "%p got_event: %d r:%d w:%d [%d]", pollset,
1032
+ pfds[i].fd, (pfds[i].revents & POLLIN_CHECK) != 0,
1033
+ (pfds[i].revents & POLLOUT_CHECK) != 0, pfds[i].revents);
1034
+ }
1016
1035
  fd_end_poll(exec_ctx, &watchers[i], pfds[i].revents & POLLIN_CHECK,
1017
1036
  pfds[i].revents & POLLOUT_CHECK, pollset);
1018
1037
  }
@@ -1068,7 +1087,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
1068
1087
  /* check shutdown conditions */
1069
1088
  if (pollset->shutting_down) {
1070
1089
  if (pollset_has_workers(pollset)) {
1071
- pollset_kick(pollset, NULL);
1090
+ pollset_kick(exec_ctx, pollset, NULL);
1072
1091
  } else if (!pollset->called_shutdown && !pollset_has_observers(pollset)) {
1073
1092
  pollset->called_shutdown = 1;
1074
1093
  gpr_mu_unlock(&pollset->mu);
@@ -1097,7 +1116,7 @@ static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
1097
1116
  GPR_ASSERT(!pollset->shutting_down);
1098
1117
  pollset->shutting_down = 1;
1099
1118
  pollset->shutdown_done = closure;
1100
- pollset_kick(pollset, GRPC_POLLSET_KICK_BROADCAST);
1119
+ pollset_kick(exec_ctx, pollset, GRPC_POLLSET_KICK_BROADCAST);
1101
1120
  if (!pollset_has_workers(pollset)) {
1102
1121
  GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pollset->idle_jobs);
1103
1122
  }
@@ -1129,7 +1148,8 @@ static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
1129
1148
  */
1130
1149
 
1131
1150
  static grpc_pollset_set *pollset_set_create(void) {
1132
- grpc_pollset_set *pollset_set = gpr_zalloc(sizeof(*pollset_set));
1151
+ grpc_pollset_set *pollset_set =
1152
+ (grpc_pollset_set *)gpr_zalloc(sizeof(*pollset_set));
1133
1153
  gpr_mu_init(&pollset_set->mu);
1134
1154
  return pollset_set;
1135
1155
  }
@@ -1172,9 +1192,9 @@ static void pollset_set_add_pollset(grpc_exec_ctx *exec_ctx,
1172
1192
  if (pollset_set->pollset_count == pollset_set->pollset_capacity) {
1173
1193
  pollset_set->pollset_capacity =
1174
1194
  GPR_MAX(8, 2 * pollset_set->pollset_capacity);
1175
- pollset_set->pollsets =
1176
- gpr_realloc(pollset_set->pollsets, pollset_set->pollset_capacity *
1177
- sizeof(*pollset_set->pollsets));
1195
+ pollset_set->pollsets = (grpc_pollset **)gpr_realloc(
1196
+ pollset_set->pollsets,
1197
+ pollset_set->pollset_capacity * sizeof(*pollset_set->pollsets));
1178
1198
  }
1179
1199
  pollset_set->pollsets[pollset_set->pollset_count++] = pollset;
1180
1200
  for (i = 0, j = 0; i < pollset_set->fd_count; i++) {
@@ -1223,9 +1243,9 @@ static void pollset_set_add_pollset_set(grpc_exec_ctx *exec_ctx,
1223
1243
  gpr_mu_lock(&bag->mu);
1224
1244
  if (bag->pollset_set_count == bag->pollset_set_capacity) {
1225
1245
  bag->pollset_set_capacity = GPR_MAX(8, 2 * bag->pollset_set_capacity);
1226
- bag->pollset_sets =
1227
- gpr_realloc(bag->pollset_sets,
1228
- bag->pollset_set_capacity * sizeof(*bag->pollset_sets));
1246
+ bag->pollset_sets = (grpc_pollset_set **)gpr_realloc(
1247
+ bag->pollset_sets,
1248
+ bag->pollset_set_capacity * sizeof(*bag->pollset_sets));
1229
1249
  }
1230
1250
  bag->pollset_sets[bag->pollset_set_count++] = item;
1231
1251
  for (i = 0, j = 0; i < bag->fd_count; i++) {
@@ -1262,7 +1282,7 @@ static void pollset_set_add_fd(grpc_exec_ctx *exec_ctx,
1262
1282
  gpr_mu_lock(&pollset_set->mu);
1263
1283
  if (pollset_set->fd_count == pollset_set->fd_capacity) {
1264
1284
  pollset_set->fd_capacity = GPR_MAX(8, 2 * pollset_set->fd_capacity);
1265
- pollset_set->fds = gpr_realloc(
1285
+ pollset_set->fds = (grpc_fd **)gpr_realloc(
1266
1286
  pollset_set->fds, pollset_set->fd_capacity * sizeof(*pollset_set->fds));
1267
1287
  }
1268
1288
  GRPC_FD_REF(fd, "pollset_set");
@@ -1316,11 +1336,12 @@ static void cache_insert_locked(poll_args *args) {
1316
1336
  }
1317
1337
 
1318
1338
  static void init_result(poll_args *pargs) {
1319
- pargs->result = gpr_malloc(sizeof(poll_result));
1339
+ pargs->result = (poll_result *)gpr_malloc(sizeof(poll_result));
1320
1340
  gpr_ref_init(&pargs->result->refcount, 1);
1321
1341
  pargs->result->watchers = NULL;
1322
1342
  pargs->result->watchcount = 0;
1323
- pargs->result->fds = gpr_malloc(sizeof(struct pollfd) * pargs->nfds);
1343
+ pargs->result->fds =
1344
+ (struct pollfd *)gpr_malloc(sizeof(struct pollfd) * pargs->nfds);
1324
1345
  memcpy(pargs->result->fds, pargs->fds, sizeof(struct pollfd) * pargs->nfds);
1325
1346
  pargs->result->nfds = pargs->nfds;
1326
1347
  pargs->result->retval = 0;
@@ -1359,7 +1380,7 @@ static poll_args *get_poller_locked(struct pollfd *fds, nfds_t count) {
1359
1380
  return pargs;
1360
1381
  }
1361
1382
 
1362
- poll_args *pargs = gpr_malloc(sizeof(struct poll_args));
1383
+ poll_args *pargs = (poll_args *)gpr_malloc(sizeof(struct poll_args));
1363
1384
  gpr_cv_init(&pargs->trigger);
1364
1385
  pargs->fds = fds;
1365
1386
  pargs->nfds = count;
@@ -1406,7 +1427,8 @@ static void cache_poller_locked(poll_args *args) {
1406
1427
  poll_args **old_active_pollers = poll_cache.active_pollers;
1407
1428
  poll_cache.size = poll_cache.size * 2;
1408
1429
  poll_cache.count = 0;
1409
- poll_cache.active_pollers = gpr_malloc(sizeof(void *) * poll_cache.size);
1430
+ poll_cache.active_pollers =
1431
+ (poll_args **)gpr_malloc(sizeof(void *) * poll_cache.size);
1410
1432
  for (unsigned int i = 0; i < poll_cache.size; i++) {
1411
1433
  poll_cache.active_pollers[i] = NULL;
1412
1434
  }
@@ -1511,17 +1533,17 @@ static int cvfd_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
1511
1533
  nfds_t nsockfds = 0;
1512
1534
  poll_result *result = NULL;
1513
1535
  gpr_mu_lock(&g_cvfds.mu);
1514
- pollcv = gpr_malloc(sizeof(cv_node));
1536
+ pollcv = (cv_node *)gpr_malloc(sizeof(cv_node));
1515
1537
  pollcv->next = NULL;
1516
1538
  gpr_cv pollcv_cv;
1517
1539
  gpr_cv_init(&pollcv_cv);
1518
1540
  pollcv->cv = &pollcv_cv;
1519
- cv_node *fd_cvs = gpr_malloc(nfds * sizeof(cv_node));
1541
+ cv_node *fd_cvs = (cv_node *)gpr_malloc(nfds * sizeof(cv_node));
1520
1542
 
1521
1543
  for (i = 0; i < nfds; i++) {
1522
1544
  fds[i].revents = 0;
1523
1545
  if (fds[i].fd < 0 && (fds[i].events & POLLIN)) {
1524
- idx = FD_TO_IDX(fds[i].fd);
1546
+ idx = GRPC_FD_TO_IDX(fds[i].fd);
1525
1547
  fd_cvs[i].cv = &pollcv_cv;
1526
1548
  fd_cvs[i].prev = NULL;
1527
1549
  fd_cvs[i].next = g_cvfds.cvfds[idx].cvs;
@@ -1548,7 +1570,8 @@ static int cvfd_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
1548
1570
 
1549
1571
  res = 0;
1550
1572
  if (!skip_poll && nsockfds > 0) {
1551
- struct pollfd *pollfds = gpr_malloc(sizeof(struct pollfd) * nsockfds);
1573
+ struct pollfd *pollfds =
1574
+ (struct pollfd *)gpr_malloc(sizeof(struct pollfd) * nsockfds);
1552
1575
  idx = 0;
1553
1576
  for (i = 0; i < nfds; i++) {
1554
1577
  if (fds[i].fd >= 0) {
@@ -1583,8 +1606,8 @@ static int cvfd_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
1583
1606
  idx = 0;
1584
1607
  for (i = 0; i < nfds; i++) {
1585
1608
  if (fds[i].fd < 0 && (fds[i].events & POLLIN)) {
1586
- remove_cvn(&g_cvfds.cvfds[FD_TO_IDX(fds[i].fd)].cvs, &(fd_cvs[i]));
1587
- if (g_cvfds.cvfds[FD_TO_IDX(fds[i].fd)].is_set) {
1609
+ remove_cvn(&g_cvfds.cvfds[GRPC_FD_TO_IDX(fds[i].fd)].cvs, &(fd_cvs[i]));
1610
+ if (g_cvfds.cvfds[GRPC_FD_TO_IDX(fds[i].fd)].is_set) {
1588
1611
  fds[i].revents = POLLIN;
1589
1612
  if (res >= 0) res++;
1590
1613
  }
@@ -1611,7 +1634,8 @@ static void global_cv_fd_table_init() {
1611
1634
  gpr_cv_init(&g_cvfds.shutdown_cv);
1612
1635
  gpr_ref_init(&g_cvfds.pollcount, 1);
1613
1636
  g_cvfds.size = CV_DEFAULT_TABLE_SIZE;
1614
- g_cvfds.cvfds = gpr_malloc(sizeof(fd_node) * CV_DEFAULT_TABLE_SIZE);
1637
+ g_cvfds.cvfds =
1638
+ (fd_node *)gpr_malloc(sizeof(fd_node) * CV_DEFAULT_TABLE_SIZE);
1615
1639
  g_cvfds.free_fds = NULL;
1616
1640
  thread_grace = gpr_time_from_millis(POLLCV_THREAD_GRACE_MS, GPR_TIMESPAN);
1617
1641
  for (int i = 0; i < CV_DEFAULT_TABLE_SIZE; i++) {
@@ -1628,7 +1652,7 @@ static void global_cv_fd_table_init() {
1628
1652
  poll_cache.size = 32;
1629
1653
  poll_cache.count = 0;
1630
1654
  poll_cache.free_pollers = NULL;
1631
- poll_cache.active_pollers = gpr_malloc(sizeof(void *) * 32);
1655
+ poll_cache.active_pollers = (poll_args **)gpr_malloc(sizeof(void *) * 32);
1632
1656
  for (unsigned int i = 0; i < poll_cache.size; i++) {
1633
1657
  poll_cache.active_pollers[i] = NULL;
1634
1658
  }
@@ -1668,34 +1692,34 @@ static void shutdown_engine(void) {
1668
1692
  }
1669
1693
 
1670
1694
  static const grpc_event_engine_vtable vtable = {
1671
- .pollset_size = sizeof(grpc_pollset),
1672
-
1673
- .fd_create = fd_create,
1674
- .fd_wrapped_fd = fd_wrapped_fd,
1675
- .fd_orphan = fd_orphan,
1676
- .fd_shutdown = fd_shutdown,
1677
- .fd_is_shutdown = fd_is_shutdown,
1678
- .fd_notify_on_read = fd_notify_on_read,
1679
- .fd_notify_on_write = fd_notify_on_write,
1680
- .fd_get_read_notifier_pollset = fd_get_read_notifier_pollset,
1681
-
1682
- .pollset_init = pollset_init,
1683
- .pollset_shutdown = pollset_shutdown,
1684
- .pollset_destroy = pollset_destroy,
1685
- .pollset_work = pollset_work,
1686
- .pollset_kick = pollset_kick,
1687
- .pollset_add_fd = pollset_add_fd,
1688
-
1689
- .pollset_set_create = pollset_set_create,
1690
- .pollset_set_destroy = pollset_set_destroy,
1691
- .pollset_set_add_pollset = pollset_set_add_pollset,
1692
- .pollset_set_del_pollset = pollset_set_del_pollset,
1693
- .pollset_set_add_pollset_set = pollset_set_add_pollset_set,
1694
- .pollset_set_del_pollset_set = pollset_set_del_pollset_set,
1695
- .pollset_set_add_fd = pollset_set_add_fd,
1696
- .pollset_set_del_fd = pollset_set_del_fd,
1697
-
1698
- .shutdown_engine = shutdown_engine,
1695
+ sizeof(grpc_pollset),
1696
+
1697
+ fd_create,
1698
+ fd_wrapped_fd,
1699
+ fd_orphan,
1700
+ fd_shutdown,
1701
+ fd_notify_on_read,
1702
+ fd_notify_on_write,
1703
+ fd_is_shutdown,
1704
+ fd_get_read_notifier_pollset,
1705
+
1706
+ pollset_init,
1707
+ pollset_shutdown,
1708
+ pollset_destroy,
1709
+ pollset_work,
1710
+ pollset_kick,
1711
+ pollset_add_fd,
1712
+
1713
+ pollset_set_create,
1714
+ pollset_set_destroy,
1715
+ pollset_set_add_pollset,
1716
+ pollset_set_del_pollset,
1717
+ pollset_set_add_pollset_set,
1718
+ pollset_set_del_pollset_set,
1719
+ pollset_set_add_fd,
1720
+ pollset_set_del_fd,
1721
+
1722
+ shutdown_engine,
1699
1723
  };
1700
1724
 
1701
1725
  const grpc_event_engine_vtable *grpc_init_poll_posix(bool explicit_request) {