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,12 +36,15 @@
36
36
 
37
37
  #include <poll.h>
38
38
 
39
+ #include "src/core/lib/debug/trace.h"
39
40
  #include "src/core/lib/iomgr/exec_ctx.h"
40
41
  #include "src/core/lib/iomgr/pollset.h"
41
42
  #include "src/core/lib/iomgr/pollset_set.h"
42
43
  #include "src/core/lib/iomgr/wakeup_fd_posix.h"
43
44
  #include "src/core/lib/iomgr/workqueue.h"
44
45
 
46
+ extern grpc_tracer_flag grpc_polling_trace; /* Disabled by default */
47
+
45
48
  typedef struct grpc_fd grpc_fd;
46
49
 
47
50
  typedef struct grpc_event_engine_vtable {
@@ -64,7 +67,7 @@ typedef struct grpc_event_engine_vtable {
64
67
  void (*pollset_init)(grpc_pollset *pollset, gpr_mu **mu);
65
68
  void (*pollset_shutdown)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
66
69
  grpc_closure *closure);
67
- void (*pollset_destroy)(grpc_pollset *pollset);
70
+ void (*pollset_destroy)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset);
68
71
  grpc_error *(*pollset_work)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
69
72
  grpc_pollset_worker **worker, gpr_timespec now,
70
73
  gpr_timespec deadline);
@@ -93,8 +96,6 @@ typedef struct grpc_event_engine_vtable {
93
96
  void (*pollset_set_del_fd)(grpc_exec_ctx *exec_ctx,
94
97
  grpc_pollset_set *pollset_set, grpc_fd *fd);
95
98
 
96
- grpc_error *(*kick_poller)(void);
97
-
98
99
  void (*shutdown_engine)(void);
99
100
 
100
101
  #ifdef GRPC_WORKQUEUE_REFCOUNT_DEBUG
@@ -0,0 +1,43 @@
1
+ /*
2
+ *
3
+ * Copyright 2015, 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
+ #include "src/core/lib/iomgr/port.h"
35
+
36
+ #ifdef GRPC_WINSOCK_SOCKET
37
+
38
+ #include "src/core/lib/debug/trace.h"
39
+
40
+ grpc_tracer_flag grpc_polling_trace =
41
+ GRPC_TRACER_INITIALIZER(false); /* Disabled by default */
42
+
43
+ #endif // GRPC_WINSOCK_SOCKET
@@ -62,6 +62,11 @@ bool grpc_always_ready_to_finish(grpc_exec_ctx *exec_ctx, void *arg_ignored) {
62
62
  return true;
63
63
  }
64
64
 
65
+ bool grpc_exec_ctx_has_work(grpc_exec_ctx *exec_ctx) {
66
+ return exec_ctx->active_combiner != NULL ||
67
+ !grpc_closure_list_empty(exec_ctx->closure_list);
68
+ }
69
+
65
70
  bool grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) {
66
71
  bool did_something = 0;
67
72
  GPR_TIMER_BEGIN("grpc_exec_ctx_flush", 0);
@@ -93,6 +93,8 @@ struct grpc_exec_ctx {
93
93
 
94
94
  extern grpc_closure_scheduler *grpc_schedule_on_exec_ctx;
95
95
 
96
+ bool grpc_exec_ctx_has_work(grpc_exec_ctx *exec_ctx);
97
+
96
98
  /** Flush any work that has been enqueued onto this grpc_exec_ctx.
97
99
  * Caller must guarantee that no interfering locks are held.
98
100
  * Returns true if work was performed, false otherwise. */
@@ -47,6 +47,7 @@
47
47
  #include "src/core/lib/iomgr/iomgr_internal.h"
48
48
  #include "src/core/lib/iomgr/network_status_tracker.h"
49
49
  #include "src/core/lib/iomgr/timer.h"
50
+ #include "src/core/lib/iomgr/timer_manager.h"
50
51
  #include "src/core/lib/support/env.h"
51
52
  #include "src/core/lib/support/string.h"
52
53
 
@@ -67,6 +68,8 @@ void grpc_iomgr_init(void) {
67
68
  grpc_iomgr_platform_init();
68
69
  }
69
70
 
71
+ void grpc_iomgr_start(void) { grpc_timer_manager_init(); }
72
+
70
73
  static size_t count_objects(void) {
71
74
  grpc_iomgr_object *obj;
72
75
  size_t n = 0;
@@ -88,6 +91,7 @@ void grpc_iomgr_shutdown(grpc_exec_ctx *exec_ctx) {
88
91
  gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(10, GPR_TIMESPAN));
89
92
  gpr_timespec last_warning_time = gpr_now(GPR_CLOCK_REALTIME);
90
93
 
94
+ grpc_timer_manager_shutdown();
91
95
  grpc_iomgr_platform_flush();
92
96
 
93
97
  gpr_mu_lock(&g_mu);
@@ -40,6 +40,9 @@
40
40
  /** Initializes the iomgr. */
41
41
  void grpc_iomgr_init(void);
42
42
 
43
+ /** Starts any background threads for iomgr. */
44
+ void grpc_iomgr_start(void);
45
+
43
46
  /** Signals the intention to shutdown the iomgr. Expects to be able to flush
44
47
  * exec_ctx. */
45
48
  void grpc_iomgr_shutdown(grpc_exec_ctx *exec_ctx);
@@ -0,0 +1,116 @@
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
+ #include "src/core/lib/iomgr/port.h"
35
+
36
+ #include "src/core/lib/iomgr/is_epollexclusive_available.h"
37
+
38
+ #ifdef GRPC_LINUX_EPOLL
39
+
40
+ #include <grpc/support/log.h>
41
+
42
+ #include <errno.h>
43
+ #include <sys/eventfd.h>
44
+ #include <unistd.h>
45
+
46
+ #include "src/core/lib/iomgr/sys_epoll_wrapper.h"
47
+
48
+ /* This polling engine is only relevant on linux kernels supporting epoll() */
49
+ bool grpc_is_epollexclusive_available(void) {
50
+ static bool logged_why_not = false;
51
+
52
+ int fd = epoll_create1(EPOLL_CLOEXEC);
53
+ if (fd < 0) {
54
+ if (!logged_why_not) {
55
+ gpr_log(GPR_ERROR,
56
+ "epoll_create1 failed with error: %d. Not using epollex polling "
57
+ "engine.",
58
+ fd);
59
+ logged_why_not = true;
60
+ }
61
+ return false;
62
+ }
63
+ int evfd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
64
+ if (evfd < 0) {
65
+ if (!logged_why_not) {
66
+ gpr_log(GPR_ERROR,
67
+ "eventfd failed with error: %d. Not using epollex polling "
68
+ "engine.",
69
+ fd);
70
+ logged_why_not = true;
71
+ }
72
+ close(fd);
73
+ return false;
74
+ }
75
+ struct epoll_event ev = {
76
+ /* choose events that should cause an error on
77
+ EPOLLEXCLUSIVE enabled kernels - specifically the combination of
78
+ EPOLLONESHOT and EPOLLEXCLUSIVE */
79
+ .events = (uint32_t)(EPOLLET | EPOLLIN | EPOLLEXCLUSIVE | EPOLLONESHOT),
80
+ .data.ptr = NULL};
81
+ if (epoll_ctl(fd, EPOLL_CTL_ADD, evfd, &ev) != 0) {
82
+ if (errno != EINVAL) {
83
+ if (!logged_why_not) {
84
+ gpr_log(
85
+ GPR_ERROR,
86
+ "epoll_ctl with EPOLLEXCLUSIVE | EPOLLONESHOT failed with error: "
87
+ "%d. Not using epollex polling engine.",
88
+ errno);
89
+ logged_why_not = true;
90
+ }
91
+ close(fd);
92
+ close(evfd);
93
+ return false;
94
+ }
95
+ } else {
96
+ if (!logged_why_not) {
97
+ gpr_log(GPR_ERROR,
98
+ "epoll_ctl with EPOLLEXCLUSIVE | EPOLLONESHOT succeeded. This is "
99
+ "evidence of no EPOLLEXCLUSIVE support. Not using "
100
+ "epollex polling engine.");
101
+ logged_why_not = true;
102
+ }
103
+ close(fd);
104
+ close(evfd);
105
+ return false;
106
+ }
107
+ close(evfd);
108
+ close(fd);
109
+ return true;
110
+ }
111
+
112
+ #else
113
+
114
+ bool grpc_is_epollexclusive_available(void) { return false; }
115
+
116
+ #endif
@@ -0,0 +1,41 @@
1
+ /*
2
+ *
3
+ * Copyright 2015, 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_IS_EPOLLEXCLUSIVE_AVAILABLE_H
35
+ #define GRPC_CORE_LIB_IOMGR_IS_EPOLLEXCLUSIVE_AVAILABLE_H
36
+
37
+ #include <stdbool.h>
38
+
39
+ bool grpc_is_epollexclusive_available(void);
40
+
41
+ #endif /* GRPC_CORE_LIB_IOMGR_IS_EPOLLEXCLUSIVE_AVAILABLE_H */
@@ -35,6 +35,10 @@
35
35
 
36
36
  #include <grpc/support/log.h>
37
37
 
38
+ #include "src/core/lib/debug/trace.h"
39
+
40
+ extern grpc_tracer_flag grpc_polling_trace;
41
+
38
42
  /* 'state' holds the to call when the fd is readable or writable respectively.
39
43
  It can contain one of the following values:
40
44
  CLOSURE_READY : The fd has an I/O event of interest but there is no
@@ -93,6 +97,10 @@ void grpc_lfev_notify_on(grpc_exec_ctx *exec_ctx, gpr_atm *state,
93
97
  grpc_closure *closure) {
94
98
  while (true) {
95
99
  gpr_atm curr = gpr_atm_no_barrier_load(state);
100
+ if (GRPC_TRACER_ON(grpc_polling_trace)) {
101
+ gpr_log(GPR_DEBUG, "lfev_notify_on: %p curr=%p closure=%p", state,
102
+ (void *)curr, closure);
103
+ }
96
104
  switch (curr) {
97
105
  case CLOSURE_NOT_READY: {
98
106
  /* CLOSURE_NOT_READY -> <closure>.
@@ -155,6 +163,10 @@ bool grpc_lfev_set_shutdown(grpc_exec_ctx *exec_ctx, gpr_atm *state,
155
163
 
156
164
  while (true) {
157
165
  gpr_atm curr = gpr_atm_no_barrier_load(state);
166
+ if (GRPC_TRACER_ON(grpc_polling_trace)) {
167
+ gpr_log(GPR_DEBUG, "lfev_set_shutdown: %p curr=%p err=%s", state,
168
+ (void *)curr, grpc_error_string(shutdown_err));
169
+ }
158
170
  switch (curr) {
159
171
  case CLOSURE_READY:
160
172
  case CLOSURE_NOT_READY:
@@ -200,6 +212,10 @@ void grpc_lfev_set_ready(grpc_exec_ctx *exec_ctx, gpr_atm *state) {
200
212
  while (true) {
201
213
  gpr_atm curr = gpr_atm_no_barrier_load(state);
202
214
 
215
+ if (GRPC_TRACER_ON(grpc_polling_trace)) {
216
+ gpr_log(GPR_DEBUG, "lfev_set_ready: %p curr=%p", state, (void *)curr);
217
+ }
218
+
203
219
  switch (curr) {
204
220
  case CLOSURE_READY: {
205
221
  /* Already ready. We are done here */
@@ -40,8 +40,6 @@
40
40
 
41
41
  #include "src/core/lib/iomgr/exec_ctx.h"
42
42
 
43
- #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1)
44
-
45
43
  /* A grpc_pollset is a set of file descriptors that a higher level item is
46
44
  interested in. For example:
47
45
  - a server will typically keep a pollset containing all connected channels,
@@ -59,7 +57,7 @@ void grpc_pollset_init(grpc_pollset *pollset, gpr_mu **mu);
59
57
  * pollset's mutex must be held */
60
58
  void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
61
59
  grpc_closure *closure);
62
- void grpc_pollset_destroy(grpc_pollset *pollset);
60
+ void grpc_pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset);
63
61
 
64
62
  /* Do some work on a pollset.
65
63
  May involve invoking asynchronous callbacks, or actually polling file
@@ -88,8 +86,7 @@ grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
88
86
  gpr_timespec deadline) GRPC_MUST_USE_RESULT;
89
87
 
90
88
  /* Break one polling thread out of polling work for this pollset.
91
- If specific_worker is GRPC_POLLSET_KICK_BROADCAST, kick ALL the workers.
92
- Otherwise, if specific_worker is non-NULL, then kick that worker. */
89
+ If specific_worker is non-NULL, then kick that worker. */
93
90
  grpc_error *grpc_pollset_kick(grpc_pollset *pollset,
94
91
  grpc_pollset_worker *specific_worker)
95
92
  GRPC_MUST_USE_RESULT;
@@ -106,7 +106,7 @@ void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
106
106
  grpc_closure_sched(exec_ctx, closure, GRPC_ERROR_NONE);
107
107
  }
108
108
 
109
- void grpc_pollset_destroy(grpc_pollset *pollset) {
109
+ void grpc_pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
110
110
  uv_close((uv_handle_t *)&pollset->timer, timer_close_cb);
111
111
  // timer.data is a boolean indicating that the timer has finished closing
112
112
  pollset->timer.data = (void *)0;
@@ -43,6 +43,8 @@
43
43
  #include "src/core/lib/iomgr/pollset.h"
44
44
  #include "src/core/lib/iomgr/pollset_windows.h"
45
45
 
46
+ #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1)
47
+
46
48
  gpr_mu grpc_polling_mu;
47
49
  static grpc_pollset_worker *g_active_poller;
48
50
  static grpc_pollset_worker g_global_root_worker;
@@ -114,7 +116,7 @@ void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
114
116
  }
115
117
  }
116
118
 
117
- void grpc_pollset_destroy(grpc_pollset *pollset) {}
119
+ void grpc_pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {}
118
120
 
119
121
  grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
120
122
  grpc_pollset_worker **worker_hdl,
@@ -227,6 +229,4 @@ grpc_error *grpc_pollset_kick(grpc_pollset *p,
227
229
  return GRPC_ERROR_NONE;
228
230
  }
229
231
 
230
- void grpc_kick_poller(void) { grpc_iocp_kick(); }
231
-
232
232
  #endif /* GRPC_WINSOCK_SOCKET */
@@ -44,7 +44,7 @@
44
44
 
45
45
  #include "src/core/lib/iomgr/combiner.h"
46
46
 
47
- int grpc_resource_quota_trace = 0;
47
+ grpc_tracer_flag grpc_resource_quota_trace = GRPC_TRACER_INITIALIZER(false);
48
48
 
49
49
  #define MEMORY_USAGE_ESTIMATION_MAX 65536
50
50
 
@@ -307,13 +307,14 @@ static bool rq_alloc(grpc_exec_ctx *exec_ctx,
307
307
  resource_user->free_pool = 0;
308
308
  resource_quota->free_pool -= amt;
309
309
  rq_update_estimate(resource_quota);
310
- if (grpc_resource_quota_trace) {
310
+ if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
311
311
  gpr_log(GPR_DEBUG, "RQ %s %s: grant alloc %" PRId64
312
312
  " bytes; rq_free_pool -> %" PRId64,
313
313
  resource_quota->name, resource_user->name, amt,
314
314
  resource_quota->free_pool);
315
315
  }
316
- } else if (grpc_resource_quota_trace && resource_user->free_pool >= 0) {
316
+ } else if (GRPC_TRACER_ON(grpc_resource_quota_trace) &&
317
+ resource_user->free_pool >= 0) {
317
318
  gpr_log(GPR_DEBUG, "RQ %s %s: discard already satisfied alloc request",
318
319
  resource_quota->name, resource_user->name);
319
320
  }
@@ -342,7 +343,7 @@ static bool rq_reclaim_from_per_user_free_pool(
342
343
  resource_user->free_pool = 0;
343
344
  resource_quota->free_pool += amt;
344
345
  rq_update_estimate(resource_quota);
345
- if (grpc_resource_quota_trace) {
346
+ if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
346
347
  gpr_log(GPR_DEBUG, "RQ %s %s: reclaim_from_per_user_free_pool %" PRId64
347
348
  " bytes; rq_free_pool -> %" PRId64,
348
349
  resource_quota->name, resource_user->name, amt,
@@ -365,7 +366,7 @@ static bool rq_reclaim(grpc_exec_ctx *exec_ctx,
365
366
  : GRPC_RULIST_RECLAIMER_BENIGN;
366
367
  grpc_resource_user *resource_user = rulist_pop_head(resource_quota, list);
367
368
  if (resource_user == NULL) return false;
368
- if (grpc_resource_quota_trace) {
369
+ if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
369
370
  gpr_log(GPR_DEBUG, "RQ %s %s: initiate %s reclamation",
370
371
  resource_quota->name, resource_user->name,
371
372
  destructive ? "destructive" : "benign");
@@ -786,7 +787,7 @@ void grpc_resource_user_alloc(grpc_exec_ctx *exec_ctx,
786
787
  gpr_mu_lock(&resource_user->mu);
787
788
  ru_ref_by(resource_user, (gpr_atm)size);
788
789
  resource_user->free_pool -= (int64_t)size;
789
- if (grpc_resource_quota_trace) {
790
+ if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
790
791
  gpr_log(GPR_DEBUG, "RQ %s %s: alloc %" PRIdPTR "; free_pool -> %" PRId64,
791
792
  resource_user->resource_quota->name, resource_user->name, size,
792
793
  resource_user->free_pool);
@@ -810,7 +811,7 @@ void grpc_resource_user_free(grpc_exec_ctx *exec_ctx,
810
811
  gpr_mu_lock(&resource_user->mu);
811
812
  bool was_zero_or_negative = resource_user->free_pool <= 0;
812
813
  resource_user->free_pool += (int64_t)size;
813
- if (grpc_resource_quota_trace) {
814
+ if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
814
815
  gpr_log(GPR_DEBUG, "RQ %s %s: free %" PRIdPTR "; free_pool -> %" PRId64,
815
816
  resource_user->resource_quota->name, resource_user->name, size,
816
817
  resource_user->free_pool);
@@ -839,7 +840,7 @@ void grpc_resource_user_post_reclaimer(grpc_exec_ctx *exec_ctx,
839
840
 
840
841
  void grpc_resource_user_finish_reclamation(grpc_exec_ctx *exec_ctx,
841
842
  grpc_resource_user *resource_user) {
842
- if (grpc_resource_quota_trace) {
843
+ if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
843
844
  gpr_log(GPR_DEBUG, "RQ %s %s: reclamation complete",
844
845
  resource_user->resource_quota->name, resource_user->name);
845
846
  }