grpc 1.2.5 → 1.3.4

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 (327) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1434 -399
  3. data/etc/roots.pem +34 -150
  4. data/include/grpc/grpc.h +71 -0
  5. data/include/grpc/impl/codegen/atm.h +5 -0
  6. data/include/grpc/impl/codegen/atm_gcc_atomic.h +6 -0
  7. data/include/grpc/impl/codegen/atm_gcc_sync.h +2 -0
  8. data/include/grpc/impl/codegen/atm_windows.h +11 -0
  9. data/include/grpc/impl/codegen/grpc_types.h +54 -13
  10. data/include/grpc/impl/codegen/port_platform.h +15 -1
  11. data/include/grpc/support/alloc.h +2 -1
  12. data/include/grpc/support/sync.h +4 -0
  13. data/include/grpc/support/tls.h +1 -1
  14. data/src/core/ext/census/gen/trace_context.pb.h +1 -1
  15. data/src/core/ext/census/grpc_filter.c +14 -10
  16. data/src/core/ext/census/grpc_plugin.c +3 -1
  17. data/src/core/ext/census/trace_label.h +1 -1
  18. data/src/core/ext/census/trace_propagation.h +1 -1
  19. data/src/core/ext/census/trace_status.h +1 -1
  20. data/src/core/ext/census/trace_string.h +1 -1
  21. data/src/core/ext/census/tracing.h +1 -1
  22. data/src/core/ext/{client_channel → filters/client_channel}/channel_connectivity.c +56 -27
  23. data/src/core/ext/{client_channel → filters/client_channel}/client_channel.c +407 -202
  24. data/src/core/ext/{client_channel → filters/client_channel}/client_channel.h +10 -6
  25. data/src/core/ext/{client_channel → filters/client_channel}/client_channel_factory.c +1 -1
  26. data/src/core/ext/{client_channel → filters/client_channel}/client_channel_factory.h +4 -4
  27. data/src/core/ext/{client_channel → filters/client_channel}/client_channel_plugin.c +12 -7
  28. data/src/core/ext/{client_channel → filters/client_channel}/connector.c +1 -1
  29. data/src/core/ext/{client_channel → filters/client_channel}/connector.h +3 -5
  30. data/src/core/ext/{client_channel → filters/client_channel}/http_connect_handshaker.c +6 -6
  31. data/src/core/ext/{client_channel → filters/client_channel}/http_connect_handshaker.h +3 -3
  32. data/src/core/ext/{client_channel → filters/client_channel}/http_proxy.c +4 -4
  33. data/src/core/ext/{client_channel → filters/client_channel}/http_proxy.h +3 -3
  34. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy.c +1 -1
  35. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy.h +4 -4
  36. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb.c +22 -20
  37. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb.h +4 -4
  38. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb_channel.h +5 -4
  39. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb_channel_secure.c +2 -2
  40. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/load_balancer_api.c +1 -1
  41. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/load_balancer_api.h +6 -5
  42. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +1 -1
  43. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +0 -0
  44. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/pick_first/pick_first.c +20 -15
  45. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/round_robin/round_robin.c +21 -16
  46. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_factory.c +1 -1
  47. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_factory.h +5 -5
  48. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_registry.c +1 -1
  49. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_registry.h +4 -4
  50. data/src/core/ext/{client_channel → filters/client_channel}/parse_address.c +1 -1
  51. data/src/core/ext/{client_channel → filters/client_channel}/parse_address.h +4 -4
  52. data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper.c +1 -1
  53. data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper.h +3 -3
  54. data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper_registry.c +10 -4
  55. data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper_registry.h +4 -4
  56. data/src/core/ext/{client_channel → filters/client_channel}/resolver.c +1 -1
  57. data/src/core/ext/{client_channel → filters/client_channel}/resolver.h +4 -4
  58. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +350 -0
  59. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +66 -0
  60. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +319 -0
  61. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +289 -0
  62. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +64 -0
  63. data/src/core/ext/{resolver → filters/client_channel/resolver}/dns/native/dns_resolver.c +21 -5
  64. data/src/core/ext/{resolver → filters/client_channel/resolver}/sockaddr/sockaddr_resolver.c +3 -3
  65. data/src/core/ext/{client_channel → filters/client_channel}/resolver_factory.c +1 -1
  66. data/src/core/ext/{client_channel → filters/client_channel}/resolver_factory.h +6 -6
  67. data/src/core/ext/{client_channel → filters/client_channel}/resolver_registry.c +1 -2
  68. data/src/core/ext/{client_channel → filters/client_channel}/resolver_registry.h +4 -4
  69. data/src/core/ext/filters/client_channel/retry_throttle.c +210 -0
  70. data/src/core/ext/filters/client_channel/retry_throttle.h +65 -0
  71. data/src/core/ext/{client_channel → filters/client_channel}/subchannel.c +49 -43
  72. data/src/core/ext/{client_channel → filters/client_channel}/subchannel.h +21 -7
  73. data/src/core/ext/{client_channel → filters/client_channel}/subchannel_index.c +1 -1
  74. data/src/core/ext/{client_channel → filters/client_channel}/subchannel_index.h +5 -5
  75. data/src/core/ext/{client_channel → filters/client_channel}/uri_parser.c +1 -1
  76. data/src/core/ext/{client_channel → filters/client_channel}/uri_parser.h +3 -3
  77. data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting.c +4 -2
  78. data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting.h +3 -3
  79. data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting_filter.c +17 -14
  80. data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting_filter.h +4 -4
  81. data/src/core/ext/filters/max_age/max_age_filter.c +439 -0
  82. data/src/core/ext/filters/max_age/max_age_filter.h +39 -0
  83. data/src/core/ext/transport/chttp2/client/chttp2_connector.c +6 -41
  84. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +1 -1
  85. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +2 -2
  86. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +3 -3
  87. data/src/core/ext/transport/chttp2/server/chttp2_server.c +2 -2
  88. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +2 -5
  89. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +2 -2
  90. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +449 -204
  91. data/src/core/ext/transport/chttp2/transport/frame_data.c +10 -7
  92. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +3 -2
  93. data/src/core/ext/transport/chttp2/transport/frame_ping.c +37 -7
  94. data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -0
  95. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +4 -3
  96. data/src/core/ext/transport/chttp2/transport/frame_settings.c +18 -38
  97. data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -29
  98. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +2 -2
  99. data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +64 -37
  100. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +11 -4
  101. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +60 -39
  102. data/src/core/ext/transport/chttp2/transport/hpack_table.c +2 -2
  103. data/src/core/ext/transport/chttp2/transport/http2_settings.c +75 -0
  104. data/src/core/ext/transport/chttp2/transport/http2_settings.h +74 -0
  105. data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +22 -43
  106. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +8 -10
  107. data/src/core/ext/transport/chttp2/transport/internal.h +24 -2
  108. data/src/core/ext/transport/chttp2/transport/parsing.c +33 -15
  109. data/src/core/ext/transport/chttp2/transport/writing.c +56 -10
  110. data/src/core/lib/channel/channel_args.c +7 -0
  111. data/src/core/lib/channel/channel_args.h +2 -0
  112. data/src/core/lib/channel/channel_stack.c +20 -27
  113. data/src/core/lib/channel/channel_stack.h +18 -16
  114. data/src/core/lib/channel/compress_filter.c +20 -18
  115. data/src/core/lib/channel/connected_channel.c +9 -8
  116. data/src/core/lib/channel/deadline_filter.c +28 -24
  117. data/src/core/lib/channel/deadline_filter.h +3 -3
  118. data/src/core/lib/channel/handshaker.c +3 -2
  119. data/src/core/lib/channel/http_client_filter.c +119 -61
  120. data/src/core/lib/channel/http_server_filter.c +124 -69
  121. data/src/core/lib/channel/message_size_filter.c +23 -19
  122. data/src/core/lib/http/httpcli.c +8 -6
  123. data/src/core/lib/http/httpcli_security_connector.c +5 -5
  124. data/src/core/lib/http/parser.c +57 -31
  125. data/src/core/lib/iomgr/closure.c +15 -0
  126. data/src/core/lib/iomgr/closure.h +4 -0
  127. data/src/core/lib/iomgr/combiner.c +8 -0
  128. data/src/core/lib/iomgr/endpoint_pair.h +2 -3
  129. data/src/core/lib/iomgr/endpoint_pair_posix.c +10 -7
  130. data/src/core/lib/iomgr/endpoint_pair_uv.c +2 -3
  131. data/src/core/lib/iomgr/endpoint_pair_windows.c +9 -6
  132. data/src/core/lib/iomgr/error.c +360 -177
  133. data/src/core/lib/iomgr/error.h +31 -33
  134. data/src/core/lib/iomgr/error_internal.h +30 -9
  135. data/src/core/lib/iomgr/ev_epoll_linux.c +25 -239
  136. data/src/core/lib/iomgr/ev_poll_posix.c +11 -7
  137. data/src/core/lib/iomgr/ev_posix.c +6 -0
  138. data/src/core/lib/iomgr/ev_posix.h +3 -0
  139. data/src/core/lib/iomgr/exec_ctx.c +6 -0
  140. data/src/core/lib/iomgr/executor.c +8 -2
  141. data/src/core/lib/iomgr/load_file.c +6 -3
  142. data/src/core/lib/iomgr/lockfree_event.c +238 -0
  143. data/src/core/{ext/client_channel/initial_connect_string.h → lib/iomgr/lockfree_event.h} +17 -13
  144. data/src/core/lib/iomgr/pollset.h +4 -0
  145. data/src/core/lib/iomgr/pollset_windows.c +2 -2
  146. data/src/core/lib/iomgr/port.h +9 -0
  147. data/src/core/lib/iomgr/resolve_address_posix.c +15 -9
  148. data/src/core/lib/iomgr/resolve_address_uv.c +8 -6
  149. data/src/core/lib/iomgr/resolve_address_windows.c +2 -2
  150. data/src/core/lib/iomgr/resource_quota.c +19 -4
  151. data/src/core/lib/iomgr/resource_quota.h +2 -0
  152. data/src/core/lib/iomgr/sockaddr_utils.c +3 -1
  153. data/src/core/lib/iomgr/socket_factory_posix.c +110 -0
  154. data/src/core/lib/iomgr/socket_factory_posix.h +90 -0
  155. data/src/core/lib/iomgr/socket_utils_common_posix.c +25 -9
  156. data/src/core/lib/iomgr/socket_utils_posix.h +7 -0
  157. data/src/core/lib/iomgr/tcp_client.h +0 -4
  158. data/src/core/lib/iomgr/tcp_client_posix.c +15 -31
  159. data/src/core/lib/iomgr/tcp_client_uv.c +10 -6
  160. data/src/core/lib/iomgr/tcp_client_windows.c +9 -19
  161. data/src/core/lib/iomgr/tcp_posix.c +111 -22
  162. data/src/core/lib/iomgr/tcp_posix.h +3 -4
  163. data/src/core/lib/iomgr/tcp_server_posix.c +39 -417
  164. data/src/core/lib/iomgr/tcp_server_utils_posix.h +135 -0
  165. data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +221 -0
  166. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c +196 -0
  167. data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c +49 -0
  168. data/src/core/lib/iomgr/tcp_server_uv.c +43 -16
  169. data/src/core/lib/iomgr/tcp_server_windows.c +10 -22
  170. data/src/core/lib/iomgr/tcp_uv.c +16 -13
  171. data/src/core/lib/iomgr/tcp_windows.c +24 -12
  172. data/src/core/lib/iomgr/tcp_windows.h +2 -2
  173. data/src/core/lib/iomgr/timer.h +3 -0
  174. data/src/core/lib/iomgr/timer_generic.c +257 -72
  175. data/src/core/lib/iomgr/timer_generic.h +1 -1
  176. data/src/core/lib/iomgr/timer_heap.c +8 -8
  177. data/src/core/lib/iomgr/udp_server.c +54 -24
  178. data/src/core/lib/iomgr/udp_server.h +7 -7
  179. data/src/core/lib/iomgr/unix_sockets_posix.c +1 -1
  180. data/src/core/lib/iomgr/unix_sockets_posix_noop.c +2 -1
  181. data/src/core/lib/iomgr/wakeup_fd_posix.h +1 -1
  182. data/src/core/lib/profiling/basic_timers.c +1 -1
  183. data/src/core/lib/security/credentials/credentials.h +1 -1
  184. data/src/core/lib/security/credentials/google_default/google_default_credentials.c +10 -9
  185. data/src/core/lib/security/credentials/jwt/json_token.c +1 -1
  186. data/src/core/lib/security/credentials/jwt/jwt_verifier.c +2 -2
  187. data/src/core/lib/security/transport/client_auth_filter.c +33 -26
  188. data/src/core/lib/security/transport/secure_endpoint.c +8 -5
  189. data/src/core/lib/security/transport/security_connector.c +37 -37
  190. data/src/core/lib/security/transport/security_connector.h +1 -1
  191. data/src/core/lib/security/transport/security_handshaker.c +15 -12
  192. data/src/core/lib/security/transport/server_auth_filter.c +20 -18
  193. data/src/core/lib/security/transport/tsi_error.c +5 -3
  194. data/src/core/lib/security/transport/tsi_error.h +1 -1
  195. data/src/core/lib/{security/util → slice}/b64.c +21 -6
  196. data/src/core/lib/{security/util → slice}/b64.h +16 -4
  197. data/src/core/lib/slice/slice.c +4 -2
  198. data/src/core/lib/slice/slice_buffer.c +16 -14
  199. data/src/core/lib/support/arena.c +98 -0
  200. data/src/core/{ext/client_channel/initial_connect_string.c → lib/support/arena.h} +17 -15
  201. data/src/core/{ext/client_channel/default_initial_connect_string.c → lib/support/atm.c} +14 -5
  202. data/src/core/lib/support/cpu_linux.c +5 -0
  203. data/src/core/lib/support/sync.c +4 -0
  204. data/src/core/lib/support/time.c +4 -10
  205. data/src/core/lib/support/wrap_memcpy.c +3 -1
  206. data/src/core/lib/surface/call.c +252 -221
  207. data/src/core/lib/surface/channel.c +72 -21
  208. data/src/core/lib/surface/channel.h +8 -0
  209. data/src/core/lib/surface/completion_queue.c +2 -3
  210. data/src/core/lib/surface/completion_queue_factory.c +77 -0
  211. data/src/core/lib/surface/completion_queue_factory.h +51 -0
  212. data/src/core/lib/surface/init_secure.c +3 -1
  213. data/src/core/lib/surface/lame_client.c +18 -14
  214. data/src/core/lib/surface/server.c +43 -41
  215. data/src/core/lib/surface/validate_metadata.c +8 -4
  216. data/src/core/lib/surface/version.c +2 -2
  217. data/src/core/lib/transport/bdp_estimator.h +1 -1
  218. data/src/core/lib/transport/connectivity_state.c +2 -1
  219. data/src/core/lib/transport/error_utils.c +17 -17
  220. data/src/core/lib/transport/error_utils.h +1 -1
  221. data/src/core/lib/transport/metadata_batch.c +6 -7
  222. data/src/core/lib/transport/pid_controller.c +1 -0
  223. data/src/core/lib/transport/service_config.c +12 -0
  224. data/src/core/lib/transport/service_config.h +6 -0
  225. data/src/core/lib/transport/transport.c +29 -17
  226. data/src/core/lib/transport/transport.h +85 -42
  227. data/src/core/lib/transport/transport_impl.h +5 -3
  228. data/src/core/lib/transport/transport_op_string.c +20 -14
  229. data/src/core/plugin_registry/grpc_plugin_registry.c +8 -0
  230. data/src/core/{lib/tsi → tsi}/fake_transport_security.c +2 -2
  231. data/src/core/{lib/tsi → tsi}/fake_transport_security.h +4 -4
  232. data/src/core/{lib/tsi → tsi}/ssl_transport_security.c +40 -79
  233. data/src/core/{lib/tsi → tsi}/ssl_transport_security.h +44 -21
  234. data/src/core/{lib/tsi → tsi}/ssl_types.h +3 -3
  235. data/src/core/{lib/tsi → tsi}/transport_security.c +2 -2
  236. data/src/core/{lib/tsi → tsi}/transport_security.h +4 -4
  237. data/src/core/{lib/tsi → tsi}/transport_security_interface.h +3 -3
  238. data/src/ruby/ext/grpc/extconf.rb +1 -0
  239. data/src/ruby/ext/grpc/rb_call_credentials.c +2 -2
  240. data/src/ruby/ext/grpc/rb_channel.c +520 -93
  241. data/src/ruby/ext/grpc/rb_channel.h +2 -0
  242. data/src/ruby/ext/grpc/rb_channel_credentials.c +3 -0
  243. data/src/ruby/ext/grpc/rb_compression_options.c +5 -2
  244. data/src/ruby/ext/grpc/rb_event_thread.c +6 -6
  245. data/src/ruby/ext/grpc/rb_grpc.c +29 -7
  246. data/src/ruby/ext/grpc/rb_grpc.h +2 -0
  247. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -0
  248. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +15 -0
  249. data/src/ruby/ext/grpc/rb_server.c +5 -3
  250. data/src/ruby/lib/grpc/version.rb +1 -1
  251. data/src/ruby/spec/channel_connection_spec.rb +173 -0
  252. data/src/ruby/spec/channel_spec.rb +29 -0
  253. data/src/ruby/spec/generic/rpc_server_pool_spec.rb +27 -17
  254. data/third_party/cares/ares_build.h +264 -0
  255. data/third_party/cares/cares/ares.h +636 -0
  256. data/third_party/cares/cares/ares__close_sockets.c +61 -0
  257. data/third_party/cares/cares/ares__get_hostent.c +261 -0
  258. data/third_party/cares/cares/ares__read_line.c +73 -0
  259. data/third_party/cares/cares/ares__timeval.c +111 -0
  260. data/third_party/cares/cares/ares_cancel.c +63 -0
  261. data/third_party/cares/cares/ares_create_query.c +202 -0
  262. data/third_party/cares/cares/ares_data.c +221 -0
  263. data/third_party/cares/cares/ares_data.h +72 -0
  264. data/third_party/cares/cares/ares_destroy.c +108 -0
  265. data/third_party/cares/cares/ares_dns.h +103 -0
  266. data/third_party/cares/cares/ares_expand_name.c +205 -0
  267. data/third_party/cares/cares/ares_expand_string.c +70 -0
  268. data/third_party/cares/cares/ares_fds.c +59 -0
  269. data/third_party/cares/cares/ares_free_hostent.c +41 -0
  270. data/third_party/cares/cares/ares_free_string.c +25 -0
  271. data/third_party/cares/cares/ares_getenv.c +30 -0
  272. data/third_party/cares/cares/ares_getenv.h +26 -0
  273. data/third_party/cares/cares/ares_gethostbyaddr.c +294 -0
  274. data/third_party/cares/cares/ares_gethostbyname.c +518 -0
  275. data/third_party/cares/cares/ares_getnameinfo.c +422 -0
  276. data/third_party/cares/cares/ares_getopt.c +122 -0
  277. data/third_party/cares/cares/ares_getopt.h +53 -0
  278. data/third_party/cares/cares/ares_getsock.c +66 -0
  279. data/third_party/cares/cares/ares_inet_net_pton.h +25 -0
  280. data/third_party/cares/cares/ares_init.c +2146 -0
  281. data/third_party/cares/cares/ares_iphlpapi.h +221 -0
  282. data/third_party/cares/cares/ares_ipv6.h +78 -0
  283. data/third_party/cares/cares/ares_library_init.c +167 -0
  284. data/third_party/cares/cares/ares_library_init.h +42 -0
  285. data/third_party/cares/cares/ares_llist.c +63 -0
  286. data/third_party/cares/cares/ares_llist.h +39 -0
  287. data/third_party/cares/cares/ares_mkquery.c +24 -0
  288. data/third_party/cares/cares/ares_nowarn.c +260 -0
  289. data/third_party/cares/cares/ares_nowarn.h +61 -0
  290. data/third_party/cares/cares/ares_options.c +402 -0
  291. data/third_party/cares/cares/ares_parse_a_reply.c +264 -0
  292. data/third_party/cares/cares/ares_parse_aaaa_reply.c +264 -0
  293. data/third_party/cares/cares/ares_parse_mx_reply.c +170 -0
  294. data/third_party/cares/cares/ares_parse_naptr_reply.c +188 -0
  295. data/third_party/cares/cares/ares_parse_ns_reply.c +183 -0
  296. data/third_party/cares/cares/ares_parse_ptr_reply.c +219 -0
  297. data/third_party/cares/cares/ares_parse_soa_reply.c +133 -0
  298. data/third_party/cares/cares/ares_parse_srv_reply.c +179 -0
  299. data/third_party/cares/cares/ares_parse_txt_reply.c +220 -0
  300. data/third_party/cares/cares/ares_platform.c +11035 -0
  301. data/third_party/cares/cares/ares_platform.h +43 -0
  302. data/third_party/cares/cares/ares_private.h +363 -0
  303. data/third_party/cares/cares/ares_process.c +1359 -0
  304. data/third_party/cares/cares/ares_query.c +186 -0
  305. data/third_party/cares/cares/ares_rules.h +125 -0
  306. data/third_party/cares/cares/ares_search.c +316 -0
  307. data/third_party/cares/cares/ares_send.c +131 -0
  308. data/third_party/cares/cares/ares_setup.h +217 -0
  309. data/third_party/cares/cares/ares_strcasecmp.c +66 -0
  310. data/third_party/cares/cares/ares_strcasecmp.h +30 -0
  311. data/third_party/cares/cares/ares_strdup.c +49 -0
  312. data/third_party/cares/cares/ares_strdup.h +24 -0
  313. data/third_party/cares/cares/ares_strerror.c +56 -0
  314. data/third_party/cares/cares/ares_timeout.c +88 -0
  315. data/third_party/cares/cares/ares_version.c +11 -0
  316. data/third_party/cares/cares/ares_version.h +24 -0
  317. data/third_party/cares/cares/ares_writev.c +79 -0
  318. data/third_party/cares/cares/bitncmp.c +59 -0
  319. data/third_party/cares/cares/bitncmp.h +26 -0
  320. data/third_party/cares/cares/config-win32.h +377 -0
  321. data/third_party/cares/cares/inet_net_pton.c +450 -0
  322. data/third_party/cares/cares/inet_ntop.c +208 -0
  323. data/third_party/cares/cares/setup_once.h +554 -0
  324. data/third_party/cares/cares/windows_port.c +22 -0
  325. data/third_party/cares/config_darwin/ares_config.h +523 -0
  326. data/third_party/cares/config_linux/ares_config.h +524 -0
  327. metadata +164 -68
@@ -37,6 +37,7 @@
37
37
  #include <stdbool.h>
38
38
  #include <stdint.h>
39
39
 
40
+ #include <grpc/slice.h>
40
41
  #include <grpc/status.h>
41
42
  #include <grpc/support/time.h>
42
43
 
@@ -45,28 +46,9 @@ extern "C" {
45
46
  #endif
46
47
 
47
48
  /// Opaque representation of an error.
48
- /// Errors are refcounted objects that represent the result of an operation.
49
- /// Ownership laws:
50
- /// if a grpc_error is returned by a function, the caller owns a ref to that
51
- /// instance
52
- /// if a grpc_error is passed to a grpc_closure callback function (functions
53
- /// with the signature:
54
- /// void (*f)(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error))
55
- /// then those functions do not own a ref to error (but are free to manually
56
- /// take a reference).
57
- /// if a grpc_error is passed to *ANY OTHER FUNCTION* then that function takes
58
- /// ownership of the error
59
- /// Errors have:
60
- /// a set of ints, strings, and timestamps that describe the error
61
- /// always present are:
62
- /// GRPC_ERROR_STR_FILE, GRPC_ERROR_INT_FILE_LINE - source location the error
63
- /// was generated
64
- /// GRPC_ERROR_STR_DESCRIPTION - a human readable description of the error
65
- /// GRPC_ERROR_TIME_CREATED - a timestamp indicating when the error happened
66
- /// an error can also have children; these are other errors that are believed
67
- /// to have contributed to this one. By accumulating children, we can begin
68
- /// to root cause high level failures from low level failures, without having
69
- /// to derive execution paths from log lines
49
+ /// See https://github.com/grpc/grpc/blob/master/doc/core/grpc-error.md for a
50
+ /// full write up of this object.
51
+
70
52
  typedef struct grpc_error grpc_error;
71
53
 
72
54
  typedef enum {
@@ -102,6 +84,9 @@ typedef enum {
102
84
  GRPC_ERROR_INT_LIMIT,
103
85
  /// chttp2: did the error occur while a write was in progress
104
86
  GRPC_ERROR_INT_OCCURRED_DURING_WRITE,
87
+
88
+ /// Must always be last
89
+ GRPC_ERROR_INT_MAX,
105
90
  } grpc_error_ints;
106
91
 
107
92
  typedef enum {
@@ -129,11 +114,17 @@ typedef enum {
129
114
  GRPC_ERROR_STR_KEY,
130
115
  /// value associated with the error
131
116
  GRPC_ERROR_STR_VALUE,
117
+
118
+ /// Must always be last
119
+ GRPC_ERROR_STR_MAX,
132
120
  } grpc_error_strs;
133
121
 
134
122
  typedef enum {
135
123
  /// timestamp of error creation
136
124
  GRPC_ERROR_TIME_CREATED,
125
+
126
+ /// Must always be last
127
+ GRPC_ERROR_TIME_MAX,
137
128
  } grpc_error_times;
138
129
 
139
130
  /// The following "special" errors can be propagated without allocating memory.
@@ -147,7 +138,7 @@ typedef enum {
147
138
  const char *grpc_error_string(grpc_error *error);
148
139
 
149
140
  /// Create an error - but use GRPC_ERROR_CREATE instead
150
- grpc_error *grpc_error_create(const char *file, int line, const char *desc,
141
+ grpc_error *grpc_error_create(grpc_slice file, int line, grpc_slice desc,
151
142
  grpc_error **referencing, size_t num_referencing);
152
143
  /// Create an error (this is the preferred way of generating an error that is
153
144
  /// not due to a system call - for system calls, use GRPC_OS_ERROR or
@@ -157,13 +148,21 @@ grpc_error *grpc_error_create(const char *file, int line, const char *desc,
157
148
  /// err = grpc_error_create(x, y, z, r, nr) is equivalent to:
158
149
  /// err = grpc_error_create(x, y, z, NULL, 0);
159
150
  /// for (i=0; i<nr; i++) err = grpc_error_add_child(err, r[i]);
160
- #define GRPC_ERROR_CREATE(desc) \
161
- grpc_error_create(__FILE__, __LINE__, desc, NULL, 0)
151
+ #define GRPC_ERROR_CREATE_FROM_STATIC_STRING(desc) \
152
+ grpc_error_create(grpc_slice_from_static_string(__FILE__), __LINE__, \
153
+ grpc_slice_from_static_string(desc), NULL, 0)
154
+ #define GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc) \
155
+ grpc_error_create(grpc_slice_from_static_string(__FILE__), __LINE__, \
156
+ grpc_slice_from_copied_string(desc), NULL, 0)
162
157
 
163
158
  // Create an error that references some other errors. This function adds a
164
159
  // reference to each error in errs - it does not consume an existing reference
165
- #define GRPC_ERROR_CREATE_REFERENCING(desc, errs, count) \
166
- grpc_error_create(__FILE__, __LINE__, desc, errs, count)
160
+ #define GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(desc, errs, count) \
161
+ grpc_error_create(grpc_slice_from_static_string(__FILE__), __LINE__, \
162
+ grpc_slice_from_static_string(desc), errs, count)
163
+ #define GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING(desc, errs, count) \
164
+ grpc_error_create(grpc_slice_from_static_string(__FILE__), __LINE__, \
165
+ grpc_slice_from_copied_string(desc), errs, count)
167
166
 
168
167
  //#define GRPC_ERROR_REFCOUNT_DEBUG
169
168
  #ifdef GRPC_ERROR_REFCOUNT_DEBUG
@@ -184,13 +183,12 @@ void grpc_error_unref(grpc_error *err);
184
183
  grpc_error *grpc_error_set_int(grpc_error *src, grpc_error_ints which,
185
184
  intptr_t value) GRPC_MUST_USE_RESULT;
186
185
  bool grpc_error_get_int(grpc_error *error, grpc_error_ints which, intptr_t *p);
187
- grpc_error *grpc_error_set_time(grpc_error *src, grpc_error_times which,
188
- gpr_timespec value) GRPC_MUST_USE_RESULT;
189
186
  grpc_error *grpc_error_set_str(grpc_error *src, grpc_error_strs which,
190
- const char *value) GRPC_MUST_USE_RESULT;
191
- /// Returns NULL if the specified string is not set.
192
- /// Caller does NOT own return value.
193
- const char *grpc_error_get_str(grpc_error *error, grpc_error_strs which);
187
+ grpc_slice str) GRPC_MUST_USE_RESULT;
188
+ /// Returns false if the specified string is not set.
189
+ /// Caller does NOT own the slice.
190
+ bool grpc_error_get_str(grpc_error *error, grpc_error_strs which,
191
+ grpc_slice *s);
194
192
 
195
193
  /// Add a child error: an error that is believed to have contributed to this
196
194
  /// error occurring. Allows root causing high level errors from lower level
@@ -35,18 +35,39 @@
35
35
  #define GRPC_CORE_LIB_IOMGR_ERROR_INTERNAL_H
36
36
 
37
37
  #include <inttypes.h>
38
- #include <stdbool.h>
38
+ #include <stdbool.h> // TODO, do we need this?
39
39
 
40
- #include <grpc/support/avl.h>
40
+ #include <grpc/support/sync.h>
41
41
 
42
+ typedef struct grpc_linked_error grpc_linked_error;
43
+
44
+ struct grpc_linked_error {
45
+ grpc_error *err;
46
+ uint8_t next;
47
+ };
48
+
49
+ // c core representation of an error. See error.h for high level description of
50
+ // this object.
42
51
  struct grpc_error {
43
- gpr_refcount refs;
44
- gpr_avl ints;
45
- gpr_avl strs;
46
- gpr_avl times;
47
- gpr_avl errs;
48
- uintptr_t next_err;
49
- gpr_atm error_string;
52
+ // All atomics in grpc_error must be stored in this nested struct. The rest of
53
+ // the object is memcpy-ed in bulk in copy_and_unref.
54
+ struct atomics {
55
+ gpr_refcount refs;
56
+ gpr_atm error_string;
57
+ } atomics;
58
+ // These arrays index into dynamic arena at the bottom of the struct.
59
+ // UINT8_MAX is used as a sentinel value.
60
+ uint8_t ints[GRPC_ERROR_INT_MAX];
61
+ uint8_t strs[GRPC_ERROR_STR_MAX];
62
+ uint8_t times[GRPC_ERROR_TIME_MAX];
63
+ // The child errors are stored in the arena, but are effectively a linked list
64
+ // structure, since they are contained withing grpc_linked_error objects.
65
+ uint8_t first_err;
66
+ uint8_t last_err;
67
+ // The arena is dynamically reallocated with a grow factor of 1.5.
68
+ uint8_t arena_size;
69
+ uint8_t arena_capacity;
70
+ intptr_t arena[0];
50
71
  };
51
72
 
52
73
  bool grpc_error_is_special(grpc_error *err);
@@ -56,6 +56,8 @@
56
56
 
57
57
  #include "src/core/lib/iomgr/ev_posix.h"
58
58
  #include "src/core/lib/iomgr/iomgr_internal.h"
59
+ #include "src/core/lib/iomgr/lockfree_event.h"
60
+ #include "src/core/lib/iomgr/timer.h"
59
61
  #include "src/core/lib/iomgr/wakeup_fd_posix.h"
60
62
  #include "src/core/lib/iomgr/workqueue.h"
61
63
  #include "src/core/lib/profiling/timers.h"
@@ -140,52 +142,11 @@ struct grpc_fd {
140
142
  Ref/Unref by two to avoid altering the orphaned bit */
141
143
  gpr_atm refst;
142
144
 
143
- /* Internally stores data of type (grpc_error *). If the FD is shutdown, this
144
- contains reason for shutdown (i.e a pointer to grpc_error) ORed with
145
- FD_SHUTDOWN_BIT. Since address allocations are word-aligned, the lower bit
146
- of (grpc_error *) addresses is guaranteed to be zero. Even if the
147
- (grpc_error *), is of special types like GRPC_ERROR_NONE, GRPC_ERROR_OOM
148
- etc, the lower bit is guaranteed to be zero.
149
-
150
- Once an fd is shutdown, any pending or future read/write closures on the
151
- fd should fail */
152
- gpr_atm shutdown_error;
153
-
154
145
  /* The fd is either closed or we relinquished control of it. In either
155
146
  cases, this indicates that the 'fd' on this structure is no longer
156
147
  valid */
157
148
  bool orphaned;
158
149
 
159
- /* Closures to call when the fd is readable or writable respectively. These
160
- fields contain one of the following values:
161
- CLOSURE_READY : The fd has an I/O event of interest but there is no
162
- closure yet to execute
163
-
164
- CLOSURE_NOT_READY : The fd has no I/O event of interest
165
-
166
- closure ptr : The closure to be executed when the fd has an I/O
167
- event of interest
168
-
169
- shutdown_error | FD_SHUTDOWN_BIT :
170
- 'shutdown_error' field ORed with FD_SHUTDOWN_BIT.
171
- This indicates that the fd is shutdown. Since all
172
- memory allocations are word-aligned, the lower two
173
- bits of the shutdown_error pointer are always 0. So
174
- it is safe to OR these with FD_SHUTDOWN_BIT
175
-
176
- Valid state transitions:
177
-
178
- <closure ptr> <-----3------ CLOSURE_NOT_READY ----1----> CLOSURE_READY
179
- | | ^ | ^ | |
180
- | | | | | | |
181
- | +--------------4----------+ 6 +---------2---------------+ |
182
- | | |
183
- | v |
184
- +-----5-------> [shutdown_error | FD_SHUTDOWN_BIT] <----7---------+
185
-
186
- For 1, 4 : See set_ready() function
187
- For 2, 3 : See notify_on() function
188
- For 5,6,7: See set_shutdown() function */
189
150
  gpr_atm read_closure;
190
151
  gpr_atm write_closure;
191
152
 
@@ -217,11 +178,6 @@ static void fd_unref(grpc_fd *fd);
217
178
  static void fd_global_init(void);
218
179
  static void fd_global_shutdown(void);
219
180
 
220
- #define CLOSURE_NOT_READY ((gpr_atm)0)
221
- #define CLOSURE_READY ((gpr_atm)2)
222
-
223
- #define FD_SHUTDOWN_BIT 1
224
-
225
181
  /*******************************************************************************
226
182
  * Polling island Declarations
227
183
  */
@@ -321,7 +277,7 @@ static bool append_error(grpc_error **composite, grpc_error *error,
321
277
  const char *desc) {
322
278
  if (error == GRPC_ERROR_NONE) return true;
323
279
  if (*composite == GRPC_ERROR_NONE) {
324
- *composite = GRPC_ERROR_CREATE(desc);
280
+ *composite = GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc);
325
281
  }
326
282
  *composite = grpc_error_add_child(*composite, error);
327
283
  return false;
@@ -948,10 +904,8 @@ static void unref_by(grpc_fd *fd, int n) {
948
904
  fd_freelist = fd;
949
905
  grpc_iomgr_unregister_object(&fd->iomgr_object);
950
906
 
951
- grpc_error *err = (grpc_error *)gpr_atm_acq_load(&fd->shutdown_error);
952
- /* Clear the least significant bit if it set (in case fd was shutdown) */
953
- err = (grpc_error *)((intptr_t)err & ~FD_SHUTDOWN_BIT);
954
- GRPC_ERROR_UNREF(err);
907
+ grpc_lfev_destroy(&fd->read_closure);
908
+ grpc_lfev_destroy(&fd->write_closure);
955
909
 
956
910
  gpr_mu_unlock(&fd_freelist_mu);
957
911
  } else {
@@ -1015,10 +969,9 @@ static grpc_fd *fd_create(int fd, const char *name) {
1015
969
 
1016
970
  gpr_atm_rel_store(&new_fd->refst, (gpr_atm)1);
1017
971
  new_fd->fd = fd;
1018
- gpr_atm_no_barrier_store(&new_fd->shutdown_error, (gpr_atm)GRPC_ERROR_NONE);
1019
972
  new_fd->orphaned = false;
1020
- gpr_atm_no_barrier_store(&new_fd->read_closure, CLOSURE_NOT_READY);
1021
- gpr_atm_no_barrier_store(&new_fd->write_closure, CLOSURE_NOT_READY);
973
+ grpc_lfev_init(&new_fd->read_closure);
974
+ grpc_lfev_init(&new_fd->write_closure);
1022
975
  gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL);
1023
976
 
1024
977
  new_fd->freelist_next = NULL;
@@ -1104,172 +1057,6 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
1104
1057
  GRPC_ERROR_UNREF(error);
1105
1058
  }
1106
1059
 
1107
- static void notify_on(grpc_exec_ctx *exec_ctx, grpc_fd *fd, gpr_atm *state,
1108
- grpc_closure *closure) {
1109
- while (true) {
1110
- /* Fast-path: CLOSURE_NOT_READY -> <closure>.
1111
- The 'release' cas here matches the 'acquire' load in set_ready and
1112
- set_shutdown ensuring that the closure (scheduled by set_ready or
1113
- set_shutdown) happens-after the I/O event on the fd */
1114
- if (gpr_atm_rel_cas(state, CLOSURE_NOT_READY, (gpr_atm)closure)) {
1115
- return; /* Fast-path successful. Return */
1116
- }
1117
-
1118
- /* Slowpath. The 'acquire' load matches the 'release' cas in set_ready and
1119
- set_shutdown */
1120
- gpr_atm curr = gpr_atm_acq_load(state);
1121
- switch (curr) {
1122
- case CLOSURE_NOT_READY: {
1123
- break; /* retry */
1124
- }
1125
-
1126
- case CLOSURE_READY: {
1127
- /* Change the state to CLOSURE_NOT_READY. Schedule the closure if
1128
- successful. If not, the state most likely transitioned to shutdown.
1129
- We should retry.
1130
-
1131
- This can be a no-barrier cas since the state is being transitioned to
1132
- CLOSURE_NOT_READY; set_ready and set_shutdown do not schedule any
1133
- closure when transitioning out of CLOSURE_NO_READY state (i.e there
1134
- is no other code that needs to 'happen-after' this) */
1135
- if (gpr_atm_no_barrier_cas(state, CLOSURE_READY, CLOSURE_NOT_READY)) {
1136
- grpc_closure_sched(exec_ctx, closure, GRPC_ERROR_NONE);
1137
- return; /* Slow-path successful. Return */
1138
- }
1139
-
1140
- break; /* retry */
1141
- }
1142
-
1143
- default: {
1144
- /* 'curr' is either a closure or the fd is shutdown(in which case 'curr'
1145
- contains a pointer to the shutdown-error). If the fd is shutdown,
1146
- schedule the closure with the shutdown error */
1147
- if ((curr & FD_SHUTDOWN_BIT) > 0) {
1148
- grpc_error *shutdown_err = (grpc_error *)(curr & ~FD_SHUTDOWN_BIT);
1149
- grpc_closure_sched(
1150
- exec_ctx, closure,
1151
- GRPC_ERROR_CREATE_REFERENCING("FD Shutdown", &shutdown_err, 1));
1152
- return;
1153
- }
1154
-
1155
- /* There is already a closure!. This indicates a bug in the code */
1156
- gpr_log(GPR_ERROR,
1157
- "notify_on called with a previous callback still pending");
1158
- abort();
1159
- }
1160
- }
1161
- }
1162
-
1163
- GPR_UNREACHABLE_CODE(return );
1164
- }
1165
-
1166
- static void set_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd, gpr_atm *state,
1167
- grpc_error *shutdown_err) {
1168
- /* Try the fast-path first (i.e expect the current value to be
1169
- CLOSURE_NOT_READY */
1170
- gpr_atm curr = CLOSURE_NOT_READY;
1171
- gpr_atm new_state = (gpr_atm)shutdown_err | FD_SHUTDOWN_BIT;
1172
-
1173
- while (true) {
1174
- /* The 'release' cas here matches the 'acquire' load in notify_on to ensure
1175
- that the closure it schedules 'happens-after' the set_shutdown is called
1176
- on the fd */
1177
- if (gpr_atm_rel_cas(state, curr, new_state)) {
1178
- return; /* Fast-path successful. Return */
1179
- }
1180
-
1181
- /* Fallback to slowpath. This 'acquire' load matches the 'release' cas in
1182
- notify_on and set_ready */
1183
- curr = gpr_atm_acq_load(state);
1184
- switch (curr) {
1185
- case CLOSURE_READY: {
1186
- break; /* retry */
1187
- }
1188
-
1189
- case CLOSURE_NOT_READY: {
1190
- break; /* retry */
1191
- }
1192
-
1193
- default: {
1194
- /* 'curr' is either a closure or the fd is already shutdown */
1195
-
1196
- /* If fd is already shutdown, we are done */
1197
- if ((curr & FD_SHUTDOWN_BIT) > 0) {
1198
- return;
1199
- }
1200
-
1201
- /* Fd is not shutdown. Schedule the closure and move the state to
1202
- shutdown state. The 'release' cas here matches the 'acquire' load in
1203
- notify_on to ensure that the closure it schedules 'happens-after'
1204
- the set_shutdown is called on the fd */
1205
- if (gpr_atm_rel_cas(state, curr, new_state)) {
1206
- grpc_closure_sched(
1207
- exec_ctx, (grpc_closure *)curr,
1208
- GRPC_ERROR_CREATE_REFERENCING("FD Shutdown", &shutdown_err, 1));
1209
- return;
1210
- }
1211
-
1212
- /* 'curr' was a closure but now changed to a different state. We will
1213
- have to retry */
1214
- break;
1215
- }
1216
- }
1217
- }
1218
-
1219
- GPR_UNREACHABLE_CODE(return );
1220
- }
1221
-
1222
- static void set_ready(grpc_exec_ctx *exec_ctx, grpc_fd *fd, gpr_atm *state) {
1223
- /* Try an optimistic case first (i.e assume current state is
1224
- CLOSURE_NOT_READY).
1225
-
1226
- This 'release' cas matches the 'acquire' load in notify_on ensuring that
1227
- any closure (scheduled by notify_on) 'happens-after' the return from
1228
- epoll_pwait */
1229
- if (gpr_atm_rel_cas(state, CLOSURE_NOT_READY, CLOSURE_READY)) {
1230
- return; /* early out */
1231
- }
1232
-
1233
- /* The 'acquire' load here matches the 'release' cas in notify_on and
1234
- set_shutdown */
1235
- gpr_atm curr = gpr_atm_acq_load(state);
1236
- switch (curr) {
1237
- case CLOSURE_READY: {
1238
- /* Already ready. We are done here */
1239
- break;
1240
- }
1241
-
1242
- case CLOSURE_NOT_READY: {
1243
- /* The state was not CLOSURE_NOT_READY when we checked initially at the
1244
- beginning of this function but now it is CLOSURE_NOT_READY again.
1245
- This is only possible if the state transitioned out of
1246
- CLOSURE_NOT_READY to either CLOSURE_READY or <some closure> and then
1247
- back to CLOSURE_NOT_READY again (i.e after we entered this function,
1248
- the fd became "ready" and the necessary actions were already done).
1249
- So there is no need to make the state CLOSURE_READY now */
1250
- break;
1251
- }
1252
-
1253
- default: {
1254
- /* 'curr' is either a closure or the fd is shutdown */
1255
- if ((curr & FD_SHUTDOWN_BIT) > 0) {
1256
- /* The fd is shutdown. Do nothing */
1257
- } else if (gpr_atm_no_barrier_cas(state, curr, CLOSURE_NOT_READY)) {
1258
- /* The cas above was no-barrier since the state is being transitioned to
1259
- CLOSURE_NOT_READY; notify_on and set_shutdown do not schedule any
1260
- closures when transitioning out of CLOSURE_NO_READY state (i.e there
1261
- is no other code that needs to 'happen-after' this) */
1262
-
1263
- grpc_closure_sched(exec_ctx, (grpc_closure *)curr, GRPC_ERROR_NONE);
1264
- }
1265
- /* else the state changed again (only possible by either a racing
1266
- set_ready or set_shutdown functions. In both these cases, the closure
1267
- would have been scheduled for execution. So we are done here */
1268
- break;
1269
- }
1270
- }
1271
- }
1272
-
1273
1060
  static grpc_pollset *fd_get_read_notifier_pollset(grpc_exec_ctx *exec_ctx,
1274
1061
  grpc_fd *fd) {
1275
1062
  gpr_atm notifier = gpr_atm_acq_load(&fd->read_notifier_pollset);
@@ -1277,33 +1064,27 @@ static grpc_pollset *fd_get_read_notifier_pollset(grpc_exec_ctx *exec_ctx,
1277
1064
  }
1278
1065
 
1279
1066
  static bool fd_is_shutdown(grpc_fd *fd) {
1280
- grpc_error *err = (grpc_error *)gpr_atm_acq_load(&fd->shutdown_error);
1281
- return (((intptr_t)err & FD_SHUTDOWN_BIT) > 0);
1067
+ return grpc_lfev_is_shutdown(&fd->read_closure);
1282
1068
  }
1283
1069
 
1284
1070
  /* Might be called multiple times */
1285
1071
  static void fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_error *why) {
1286
- /* Store the shutdown error ORed with FD_SHUTDOWN_BIT in fd->shutdown_error */
1287
- if (gpr_atm_rel_cas(&fd->shutdown_error, (gpr_atm)GRPC_ERROR_NONE,
1288
- (gpr_atm)why | FD_SHUTDOWN_BIT)) {
1072
+ if (grpc_lfev_set_shutdown(exec_ctx, &fd->read_closure,
1073
+ GRPC_ERROR_REF(why))) {
1289
1074
  shutdown(fd->fd, SHUT_RDWR);
1290
-
1291
- set_shutdown(exec_ctx, fd, &fd->read_closure, why);
1292
- set_shutdown(exec_ctx, fd, &fd->write_closure, why);
1293
- } else {
1294
- /* Shutdown already called */
1295
- GRPC_ERROR_UNREF(why);
1075
+ grpc_lfev_set_shutdown(exec_ctx, &fd->write_closure, GRPC_ERROR_REF(why));
1296
1076
  }
1077
+ GRPC_ERROR_UNREF(why);
1297
1078
  }
1298
1079
 
1299
1080
  static void fd_notify_on_read(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
1300
1081
  grpc_closure *closure) {
1301
- notify_on(exec_ctx, fd, &fd->read_closure, closure);
1082
+ grpc_lfev_notify_on(exec_ctx, &fd->read_closure, closure);
1302
1083
  }
1303
1084
 
1304
1085
  static void fd_notify_on_write(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
1305
1086
  grpc_closure *closure) {
1306
- notify_on(exec_ctx, fd, &fd->write_closure, closure);
1087
+ grpc_lfev_notify_on(exec_ctx, &fd->write_closure, closure);
1307
1088
  }
1308
1089
 
1309
1090
  static grpc_workqueue *fd_get_workqueue(grpc_fd *fd) {
@@ -1351,7 +1132,7 @@ static grpc_error *pollset_worker_kick(grpc_pollset_worker *worker) {
1351
1132
  if (gpr_atm_no_barrier_cas(&worker->is_kicked, (gpr_atm)0, (gpr_atm)1)) {
1352
1133
  GRPC_POLLING_TRACE(
1353
1134
  "pollset_worker_kick: Kicking worker: %p (thread id: %ld)",
1354
- (void *)worker, worker->pt_id);
1135
+ (void *)worker, (long int)worker->pt_id);
1355
1136
  int err_num = pthread_kill(worker->pt_id, grpc_wakeup_signal);
1356
1137
  if (err_num != 0) {
1357
1138
  err = GRPC_OS_ERROR(err_num, "pthread_kill");
@@ -1486,13 +1267,14 @@ static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
1486
1267
  return 0;
1487
1268
  }
1488
1269
  timeout = gpr_time_sub(deadline, now);
1489
- return gpr_time_to_millis(gpr_time_add(
1270
+ int millis = gpr_time_to_millis(gpr_time_add(
1490
1271
  timeout, gpr_time_from_nanos(GPR_NS_PER_MS - 1, GPR_TIMESPAN)));
1272
+ return millis >= 1 ? millis : 1;
1491
1273
  }
1492
1274
 
1493
1275
  static void fd_become_readable(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
1494
1276
  grpc_pollset *notifier) {
1495
- set_ready(exec_ctx, fd, &fd->read_closure);
1277
+ grpc_lfev_set_ready(exec_ctx, &fd->read_closure);
1496
1278
 
1497
1279
  /* Note, it is possible that fd_become_readable might be called twice with
1498
1280
  different 'notifier's when an fd becomes readable and it is in two epoll
@@ -1504,7 +1286,7 @@ static void fd_become_readable(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
1504
1286
  }
1505
1287
 
1506
1288
  static void fd_become_writable(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
1507
- set_ready(exec_ctx, fd, &fd->write_closure);
1289
+ grpc_lfev_set_ready(exec_ctx, &fd->write_closure);
1508
1290
  }
1509
1291
 
1510
1292
  static void pollset_release_polling_island(grpc_exec_ctx *exec_ctx,
@@ -1566,6 +1348,9 @@ static bool maybe_do_workqueue_work(grpc_exec_ctx *exec_ctx,
1566
1348
  }
1567
1349
  grpc_closure *c = (grpc_closure *)n;
1568
1350
  grpc_error *error = c->error_data.error;
1351
+ #ifndef NDEBUG
1352
+ c->scheduled = false;
1353
+ #endif
1569
1354
  c->cb(exec_ctx, c->cb_arg, error);
1570
1355
  GRPC_ERROR_UNREF(error);
1571
1356
  return true;
@@ -1669,6 +1454,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
1669
1454
  for (int i = 0; i < ep_rv; ++i) {
1670
1455
  void *data_ptr = ep_ev[i].data.ptr;
1671
1456
  if (data_ptr == &global_wakeup_fd) {
1457
+ grpc_timer_consume_kick();
1672
1458
  append_error(error, grpc_wakeup_fd_consume_wakeup(&global_wakeup_fd),
1673
1459
  err_desc);
1674
1460
  } else if (data_ptr == &pi->workqueue_wakeup_fd) {
@@ -1733,7 +1519,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
1733
1519
  worker.pt_id = pthread_self();
1734
1520
  gpr_atm_no_barrier_store(&worker.is_kicked, (gpr_atm)0);
1735
1521
 
1736
- *worker_hdl = &worker;
1522
+ if (worker_hdl) *worker_hdl = &worker;
1737
1523
 
1738
1524
  gpr_tls_set(&g_current_thread_pollset, (intptr_t)pollset);
1739
1525
  gpr_tls_set(&g_current_thread_worker, (intptr_t)&worker);
@@ -1811,7 +1597,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
1811
1597
  gpr_mu_lock(&pollset->po.mu);
1812
1598
  }
1813
1599
 
1814
- *worker_hdl = NULL;
1600
+ if (worker_hdl) *worker_hdl = NULL;
1815
1601
 
1816
1602
  gpr_tls_set(&g_current_thread_pollset, (intptr_t)0);
1817
1603
  gpr_tls_set(&g_current_thread_worker, (intptr_t)0);