grpc 1.8.7 → 1.9.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 (488) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +549 -325
  3. data/include/grpc/impl/codegen/grpc_types.h +1 -2
  4. data/include/grpc/impl/codegen/port_platform.h +46 -5
  5. data/include/grpc/impl/codegen/slice.h +1 -2
  6. data/include/grpc/module.modulemap +0 -2
  7. data/include/grpc/slice_buffer.h +1 -2
  8. data/include/grpc/support/log.h +4 -2
  9. data/include/grpc/support/thd.h +4 -1
  10. data/include/grpc/support/tls.h +6 -0
  11. data/include/grpc/support/tls_gcc.h +5 -40
  12. data/include/grpc/support/tls_msvc.h +9 -0
  13. data/include/grpc/support/tls_pthread.h +9 -0
  14. data/src/core/ext/filters/client_channel/backup_poller.cc +32 -29
  15. data/src/core/ext/filters/client_channel/backup_poller.h +2 -2
  16. data/src/core/ext/filters/client_channel/channel_connectivity.cc +26 -32
  17. data/src/core/ext/filters/client_channel/client_channel.cc +325 -356
  18. data/src/core/ext/filters/client_channel/client_channel.h +4 -12
  19. data/src/core/ext/filters/client_channel/client_channel_factory.cc +9 -14
  20. data/src/core/ext/filters/client_channel/client_channel_factory.h +7 -20
  21. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +7 -10
  22. data/src/core/ext/filters/client_channel/connector.cc +6 -7
  23. data/src/core/ext/filters/client_channel/connector.h +6 -16
  24. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +38 -50
  25. data/src/core/ext/filters/client_channel/http_connect_handshaker.h +0 -8
  26. data/src/core/ext/filters/client_channel/http_proxy.cc +9 -13
  27. data/src/core/ext/filters/client_channel/http_proxy.h +0 -8
  28. data/src/core/ext/filters/client_channel/lb_policy.cc +72 -94
  29. data/src/core/ext/filters/client_channel/lb_policy.h +83 -92
  30. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +14 -19
  31. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +0 -8
  32. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +474 -591
  33. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +0 -8
  34. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +2 -10
  35. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +6 -6
  36. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +0 -8
  37. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +0 -9
  38. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +0 -9
  39. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +3 -4
  40. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +9 -12
  41. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +160 -182
  42. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +182 -221
  43. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +24 -35
  44. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +9 -20
  45. data/src/core/ext/filters/client_channel/lb_policy_factory.cc +6 -9
  46. data/src/core/ext/filters/client_channel/lb_policy_factory.h +4 -15
  47. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +3 -3
  48. data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -9
  49. data/src/core/ext/filters/client_channel/parse_address.cc +1 -1
  50. data/src/core/ext/filters/client_channel/parse_address.h +0 -8
  51. data/src/core/ext/filters/client_channel/proxy_mapper.cc +6 -8
  52. data/src/core/ext/filters/client_channel/proxy_mapper.h +6 -16
  53. data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +13 -17
  54. data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +2 -12
  55. data/src/core/ext/filters/client_channel/resolver.cc +11 -13
  56. data/src/core/ext/filters/client_channel/resolver.h +14 -25
  57. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +57 -70
  58. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +2 -12
  59. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +23 -31
  60. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +27 -45
  61. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +5 -15
  62. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +9 -11
  63. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +53 -66
  64. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +25 -33
  65. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +1 -9
  66. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +26 -35
  67. data/src/core/ext/filters/client_channel/resolver_factory.cc +2 -3
  68. data/src/core/ext/filters/client_channel/resolver_factory.h +2 -12
  69. data/src/core/ext/filters/client_channel/resolver_registry.cc +12 -15
  70. data/src/core/ext/filters/client_channel/resolver_registry.h +3 -12
  71. data/src/core/ext/filters/client_channel/retry_throttle.h +0 -8
  72. data/src/core/ext/filters/client_channel/subchannel.cc +289 -301
  73. data/src/core/ext/filters/client_channel/subchannel.h +57 -84
  74. data/src/core/ext/filters/client_channel/subchannel_index.cc +30 -33
  75. data/src/core/ext/filters/client_channel/subchannel_index.h +4 -16
  76. data/src/core/ext/filters/client_channel/uri_parser.cc +13 -17
  77. data/src/core/ext/filters/client_channel/uri_parser.h +1 -10
  78. data/src/core/ext/filters/deadline/deadline_filter.cc +49 -67
  79. data/src/core/ext/filters/deadline/deadline_filter.h +4 -14
  80. data/src/core/ext/filters/http/client/http_client_filter.cc +60 -77
  81. data/src/core/ext/filters/http/client/http_client_filter.h +0 -8
  82. data/src/core/ext/filters/http/http_filters_plugin.cc +4 -6
  83. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +63 -79
  84. data/src/core/ext/filters/http/message_compress/message_compress_filter.h +0 -8
  85. data/src/core/ext/filters/http/server/http_server_filter.cc +57 -71
  86. data/src/core/ext/filters/http/server/http_server_filter.h +0 -8
  87. data/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +19 -24
  88. data/src/core/ext/filters/load_reporting/server_load_reporting_filter.h +0 -8
  89. data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc +3 -3
  90. data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h +0 -8
  91. data/src/core/ext/filters/max_age/max_age_filter.cc +49 -62
  92. data/src/core/ext/filters/max_age/max_age_filter.h +0 -8
  93. data/src/core/ext/filters/message_size/message_size_filter.cc +23 -29
  94. data/src/core/ext/filters/message_size/message_size_filter.h +0 -8
  95. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +15 -18
  96. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +0 -8
  97. data/src/core/ext/filters/workarounds/workaround_utils.h +0 -8
  98. data/src/core/ext/transport/chttp2/alpn/alpn.h +0 -8
  99. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +33 -40
  100. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +0 -8
  101. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +15 -17
  102. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +8 -8
  103. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +23 -28
  104. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +50 -57
  105. data/src/core/ext/transport/chttp2/server/chttp2_server.h +1 -10
  106. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +3 -3
  107. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +7 -10
  108. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +5 -6
  109. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +7 -9
  110. data/src/core/ext/transport/chttp2/transport/bin_decoder.h +2 -11
  111. data/src/core/ext/transport/chttp2/transport/bin_encoder.h +1 -9
  112. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +10 -2
  113. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +516 -636
  114. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +4 -11
  115. data/src/core/ext/transport/chttp2/transport/flow_control.cc +29 -13
  116. data/src/core/ext/transport/chttp2/transport/flow_control.h +196 -53
  117. data/src/core/ext/transport/chttp2/transport/frame.h +0 -8
  118. data/src/core/ext/transport/chttp2/transport/frame_data.cc +31 -33
  119. data/src/core/ext/transport/chttp2/transport/frame_data.h +3 -12
  120. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -3
  121. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +1 -10
  122. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -6
  123. data/src/core/ext/transport/chttp2/transport/frame_ping.h +1 -9
  124. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +2 -3
  125. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +1 -10
  126. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +8 -3
  127. data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -10
  128. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +8 -8
  129. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +5 -11
  130. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +63 -81
  131. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -12
  132. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +230 -318
  133. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +6 -19
  134. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +14 -20
  135. data/src/core/ext/transport/chttp2/transport/hpack_table.h +5 -16
  136. data/src/core/ext/transport/chttp2/transport/http2_settings.h +0 -7
  137. data/src/core/ext/transport/chttp2/transport/huffsyms.h +0 -8
  138. data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +8 -11
  139. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +4 -13
  140. data/src/core/ext/transport/chttp2/transport/internal.h +51 -75
  141. data/src/core/ext/transport/chttp2/transport/parsing.cc +83 -109
  142. data/src/core/ext/transport/chttp2/transport/stream_lists.cc +2 -0
  143. data/src/core/ext/transport/chttp2/transport/stream_map.h +0 -8
  144. data/src/core/ext/transport/chttp2/transport/varint.h +0 -8
  145. data/src/core/ext/transport/chttp2/transport/writing.cc +61 -65
  146. data/src/core/ext/transport/inproc/inproc_plugin.cc +2 -4
  147. data/src/core/ext/transport/inproc/inproc_transport.cc +177 -188
  148. data/src/core/ext/transport/inproc/inproc_transport.h +0 -8
  149. data/src/core/lib/backoff/backoff.cc +39 -44
  150. data/src/core/lib/backoff/backoff.h +61 -57
  151. data/src/core/lib/channel/channel_args.cc +8 -10
  152. data/src/core/lib/channel/channel_args.h +4 -13
  153. data/src/core/lib/channel/channel_stack.cc +19 -27
  154. data/src/core/lib/channel/channel_stack.h +27 -47
  155. data/src/core/lib/channel/channel_stack_builder.cc +11 -14
  156. data/src/core/lib/channel/channel_stack_builder.h +4 -15
  157. data/src/core/lib/channel/connected_channel.cc +23 -36
  158. data/src/core/lib/channel/connected_channel.h +1 -10
  159. data/src/core/lib/channel/handshaker.cc +31 -40
  160. data/src/core/lib/channel/handshaker.h +14 -25
  161. data/src/core/lib/channel/handshaker_factory.cc +6 -6
  162. data/src/core/lib/channel/handshaker_factory.h +5 -15
  163. data/src/core/lib/channel/handshaker_registry.cc +9 -13
  164. data/src/core/lib/channel/handshaker_registry.h +2 -11
  165. data/src/core/lib/compression/algorithm_metadata.h +0 -8
  166. data/src/core/lib/compression/message_compress.cc +19 -23
  167. data/src/core/lib/compression/message_compress.h +2 -12
  168. data/src/core/lib/compression/stream_compression.cc +1 -1
  169. data/src/core/lib/compression/stream_compression.h +0 -8
  170. data/src/core/lib/compression/stream_compression_gzip.cc +12 -11
  171. data/src/core/lib/compression/stream_compression_gzip.h +0 -8
  172. data/src/core/lib/compression/stream_compression_identity.h +0 -8
  173. data/src/core/lib/debug/stats.cc +4 -4
  174. data/src/core/lib/debug/stats.h +9 -19
  175. data/src/core/lib/debug/stats_data.cc +85 -116
  176. data/src/core/lib/debug/stats_data.h +236 -312
  177. data/src/core/lib/debug/trace.cc +1 -1
  178. data/src/core/lib/debug/trace.h +0 -12
  179. data/src/core/lib/{support → gpr++}/abstract.h +8 -3
  180. data/src/core/lib/{support → gpr++}/atomic.h +5 -5
  181. data/src/core/lib/{support → gpr++}/atomic_with_atm.h +3 -3
  182. data/src/core/lib/{support → gpr++}/atomic_with_std.h +3 -3
  183. data/src/core/lib/gpr++/debug_location.h +52 -0
  184. data/src/core/lib/gpr++/inlined_vector.h +112 -0
  185. data/src/core/lib/{support → gpr++}/manual_constructor.h +2 -2
  186. data/src/core/lib/{support → gpr++}/memory.h +3 -3
  187. data/src/core/lib/gpr++/orphanable.h +171 -0
  188. data/src/core/lib/gpr++/ref_counted.h +133 -0
  189. data/src/core/lib/gpr++/ref_counted_ptr.h +99 -0
  190. data/src/core/lib/{support → gpr}/alloc.cc +0 -0
  191. data/src/core/lib/{support → gpr}/arena.cc +1 -1
  192. data/src/core/lib/{support → gpr}/arena.h +3 -11
  193. data/src/core/lib/{support → gpr}/atm.cc +0 -0
  194. data/src/core/lib/{support → gpr}/avl.cc +0 -0
  195. data/src/core/lib/{support → gpr}/cmdline.cc +1 -1
  196. data/src/core/lib/{support → gpr}/cpu_iphone.cc +0 -0
  197. data/src/core/lib/{support → gpr}/cpu_linux.cc +0 -0
  198. data/src/core/lib/{support → gpr}/cpu_posix.cc +0 -0
  199. data/src/core/lib/{support → gpr}/cpu_windows.cc +0 -0
  200. data/src/core/lib/{support → gpr}/env.h +3 -11
  201. data/src/core/lib/{support → gpr}/env_linux.cc +2 -2
  202. data/src/core/lib/{support → gpr}/env_posix.cc +4 -4
  203. data/src/core/lib/{support → gpr}/env_windows.cc +3 -3
  204. data/src/core/lib/{support → gpr}/fork.cc +3 -3
  205. data/src/core/lib/{support → gpr}/fork.h +3 -3
  206. data/src/core/lib/{support → gpr}/host_port.cc +1 -1
  207. data/src/core/lib/{support → gpr}/log.cc +3 -3
  208. data/src/core/lib/{support → gpr}/log_android.cc +3 -3
  209. data/src/core/lib/{support → gpr}/log_linux.cc +1 -1
  210. data/src/core/lib/{support → gpr}/log_posix.cc +5 -5
  211. data/src/core/lib/{support → gpr}/log_windows.cc +3 -3
  212. data/src/core/lib/{support → gpr}/mpscq.cc +1 -1
  213. data/src/core/lib/{support → gpr}/mpscq.h +3 -10
  214. data/src/core/lib/{support → gpr}/murmur_hash.cc +1 -1
  215. data/src/core/lib/{support → gpr}/murmur_hash.h +3 -11
  216. data/src/core/lib/{support → gpr}/spinlock.h +3 -3
  217. data/src/core/lib/{support → gpr}/string.cc +1 -1
  218. data/src/core/lib/{support → gpr}/string.h +3 -10
  219. data/src/core/lib/{support → gpr}/string_posix.cc +0 -0
  220. data/src/core/lib/{support → gpr}/string_util_windows.cc +2 -2
  221. data/src/core/lib/{support → gpr}/string_windows.cc +1 -1
  222. data/src/core/lib/{support → gpr}/string_windows.h +3 -11
  223. data/src/core/lib/{support → gpr}/subprocess_posix.cc +0 -0
  224. data/src/core/lib/{support → gpr}/subprocess_windows.cc +2 -2
  225. data/src/core/lib/{support → gpr}/sync.cc +0 -0
  226. data/src/core/lib/{support → gpr}/sync_posix.cc +10 -1
  227. data/src/core/lib/{support → gpr}/sync_windows.cc +0 -0
  228. data/src/core/lib/{support → gpr}/thd.cc +0 -0
  229. data/src/core/lib/{support → gpr}/thd_internal.h +3 -3
  230. data/src/core/lib/{support → gpr}/thd_posix.cc +18 -2
  231. data/src/core/lib/{support → gpr}/thd_windows.cc +2 -1
  232. data/src/core/lib/{support → gpr}/time.cc +0 -0
  233. data/src/core/lib/{support → gpr}/time_posix.cc +2 -4
  234. data/src/core/lib/{support → gpr}/time_precise.cc +1 -1
  235. data/src/core/lib/{support → gpr}/time_precise.h +3 -11
  236. data/src/core/lib/{support → gpr}/time_windows.cc +1 -3
  237. data/src/core/lib/{support → gpr}/tls_pthread.cc +0 -0
  238. data/src/core/lib/{support → gpr}/tmpfile.h +3 -11
  239. data/src/core/lib/{support → gpr}/tmpfile_msys.cc +2 -2
  240. data/src/core/lib/{support → gpr}/tmpfile_posix.cc +2 -2
  241. data/src/core/lib/{support → gpr}/tmpfile_windows.cc +2 -2
  242. data/src/core/lib/{support → gpr}/wrap_memcpy.cc +0 -0
  243. data/src/core/lib/http/format_request.cc +1 -1
  244. data/src/core/lib/http/format_request.h +0 -8
  245. data/src/core/lib/http/httpcli.cc +55 -74
  246. data/src/core/lib/http/httpcli.h +13 -22
  247. data/src/core/lib/http/httpcli_security_connector.cc +27 -33
  248. data/src/core/lib/http/parser.h +0 -8
  249. data/src/core/lib/iomgr/block_annotate.h +10 -17
  250. data/src/core/lib/iomgr/call_combiner.cc +14 -17
  251. data/src/core/lib/iomgr/call_combiner.h +16 -34
  252. data/src/core/lib/iomgr/closure.h +24 -37
  253. data/src/core/lib/iomgr/combiner.cc +62 -66
  254. data/src/core/lib/iomgr/combiner.h +6 -16
  255. data/src/core/lib/iomgr/endpoint.cc +15 -21
  256. data/src/core/lib/iomgr/endpoint.h +16 -33
  257. data/src/core/lib/iomgr/endpoint_pair.h +0 -8
  258. data/src/core/lib/iomgr/endpoint_pair_posix.cc +4 -5
  259. data/src/core/lib/iomgr/endpoint_pair_windows.cc +4 -6
  260. data/src/core/lib/iomgr/error.cc +2 -6
  261. data/src/core/lib/iomgr/error.h +4 -9
  262. data/src/core/lib/iomgr/error_internal.h +0 -8
  263. data/src/core/lib/iomgr/ev_epoll1_linux.cc +110 -117
  264. data/src/core/lib/iomgr/ev_epoll1_linux.h +0 -8
  265. data/src/core/lib/iomgr/ev_epollex_linux.cc +111 -141
  266. data/src/core/lib/iomgr/ev_epollex_linux.h +0 -8
  267. data/src/core/lib/iomgr/ev_epollsig_linux.cc +83 -109
  268. data/src/core/lib/iomgr/ev_epollsig_linux.h +2 -10
  269. data/src/core/lib/iomgr/ev_poll_posix.cc +103 -125
  270. data/src/core/lib/iomgr/ev_poll_posix.h +0 -8
  271. data/src/core/lib/iomgr/ev_posix.cc +35 -50
  272. data/src/core/lib/iomgr/ev_posix.h +27 -53
  273. data/src/core/lib/iomgr/exec_ctx.cc +46 -78
  274. data/src/core/lib/iomgr/exec_ctx.h +127 -60
  275. data/src/core/lib/iomgr/executor.cc +34 -38
  276. data/src/core/lib/iomgr/executor.h +3 -11
  277. data/src/core/lib/iomgr/fork_posix.cc +13 -12
  278. data/src/core/lib/iomgr/gethostname.h +0 -8
  279. data/src/core/lib/iomgr/gethostname_sysconf.cc +1 -1
  280. data/src/core/lib/iomgr/iocp_windows.cc +14 -16
  281. data/src/core/lib/iomgr/iocp_windows.h +1 -10
  282. data/src/core/lib/iomgr/iomgr.cc +60 -59
  283. data/src/core/lib/iomgr/iomgr.h +3 -12
  284. data/src/core/lib/iomgr/iomgr_internal.h +0 -8
  285. data/src/core/lib/iomgr/iomgr_uv.cc +2 -3
  286. data/src/core/lib/iomgr/iomgr_uv.h +0 -8
  287. data/src/core/lib/iomgr/is_epollexclusive_available.cc +1 -1
  288. data/src/core/lib/iomgr/load_file.cc +1 -1
  289. data/src/core/lib/iomgr/load_file.h +0 -8
  290. data/src/core/lib/iomgr/lockfree_event.cc +7 -8
  291. data/src/core/lib/iomgr/lockfree_event.h +3 -3
  292. data/src/core/lib/iomgr/polling_entity.cc +6 -10
  293. data/src/core/lib/iomgr/polling_entity.h +2 -11
  294. data/src/core/lib/iomgr/pollset.h +4 -13
  295. data/src/core/lib/iomgr/pollset_set.h +5 -18
  296. data/src/core/lib/iomgr/pollset_set_uv.cc +5 -10
  297. data/src/core/lib/iomgr/pollset_set_windows.cc +5 -10
  298. data/src/core/lib/iomgr/pollset_uv.cc +8 -9
  299. data/src/core/lib/iomgr/pollset_uv.h +0 -8
  300. data/src/core/lib/iomgr/pollset_windows.cc +14 -15
  301. data/src/core/lib/iomgr/pollset_windows.h +0 -8
  302. data/src/core/lib/iomgr/port.h +6 -1
  303. data/src/core/lib/iomgr/resolve_address.h +1 -10
  304. data/src/core/lib/iomgr/resolve_address_posix.cc +10 -12
  305. data/src/core/lib/iomgr/resolve_address_uv.cc +7 -8
  306. data/src/core/lib/iomgr/resolve_address_windows.cc +8 -9
  307. data/src/core/lib/iomgr/resource_quota.cc +77 -107
  308. data/src/core/lib/iomgr/resource_quota.h +8 -25
  309. data/src/core/lib/iomgr/sockaddr_utils.cc +1 -1
  310. data/src/core/lib/iomgr/sockaddr_utils.h +0 -8
  311. data/src/core/lib/iomgr/socket_factory_posix.cc +1 -1
  312. data/src/core/lib/iomgr/socket_factory_posix.h +0 -8
  313. data/src/core/lib/iomgr/socket_mutator.cc +1 -1
  314. data/src/core/lib/iomgr/socket_mutator.h +1 -9
  315. data/src/core/lib/iomgr/socket_utils.h +0 -8
  316. data/src/core/lib/iomgr/socket_utils_common_posix.cc +1 -1
  317. data/src/core/lib/iomgr/socket_utils_posix.h +0 -8
  318. data/src/core/lib/iomgr/socket_windows.cc +8 -11
  319. data/src/core/lib/iomgr/socket_windows.h +3 -14
  320. data/src/core/lib/iomgr/tcp_client.h +1 -10
  321. data/src/core/lib/iomgr/tcp_client_posix.cc +94 -78
  322. data/src/core/lib/iomgr/tcp_client_posix.h +36 -8
  323. data/src/core/lib/iomgr/tcp_client_uv.cc +16 -23
  324. data/src/core/lib/iomgr/tcp_client_windows.cc +22 -25
  325. data/src/core/lib/iomgr/tcp_posix.cc +131 -153
  326. data/src/core/lib/iomgr/tcp_posix.h +3 -12
  327. data/src/core/lib/iomgr/tcp_server.h +6 -17
  328. data/src/core/lib/iomgr/tcp_server_posix.cc +31 -35
  329. data/src/core/lib/iomgr/tcp_server_utils_posix.h +0 -8
  330. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -1
  331. data/src/core/lib/iomgr/tcp_server_uv.cc +23 -34
  332. data/src/core/lib/iomgr/tcp_server_windows.cc +24 -34
  333. data/src/core/lib/iomgr/tcp_uv.cc +42 -56
  334. data/src/core/lib/iomgr/tcp_uv.h +0 -8
  335. data/src/core/lib/iomgr/tcp_windows.cc +43 -50
  336. data/src/core/lib/iomgr/tcp_windows.h +1 -9
  337. data/src/core/lib/iomgr/time_averaged_stats.h +0 -8
  338. data/src/core/lib/iomgr/timer.h +6 -15
  339. data/src/core/lib/iomgr/timer_generic.cc +22 -27
  340. data/src/core/lib/iomgr/timer_heap.h +0 -8
  341. data/src/core/lib/iomgr/timer_manager.cc +17 -19
  342. data/src/core/lib/iomgr/timer_manager.h +0 -8
  343. data/src/core/lib/iomgr/timer_uv.cc +12 -14
  344. data/src/core/lib/iomgr/udp_server.cc +148 -54
  345. data/src/core/lib/iomgr/udp_server.h +16 -21
  346. data/src/core/lib/iomgr/unix_sockets_posix.h +0 -8
  347. data/src/core/lib/iomgr/wakeup_fd_cv.cc +4 -4
  348. data/src/core/lib/iomgr/wakeup_fd_cv.h +12 -20
  349. data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +1 -1
  350. data/src/core/lib/iomgr/wakeup_fd_pipe.h +0 -8
  351. data/src/core/lib/iomgr/wakeup_fd_posix.h +0 -8
  352. data/src/core/lib/json/json.h +0 -8
  353. data/src/core/lib/json/json_reader.h +0 -8
  354. data/src/core/lib/json/json_writer.h +0 -8
  355. data/src/core/lib/profiling/basic_timers.cc +3 -2
  356. data/src/core/lib/profiling/timers.h +0 -8
  357. data/src/core/lib/security/context/security_context.cc +9 -10
  358. data/src/core/lib/security/context/security_context.h +0 -8
  359. data/src/core/lib/security/credentials/composite/composite_credentials.cc +23 -28
  360. data/src/core/lib/security/credentials/composite/composite_credentials.h +0 -8
  361. data/src/core/lib/security/credentials/credentials.cc +33 -42
  362. data/src/core/lib/security/credentials/credentials.h +24 -43
  363. data/src/core/lib/security/credentials/credentials_metadata.cc +2 -2
  364. data/src/core/lib/security/credentials/fake/fake_credentials.cc +16 -22
  365. data/src/core/lib/security/credentials/fake/fake_credentials.h +0 -8
  366. data/src/core/lib/security/credentials/google_default/credentials_generic.cc +3 -3
  367. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +28 -34
  368. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +0 -8
  369. data/src/core/lib/security/credentials/iam/iam_credentials.cc +9 -13
  370. data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
  371. data/src/core/lib/security/credentials/jwt/json_token.h +0 -8
  372. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +14 -20
  373. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +1 -10
  374. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +56 -72
  375. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +5 -17
  376. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +47 -55
  377. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +3 -12
  378. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +23 -28
  379. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +8 -13
  380. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +0 -8
  381. data/src/core/lib/security/transport/auth_filters.h +0 -8
  382. data/src/core/lib/security/transport/client_auth_filter.cc +45 -54
  383. data/src/core/lib/security/transport/lb_targets_info.cc +2 -2
  384. data/src/core/lib/security/transport/lb_targets_info.h +0 -8
  385. data/src/core/lib/security/transport/secure_endpoint.cc +54 -68
  386. data/src/core/lib/security/transport/secure_endpoint.h +0 -8
  387. data/src/core/lib/security/transport/security_connector.cc +62 -86
  388. data/src/core/lib/security/transport/security_connector.h +22 -39
  389. data/src/core/lib/security/transport/security_handshaker.cc +83 -106
  390. data/src/core/lib/security/transport/security_handshaker.h +1 -10
  391. data/src/core/lib/security/transport/server_auth_filter.cc +31 -38
  392. data/src/core/lib/security/transport/tsi_error.h +0 -8
  393. data/src/core/lib/security/util/json_util.h +0 -8
  394. data/src/core/lib/slice/b64.cc +5 -6
  395. data/src/core/lib/slice/b64.h +3 -12
  396. data/src/core/lib/slice/percent_encoding.h +0 -8
  397. data/src/core/lib/slice/slice.cc +8 -9
  398. data/src/core/lib/slice/slice_buffer.cc +11 -16
  399. data/src/core/lib/slice/slice_hash_table.cc +5 -7
  400. data/src/core/lib/slice/slice_hash_table.h +2 -12
  401. data/src/core/lib/slice/slice_intern.cc +4 -5
  402. data/src/core/lib/slice/slice_internal.h +4 -15
  403. data/src/core/lib/slice/slice_string_helpers.cc +1 -1
  404. data/src/core/lib/slice/slice_string_helpers.h +1 -9
  405. data/src/core/lib/surface/alarm.cc +11 -14
  406. data/src/core/lib/surface/alarm_internal.h +0 -8
  407. data/src/core/lib/surface/byte_buffer.cc +2 -3
  408. data/src/core/lib/surface/byte_buffer_reader.cc +7 -9
  409. data/src/core/lib/surface/call.cc +198 -241
  410. data/src/core/lib/surface/call.h +9 -23
  411. data/src/core/lib/surface/call_details.cc +3 -4
  412. data/src/core/lib/surface/call_log_batch.cc +1 -1
  413. data/src/core/lib/surface/call_test_only.h +0 -8
  414. data/src/core/lib/surface/channel.cc +53 -64
  415. data/src/core/lib/surface/channel.h +12 -23
  416. data/src/core/lib/surface/channel_init.cc +2 -3
  417. data/src/core/lib/surface/channel_init.h +2 -12
  418. data/src/core/lib/surface/channel_ping.cc +7 -9
  419. data/src/core/lib/surface/channel_stack_type.h +0 -8
  420. data/src/core/lib/surface/completion_queue.cc +158 -176
  421. data/src/core/lib/surface/completion_queue.h +9 -20
  422. data/src/core/lib/surface/completion_queue_factory.h +0 -8
  423. data/src/core/lib/surface/event_string.cc +1 -1
  424. data/src/core/lib/surface/event_string.h +0 -8
  425. data/src/core/lib/surface/init.cc +27 -25
  426. data/src/core/lib/surface/init.h +0 -8
  427. data/src/core/lib/surface/init_secure.cc +2 -2
  428. data/src/core/lib/surface/lame_client.cc +30 -33
  429. data/src/core/lib/surface/lame_client.h +0 -8
  430. data/src/core/lib/surface/server.cc +151 -203
  431. data/src/core/lib/surface/server.h +7 -16
  432. data/src/core/lib/surface/validate_metadata.h +0 -8
  433. data/src/core/lib/surface/version.cc +2 -2
  434. data/src/core/lib/transport/bdp_estimator.cc +2 -2
  435. data/src/core/lib/transport/bdp_estimator.h +1 -1
  436. data/src/core/lib/transport/byte_stream.cc +24 -38
  437. data/src/core/lib/transport/byte_stream.h +10 -25
  438. data/src/core/lib/transport/connectivity_state.cc +9 -13
  439. data/src/core/lib/transport/connectivity_state.h +4 -14
  440. data/src/core/lib/transport/error_utils.cc +6 -6
  441. data/src/core/lib/transport/error_utils.h +2 -11
  442. data/src/core/lib/transport/metadata.cc +21 -23
  443. data/src/core/lib/transport/metadata.h +8 -20
  444. data/src/core/lib/transport/metadata_batch.cc +34 -45
  445. data/src/core/lib/transport/metadata_batch.h +18 -32
  446. data/src/core/lib/transport/service_config.cc +11 -15
  447. data/src/core/lib/transport/service_config.h +3 -13
  448. data/src/core/lib/transport/static_metadata.cc +1 -1
  449. data/src/core/lib/transport/static_metadata.h +1 -7
  450. data/src/core/lib/transport/status_conversion.cc +2 -3
  451. data/src/core/lib/transport/status_conversion.h +1 -10
  452. data/src/core/lib/transport/timeout_encoding.cc +1 -1
  453. data/src/core/lib/transport/timeout_encoding.h +1 -9
  454. data/src/core/lib/transport/transport.cc +36 -50
  455. data/src/core/lib/transport/transport.h +28 -30
  456. data/src/core/lib/transport/transport_impl.h +12 -23
  457. data/src/core/lib/transport/transport_op_string.cc +2 -2
  458. data/src/core/plugin_registry/grpc_plugin_registry.cc +34 -34
  459. data/src/core/tsi/fake_transport_security.cc +7 -10
  460. data/src/core/tsi/fake_transport_security.h +0 -8
  461. data/src/core/tsi/gts_transport_security.cc +2 -2
  462. data/src/core/tsi/gts_transport_security.h +0 -8
  463. data/src/core/tsi/ssl_transport_security.cc +3 -0
  464. data/src/core/tsi/ssl_transport_security.h +0 -8
  465. data/src/core/tsi/ssl_types.h +0 -8
  466. data/src/core/tsi/transport_security.h +1 -9
  467. data/src/core/tsi/transport_security_adapter.h +0 -8
  468. data/src/core/tsi/transport_security_grpc.cc +11 -18
  469. data/src/core/tsi/transport_security_grpc.h +9 -21
  470. data/src/core/tsi/transport_security_interface.h +0 -8
  471. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +0 -30
  472. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +2 -48
  473. data/src/ruby/lib/grpc/version.rb +1 -1
  474. data/src/ruby/spec/channel_connection_spec.rb +2 -1
  475. data/src/ruby/spec/client_auth_spec.rb +1 -1
  476. data/src/ruby/spec/client_server_spec.rb +2 -2
  477. data/src/ruby/spec/generic/active_call_spec.rb +1 -1
  478. data/src/ruby/spec/generic/client_stub_spec.rb +4 -4
  479. data/src/ruby/spec/generic/interceptor_registry_spec.rb +1 -1
  480. data/src/ruby/spec/generic/rpc_server_spec.rb +12 -12
  481. data/src/ruby/spec/google_rpc_status_utils_spec.rb +3 -2
  482. data/src/ruby/spec/pb/health/checker_spec.rb +1 -1
  483. data/src/ruby/spec/server_spec.rb +9 -9
  484. data/src/ruby/spec/support/helpers.rb +35 -1
  485. metadata +68 -66
  486. data/include/grpc/impl/codegen/exec_ctx_fwd.h +0 -26
  487. data/include/grpc/support/histogram.h +0 -64
  488. data/src/core/lib/support/histogram.cc +0 -227
@@ -23,16 +23,44 @@
23
23
  #include "src/core/lib/iomgr/ev_posix.h"
24
24
  #include "src/core/lib/iomgr/tcp_client.h"
25
25
 
26
- #ifdef __cplusplus
27
- extern "C" {
28
- #endif
26
+ /* Create an endpoint from a connected grpc_fd.
29
27
 
28
+ fd: a connected FD. Ownership is taken.
29
+ channel_args: may contain custom settings for the endpoint
30
+ addr_str: destination address in printable format
31
+ Returns: a new endpoint
32
+ */
30
33
  grpc_endpoint* grpc_tcp_client_create_from_fd(
31
- grpc_exec_ctx* exec_ctx, grpc_fd* fd, const grpc_channel_args* channel_args,
32
- const char* addr_str);
34
+ grpc_fd* fd, const grpc_channel_args* channel_args, const char* addr_str);
33
35
 
34
- #ifdef __cplusplus
35
- }
36
- #endif
36
+ /* Return a configured, unbound, unconnected TCP client grpc_fd.
37
+
38
+ channel_args: may contain custom settings for the fd
39
+ addr: the destination address
40
+ mapped_addr: out parameter. addr mapped to an address appropriate to the
41
+ type of socket FD created. For example, if addr is IPv4 and dual stack
42
+ sockets are available, mapped_addr will be an IPv4-mapped IPv6 address
43
+ fdobj: out parameter. The new FD
44
+ Returns: error, if any. Out parameters are not set on error
45
+ */
46
+ grpc_error* grpc_tcp_client_prepare_fd(const grpc_channel_args* channel_args,
47
+ const grpc_resolved_address* addr,
48
+ grpc_resolved_address* mapped_addr,
49
+ grpc_fd** fdobj);
50
+
51
+ /* Connect a configured TCP client grpc_fd.
52
+
53
+ interested_parties: a set of pollsets that would be interested in this
54
+ connection being established (in order to continue their work
55
+ closure: called when complete. On success, *ep will be set.
56
+ fdobj: an FD returned from grpc_tcp_client_prepare_fd(). Ownership is taken
57
+ channel_args: may contain custom settings for the endpoint
58
+ deadline: connection deadline
59
+ ep: out parameter. Set before closure is called if successful
60
+ */
61
+ void grpc_tcp_client_create_from_prepared_fd(
62
+ grpc_pollset_set* interested_parties, grpc_closure* closure, grpc_fd* fdobj,
63
+ const grpc_channel_args* channel_args, const grpc_resolved_address* addr,
64
+ grpc_millis deadline, grpc_endpoint** ep);
37
65
 
38
66
  #endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H */
@@ -46,17 +46,15 @@ typedef struct grpc_uv_tcp_connect {
46
46
  grpc_resource_quota* resource_quota;
47
47
  } grpc_uv_tcp_connect;
48
48
 
49
- static void uv_tcp_connect_cleanup(grpc_exec_ctx* exec_ctx,
50
- grpc_uv_tcp_connect* connect) {
51
- grpc_resource_quota_unref_internal(exec_ctx, connect->resource_quota);
49
+ static void uv_tcp_connect_cleanup(grpc_uv_tcp_connect* connect) {
50
+ grpc_resource_quota_unref_internal(connect->resource_quota);
52
51
  gpr_free(connect->addr_name);
53
52
  gpr_free(connect);
54
53
  }
55
54
 
56
55
  static void tcp_close_callback(uv_handle_t* handle) { gpr_free(handle); }
57
56
 
58
- static void uv_tc_on_alarm(grpc_exec_ctx* exec_ctx, void* acp,
59
- grpc_error* error) {
57
+ static void uv_tc_on_alarm(void* acp, grpc_error* error) {
60
58
  int done;
61
59
  grpc_uv_tcp_connect* connect = (grpc_uv_tcp_connect*)acp;
62
60
  if (grpc_tcp_trace.enabled()) {
@@ -72,17 +70,17 @@ static void uv_tc_on_alarm(grpc_exec_ctx* exec_ctx, void* acp,
72
70
  }
73
71
  done = (--connect->refs == 0);
74
72
  if (done) {
75
- uv_tcp_connect_cleanup(exec_ctx, connect);
73
+ uv_tcp_connect_cleanup(connect);
76
74
  }
77
75
  }
78
76
 
79
77
  static void uv_tc_on_connect(uv_connect_t* req, int status) {
80
78
  grpc_uv_tcp_connect* connect = (grpc_uv_tcp_connect*)req->data;
81
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
79
+ grpc_core::ExecCtx exec_ctx;
82
80
  grpc_error* error = GRPC_ERROR_NONE;
83
81
  int done;
84
82
  grpc_closure* closure = connect->closure;
85
- grpc_timer_cancel(&exec_ctx, &connect->alarm);
83
+ grpc_timer_cancel(&connect->alarm);
86
84
  if (status == 0) {
87
85
  *connect->endpoint = grpc_tcp_create(
88
86
  connect->tcp_handle, connect->resource_quota, connect->addr_name);
@@ -107,15 +105,13 @@ static void uv_tc_on_connect(uv_connect_t* req, int status) {
107
105
  }
108
106
  done = (--connect->refs == 0);
109
107
  if (done) {
110
- grpc_exec_ctx_flush(&exec_ctx);
111
- uv_tcp_connect_cleanup(&exec_ctx, connect);
108
+ grpc_core::ExecCtx::Get()->Flush();
109
+ uv_tcp_connect_cleanup(connect);
112
110
  }
113
- GRPC_CLOSURE_SCHED(&exec_ctx, closure, error);
114
- grpc_exec_ctx_finish(&exec_ctx);
111
+ GRPC_CLOSURE_SCHED(closure, error);
115
112
  }
116
113
 
117
- static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
118
- grpc_closure* closure, grpc_endpoint** ep,
114
+ static void tcp_client_connect_impl(grpc_closure* closure, grpc_endpoint** ep,
119
115
  grpc_pollset_set* interested_parties,
120
116
  const grpc_channel_args* channel_args,
121
117
  const grpc_resolved_address* resolved_addr,
@@ -130,7 +126,7 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
130
126
  if (channel_args != NULL) {
131
127
  for (size_t i = 0; i < channel_args->num_args; i++) {
132
128
  if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
133
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
129
+ grpc_resource_quota_unref_internal(resource_quota);
134
130
  resource_quota = grpc_resource_quota_ref_internal(
135
131
  (grpc_resource_quota*)channel_args->args[i].value.pointer.p);
136
132
  }
@@ -157,26 +153,23 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
157
153
  (const struct sockaddr*)resolved_addr->addr, uv_tc_on_connect);
158
154
  GRPC_CLOSURE_INIT(&connect->on_alarm, uv_tc_on_alarm, connect,
159
155
  grpc_schedule_on_exec_ctx);
160
- grpc_timer_init(exec_ctx, &connect->alarm, deadline, &connect->on_alarm);
156
+ grpc_timer_init(&connect->alarm, deadline, &connect->on_alarm);
161
157
  }
162
158
 
163
159
  // overridden by api_fuzzer.c
164
- extern "C" {
165
160
  void (*grpc_tcp_client_connect_impl)(
166
- grpc_exec_ctx* exec_ctx, grpc_closure* closure, grpc_endpoint** ep,
161
+ grpc_closure* closure, grpc_endpoint** ep,
167
162
  grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args,
168
163
  const grpc_resolved_address* addr,
169
164
  grpc_millis deadline) = tcp_client_connect_impl;
170
- }
171
165
 
172
- void grpc_tcp_client_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
173
- grpc_endpoint** ep,
166
+ void grpc_tcp_client_connect(grpc_closure* closure, grpc_endpoint** ep,
174
167
  grpc_pollset_set* interested_parties,
175
168
  const grpc_channel_args* channel_args,
176
169
  const grpc_resolved_address* addr,
177
170
  grpc_millis deadline) {
178
- grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties,
179
- channel_args, addr, deadline);
171
+ grpc_tcp_client_connect_impl(closure, ep, interested_parties, channel_args,
172
+ addr, deadline);
180
173
  }
181
174
 
182
175
  #endif /* GRPC_UV */
@@ -52,13 +52,12 @@ typedef struct {
52
52
  grpc_channel_args* channel_args;
53
53
  } async_connect;
54
54
 
55
- static void async_connect_unlock_and_cleanup(grpc_exec_ctx* exec_ctx,
56
- async_connect* ac,
55
+ static void async_connect_unlock_and_cleanup(async_connect* ac,
57
56
  grpc_winsocket* socket) {
58
57
  int done = (--ac->refs == 0);
59
58
  gpr_mu_unlock(&ac->mu);
60
59
  if (done) {
61
- grpc_channel_args_destroy(exec_ctx, ac->channel_args);
60
+ grpc_channel_args_destroy(ac->channel_args);
62
61
  gpr_mu_destroy(&ac->mu);
63
62
  gpr_free(ac->addr_name);
64
63
  gpr_free(ac);
@@ -66,7 +65,7 @@ static void async_connect_unlock_and_cleanup(grpc_exec_ctx* exec_ctx,
66
65
  if (socket != NULL) grpc_winsocket_destroy(socket);
67
66
  }
68
67
 
69
- static void on_alarm(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
68
+ static void on_alarm(void* acp, grpc_error* error) {
70
69
  async_connect* ac = (async_connect*)acp;
71
70
  gpr_mu_lock(&ac->mu);
72
71
  grpc_winsocket* socket = ac->socket;
@@ -74,10 +73,10 @@ static void on_alarm(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
74
73
  if (socket != NULL) {
75
74
  grpc_winsocket_shutdown(socket);
76
75
  }
77
- async_connect_unlock_and_cleanup(exec_ctx, ac, socket);
76
+ async_connect_unlock_and_cleanup(ac, socket);
78
77
  }
79
78
 
80
- static void on_connect(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
79
+ static void on_connect(void* acp, grpc_error* error) {
81
80
  async_connect* ac = (async_connect*)acp;
82
81
  grpc_endpoint** ep = ac->endpoint;
83
82
  GPR_ASSERT(*ep == NULL);
@@ -90,7 +89,7 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
90
89
  ac->socket = NULL;
91
90
  gpr_mu_unlock(&ac->mu);
92
91
 
93
- grpc_timer_cancel(exec_ctx, &ac->alarm);
92
+ grpc_timer_cancel(&ac->alarm);
94
93
 
95
94
  gpr_mu_lock(&ac->mu);
96
95
 
@@ -106,8 +105,7 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
106
105
  error = GRPC_WSA_ERROR(WSAGetLastError(), "ConnectEx");
107
106
  closesocket(socket->socket);
108
107
  } else {
109
- *ep =
110
- grpc_tcp_create(exec_ctx, socket, ac->channel_args, ac->addr_name);
108
+ *ep = grpc_tcp_create(socket, ac->channel_args, ac->addr_name);
111
109
  socket = NULL;
112
110
  }
113
111
  } else {
@@ -115,18 +113,20 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
115
113
  }
116
114
  }
117
115
 
118
- async_connect_unlock_and_cleanup(exec_ctx, ac, socket);
116
+ async_connect_unlock_and_cleanup(ac, socket);
119
117
  /* If the connection was aborted, the callback was already called when
120
118
  the deadline was met. */
121
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
119
+ GRPC_CLOSURE_SCHED(on_done, error);
122
120
  }
123
121
 
124
122
  /* Tries to issue one async connection, then schedules both an IOCP
125
123
  notification request for the connection, and one timeout alert. */
126
- static void tcp_client_connect_impl(
127
- grpc_exec_ctx* exec_ctx, grpc_closure* on_done, grpc_endpoint** endpoint,
128
- grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args,
129
- const grpc_resolved_address* addr, grpc_millis deadline) {
124
+ static void tcp_client_connect_impl(grpc_closure* on_done,
125
+ grpc_endpoint** endpoint,
126
+ grpc_pollset_set* interested_parties,
127
+ const grpc_channel_args* channel_args,
128
+ const grpc_resolved_address* addr,
129
+ grpc_millis deadline) {
130
130
  SOCKET sock = INVALID_SOCKET;
131
131
  BOOL success;
132
132
  int status;
@@ -206,8 +206,8 @@ static void tcp_client_connect_impl(
206
206
  GRPC_CLOSURE_INIT(&ac->on_connect, on_connect, ac, grpc_schedule_on_exec_ctx);
207
207
 
208
208
  GRPC_CLOSURE_INIT(&ac->on_alarm, on_alarm, ac, grpc_schedule_on_exec_ctx);
209
- grpc_timer_init(exec_ctx, &ac->alarm, deadline, &ac->on_alarm);
210
- grpc_socket_notify_on_write(exec_ctx, socket, &ac->on_connect);
209
+ grpc_timer_init(&ac->alarm, deadline, &ac->on_alarm);
210
+ grpc_socket_notify_on_write(socket, &ac->on_connect);
211
211
  return;
212
212
 
213
213
  failure:
@@ -223,26 +223,23 @@ failure:
223
223
  } else if (sock != INVALID_SOCKET) {
224
224
  closesocket(sock);
225
225
  }
226
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, final_error);
226
+ GRPC_CLOSURE_SCHED(on_done, final_error);
227
227
  }
228
228
 
229
229
  // overridden by api_fuzzer.c
230
- extern "C" {
231
230
  void (*grpc_tcp_client_connect_impl)(
232
- grpc_exec_ctx* exec_ctx, grpc_closure* closure, grpc_endpoint** ep,
231
+ grpc_closure* closure, grpc_endpoint** ep,
233
232
  grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args,
234
233
  const grpc_resolved_address* addr,
235
234
  grpc_millis deadline) = tcp_client_connect_impl;
236
- }
237
235
 
238
- void grpc_tcp_client_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
239
- grpc_endpoint** ep,
236
+ void grpc_tcp_client_connect(grpc_closure* closure, grpc_endpoint** ep,
240
237
  grpc_pollset_set* interested_parties,
241
238
  const grpc_channel_args* channel_args,
242
239
  const grpc_resolved_address* addr,
243
240
  grpc_millis deadline) {
244
- grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties,
245
- channel_args, addr, deadline);
241
+ grpc_tcp_client_connect_impl(closure, ep, interested_parties, channel_args,
242
+ addr, deadline);
246
243
  }
247
244
 
248
245
  #endif /* GRPC_WINSOCK_SOCKET */
@@ -42,12 +42,12 @@
42
42
  #include "src/core/lib/channel/channel_args.h"
43
43
  #include "src/core/lib/debug/stats.h"
44
44
  #include "src/core/lib/debug/trace.h"
45
+ #include "src/core/lib/gpr/string.h"
45
46
  #include "src/core/lib/iomgr/ev_posix.h"
46
47
  #include "src/core/lib/iomgr/executor.h"
47
48
  #include "src/core/lib/profiling/timers.h"
48
49
  #include "src/core/lib/slice/slice_internal.h"
49
50
  #include "src/core/lib/slice/slice_string_helpers.h"
50
- #include "src/core/lib/support/string.h"
51
51
 
52
52
  #ifdef GRPC_HAVE_MSG_NOSIGNAL
53
53
  #define SENDMSG_FLAGS MSG_NOSIGNAL
@@ -63,7 +63,8 @@ typedef size_t msg_iovlen_type;
63
63
 
64
64
  grpc_core::TraceFlag grpc_tcp_trace(false, "tcp");
65
65
 
66
- typedef struct {
66
+ namespace {
67
+ struct grpc_tcp {
67
68
  grpc_endpoint base;
68
69
  grpc_fd* em_fd;
69
70
  int fd;
@@ -96,48 +97,44 @@ typedef struct {
96
97
 
97
98
  grpc_resource_user* resource_user;
98
99
  grpc_resource_user_slice_allocator slice_allocator;
99
- } grpc_tcp;
100
+ };
100
101
 
101
- typedef struct backup_poller {
102
+ struct backup_poller {
102
103
  gpr_mu* pollset_mu;
103
104
  grpc_closure run_poller;
104
- } backup_poller;
105
+ };
106
+ } // namespace
105
107
 
106
108
  #define BACKUP_POLLER_POLLSET(b) ((grpc_pollset*)((b) + 1))
107
109
 
108
110
  static gpr_atm g_uncovered_notifications_pending;
109
111
  static gpr_atm g_backup_poller; /* backup_poller* */
110
112
 
111
- static void tcp_handle_read(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
112
- grpc_error* error);
113
- static void tcp_handle_write(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
114
- grpc_error* error);
115
- static void tcp_drop_uncovered_then_handle_write(grpc_exec_ctx* exec_ctx,
116
- void* arg /* grpc_tcp */,
113
+ static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error);
114
+ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error);
115
+ static void tcp_drop_uncovered_then_handle_write(void* arg /* grpc_tcp */,
117
116
  grpc_error* error);
118
117
 
119
- static void done_poller(grpc_exec_ctx* exec_ctx, void* bp,
120
- grpc_error* error_ignored) {
118
+ static void done_poller(void* bp, grpc_error* error_ignored) {
121
119
  backup_poller* p = (backup_poller*)bp;
122
120
  if (grpc_tcp_trace.enabled()) {
123
121
  gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p destroy", p);
124
122
  }
125
- grpc_pollset_destroy(exec_ctx, BACKUP_POLLER_POLLSET(p));
123
+ grpc_pollset_destroy(BACKUP_POLLER_POLLSET(p));
126
124
  gpr_free(p);
127
125
  }
128
126
 
129
- static void run_poller(grpc_exec_ctx* exec_ctx, void* bp,
130
- grpc_error* error_ignored) {
127
+ static void run_poller(void* bp, grpc_error* error_ignored) {
131
128
  backup_poller* p = (backup_poller*)bp;
132
129
  if (grpc_tcp_trace.enabled()) {
133
130
  gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p run", p);
134
131
  }
135
132
  gpr_mu_lock(p->pollset_mu);
136
- grpc_millis deadline = grpc_exec_ctx_now(exec_ctx) + 13 * GPR_MS_PER_SEC;
137
- GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS(exec_ctx);
133
+ grpc_millis deadline = grpc_core::ExecCtx::Get()->Now() + 13 * GPR_MS_PER_SEC;
134
+ GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS();
138
135
  GRPC_LOG_IF_ERROR(
139
136
  "backup_poller:pollset_work",
140
- grpc_pollset_work(exec_ctx, BACKUP_POLLER_POLLSET(p), nullptr, deadline));
137
+ grpc_pollset_work(BACKUP_POLLER_POLLSET(p), nullptr, deadline));
141
138
  gpr_mu_unlock(p->pollset_mu);
142
139
  /* last "uncovered" notification is the ref that keeps us polling, if we get
143
140
  * there try a cas to release it */
@@ -152,18 +149,18 @@ static void run_poller(grpc_exec_ctx* exec_ctx, void* bp,
152
149
  if (grpc_tcp_trace.enabled()) {
153
150
  gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p shutdown", p);
154
151
  }
155
- grpc_pollset_shutdown(exec_ctx, BACKUP_POLLER_POLLSET(p),
152
+ grpc_pollset_shutdown(BACKUP_POLLER_POLLSET(p),
156
153
  GRPC_CLOSURE_INIT(&p->run_poller, done_poller, p,
157
154
  grpc_schedule_on_exec_ctx));
158
155
  } else {
159
156
  if (grpc_tcp_trace.enabled()) {
160
157
  gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p reschedule", p);
161
158
  }
162
- GRPC_CLOSURE_SCHED(exec_ctx, &p->run_poller, GRPC_ERROR_NONE);
159
+ GRPC_CLOSURE_SCHED(&p->run_poller, GRPC_ERROR_NONE);
163
160
  }
164
161
  }
165
162
 
166
- static void drop_uncovered(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
163
+ static void drop_uncovered(grpc_tcp* tcp) {
167
164
  backup_poller* p = (backup_poller*)gpr_atm_acq_load(&g_backup_poller);
168
165
  gpr_atm old_count =
169
166
  gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, -1);
@@ -174,7 +171,7 @@ static void drop_uncovered(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
174
171
  GPR_ASSERT(old_count != 1);
175
172
  }
176
173
 
177
- static void cover_self(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
174
+ static void cover_self(grpc_tcp* tcp) {
178
175
  backup_poller* p;
179
176
  gpr_atm old_count =
180
177
  gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, 2);
@@ -183,7 +180,7 @@ static void cover_self(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
183
180
  2 + (int)old_count);
184
181
  }
185
182
  if (old_count == 0) {
186
- GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED(exec_ctx);
183
+ GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED();
187
184
  p = (backup_poller*)gpr_zalloc(sizeof(*p) + grpc_pollset_size());
188
185
  if (grpc_tcp_trace.enabled()) {
189
186
  gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p create", p);
@@ -191,7 +188,6 @@ static void cover_self(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
191
188
  grpc_pollset_init(BACKUP_POLLER_POLLSET(p), &p->pollset_mu);
192
189
  gpr_atm_rel_store(&g_backup_poller, (gpr_atm)p);
193
190
  GRPC_CLOSURE_SCHED(
194
- exec_ctx,
195
191
  GRPC_CLOSURE_INIT(&p->run_poller, run_poller, p,
196
192
  grpc_executor_scheduler(GRPC_EXECUTOR_LONG)),
197
193
  GRPC_ERROR_NONE);
@@ -204,39 +200,38 @@ static void cover_self(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
204
200
  if (grpc_tcp_trace.enabled()) {
205
201
  gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p add %p", p, tcp);
206
202
  }
207
- grpc_pollset_add_fd(exec_ctx, BACKUP_POLLER_POLLSET(p), tcp->em_fd);
203
+ grpc_pollset_add_fd(BACKUP_POLLER_POLLSET(p), tcp->em_fd);
208
204
  if (old_count != 0) {
209
- drop_uncovered(exec_ctx, tcp);
205
+ drop_uncovered(tcp);
210
206
  }
211
207
  }
212
208
 
213
- static void notify_on_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
209
+ static void notify_on_read(grpc_tcp* tcp) {
214
210
  if (grpc_tcp_trace.enabled()) {
215
211
  gpr_log(GPR_DEBUG, "TCP:%p notify_on_read", tcp);
216
212
  }
217
213
  GRPC_CLOSURE_INIT(&tcp->read_done_closure, tcp_handle_read, tcp,
218
214
  grpc_schedule_on_exec_ctx);
219
- grpc_fd_notify_on_read(exec_ctx, tcp->em_fd, &tcp->read_done_closure);
215
+ grpc_fd_notify_on_read(tcp->em_fd, &tcp->read_done_closure);
220
216
  }
221
217
 
222
- static void notify_on_write(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
218
+ static void notify_on_write(grpc_tcp* tcp) {
223
219
  if (grpc_tcp_trace.enabled()) {
224
220
  gpr_log(GPR_DEBUG, "TCP:%p notify_on_write", tcp);
225
221
  }
226
- cover_self(exec_ctx, tcp);
222
+ cover_self(tcp);
227
223
  GRPC_CLOSURE_INIT(&tcp->write_done_closure,
228
224
  tcp_drop_uncovered_then_handle_write, tcp,
229
225
  grpc_schedule_on_exec_ctx);
230
- grpc_fd_notify_on_write(exec_ctx, tcp->em_fd, &tcp->write_done_closure);
226
+ grpc_fd_notify_on_write(tcp->em_fd, &tcp->write_done_closure);
231
227
  }
232
228
 
233
- static void tcp_drop_uncovered_then_handle_write(grpc_exec_ctx* exec_ctx,
234
- void* arg, grpc_error* error) {
229
+ static void tcp_drop_uncovered_then_handle_write(void* arg, grpc_error* error) {
235
230
  if (grpc_tcp_trace.enabled()) {
236
231
  gpr_log(GPR_DEBUG, "TCP:%p got_write: %s", arg, grpc_error_string(error));
237
232
  }
238
- drop_uncovered(exec_ctx, (grpc_tcp*)arg);
239
- tcp_handle_write(exec_ctx, arg, error);
233
+ drop_uncovered((grpc_tcp*)arg);
234
+ tcp_handle_write(arg, error);
240
235
  }
241
236
 
242
237
  static void add_to_estimate(grpc_tcp* tcp, size_t bytes) {
@@ -277,38 +272,38 @@ static size_t get_target_read_size(grpc_tcp* tcp) {
277
272
 
278
273
  static grpc_error* tcp_annotate_error(grpc_error* src_error, grpc_tcp* tcp) {
279
274
  return grpc_error_set_str(
280
- grpc_error_set_int(src_error, GRPC_ERROR_INT_FD, tcp->fd),
275
+ grpc_error_set_int(
276
+ grpc_error_set_int(src_error, GRPC_ERROR_INT_FD, tcp->fd),
277
+ /* All tcp errors are marked with UNAVAILABLE so that application may
278
+ * choose to retry. */
279
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE),
281
280
  GRPC_ERROR_STR_TARGET_ADDRESS,
282
281
  grpc_slice_from_copied_string(tcp->peer_string));
283
282
  }
284
283
 
285
- static void tcp_handle_read(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
286
- grpc_error* error);
287
- static void tcp_handle_write(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
288
- grpc_error* error);
284
+ static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error);
285
+ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error);
289
286
 
290
- static void tcp_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
291
- grpc_error* why) {
287
+ static void tcp_shutdown(grpc_endpoint* ep, grpc_error* why) {
292
288
  grpc_tcp* tcp = (grpc_tcp*)ep;
293
- grpc_fd_shutdown(exec_ctx, tcp->em_fd, why);
294
- grpc_resource_user_shutdown(exec_ctx, tcp->resource_user);
289
+ grpc_fd_shutdown(tcp->em_fd, why);
290
+ grpc_resource_user_shutdown(tcp->resource_user);
295
291
  }
296
292
 
297
- static void tcp_free(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
298
- grpc_fd_orphan(exec_ctx, tcp->em_fd, tcp->release_fd_cb, tcp->release_fd,
293
+ static void tcp_free(grpc_tcp* tcp) {
294
+ grpc_fd_orphan(tcp->em_fd, tcp->release_fd_cb, tcp->release_fd,
299
295
  false /* already_closed */, "tcp_unref_orphan");
300
- grpc_slice_buffer_destroy_internal(exec_ctx, &tcp->last_read_buffer);
301
- grpc_resource_user_unref(exec_ctx, tcp->resource_user);
296
+ grpc_slice_buffer_destroy_internal(&tcp->last_read_buffer);
297
+ grpc_resource_user_unref(tcp->resource_user);
302
298
  gpr_free(tcp->peer_string);
303
299
  gpr_free(tcp);
304
300
  }
305
301
 
306
302
  #ifndef NDEBUG
307
- #define TCP_UNREF(cl, tcp, reason) \
308
- tcp_unref((cl), (tcp), (reason), __FILE__, __LINE__)
303
+ #define TCP_UNREF(tcp, reason) tcp_unref((tcp), (reason), __FILE__, __LINE__)
309
304
  #define TCP_REF(tcp, reason) tcp_ref((tcp), (reason), __FILE__, __LINE__)
310
- static void tcp_unref(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
311
- const char* reason, const char* file, int line) {
305
+ static void tcp_unref(grpc_tcp* tcp, const char* reason, const char* file,
306
+ int line) {
312
307
  if (grpc_tcp_trace.enabled()) {
313
308
  gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count);
314
309
  gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
@@ -316,7 +311,7 @@ static void tcp_unref(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
316
311
  val - 1);
317
312
  }
318
313
  if (gpr_unref(&tcp->refcount)) {
319
- tcp_free(exec_ctx, tcp);
314
+ tcp_free(tcp);
320
315
  }
321
316
  }
322
317
 
@@ -331,26 +326,25 @@ static void tcp_ref(grpc_tcp* tcp, const char* reason, const char* file,
331
326
  gpr_ref(&tcp->refcount);
332
327
  }
333
328
  #else
334
- #define TCP_UNREF(cl, tcp, reason) tcp_unref((cl), (tcp))
329
+ #define TCP_UNREF(tcp, reason) tcp_unref((tcp))
335
330
  #define TCP_REF(tcp, reason) tcp_ref((tcp))
336
- static void tcp_unref(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
331
+ static void tcp_unref(grpc_tcp* tcp) {
337
332
  if (gpr_unref(&tcp->refcount)) {
338
- tcp_free(exec_ctx, tcp);
333
+ tcp_free(tcp);
339
334
  }
340
335
  }
341
336
 
342
337
  static void tcp_ref(grpc_tcp* tcp) { gpr_ref(&tcp->refcount); }
343
338
  #endif
344
339
 
345
- static void tcp_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) {
340
+ static void tcp_destroy(grpc_endpoint* ep) {
346
341
  grpc_network_status_unregister_endpoint(ep);
347
342
  grpc_tcp* tcp = (grpc_tcp*)ep;
348
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &tcp->last_read_buffer);
349
- TCP_UNREF(exec_ctx, tcp, "destroy");
343
+ grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
344
+ TCP_UNREF(tcp, "destroy");
350
345
  }
351
346
 
352
- static void call_read_cb(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
353
- grpc_error* error) {
347
+ static void call_read_cb(grpc_tcp* tcp, grpc_error* error) {
354
348
  grpc_closure* cb = tcp->read_cb;
355
349
 
356
350
  if (grpc_tcp_trace.enabled()) {
@@ -369,11 +363,11 @@ static void call_read_cb(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
369
363
 
370
364
  tcp->read_cb = nullptr;
371
365
  tcp->incoming_buffer = nullptr;
372
- GRPC_CLOSURE_RUN(exec_ctx, cb, error);
366
+ GRPC_CLOSURE_RUN(cb, error);
373
367
  }
374
368
 
375
369
  #define MAX_READ_IOVEC 4
376
- static void tcp_do_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
370
+ static void tcp_do_read(grpc_tcp* tcp) {
377
371
  struct msghdr msg;
378
372
  struct iovec iov[MAX_READ_IOVEC];
379
373
  ssize_t read_bytes;
@@ -396,12 +390,12 @@ static void tcp_do_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
396
390
  msg.msg_controllen = 0;
397
391
  msg.msg_flags = 0;
398
392
 
399
- GRPC_STATS_INC_TCP_READ_OFFER(exec_ctx, tcp->incoming_buffer->length);
400
- GRPC_STATS_INC_TCP_READ_OFFER_IOV_SIZE(exec_ctx, tcp->incoming_buffer->count);
393
+ GRPC_STATS_INC_TCP_READ_OFFER(tcp->incoming_buffer->length);
394
+ GRPC_STATS_INC_TCP_READ_OFFER_IOV_SIZE(tcp->incoming_buffer->count);
401
395
 
402
396
  GPR_TIMER_BEGIN("recvmsg", 0);
403
397
  do {
404
- GRPC_STATS_INC_SYSCALL_READ(exec_ctx);
398
+ GRPC_STATS_INC_SYSCALL_READ();
405
399
  read_bytes = recvmsg(tcp->fd, &msg, 0);
406
400
  } while (read_bytes < 0 && errno == EINTR);
407
401
  GPR_TIMER_END("recvmsg", read_bytes >= 0);
@@ -412,24 +406,22 @@ static void tcp_do_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
412
406
  if (errno == EAGAIN) {
413
407
  finish_estimate(tcp);
414
408
  /* We've consumed the edge, request a new one */
415
- notify_on_read(exec_ctx, tcp);
409
+ notify_on_read(tcp);
416
410
  } else {
417
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
418
- tcp->incoming_buffer);
419
- call_read_cb(exec_ctx, tcp,
411
+ grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
412
+ call_read_cb(tcp,
420
413
  tcp_annotate_error(GRPC_OS_ERROR(errno, "recvmsg"), tcp));
421
- TCP_UNREF(exec_ctx, tcp, "read");
414
+ TCP_UNREF(tcp, "read");
422
415
  }
423
416
  } else if (read_bytes == 0) {
424
417
  /* 0 read size ==> end of stream */
425
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, tcp->incoming_buffer);
418
+ grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
426
419
  call_read_cb(
427
- exec_ctx, tcp,
428
- tcp_annotate_error(
429
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Socket closed"), tcp));
430
- TCP_UNREF(exec_ctx, tcp, "read");
420
+ tcp, tcp_annotate_error(
421
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Socket closed"), tcp));
422
+ TCP_UNREF(tcp, "read");
431
423
  } else {
432
- GRPC_STATS_INC_TCP_READ_SIZE(exec_ctx, read_bytes);
424
+ GRPC_STATS_INC_TCP_READ_SIZE(read_bytes);
433
425
  add_to_estimate(tcp, (size_t)read_bytes);
434
426
  GPR_ASSERT((size_t)read_bytes <= tcp->incoming_buffer->length);
435
427
  if ((size_t)read_bytes < tcp->incoming_buffer->length) {
@@ -439,50 +431,47 @@ static void tcp_do_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
439
431
  &tcp->last_read_buffer);
440
432
  }
441
433
  GPR_ASSERT((size_t)read_bytes == tcp->incoming_buffer->length);
442
- call_read_cb(exec_ctx, tcp, GRPC_ERROR_NONE);
443
- TCP_UNREF(exec_ctx, tcp, "read");
434
+ call_read_cb(tcp, GRPC_ERROR_NONE);
435
+ TCP_UNREF(tcp, "read");
444
436
  }
445
437
 
446
438
  GPR_TIMER_END("tcp_continue_read", 0);
447
439
  }
448
440
 
449
- static void tcp_read_allocation_done(grpc_exec_ctx* exec_ctx, void* tcpp,
450
- grpc_error* error) {
441
+ static void tcp_read_allocation_done(void* tcpp, grpc_error* error) {
451
442
  grpc_tcp* tcp = (grpc_tcp*)tcpp;
452
443
  if (grpc_tcp_trace.enabled()) {
453
444
  gpr_log(GPR_DEBUG, "TCP:%p read_allocation_done: %s", tcp,
454
445
  grpc_error_string(error));
455
446
  }
456
447
  if (error != GRPC_ERROR_NONE) {
457
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, tcp->incoming_buffer);
458
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
459
- &tcp->last_read_buffer);
460
- call_read_cb(exec_ctx, tcp, GRPC_ERROR_REF(error));
461
- TCP_UNREF(exec_ctx, tcp, "read");
448
+ grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
449
+ grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
450
+ call_read_cb(tcp, GRPC_ERROR_REF(error));
451
+ TCP_UNREF(tcp, "read");
462
452
  } else {
463
- tcp_do_read(exec_ctx, tcp);
453
+ tcp_do_read(tcp);
464
454
  }
465
455
  }
466
456
 
467
- static void tcp_continue_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
457
+ static void tcp_continue_read(grpc_tcp* tcp) {
468
458
  size_t target_read_size = get_target_read_size(tcp);
469
459
  if (tcp->incoming_buffer->length < target_read_size &&
470
460
  tcp->incoming_buffer->count < MAX_READ_IOVEC) {
471
461
  if (grpc_tcp_trace.enabled()) {
472
462
  gpr_log(GPR_DEBUG, "TCP:%p alloc_slices", tcp);
473
463
  }
474
- grpc_resource_user_alloc_slices(exec_ctx, &tcp->slice_allocator,
475
- target_read_size, 1, tcp->incoming_buffer);
464
+ grpc_resource_user_alloc_slices(&tcp->slice_allocator, target_read_size, 1,
465
+ tcp->incoming_buffer);
476
466
  } else {
477
467
  if (grpc_tcp_trace.enabled()) {
478
468
  gpr_log(GPR_DEBUG, "TCP:%p do_read", tcp);
479
469
  }
480
- tcp_do_read(exec_ctx, tcp);
470
+ tcp_do_read(tcp);
481
471
  }
482
472
  }
483
473
 
484
- static void tcp_handle_read(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
485
- grpc_error* error) {
474
+ static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error) {
486
475
  grpc_tcp* tcp = (grpc_tcp*)arg;
487
476
  GPR_ASSERT(!tcp->finished_edge);
488
477
  if (grpc_tcp_trace.enabled()) {
@@ -490,37 +479,35 @@ static void tcp_handle_read(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
490
479
  }
491
480
 
492
481
  if (error != GRPC_ERROR_NONE) {
493
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, tcp->incoming_buffer);
494
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
495
- &tcp->last_read_buffer);
496
- call_read_cb(exec_ctx, tcp, GRPC_ERROR_REF(error));
497
- TCP_UNREF(exec_ctx, tcp, "read");
482
+ grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
483
+ grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
484
+ call_read_cb(tcp, GRPC_ERROR_REF(error));
485
+ TCP_UNREF(tcp, "read");
498
486
  } else {
499
- tcp_continue_read(exec_ctx, tcp);
487
+ tcp_continue_read(tcp);
500
488
  }
501
489
  }
502
490
 
503
- static void tcp_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
504
- grpc_slice_buffer* incoming_buffer, grpc_closure* cb) {
491
+ static void tcp_read(grpc_endpoint* ep, grpc_slice_buffer* incoming_buffer,
492
+ grpc_closure* cb) {
505
493
  grpc_tcp* tcp = (grpc_tcp*)ep;
506
494
  GPR_ASSERT(tcp->read_cb == nullptr);
507
495
  tcp->read_cb = cb;
508
496
  tcp->incoming_buffer = incoming_buffer;
509
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, incoming_buffer);
497
+ grpc_slice_buffer_reset_and_unref_internal(incoming_buffer);
510
498
  grpc_slice_buffer_swap(incoming_buffer, &tcp->last_read_buffer);
511
499
  TCP_REF(tcp, "read");
512
500
  if (tcp->finished_edge) {
513
501
  tcp->finished_edge = false;
514
- notify_on_read(exec_ctx, tcp);
502
+ notify_on_read(tcp);
515
503
  } else {
516
- GRPC_CLOSURE_SCHED(exec_ctx, &tcp->read_done_closure, GRPC_ERROR_NONE);
504
+ GRPC_CLOSURE_SCHED(&tcp->read_done_closure, GRPC_ERROR_NONE);
517
505
  }
518
506
  }
519
507
 
520
508
  /* returns true if done, false if pending; if returning true, *error is set */
521
509
  #define MAX_WRITE_IOVEC 1000
522
- static bool tcp_flush(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
523
- grpc_error** error) {
510
+ static bool tcp_flush(grpc_tcp* tcp, grpc_error** error) {
524
511
  struct msghdr msg;
525
512
  struct iovec iov[MAX_WRITE_IOVEC];
526
513
  msg_iovlen_type iov_size;
@@ -562,13 +549,13 @@ static bool tcp_flush(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
562
549
  msg.msg_controllen = 0;
563
550
  msg.msg_flags = 0;
564
551
 
565
- GRPC_STATS_INC_TCP_WRITE_SIZE(exec_ctx, sending_length);
566
- GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(exec_ctx, iov_size);
552
+ GRPC_STATS_INC_TCP_WRITE_SIZE(sending_length);
553
+ GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(iov_size);
567
554
 
568
555
  GPR_TIMER_BEGIN("sendmsg", 1);
569
556
  do {
570
557
  /* TODO(klempner): Cork if this is a partial write */
571
- GRPC_STATS_INC_SYSCALL_WRITE(exec_ctx);
558
+ GRPC_STATS_INC_SYSCALL_WRITE();
572
559
  sent_length = sendmsg(tcp->fd, &msg, SENDMSG_FLAGS);
573
560
  } while (sent_length < 0 && errno == EINTR);
574
561
  GPR_TIMER_END("sendmsg", 0);
@@ -580,20 +567,16 @@ static bool tcp_flush(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
580
567
  // point
581
568
  for (size_t idx = 0; idx < unwind_slice_idx; ++idx) {
582
569
  grpc_slice_unref_internal(
583
- exec_ctx, grpc_slice_buffer_take_first(tcp->outgoing_buffer));
570
+ grpc_slice_buffer_take_first(tcp->outgoing_buffer));
584
571
  }
585
572
  return false;
586
573
  } else if (errno == EPIPE) {
587
- *error = grpc_error_set_int(GRPC_OS_ERROR(errno, "sendmsg"),
588
- GRPC_ERROR_INT_GRPC_STATUS,
589
- GRPC_STATUS_UNAVAILABLE);
590
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
591
- tcp->outgoing_buffer);
574
+ *error = tcp_annotate_error(GRPC_OS_ERROR(errno, "sendmsg"), tcp);
575
+ grpc_slice_buffer_reset_and_unref_internal(tcp->outgoing_buffer);
592
576
  return true;
593
577
  } else {
594
578
  *error = tcp_annotate_error(GRPC_OS_ERROR(errno, "sendmsg"), tcp);
595
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
596
- tcp->outgoing_buffer);
579
+ grpc_slice_buffer_reset_and_unref_internal(tcp->outgoing_buffer);
597
580
  return true;
598
581
  }
599
582
  }
@@ -616,31 +599,29 @@ static bool tcp_flush(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
616
599
 
617
600
  if (outgoing_slice_idx == tcp->outgoing_buffer->count) {
618
601
  *error = GRPC_ERROR_NONE;
619
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
620
- tcp->outgoing_buffer);
602
+ grpc_slice_buffer_reset_and_unref_internal(tcp->outgoing_buffer);
621
603
  return true;
622
604
  }
623
605
  }
624
606
  }
625
607
 
626
- static void tcp_handle_write(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
627
- grpc_error* error) {
608
+ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) {
628
609
  grpc_tcp* tcp = (grpc_tcp*)arg;
629
610
  grpc_closure* cb;
630
611
 
631
612
  if (error != GRPC_ERROR_NONE) {
632
613
  cb = tcp->write_cb;
633
614
  tcp->write_cb = nullptr;
634
- cb->cb(exec_ctx, cb->cb_arg, error);
635
- TCP_UNREF(exec_ctx, tcp, "write");
615
+ cb->cb(cb->cb_arg, error);
616
+ TCP_UNREF(tcp, "write");
636
617
  return;
637
618
  }
638
619
 
639
- if (!tcp_flush(exec_ctx, tcp, &error)) {
620
+ if (!tcp_flush(tcp, &error)) {
640
621
  if (grpc_tcp_trace.enabled()) {
641
622
  gpr_log(GPR_DEBUG, "write: delayed");
642
623
  }
643
- notify_on_write(exec_ctx, tcp);
624
+ notify_on_write(tcp);
644
625
  } else {
645
626
  cb = tcp->write_cb;
646
627
  tcp->write_cb = nullptr;
@@ -649,13 +630,13 @@ static void tcp_handle_write(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
649
630
  gpr_log(GPR_DEBUG, "write: %s", str);
650
631
  }
651
632
 
652
- GRPC_CLOSURE_RUN(exec_ctx, cb, error);
653
- TCP_UNREF(exec_ctx, tcp, "write");
633
+ GRPC_CLOSURE_RUN(cb, error);
634
+ TCP_UNREF(tcp, "write");
654
635
  }
655
636
  }
656
637
 
657
- static void tcp_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
658
- grpc_slice_buffer* buf, grpc_closure* cb) {
638
+ static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
639
+ grpc_closure* cb) {
659
640
  grpc_tcp* tcp = (grpc_tcp*)ep;
660
641
  grpc_error* error = GRPC_ERROR_NONE;
661
642
 
@@ -676,51 +657,48 @@ static void tcp_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
676
657
  if (buf->length == 0) {
677
658
  GPR_TIMER_END("tcp_write", 0);
678
659
  GRPC_CLOSURE_SCHED(
679
- exec_ctx, cb,
680
- grpc_fd_is_shutdown(tcp->em_fd)
681
- ? tcp_annotate_error(GRPC_ERROR_CREATE_FROM_STATIC_STRING("EOF"),
682
- tcp)
683
- : GRPC_ERROR_NONE);
660
+ cb, grpc_fd_is_shutdown(tcp->em_fd)
661
+ ? tcp_annotate_error(
662
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("EOF"), tcp)
663
+ : GRPC_ERROR_NONE);
684
664
  return;
685
665
  }
686
666
  tcp->outgoing_buffer = buf;
687
667
  tcp->outgoing_byte_idx = 0;
688
668
 
689
- if (!tcp_flush(exec_ctx, tcp, &error)) {
669
+ if (!tcp_flush(tcp, &error)) {
690
670
  TCP_REF(tcp, "write");
691
671
  tcp->write_cb = cb;
692
672
  if (grpc_tcp_trace.enabled()) {
693
673
  gpr_log(GPR_DEBUG, "write: delayed");
694
674
  }
695
- notify_on_write(exec_ctx, tcp);
675
+ notify_on_write(tcp);
696
676
  } else {
697
677
  if (grpc_tcp_trace.enabled()) {
698
678
  const char* str = grpc_error_string(error);
699
679
  gpr_log(GPR_DEBUG, "write: %s", str);
700
680
  }
701
- GRPC_CLOSURE_SCHED(exec_ctx, cb, error);
681
+ GRPC_CLOSURE_SCHED(cb, error);
702
682
  }
703
683
 
704
684
  GPR_TIMER_END("tcp_write", 0);
705
685
  }
706
686
 
707
- static void tcp_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
708
- grpc_pollset* pollset) {
687
+ static void tcp_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {
709
688
  grpc_tcp* tcp = (grpc_tcp*)ep;
710
- grpc_pollset_add_fd(exec_ctx, pollset, tcp->em_fd);
689
+ grpc_pollset_add_fd(pollset, tcp->em_fd);
711
690
  }
712
691
 
713
- static void tcp_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
692
+ static void tcp_add_to_pollset_set(grpc_endpoint* ep,
714
693
  grpc_pollset_set* pollset_set) {
715
694
  grpc_tcp* tcp = (grpc_tcp*)ep;
716
- grpc_pollset_set_add_fd(exec_ctx, pollset_set, tcp->em_fd);
695
+ grpc_pollset_set_add_fd(pollset_set, tcp->em_fd);
717
696
  }
718
697
 
719
- static void tcp_delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
720
- grpc_endpoint* ep,
698
+ static void tcp_delete_from_pollset_set(grpc_endpoint* ep,
721
699
  grpc_pollset_set* pollset_set) {
722
700
  grpc_tcp* tcp = (grpc_tcp*)ep;
723
- grpc_pollset_set_del_fd(exec_ctx, pollset_set, tcp->em_fd);
701
+ grpc_pollset_set_del_fd(pollset_set, tcp->em_fd);
724
702
  }
725
703
 
726
704
  static char* tcp_get_peer(grpc_endpoint* ep) {
@@ -751,7 +729,7 @@ static const grpc_endpoint_vtable vtable = {tcp_read,
751
729
 
752
730
  #define MAX_CHUNK_SIZE 32 * 1024 * 1024
753
731
 
754
- grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_fd* em_fd,
732
+ grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd,
755
733
  const grpc_channel_args* channel_args,
756
734
  const char* peer_string) {
757
735
  int tcp_read_chunk_size = GRPC_TCP_DEFAULT_READ_SLICE_SIZE;
@@ -780,7 +758,7 @@ grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_fd* em_fd,
780
758
  grpc_channel_arg_get_integer(&channel_args->args[i], options);
781
759
  } else if (0 ==
782
760
  strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
783
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
761
+ grpc_resource_quota_unref_internal(resource_quota);
784
762
  resource_quota = grpc_resource_quota_ref_internal(
785
763
  (grpc_resource_quota*)channel_args->args[i].value.pointer.p);
786
764
  }
@@ -817,7 +795,7 @@ grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_fd* em_fd,
817
795
  &tcp->slice_allocator, tcp->resource_user, tcp_read_allocation_done, tcp);
818
796
  /* Tell network status tracker about new endpoint */
819
797
  grpc_network_status_register_endpoint(&tcp->base);
820
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
798
+ grpc_resource_quota_unref_internal(resource_quota);
821
799
 
822
800
  return &tcp->base;
823
801
  }
@@ -828,15 +806,15 @@ int grpc_tcp_fd(grpc_endpoint* ep) {
828
806
  return grpc_fd_wrapped_fd(tcp->em_fd);
829
807
  }
830
808
 
831
- void grpc_tcp_destroy_and_release_fd(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
832
- int* fd, grpc_closure* done) {
809
+ void grpc_tcp_destroy_and_release_fd(grpc_endpoint* ep, int* fd,
810
+ grpc_closure* done) {
833
811
  grpc_network_status_unregister_endpoint(ep);
834
812
  grpc_tcp* tcp = (grpc_tcp*)ep;
835
813
  GPR_ASSERT(ep->vtable == &vtable);
836
814
  tcp->release_fd = fd;
837
815
  tcp->release_fd_cb = done;
838
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &tcp->last_read_buffer);
839
- TCP_UNREF(exec_ctx, tcp, "destroy");
816
+ grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
817
+ TCP_UNREF(tcp, "destroy");
840
818
  }
841
819
 
842
820
  #endif