grpc 1.3.4 → 1.4.0

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 (286) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +581 -450
  3. data/include/grpc/census.h +49 -49
  4. data/include/grpc/grpc.h +16 -70
  5. data/include/grpc/grpc_security.h +59 -59
  6. data/include/grpc/grpc_security_constants.h +9 -9
  7. data/include/grpc/impl/codegen/atm.h +1 -1
  8. data/include/grpc/impl/codegen/atm_windows.h +4 -4
  9. data/include/grpc/impl/codegen/byte_buffer_reader.h +2 -2
  10. data/include/grpc/impl/codegen/compression_types.h +4 -5
  11. data/include/grpc/impl/codegen/gpr_slice.h +5 -5
  12. data/include/grpc/impl/codegen/gpr_types.h +6 -7
  13. data/include/grpc/impl/codegen/grpc_types.h +128 -59
  14. data/include/grpc/impl/codegen/port_platform.h +6 -0
  15. data/include/grpc/impl/codegen/propagation_bits.h +2 -2
  16. data/include/grpc/impl/codegen/slice.h +13 -12
  17. data/include/grpc/impl/codegen/status.h +23 -18
  18. data/include/grpc/impl/codegen/sync.h +1 -1
  19. data/include/grpc/load_reporting.h +6 -6
  20. data/include/grpc/slice.h +47 -25
  21. data/include/grpc/slice_buffer.h +18 -14
  22. data/include/grpc/support/alloc.h +7 -7
  23. data/include/grpc/support/cmdline.h +10 -10
  24. data/include/grpc/support/cpu.h +3 -3
  25. data/include/grpc/support/histogram.h +1 -1
  26. data/include/grpc/support/host_port.h +2 -2
  27. data/include/grpc/support/log.h +9 -9
  28. data/include/grpc/support/log_windows.h +1 -1
  29. data/include/grpc/support/string_util.h +3 -3
  30. data/include/grpc/support/subprocess.h +3 -3
  31. data/include/grpc/support/sync.h +31 -31
  32. data/include/grpc/support/thd.h +11 -11
  33. data/include/grpc/support/time.h +12 -12
  34. data/include/grpc/support/tls.h +1 -1
  35. data/include/grpc/support/tls_gcc.h +2 -2
  36. data/include/grpc/support/tls_msvc.h +1 -1
  37. data/include/grpc/support/tls_pthread.h +1 -1
  38. data/include/grpc/support/useful.h +2 -2
  39. data/include/grpc/support/workaround_list.h +46 -0
  40. data/src/core/ext/census/context.c +1 -1
  41. data/src/core/ext/census/intrusive_hash_map.c +319 -0
  42. data/src/core/ext/census/intrusive_hash_map.h +167 -0
  43. data/src/core/ext/census/intrusive_hash_map_internal.h +63 -0
  44. data/src/core/ext/census/resource.c +3 -1
  45. data/src/core/ext/filters/client_channel/channel_connectivity.c +1 -1
  46. data/src/core/ext/filters/client_channel/client_channel.c +173 -103
  47. data/src/core/ext/filters/client_channel/client_channel_plugin.c +3 -2
  48. data/src/core/ext/filters/client_channel/lb_policy.c +2 -1
  49. data/src/core/ext/filters/client_channel/lb_policy.h +8 -7
  50. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +153 -0
  51. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +42 -0
  52. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +405 -102
  53. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +133 -0
  54. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +65 -0
  55. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +90 -51
  56. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +7 -1
  57. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +19 -8
  58. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +63 -34
  59. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +2 -1
  60. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +188 -294
  61. data/src/core/ext/filters/client_channel/lb_policy_factory.c +28 -5
  62. data/src/core/ext/filters/client_channel/lb_policy_factory.h +18 -4
  63. data/src/core/ext/filters/client_channel/parse_address.c +90 -59
  64. data/src/core/ext/filters/client_channel/parse_address.h +17 -8
  65. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +11 -7
  66. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +59 -14
  67. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +6 -0
  68. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c +3 -3
  69. data/src/core/ext/filters/client_channel/subchannel.c +20 -17
  70. data/src/core/ext/filters/client_channel/subchannel.h +1 -0
  71. data/src/core/ext/filters/client_channel/subchannel_index.c +11 -1
  72. data/src/core/ext/filters/client_channel/uri_parser.c +36 -22
  73. data/src/core/ext/filters/client_channel/uri_parser.h +1 -1
  74. data/src/core/{lib/channel → ext/filters/deadline}/deadline_filter.c +42 -17
  75. data/src/core/{lib/channel → ext/filters/deadline}/deadline_filter.h +8 -9
  76. data/src/core/{lib/channel → ext/filters/http/client}/http_client_filter.c +19 -11
  77. data/src/core/{lib/channel → ext/filters/http/client}/http_client_filter.h +3 -6
  78. data/src/core/ext/filters/http/http_filters_plugin.c +104 -0
  79. data/src/core/{lib/channel/compress_filter.c → ext/filters/http/message_compress/message_compress_filter.c} +124 -23
  80. data/src/core/{lib/channel/compress_filter.h → ext/filters/http/message_compress/message_compress_filter.h} +5 -6
  81. data/src/core/{lib/channel → ext/filters/http/server}/http_server_filter.c +4 -6
  82. data/src/core/{lib/channel → ext/filters/http/server}/http_server_filter.h +3 -3
  83. data/src/core/ext/filters/load_reporting/load_reporting.c +2 -25
  84. data/src/core/ext/filters/load_reporting/load_reporting_filter.c +26 -1
  85. data/src/core/ext/filters/max_age/max_age_filter.c +14 -14
  86. data/src/core/{lib/channel → ext/filters/message_size}/message_size_filter.c +91 -47
  87. data/src/core/{lib/channel → ext/filters/message_size}/message_size_filter.h +3 -3
  88. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c +223 -0
  89. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +40 -0
  90. data/src/core/ext/filters/workarounds/workaround_utils.c +65 -0
  91. data/src/core/ext/filters/workarounds/workaround_utils.h +52 -0
  92. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +1 -1
  93. data/src/core/ext/transport/chttp2/server/chttp2_server.c +3 -2
  94. data/src/core/ext/transport/chttp2/transport/bin_decoder.c +2 -2
  95. data/src/core/ext/transport/chttp2/transport/bin_encoder.c +3 -3
  96. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +319 -175
  97. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +3 -2
  98. data/src/core/ext/transport/chttp2/transport/frame_data.c +203 -164
  99. data/src/core/ext/transport/chttp2/transport/frame_data.h +8 -14
  100. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +1 -1
  101. data/src/core/ext/transport/chttp2/transport/frame_ping.c +1 -1
  102. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +1 -1
  103. data/src/core/ext/transport/chttp2/transport/frame_settings.c +5 -5
  104. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +1 -1
  105. data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +4 -4
  106. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +2 -4
  107. data/src/core/ext/transport/chttp2/transport/hpack_table.c +4 -3
  108. data/src/core/ext/transport/chttp2/transport/internal.h +50 -33
  109. data/src/core/ext/transport/chttp2/transport/parsing.c +10 -11
  110. data/src/core/ext/transport/chttp2/transport/writing.c +32 -13
  111. data/src/core/lib/channel/channel_args.c +30 -9
  112. data/src/core/lib/channel/channel_args.h +5 -1
  113. data/src/core/lib/channel/channel_stack.c +1 -1
  114. data/src/core/lib/channel/channel_stack.h +2 -2
  115. data/src/core/lib/channel/channel_stack_builder.c +13 -1
  116. data/src/core/lib/channel/channel_stack_builder.h +5 -1
  117. data/src/core/lib/channel/connected_channel.c +3 -1
  118. data/src/core/lib/channel/context.h +2 -2
  119. data/src/core/lib/compression/message_compress.c +2 -2
  120. data/src/core/lib/debug/trace.c +13 -6
  121. data/src/core/lib/debug/trace.h +27 -1
  122. data/src/core/lib/http/httpcli.c +1 -1
  123. data/src/core/lib/http/httpcli_security_connector.c +9 -11
  124. data/src/core/lib/http/parser.c +2 -2
  125. data/src/core/lib/http/parser.h +2 -1
  126. data/src/core/lib/iomgr/combiner.c +6 -6
  127. data/src/core/lib/iomgr/combiner.h +2 -1
  128. data/src/core/lib/iomgr/error.c +12 -5
  129. data/src/core/lib/iomgr/error.h +13 -13
  130. data/src/core/lib/iomgr/ev_epoll1_linux.c +984 -0
  131. data/src/core/lib/iomgr/ev_epoll1_linux.h +44 -0
  132. data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +2146 -0
  133. data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.h +43 -0
  134. data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +1337 -0
  135. data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.h +43 -0
  136. data/src/core/lib/iomgr/ev_epollex_linux.c +1511 -0
  137. data/src/core/lib/iomgr/ev_epollex_linux.h +43 -0
  138. data/src/core/lib/iomgr/{ev_epoll_linux.c → ev_epollsig_linux.c} +41 -33
  139. data/src/core/lib/iomgr/{ev_epoll_linux.h → ev_epollsig_linux.h} +4 -4
  140. data/src/core/lib/iomgr/ev_poll_posix.c +12 -27
  141. data/src/core/lib/iomgr/ev_poll_posix.h +2 -2
  142. data/src/core/lib/iomgr/ev_posix.c +22 -8
  143. data/src/core/lib/iomgr/ev_posix.h +4 -3
  144. data/src/core/lib/iomgr/ev_windows.c +43 -0
  145. data/src/core/lib/iomgr/exec_ctx.c +5 -0
  146. data/src/core/lib/iomgr/exec_ctx.h +2 -0
  147. data/src/core/lib/iomgr/iomgr.c +4 -0
  148. data/src/core/lib/iomgr/iomgr.h +3 -0
  149. data/src/core/lib/iomgr/is_epollexclusive_available.c +116 -0
  150. data/src/core/lib/iomgr/is_epollexclusive_available.h +41 -0
  151. data/src/core/lib/iomgr/lockfree_event.c +16 -0
  152. data/src/core/lib/iomgr/pollset.h +2 -5
  153. data/src/core/lib/iomgr/pollset_uv.c +1 -1
  154. data/src/core/lib/iomgr/pollset_windows.c +3 -3
  155. data/src/core/lib/iomgr/resource_quota.c +9 -8
  156. data/src/core/lib/iomgr/resource_quota.h +2 -1
  157. data/src/core/lib/iomgr/sockaddr_utils.h +1 -1
  158. data/src/core/lib/iomgr/socket_mutator.h +2 -0
  159. data/src/core/lib/iomgr/sys_epoll_wrapper.h +43 -0
  160. data/src/core/lib/iomgr/tcp_client_posix.c +6 -6
  161. data/src/core/lib/iomgr/tcp_client_uv.c +3 -3
  162. data/src/core/lib/iomgr/tcp_posix.c +7 -7
  163. data/src/core/lib/iomgr/tcp_posix.h +2 -1
  164. data/src/core/lib/iomgr/tcp_server_posix.c +1 -1
  165. data/src/core/lib/iomgr/tcp_uv.c +6 -6
  166. data/src/core/lib/iomgr/tcp_uv.h +2 -1
  167. data/src/core/lib/iomgr/tcp_windows.c +1 -1
  168. data/src/core/lib/iomgr/timer_generic.c +24 -25
  169. data/src/core/lib/iomgr/timer_manager.c +276 -0
  170. data/src/core/lib/iomgr/timer_manager.h +52 -0
  171. data/src/core/lib/iomgr/timer_uv.c +6 -0
  172. data/src/core/lib/iomgr/udp_server.c +42 -9
  173. data/src/core/lib/iomgr/udp_server.h +3 -1
  174. data/src/core/lib/security/credentials/credentials.c +0 -1
  175. data/src/core/lib/security/credentials/fake/fake_credentials.c +23 -0
  176. data/src/core/lib/security/credentials/fake/fake_credentials.h +12 -9
  177. data/src/core/lib/security/credentials/google_default/google_default_credentials.c +1 -1
  178. data/src/core/lib/security/credentials/jwt/jwt_credentials.c +1 -1
  179. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +1 -1
  180. data/src/core/lib/security/credentials/ssl/ssl_credentials.c +24 -53
  181. data/src/core/lib/security/transport/client_auth_filter.c +9 -3
  182. data/src/core/lib/security/transport/secure_endpoint.c +7 -7
  183. data/src/core/lib/security/transport/secure_endpoint.h +1 -1
  184. data/src/core/lib/security/transport/security_connector.c +45 -57
  185. data/src/core/lib/security/transport/security_connector.h +10 -14
  186. data/src/core/lib/security/transport/security_handshaker.c +123 -97
  187. data/src/core/lib/slice/b64.c +1 -1
  188. data/src/core/lib/slice/percent_encoding.c +3 -3
  189. data/src/core/lib/slice/slice.c +66 -33
  190. data/src/core/lib/slice/slice_buffer.c +25 -6
  191. data/src/core/lib/slice/slice_hash_table.c +33 -35
  192. data/src/core/lib/slice/slice_hash_table.h +7 -12
  193. data/src/core/lib/support/atomic.h +45 -0
  194. data/src/core/lib/support/atomic_with_atm.h +70 -0
  195. data/src/core/lib/support/atomic_with_std.h +48 -0
  196. data/src/core/lib/support/avl.c +14 -14
  197. data/src/core/lib/support/cmdline.c +3 -3
  198. data/src/core/lib/support/histogram.c +2 -2
  199. data/src/core/lib/support/host_port.c +1 -1
  200. data/src/core/lib/support/memory.h +74 -0
  201. data/src/core/lib/support/mpscq.c +36 -2
  202. data/src/core/lib/support/mpscq.h +28 -1
  203. data/src/core/lib/support/stack_lockfree.c +3 -36
  204. data/src/core/lib/support/string.c +12 -12
  205. data/src/core/lib/support/string_posix.c +1 -1
  206. data/src/core/lib/support/subprocess_posix.c +2 -2
  207. data/src/core/lib/support/thd_posix.c +1 -1
  208. data/src/core/lib/support/time_posix.c +8 -0
  209. data/src/core/lib/support/tmpfile_posix.c +10 -10
  210. data/src/core/lib/surface/alarm.c +3 -1
  211. data/src/core/lib/surface/api_trace.c +2 -1
  212. data/src/core/lib/surface/api_trace.h +2 -2
  213. data/src/core/lib/surface/byte_buffer_reader.c +1 -1
  214. data/src/core/lib/surface/call.c +65 -22
  215. data/src/core/lib/surface/call.h +4 -2
  216. data/src/core/lib/surface/channel_init.c +2 -19
  217. data/src/core/lib/surface/channel_stack_type.c +18 -0
  218. data/src/core/lib/surface/channel_stack_type.h +2 -0
  219. data/src/core/lib/surface/completion_queue.c +694 -247
  220. data/src/core/lib/surface/completion_queue.h +30 -13
  221. data/src/core/lib/surface/completion_queue_factory.c +24 -9
  222. data/src/core/lib/surface/init.c +1 -52
  223. data/src/core/lib/surface/{lame_client.c → lame_client.cc} +37 -26
  224. data/src/core/lib/surface/server.c +79 -110
  225. data/src/core/lib/surface/server.h +2 -1
  226. data/src/core/lib/surface/version.c +2 -2
  227. data/src/core/lib/transport/bdp_estimator.c +25 -9
  228. data/src/core/lib/transport/bdp_estimator.h +7 -1
  229. data/src/core/lib/transport/byte_stream.c +23 -9
  230. data/src/core/lib/transport/byte_stream.h +15 -6
  231. data/src/core/lib/transport/connectivity_state.c +6 -6
  232. data/src/core/lib/transport/connectivity_state.h +2 -1
  233. data/src/core/lib/transport/service_config.c +6 -13
  234. data/src/core/lib/transport/service_config.h +2 -2
  235. data/src/core/lib/transport/static_metadata.c +403 -389
  236. data/src/core/lib/transport/static_metadata.h +127 -114
  237. data/src/core/plugin_registry/grpc_plugin_registry.c +16 -0
  238. data/src/core/tsi/fake_transport_security.c +5 -4
  239. data/src/core/tsi/ssl_transport_security.c +71 -82
  240. data/src/core/tsi/ssl_transport_security.h +39 -61
  241. data/src/core/tsi/transport_security.c +83 -2
  242. data/src/core/tsi/transport_security.h +27 -2
  243. data/src/core/tsi/transport_security_adapter.c +236 -0
  244. data/src/core/tsi/transport_security_adapter.h +62 -0
  245. data/src/core/tsi/transport_security_interface.h +179 -66
  246. data/src/ruby/ext/grpc/extconf.rb +2 -1
  247. data/src/ruby/ext/grpc/rb_byte_buffer.c +8 -6
  248. data/src/ruby/ext/grpc/rb_call.c +56 -48
  249. data/src/ruby/ext/grpc/rb_call.h +3 -4
  250. data/src/ruby/ext/grpc/rb_call_credentials.c +23 -22
  251. data/src/ruby/ext/grpc/rb_channel.c +2 -3
  252. data/src/ruby/ext/grpc/rb_channel_args.c +11 -9
  253. data/src/ruby/ext/grpc/rb_channel_credentials.c +16 -12
  254. data/src/ruby/ext/grpc/rb_completion_queue.c +7 -9
  255. data/src/ruby/ext/grpc/rb_compression_options.c +7 -6
  256. data/src/ruby/ext/grpc/rb_event_thread.c +10 -12
  257. data/src/ruby/ext/grpc/rb_event_thread.h +1 -2
  258. data/src/ruby/ext/grpc/rb_grpc.c +11 -15
  259. data/src/ruby/ext/grpc/rb_grpc.h +2 -2
  260. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +16 -6
  261. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +25 -10
  262. data/src/ruby/ext/grpc/rb_server.c +26 -28
  263. data/src/ruby/lib/grpc/grpc.rb +1 -1
  264. data/src/ruby/lib/grpc/version.rb +1 -1
  265. data/third_party/cares/config_linux/ares_config.h +36 -2
  266. data/third_party/zlib/adler32.c +14 -7
  267. data/third_party/zlib/compress.c +24 -18
  268. data/third_party/zlib/crc32.c +29 -12
  269. data/third_party/zlib/deflate.c +499 -303
  270. data/third_party/zlib/deflate.h +19 -16
  271. data/third_party/zlib/gzguts.h +16 -7
  272. data/third_party/zlib/gzlib.c +17 -14
  273. data/third_party/zlib/gzread.c +108 -48
  274. data/third_party/zlib/gzwrite.c +210 -122
  275. data/third_party/zlib/infback.c +2 -2
  276. data/third_party/zlib/inffast.c +34 -51
  277. data/third_party/zlib/inflate.c +86 -37
  278. data/third_party/zlib/inflate.h +7 -4
  279. data/third_party/zlib/inftrees.c +12 -14
  280. data/third_party/zlib/trees.c +38 -61
  281. data/third_party/zlib/uncompr.c +66 -32
  282. data/third_party/zlib/zconf.h +32 -9
  283. data/third_party/zlib/zlib.h +298 -154
  284. data/third_party/zlib/zutil.c +25 -24
  285. data/third_party/zlib/zutil.h +35 -17
  286. metadata +63 -30
@@ -36,6 +36,7 @@
36
36
 
37
37
  #include <grpc/grpc.h>
38
38
 
39
+ #include "src/core/lib/debug/trace.h"
39
40
  #include "src/core/lib/iomgr/exec_ctx.h"
40
41
 
41
42
  /** \file Tracks resource usage against a pool.
@@ -75,7 +76,7 @@
75
76
  maintain lists of users (which users arrange to leave before they are
76
77
  destroyed) */
77
78
 
78
- extern int grpc_resource_quota_trace;
79
+ extern grpc_tracer_flag grpc_resource_quota_trace;
79
80
 
80
81
  grpc_resource_quota *grpc_resource_quota_ref_internal(
81
82
  grpc_resource_quota *resource_quota);
@@ -50,7 +50,7 @@ int grpc_sockaddr_to_v4mapped(const grpc_resolved_address *addr,
50
50
  grpc_resolved_address *addr6_out);
51
51
 
52
52
  /* If addr is ::, 0.0.0.0, or ::ffff:0.0.0.0, writes the port number to
53
- *port_out (if not NULL) and returns true, otherwise returns false. */
53
+ *port_out (if not NULL) and returns true, otherwise returns false. */
54
54
  int grpc_sockaddr_is_wildcard(const grpc_resolved_address *addr, int *port_out);
55
55
 
56
56
  /* Writes 0.0.0.0:port and [::]:port to separate sockaddrs. */
@@ -37,6 +37,8 @@
37
37
  #include <grpc/impl/codegen/grpc_types.h>
38
38
  #include <grpc/support/sync.h>
39
39
 
40
+ #include <stdbool.h>
41
+
40
42
  #ifdef __cplusplus
41
43
  extern "C" {
42
44
  #endif
@@ -0,0 +1,43 @@
1
+ /*
2
+ *
3
+ * Copyright 2017, Google Inc.
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are
8
+ * met:
9
+ *
10
+ * * Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * * Redistributions in binary form must reproduce the above
13
+ * copyright notice, this list of conditions and the following disclaimer
14
+ * in the documentation and/or other materials provided with the
15
+ * distribution.
16
+ * * Neither the name of Google Inc. nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ */
33
+
34
+ #ifndef GRPC_CORE_LIB_IOMGR_SYS_EPOLL_WRAPPER_H
35
+ #define GRPC_CORE_LIB_IOMGR_SYS_EPOLL_WRAPPER_H
36
+
37
+ #include <sys/epoll.h>
38
+
39
+ #ifndef EPOLLEXCLUSIVE
40
+ #define EPOLLEXCLUSIVE (1 << 28)
41
+ #endif
42
+
43
+ #endif /* GRPC_CORE_LIB_IOMGR_SYS_EPOLL_WRAPPER_H */
@@ -58,7 +58,7 @@
58
58
  #include "src/core/lib/iomgr/unix_sockets_posix.h"
59
59
  #include "src/core/lib/support/string.h"
60
60
 
61
- extern int grpc_tcp_trace;
61
+ extern grpc_tracer_flag grpc_tcp_trace;
62
62
 
63
63
  typedef struct {
64
64
  gpr_mu mu;
@@ -114,7 +114,7 @@ done:
114
114
  static void tc_on_alarm(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
115
115
  int done;
116
116
  async_connect *ac = acp;
117
- if (grpc_tcp_trace) {
117
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
118
118
  const char *str = grpc_error_string(error);
119
119
  gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: on_alarm: error=%s", ac->addr_str,
120
120
  str);
@@ -152,7 +152,7 @@ static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
152
152
 
153
153
  GRPC_ERROR_REF(error);
154
154
 
155
- if (grpc_tcp_trace) {
155
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
156
156
  const char *str = grpc_error_string(error);
157
157
  gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: on_writable: error=%s",
158
158
  ac->addr_str, str);
@@ -330,9 +330,9 @@ static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx,
330
330
  grpc_schedule_on_exec_ctx);
331
331
  ac->channel_args = grpc_channel_args_copy(channel_args);
332
332
 
333
- if (grpc_tcp_trace) {
334
- gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: asynchronously connecting",
335
- ac->addr_str);
333
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
334
+ gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: asynchronously connecting fd %p",
335
+ ac->addr_str, fdobj);
336
336
  }
337
337
 
338
338
  gpr_mu_lock(&ac->mu);
@@ -46,7 +46,7 @@
46
46
  #include "src/core/lib/iomgr/tcp_uv.h"
47
47
  #include "src/core/lib/iomgr/timer.h"
48
48
 
49
- extern int grpc_tcp_trace;
49
+ extern grpc_tracer_flag grpc_tcp_trace;
50
50
 
51
51
  typedef struct grpc_uv_tcp_connect {
52
52
  uv_connect_t connect_req;
@@ -72,7 +72,7 @@ static void uv_tc_on_alarm(grpc_exec_ctx *exec_ctx, void *acp,
72
72
  grpc_error *error) {
73
73
  int done;
74
74
  grpc_uv_tcp_connect *connect = acp;
75
- if (grpc_tcp_trace) {
75
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
76
76
  const char *str = grpc_error_string(error);
77
77
  gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: on_alarm: error=%s",
78
78
  connect->addr_name, str);
@@ -156,7 +156,7 @@ static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx,
156
156
  uv_tcp_init(uv_default_loop(), connect->tcp_handle);
157
157
  connect->connect_req.data = connect;
158
158
 
159
- if (grpc_tcp_trace) {
159
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
160
160
  gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: asynchronously connecting",
161
161
  connect->addr_name);
162
162
  }
@@ -74,7 +74,7 @@ typedef GRPC_MSG_IOVLEN_TYPE msg_iovlen_type;
74
74
  typedef size_t msg_iovlen_type;
75
75
  #endif
76
76
 
77
- int grpc_tcp_trace = 0;
77
+ grpc_tracer_flag grpc_tcp_trace = GRPC_TRACER_INITIALIZER(false);
78
78
 
79
79
  typedef struct {
80
80
  grpc_endpoint base;
@@ -221,7 +221,7 @@ static void call_read_cb(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp,
221
221
  grpc_error *error) {
222
222
  grpc_closure *cb = tcp->read_cb;
223
223
 
224
- if (grpc_tcp_trace) {
224
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
225
225
  size_t i;
226
226
  const char *str = grpc_error_string(error);
227
227
  gpr_log(GPR_DEBUG, "read: error=%s", str);
@@ -468,14 +468,14 @@ static void tcp_handle_write(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */,
468
468
  }
469
469
 
470
470
  if (!tcp_flush(tcp, &error)) {
471
- if (grpc_tcp_trace) {
471
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
472
472
  gpr_log(GPR_DEBUG, "write: delayed");
473
473
  }
474
474
  grpc_fd_notify_on_write(exec_ctx, tcp->em_fd, &tcp->write_closure);
475
475
  } else {
476
476
  cb = tcp->write_cb;
477
477
  tcp->write_cb = NULL;
478
- if (grpc_tcp_trace) {
478
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
479
479
  const char *str = grpc_error_string(error);
480
480
  gpr_log(GPR_DEBUG, "write: %s", str);
481
481
  }
@@ -490,7 +490,7 @@ static void tcp_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
490
490
  grpc_tcp *tcp = (grpc_tcp *)ep;
491
491
  grpc_error *error = GRPC_ERROR_NONE;
492
492
 
493
- if (grpc_tcp_trace) {
493
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
494
494
  size_t i;
495
495
 
496
496
  for (i = 0; i < buf->count; i++) {
@@ -521,12 +521,12 @@ static void tcp_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
521
521
  if (!tcp_flush(tcp, &error)) {
522
522
  TCP_REF(tcp, "write");
523
523
  tcp->write_cb = cb;
524
- if (grpc_tcp_trace) {
524
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
525
525
  gpr_log(GPR_DEBUG, "write: delayed");
526
526
  }
527
527
  grpc_fd_notify_on_write(exec_ctx, tcp->em_fd, &tcp->write_closure);
528
528
  } else {
529
- if (grpc_tcp_trace) {
529
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
530
530
  const char *str = grpc_error_string(error);
531
531
  gpr_log(GPR_DEBUG, "write: %s", str);
532
532
  }
@@ -44,10 +44,11 @@
44
44
  otherwise specified.
45
45
  */
46
46
 
47
+ #include "src/core/lib/debug/trace.h"
47
48
  #include "src/core/lib/iomgr/endpoint.h"
48
49
  #include "src/core/lib/iomgr/ev_posix.h"
49
50
 
50
- extern int grpc_tcp_trace;
51
+ extern grpc_tracer_flag grpc_tcp_trace;
51
52
 
52
53
  /* Create a tcp endpoint given a file desciptor and a read slice size.
53
54
  Takes ownership of fd. */
@@ -257,7 +257,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *err) {
257
257
  addr_str = grpc_sockaddr_to_uri(&addr);
258
258
  gpr_asprintf(&name, "tcp-server-connection:%s", addr_str);
259
259
 
260
- if (grpc_tcp_trace) {
260
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
261
261
  gpr_log(GPR_DEBUG, "SERVER_CONNECT: incoming connection: %s", addr_str);
262
262
  }
263
263
 
@@ -52,7 +52,7 @@
52
52
  #include "src/core/lib/slice/slice_string_helpers.h"
53
53
  #include "src/core/lib/support/string.h"
54
54
 
55
- int grpc_tcp_trace = 0;
55
+ grpc_tracer_flag grpc_tcp_trace = GRPC_TRACER_INITIALIZER(false);
56
56
 
57
57
  typedef struct {
58
58
  grpc_endpoint base;
@@ -159,7 +159,7 @@ static void read_callback(uv_stream_t *stream, ssize_t nread,
159
159
  sub = grpc_slice_sub_no_ref(tcp->read_slice, 0, (size_t)nread);
160
160
  grpc_slice_buffer_add(tcp->read_slices, sub);
161
161
  error = GRPC_ERROR_NONE;
162
- if (grpc_tcp_trace) {
162
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
163
163
  size_t i;
164
164
  const char *str = grpc_error_string(error);
165
165
  gpr_log(GPR_DEBUG, "read: error=%s", str);
@@ -200,7 +200,7 @@ static void uv_endpoint_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
200
200
  grpc_slice_from_static_string(uv_strerror(status)));
201
201
  grpc_closure_sched(exec_ctx, cb, error);
202
202
  }
203
- if (grpc_tcp_trace) {
203
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
204
204
  const char *str = grpc_error_string(error);
205
205
  gpr_log(GPR_DEBUG, "Initiating read on %p: error=%s", tcp, str);
206
206
  }
@@ -218,7 +218,7 @@ static void write_callback(uv_write_t *req, int status) {
218
218
  } else {
219
219
  error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Write failed");
220
220
  }
221
- if (grpc_tcp_trace) {
221
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
222
222
  const char *str = grpc_error_string(error);
223
223
  gpr_log(GPR_DEBUG, "write complete on %p: error=%s", tcp, str);
224
224
  }
@@ -239,7 +239,7 @@ static void uv_endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
239
239
  grpc_slice *slice;
240
240
  uv_write_t *write_req;
241
241
 
242
- if (grpc_tcp_trace) {
242
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
243
243
  size_t j;
244
244
 
245
245
  for (j = 0; j < write_slices->count; j++) {
@@ -348,7 +348,7 @@ grpc_endpoint *grpc_tcp_create(uv_tcp_t *handle,
348
348
  char *peer_string) {
349
349
  grpc_tcp *tcp = (grpc_tcp *)gpr_malloc(sizeof(grpc_tcp));
350
350
 
351
- if (grpc_tcp_trace) {
351
+ if (GRPC_TRACER_ON(grpc_tcp_trace)) {
352
352
  gpr_log(GPR_DEBUG, "Creating TCP endpoint %p", tcp);
353
353
  }
354
354
 
@@ -44,11 +44,12 @@
44
44
  otherwise specified.
45
45
  */
46
46
 
47
+ #include "src/core/lib/debug/trace.h"
47
48
  #include "src/core/lib/iomgr/endpoint.h"
48
49
 
49
50
  #include <uv.h>
50
51
 
51
- extern int grpc_tcp_trace;
52
+ extern grpc_tracer_flag grpc_tcp_trace;
52
53
 
53
54
  #define GRPC_TCP_DEFAULT_READ_SLICE_SIZE 8192
54
55
 
@@ -219,7 +219,7 @@ static void win_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
219
219
  tcp->read_slices = read_slices;
220
220
  grpc_slice_buffer_reset_and_unref_internal(exec_ctx, read_slices);
221
221
 
222
- tcp->read_slice = grpc_slice_malloc(8192);
222
+ tcp->read_slice = GRPC_SLICE_MALLOC(8192);
223
223
 
224
224
  buffer.len = (ULONG)GRPC_SLICE_LENGTH(
225
225
  tcp->read_slice); // we know slice size fits in 32bit.
@@ -56,8 +56,8 @@
56
56
  #define MIN_QUEUE_WINDOW_DURATION 0.01
57
57
  #define MAX_QUEUE_WINDOW_DURATION 1
58
58
 
59
- int grpc_timer_trace = 0;
60
- int grpc_timer_check_trace = 0;
59
+ grpc_tracer_flag grpc_timer_trace = GRPC_TRACER_INITIALIZER(false);
60
+ grpc_tracer_flag grpc_timer_check_trace = GRPC_TRACER_INITIALIZER(false);
61
61
 
62
62
  typedef struct {
63
63
  gpr_mu mu;
@@ -232,14 +232,13 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer,
232
232
  GPR_ASSERT(deadline.clock_type == g_clock_type);
233
233
  GPR_ASSERT(now.clock_type == g_clock_type);
234
234
  timer->closure = closure;
235
- timer->deadline = timespec_to_atm_round_up(deadline);
235
+ gpr_atm deadline_atm = timer->deadline = timespec_to_atm_round_up(deadline);
236
236
 
237
- if (grpc_timer_trace) {
237
+ if (GRPC_TRACER_ON(grpc_timer_trace)) {
238
238
  gpr_log(GPR_DEBUG, "TIMER %p: SET %" PRId64 ".%09d [%" PRIdPTR
239
239
  "] now %" PRId64 ".%09d [%" PRIdPTR "] call %p[%p]",
240
- timer, deadline.tv_sec, deadline.tv_nsec, timer->deadline,
241
- now.tv_sec, now.tv_nsec, timespec_to_atm_round_down(now), closure,
242
- closure->cb);
240
+ timer, deadline.tv_sec, deadline.tv_nsec, deadline_atm, now.tv_sec,
241
+ now.tv_nsec, timespec_to_atm_round_down(now), closure, closure->cb);
243
242
  }
244
243
 
245
244
  if (!g_shared_mutables.initialized) {
@@ -262,13 +261,13 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer,
262
261
 
263
262
  grpc_time_averaged_stats_add_sample(&shard->stats,
264
263
  ts_to_dbl(gpr_time_sub(deadline, now)));
265
- if (timer->deadline < shard->queue_deadline_cap) {
264
+ if (deadline_atm < shard->queue_deadline_cap) {
266
265
  is_first_timer = grpc_timer_heap_add(&shard->heap, timer);
267
266
  } else {
268
267
  timer->heap_index = INVALID_HEAP_INDEX;
269
268
  list_join(&shard->list, timer);
270
269
  }
271
- if (grpc_timer_trace) {
270
+ if (GRPC_TRACER_ON(grpc_timer_trace)) {
272
271
  gpr_log(GPR_DEBUG, " .. add to shard %d with queue_deadline_cap=%" PRIdPTR
273
272
  " => is_first_timer=%s",
274
273
  (int)(shard - g_shards), shard->queue_deadline_cap,
@@ -289,16 +288,16 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer,
289
288
  grpc_timer_check. */
290
289
  if (is_first_timer) {
291
290
  gpr_mu_lock(&g_shared_mutables.mu);
292
- if (grpc_timer_trace) {
291
+ if (GRPC_TRACER_ON(grpc_timer_trace)) {
293
292
  gpr_log(GPR_DEBUG, " .. old shard min_deadline=%" PRIdPTR,
294
293
  shard->min_deadline);
295
294
  }
296
- if (timer->deadline < shard->min_deadline) {
295
+ if (deadline_atm < shard->min_deadline) {
297
296
  gpr_atm old_min_deadline = g_shard_queue[0]->min_deadline;
298
- shard->min_deadline = timer->deadline;
297
+ shard->min_deadline = deadline_atm;
299
298
  note_deadline_change(shard);
300
- if (shard->shard_queue_index == 0 && timer->deadline < old_min_deadline) {
301
- gpr_atm_no_barrier_store(&g_shared_mutables.min_timer, timer->deadline);
299
+ if (shard->shard_queue_index == 0 && deadline_atm < old_min_deadline) {
300
+ gpr_atm_no_barrier_store(&g_shared_mutables.min_timer, deadline_atm);
302
301
  grpc_kick_poller();
303
302
  }
304
303
  }
@@ -319,7 +318,7 @@ void grpc_timer_cancel(grpc_exec_ctx *exec_ctx, grpc_timer *timer) {
319
318
 
320
319
  shard_type *shard = &g_shards[GPR_HASH_POINTER(timer, NUM_SHARDS)];
321
320
  gpr_mu_lock(&shard->mu);
322
- if (grpc_timer_trace) {
321
+ if (GRPC_TRACER_ON(grpc_timer_trace)) {
323
322
  gpr_log(GPR_DEBUG, "TIMER %p: CANCEL pending=%s", timer,
324
323
  timer->pending ? "true" : "false");
325
324
  }
@@ -355,7 +354,7 @@ static int refill_queue(shard_type *shard, gpr_atm now) {
355
354
  saturating_add(GPR_MAX(now, shard->queue_deadline_cap),
356
355
  (gpr_atm)(deadline_delta * 1000.0));
357
356
 
358
- if (grpc_timer_check_trace) {
357
+ if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
359
358
  gpr_log(GPR_DEBUG, " .. shard[%d]->queue_deadline_cap --> %" PRIdPTR,
360
359
  (int)(shard - g_shards), shard->queue_deadline_cap);
361
360
  }
@@ -363,7 +362,7 @@ static int refill_queue(shard_type *shard, gpr_atm now) {
363
362
  next = timer->next;
364
363
 
365
364
  if (timer->deadline < shard->queue_deadline_cap) {
366
- if (grpc_timer_check_trace) {
365
+ if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
367
366
  gpr_log(GPR_DEBUG, " .. add timer with deadline %" PRIdPTR " to heap",
368
367
  timer->deadline);
369
368
  }
@@ -380,7 +379,7 @@ static int refill_queue(shard_type *shard, gpr_atm now) {
380
379
  static grpc_timer *pop_one(shard_type *shard, gpr_atm now) {
381
380
  grpc_timer *timer;
382
381
  for (;;) {
383
- if (grpc_timer_check_trace) {
382
+ if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
384
383
  gpr_log(GPR_DEBUG, " .. shard[%d]: heap_empty=%s",
385
384
  (int)(shard - g_shards),
386
385
  grpc_timer_heap_is_empty(&shard->heap) ? "true" : "false");
@@ -390,13 +389,13 @@ static grpc_timer *pop_one(shard_type *shard, gpr_atm now) {
390
389
  if (!refill_queue(shard, now)) return NULL;
391
390
  }
392
391
  timer = grpc_timer_heap_top(&shard->heap);
393
- if (grpc_timer_check_trace) {
392
+ if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
394
393
  gpr_log(GPR_DEBUG,
395
394
  " .. check top timer deadline=%" PRIdPTR " now=%" PRIdPTR,
396
395
  timer->deadline, now);
397
396
  }
398
397
  if (timer->deadline > now) return NULL;
399
- if (grpc_timer_trace) {
398
+ if (GRPC_TRACER_ON(grpc_timer_trace)) {
400
399
  gpr_log(GPR_DEBUG, "TIMER %p: FIRE %" PRIdPTR "ms late", timer,
401
400
  now - timer->deadline);
402
401
  }
@@ -436,7 +435,7 @@ static int run_some_expired_timers(grpc_exec_ctx *exec_ctx, gpr_atm now,
436
435
  if (gpr_spinlock_trylock(&g_shared_mutables.checker_mu)) {
437
436
  gpr_mu_lock(&g_shared_mutables.mu);
438
437
 
439
- if (grpc_timer_check_trace) {
438
+ if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
440
439
  gpr_log(GPR_DEBUG, " .. shard[%d]->min_deadline = %" PRIdPTR,
441
440
  (int)(g_shard_queue[0] - g_shards),
442
441
  g_shard_queue[0]->min_deadline);
@@ -452,7 +451,7 @@ static int run_some_expired_timers(grpc_exec_ctx *exec_ctx, gpr_atm now,
452
451
  n +=
453
452
  pop_timers(exec_ctx, g_shard_queue[0], now, &new_min_deadline, error);
454
453
 
455
- if (grpc_timer_check_trace) {
454
+ if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
456
455
  gpr_log(GPR_DEBUG, " .. popped --> %" PRIdPTR
457
456
  ", shard[%d]->min_deadline %" PRIdPTR
458
457
  " --> %" PRIdPTR ", now=%" PRIdPTR,
@@ -509,7 +508,7 @@ bool grpc_timer_check(grpc_exec_ctx *exec_ctx, gpr_timespec now,
509
508
  *next =
510
509
  atm_to_timespec(GPR_MIN(timespec_to_atm_round_up(*next), min_timer));
511
510
  }
512
- if (grpc_timer_check_trace) {
511
+ if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
513
512
  gpr_log(GPR_DEBUG,
514
513
  "TIMER CHECK SKIP: now_atm=%" PRIdPTR " min_timer=%" PRIdPTR,
515
514
  now_atm, min_timer);
@@ -523,7 +522,7 @@ bool grpc_timer_check(grpc_exec_ctx *exec_ctx, gpr_timespec now,
523
522
  : GRPC_ERROR_CREATE_FROM_STATIC_STRING("Shutting down timer system");
524
523
 
525
524
  // tracing
526
- if (grpc_timer_check_trace) {
525
+ if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
527
526
  char *next_str;
528
527
  if (next == NULL) {
529
528
  next_str = gpr_strdup("NULL");
@@ -549,7 +548,7 @@ bool grpc_timer_check(grpc_exec_ctx *exec_ctx, gpr_timespec now,
549
548
  *next = atm_to_timespec(next_atm);
550
549
  }
551
550
  // tracing
552
- if (grpc_timer_check_trace) {
551
+ if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
553
552
  char *next_str;
554
553
  if (next == NULL) {
555
554
  next_str = gpr_strdup("NULL");