wearefair-grpc 1.3.1.pre.c → 1.4.0.fair

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +418 -126
  3. data/include/grpc/grpc.h +15 -69
  4. data/include/grpc/grpc_security.h +1 -1
  5. data/include/grpc/impl/codegen/compression_types.h +3 -4
  6. data/include/grpc/impl/codegen/gpr_types.h +0 -1
  7. data/include/grpc/impl/codegen/grpc_types.h +69 -3
  8. data/include/grpc/impl/codegen/port_platform.h +6 -0
  9. data/include/grpc/impl/codegen/slice.h +2 -1
  10. data/include/grpc/load_reporting.h +6 -6
  11. data/include/grpc/slice.h +25 -3
  12. data/include/grpc/slice_buffer.h +4 -0
  13. data/src/core/ext/census/context.c +1 -1
  14. data/src/core/ext/census/resource.c +3 -1
  15. data/src/core/ext/filters/client_channel/channel_connectivity.c +1 -1
  16. data/src/core/ext/filters/client_channel/client_channel.c +158 -100
  17. data/src/core/ext/filters/client_channel/client_channel_plugin.c +3 -2
  18. data/src/core/ext/filters/client_channel/lb_policy.c +2 -1
  19. data/src/core/ext/filters/client_channel/lb_policy.h +5 -6
  20. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +153 -0
  21. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +42 -0
  22. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +344 -88
  23. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +133 -0
  24. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +65 -0
  25. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +47 -5
  26. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +6 -0
  27. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +19 -8
  28. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +63 -34
  29. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +2 -1
  30. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +13 -12
  31. data/src/core/ext/filters/client_channel/lb_policy_factory.c +28 -5
  32. data/src/core/ext/filters/client_channel/lb_policy_factory.h +18 -4
  33. data/src/core/ext/filters/client_channel/parse_address.c +37 -7
  34. data/src/core/ext/filters/client_channel/parse_address.h +11 -8
  35. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c +3 -3
  36. data/src/core/ext/filters/client_channel/subchannel.c +19 -16
  37. data/src/core/ext/filters/client_channel/subchannel.h +1 -0
  38. data/src/core/ext/filters/client_channel/uri_parser.c +36 -22
  39. data/src/core/ext/filters/client_channel/uri_parser.h +1 -1
  40. data/src/core/{lib/channel → ext/filters/deadline}/deadline_filter.c +42 -17
  41. data/src/core/{lib/channel → ext/filters/deadline}/deadline_filter.h +8 -9
  42. data/src/core/{lib/channel → ext/filters/http/client}/http_client_filter.c +19 -11
  43. data/src/core/{lib/channel → ext/filters/http/client}/http_client_filter.h +3 -6
  44. data/src/core/ext/filters/http/http_filters_plugin.c +104 -0
  45. data/src/core/{lib/channel/compress_filter.c → ext/filters/http/message_compress/message_compress_filter.c} +124 -23
  46. data/src/core/{lib/channel/compress_filter.h → ext/filters/http/message_compress/message_compress_filter.h} +5 -6
  47. data/src/core/{lib/channel → ext/filters/http/server}/http_server_filter.c +4 -6
  48. data/src/core/{lib/channel → ext/filters/http/server}/http_server_filter.h +3 -3
  49. data/src/core/ext/filters/load_reporting/load_reporting.c +2 -25
  50. data/src/core/ext/filters/load_reporting/load_reporting_filter.c +26 -1
  51. data/src/core/ext/filters/max_age/max_age_filter.c +14 -14
  52. data/src/core/{lib/channel → ext/filters/message_size}/message_size_filter.c +91 -47
  53. data/src/core/{lib/channel → ext/filters/message_size}/message_size_filter.h +3 -3
  54. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +1 -1
  55. data/src/core/ext/transport/chttp2/server/chttp2_server.c +2 -2
  56. data/src/core/ext/transport/chttp2/transport/bin_decoder.c +2 -2
  57. data/src/core/ext/transport/chttp2/transport/bin_encoder.c +3 -3
  58. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +296 -172
  59. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +3 -2
  60. data/src/core/ext/transport/chttp2/transport/frame_data.c +203 -164
  61. data/src/core/ext/transport/chttp2/transport/frame_data.h +8 -14
  62. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +1 -1
  63. data/src/core/ext/transport/chttp2/transport/frame_ping.c +1 -1
  64. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +1 -1
  65. data/src/core/ext/transport/chttp2/transport/frame_settings.c +5 -5
  66. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +1 -1
  67. data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +4 -4
  68. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +2 -4
  69. data/src/core/ext/transport/chttp2/transport/hpack_table.c +4 -3
  70. data/src/core/ext/transport/chttp2/transport/internal.h +50 -33
  71. data/src/core/ext/transport/chttp2/transport/parsing.c +10 -11
  72. data/src/core/ext/transport/chttp2/transport/writing.c +32 -13
  73. data/src/core/lib/channel/channel_args.c +28 -9
  74. data/src/core/lib/channel/channel_args.h +5 -1
  75. data/src/core/lib/channel/channel_stack.c +1 -1
  76. data/src/core/lib/channel/channel_stack.h +2 -2
  77. data/src/core/lib/channel/channel_stack_builder.c +13 -1
  78. data/src/core/lib/channel/channel_stack_builder.h +5 -1
  79. data/src/core/lib/channel/connected_channel.c +3 -1
  80. data/src/core/lib/channel/context.h +2 -2
  81. data/src/core/lib/compression/message_compress.c +2 -2
  82. data/src/core/lib/debug/trace.c +13 -6
  83. data/src/core/lib/debug/trace.h +27 -1
  84. data/src/core/lib/http/httpcli.c +1 -1
  85. data/src/core/lib/http/httpcli_security_connector.c +6 -10
  86. data/src/core/lib/http/parser.c +2 -2
  87. data/src/core/lib/http/parser.h +2 -1
  88. data/src/core/lib/iomgr/combiner.c +6 -6
  89. data/src/core/lib/iomgr/combiner.h +2 -1
  90. data/src/core/lib/iomgr/error.c +12 -5
  91. data/src/core/lib/iomgr/error.h +13 -13
  92. data/src/core/lib/iomgr/ev_epoll1_linux.c +984 -0
  93. data/src/core/lib/iomgr/ev_epoll1_linux.h +44 -0
  94. data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +2146 -0
  95. data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.h +43 -0
  96. data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +1337 -0
  97. data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.h +43 -0
  98. data/src/core/lib/iomgr/ev_epollex_linux.c +1511 -0
  99. data/src/core/lib/iomgr/ev_epollex_linux.h +43 -0
  100. data/src/core/lib/iomgr/{ev_epoll_linux.c → ev_epollsig_linux.c} +24 -31
  101. data/src/core/lib/iomgr/{ev_epoll_linux.h → ev_epollsig_linux.h} +4 -4
  102. data/src/core/lib/iomgr/ev_poll_posix.c +12 -27
  103. data/src/core/lib/iomgr/ev_poll_posix.h +2 -2
  104. data/src/core/lib/iomgr/ev_posix.c +22 -8
  105. data/src/core/lib/iomgr/ev_posix.h +4 -3
  106. data/src/core/lib/iomgr/exec_ctx.c +5 -0
  107. data/src/core/lib/iomgr/exec_ctx.h +2 -0
  108. data/src/core/lib/iomgr/iomgr.c +4 -0
  109. data/src/core/lib/iomgr/iomgr.h +3 -0
  110. data/src/core/lib/iomgr/is_epollexclusive_available.c +116 -0
  111. data/src/core/lib/iomgr/is_epollexclusive_available.h +41 -0
  112. data/src/core/lib/iomgr/lockfree_event.c +16 -0
  113. data/src/core/lib/iomgr/pollset.h +2 -5
  114. data/src/core/lib/iomgr/pollset_uv.c +1 -1
  115. data/src/core/lib/iomgr/pollset_windows.c +3 -3
  116. data/src/core/lib/iomgr/resource_quota.c +9 -8
  117. data/src/core/lib/iomgr/resource_quota.h +2 -1
  118. data/src/core/lib/iomgr/sockaddr_utils.h +1 -1
  119. data/src/core/lib/iomgr/socket_mutator.h +2 -0
  120. data/src/core/lib/iomgr/sys_epoll_wrapper.h +43 -0
  121. data/src/core/lib/iomgr/tcp_client_posix.c +6 -6
  122. data/src/core/lib/iomgr/tcp_client_uv.c +3 -3
  123. data/src/core/lib/iomgr/tcp_posix.c +7 -7
  124. data/src/core/lib/iomgr/tcp_posix.h +2 -1
  125. data/src/core/lib/iomgr/tcp_server_posix.c +1 -1
  126. data/src/core/lib/iomgr/tcp_uv.c +6 -6
  127. data/src/core/lib/iomgr/tcp_uv.h +2 -1
  128. data/src/core/lib/iomgr/tcp_windows.c +1 -1
  129. data/src/core/lib/iomgr/timer_generic.c +24 -25
  130. data/src/core/lib/iomgr/timer_manager.c +276 -0
  131. data/src/core/lib/iomgr/timer_manager.h +52 -0
  132. data/src/core/lib/iomgr/timer_uv.c +6 -0
  133. data/src/core/lib/iomgr/udp_server.c +42 -9
  134. data/src/core/lib/iomgr/udp_server.h +3 -1
  135. data/src/core/lib/security/credentials/credentials.c +0 -1
  136. data/src/core/lib/security/credentials/fake/fake_credentials.c +23 -0
  137. data/src/core/lib/security/credentials/fake/fake_credentials.h +12 -9
  138. data/src/core/lib/security/credentials/google_default/google_default_credentials.c +1 -1
  139. data/src/core/lib/security/credentials/jwt/jwt_credentials.c +1 -1
  140. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +1 -1
  141. data/src/core/lib/security/credentials/ssl/ssl_credentials.c +24 -53
  142. data/src/core/lib/security/transport/client_auth_filter.c +9 -3
  143. data/src/core/lib/security/transport/secure_endpoint.c +7 -7
  144. data/src/core/lib/security/transport/secure_endpoint.h +1 -1
  145. data/src/core/lib/security/transport/security_connector.c +32 -51
  146. data/src/core/lib/security/transport/security_connector.h +10 -14
  147. data/src/core/lib/slice/b64.c +1 -1
  148. data/src/core/lib/slice/percent_encoding.c +3 -3
  149. data/src/core/lib/slice/slice.c +66 -33
  150. data/src/core/lib/slice/slice_buffer.c +25 -6
  151. data/src/core/lib/slice/slice_hash_table.c +33 -35
  152. data/src/core/lib/slice/slice_hash_table.h +7 -12
  153. data/src/core/lib/support/atomic.h +45 -0
  154. data/src/core/lib/support/atomic_with_atm.h +70 -0
  155. data/src/core/lib/support/atomic_with_std.h +48 -0
  156. data/src/core/lib/support/avl.c +14 -14
  157. data/src/core/lib/support/memory.h +74 -0
  158. data/src/core/lib/support/mpscq.c +12 -1
  159. data/src/core/lib/support/mpscq.h +4 -0
  160. data/src/core/lib/support/stack_lockfree.c +3 -36
  161. data/src/core/lib/support/time_posix.c +8 -0
  162. data/src/core/lib/support/tmpfile_posix.c +10 -10
  163. data/src/core/lib/surface/alarm.c +3 -1
  164. data/src/core/lib/surface/api_trace.c +2 -1
  165. data/src/core/lib/surface/api_trace.h +2 -2
  166. data/src/core/lib/surface/byte_buffer_reader.c +1 -1
  167. data/src/core/lib/surface/call.c +65 -22
  168. data/src/core/lib/surface/call.h +4 -2
  169. data/src/core/lib/surface/channel_init.c +2 -19
  170. data/src/core/lib/surface/channel_stack_type.c +18 -0
  171. data/src/core/lib/surface/channel_stack_type.h +2 -0
  172. data/src/core/lib/surface/completion_queue.c +249 -83
  173. data/src/core/lib/surface/completion_queue.h +18 -13
  174. data/src/core/lib/surface/completion_queue_factory.c +24 -9
  175. data/src/core/lib/surface/init.c +1 -52
  176. data/src/core/lib/surface/{lame_client.c → lame_client.cc} +37 -26
  177. data/src/core/lib/surface/server.c +50 -27
  178. data/src/core/lib/surface/server.h +2 -1
  179. data/src/core/lib/surface/version.c +2 -2
  180. data/src/core/lib/transport/bdp_estimator.c +20 -9
  181. data/src/core/lib/transport/bdp_estimator.h +5 -1
  182. data/src/core/lib/transport/byte_stream.c +23 -9
  183. data/src/core/lib/transport/byte_stream.h +15 -6
  184. data/src/core/lib/transport/connectivity_state.c +6 -6
  185. data/src/core/lib/transport/connectivity_state.h +2 -1
  186. data/src/core/lib/transport/service_config.c +6 -13
  187. data/src/core/lib/transport/service_config.h +2 -2
  188. data/src/core/lib/transport/static_metadata.c +403 -389
  189. data/src/core/lib/transport/static_metadata.h +127 -114
  190. data/src/core/plugin_registry/grpc_plugin_registry.c +12 -0
  191. data/src/core/tsi/fake_transport_security.c +5 -4
  192. data/src/core/tsi/ssl_transport_security.c +71 -82
  193. data/src/core/tsi/ssl_transport_security.h +39 -61
  194. data/src/core/tsi/transport_security.c +83 -2
  195. data/src/core/tsi/transport_security.h +27 -2
  196. data/src/core/tsi/transport_security_adapter.c +236 -0
  197. data/src/core/tsi/transport_security_adapter.h +62 -0
  198. data/src/core/tsi/transport_security_interface.h +179 -66
  199. data/src/ruby/ext/grpc/extconf.rb +2 -1
  200. data/src/ruby/ext/grpc/rb_byte_buffer.c +8 -6
  201. data/src/ruby/ext/grpc/rb_call.c +56 -48
  202. data/src/ruby/ext/grpc/rb_call.h +3 -4
  203. data/src/ruby/ext/grpc/rb_call_credentials.c +23 -22
  204. data/src/ruby/ext/grpc/rb_channel.c +45 -29
  205. data/src/ruby/ext/grpc/rb_channel_args.c +11 -9
  206. data/src/ruby/ext/grpc/rb_channel_credentials.c +16 -12
  207. data/src/ruby/ext/grpc/rb_completion_queue.c +7 -9
  208. data/src/ruby/ext/grpc/rb_compression_options.c +7 -6
  209. data/src/ruby/ext/grpc/rb_event_thread.c +10 -12
  210. data/src/ruby/ext/grpc/rb_event_thread.h +1 -2
  211. data/src/ruby/ext/grpc/rb_grpc.c +11 -15
  212. data/src/ruby/ext/grpc/rb_grpc.h +2 -2
  213. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +14 -6
  214. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +22 -10
  215. data/src/ruby/ext/grpc/rb_server.c +26 -28
  216. data/src/ruby/lib/grpc/version.rb +1 -1
  217. metadata +40 -18
  218. data/src/ruby/lib/grpc/grpc_c.bundle +0 -0
  219. data/src/ruby/lib/grpc/grpc_c.so +0 -0
@@ -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
+ #ifndef GRPC_CORE_LIB_IOMGR_EV_EPOLLEX_LINUX_H
35
+ #define GRPC_CORE_LIB_IOMGR_EV_EPOLLEX_LINUX_H
36
+
37
+ #include "src/core/lib/iomgr/ev_posix.h"
38
+ #include "src/core/lib/iomgr/port.h"
39
+
40
+ const grpc_event_engine_vtable *grpc_init_epollex_linux(
41
+ bool explicitly_requested);
42
+
43
+ #endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLLEX_LINUX_H */
@@ -36,7 +36,7 @@
36
36
  /* This polling engine is only relevant on linux kernels supporting epoll() */
37
37
  #ifdef GRPC_LINUX_EPOLL
38
38
 
39
- #include "src/core/lib/iomgr/ev_epoll_linux.h"
39
+ #include "src/core/lib/iomgr/ev_epollsig_linux.h"
40
40
 
41
41
  #include <assert.h>
42
42
  #include <errno.h>
@@ -63,11 +63,11 @@
63
63
  #include "src/core/lib/profiling/timers.h"
64
64
  #include "src/core/lib/support/block_annotate.h"
65
65
 
66
- /* TODO: sreek - Move this to init.c and initialize this like other tracers. */
67
- static int grpc_polling_trace = 0; /* Disabled by default */
68
- #define GRPC_POLLING_TRACE(fmt, ...) \
69
- if (grpc_polling_trace) { \
70
- gpr_log(GPR_INFO, (fmt), __VA_ARGS__); \
66
+ #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1)
67
+
68
+ #define GRPC_POLLING_TRACE(fmt, ...) \
69
+ if (GRPC_TRACER_ON(grpc_polling_trace)) { \
70
+ gpr_log(GPR_INFO, (fmt), __VA_ARGS__); \
71
71
  }
72
72
 
73
73
  /* Uncomment the following to enable extra checks on poll_object operations */
@@ -76,11 +76,6 @@ static int grpc_polling_trace = 0; /* Disabled by default */
76
76
  static int grpc_wakeup_signal = -1;
77
77
  static bool is_grpc_wakeup_signal_initialized = false;
78
78
 
79
- /* TODO: sreek: Right now, this wakes up all pollers. In future we should make
80
- * sure to wake up one polling thread (which can wake up other threads if
81
- * needed) */
82
- static grpc_wakeup_fd global_wakeup_fd;
83
-
84
79
  /* Implements the function defined in grpc_posix.h. This function might be
85
80
  * called before even calling grpc_init() to set either a different signal to
86
81
  * use. If signum == -1, then the use of signals is disabled */
@@ -454,8 +449,8 @@ static void polling_island_add_wakeup_fd_locked(polling_island *pi,
454
449
  gpr_asprintf(&err_msg,
455
450
  "epoll_ctl (epoll_fd: %d) add wakeup fd: %d failed with "
456
451
  "error: %d (%s)",
457
- pi->epoll_fd, GRPC_WAKEUP_FD_GET_READ_FD(&global_wakeup_fd),
458
- errno, strerror(errno));
452
+ pi->epoll_fd, GRPC_WAKEUP_FD_GET_READ_FD(wakeup_fd), errno,
453
+ strerror(errno));
459
454
  append_error(error, GRPC_OS_ERROR(errno, err_msg), err_desc);
460
455
  gpr_free(err_msg);
461
456
  }
@@ -558,7 +553,6 @@ static polling_island *polling_island_create(grpc_exec_ctx *exec_ctx,
558
553
  goto done;
559
554
  }
560
555
 
561
- polling_island_add_wakeup_fd_locked(pi, &global_wakeup_fd, error);
562
556
  polling_island_add_wakeup_fd_locked(pi, &pi->workqueue_wakeup_fd, error);
563
557
 
564
558
  if (initial_fd != NULL) {
@@ -1116,11 +1110,10 @@ static grpc_error *pollset_global_init(void) {
1116
1110
  gpr_tls_init(&g_current_thread_pollset);
1117
1111
  gpr_tls_init(&g_current_thread_worker);
1118
1112
  poller_kick_init();
1119
- return grpc_wakeup_fd_init(&global_wakeup_fd);
1113
+ return GRPC_ERROR_NONE;
1120
1114
  }
1121
1115
 
1122
1116
  static void pollset_global_shutdown(void) {
1123
- grpc_wakeup_fd_destroy(&global_wakeup_fd);
1124
1117
  gpr_tls_destroy(&g_current_thread_pollset);
1125
1118
  gpr_tls_destroy(&g_current_thread_worker);
1126
1119
  }
@@ -1226,10 +1219,6 @@ static grpc_error *pollset_kick(grpc_pollset *p,
1226
1219
  return error;
1227
1220
  }
1228
1221
 
1229
- static grpc_error *kick_poller(void) {
1230
- return grpc_wakeup_fd_wakeup(&global_wakeup_fd);
1231
- }
1232
-
1233
1222
  static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
1234
1223
  gpr_mu_init(&pollset->po.mu);
1235
1224
  *mu = &pollset->po.mu;
@@ -1332,7 +1321,7 @@ static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
1332
1321
  /* pollset_shutdown is guaranteed to be called before pollset_destroy. So other
1333
1322
  * than destroying the mutexes, there is nothing special that needs to be done
1334
1323
  * here */
1335
- static void pollset_destroy(grpc_pollset *pollset) {
1324
+ static void pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
1336
1325
  GPR_ASSERT(!pollset_has_workers(pollset));
1337
1326
  gpr_mu_destroy(&pollset->po.mu);
1338
1327
  }
@@ -1453,11 +1442,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
1453
1442
 
1454
1443
  for (int i = 0; i < ep_rv; ++i) {
1455
1444
  void *data_ptr = ep_ev[i].data.ptr;
1456
- if (data_ptr == &global_wakeup_fd) {
1457
- grpc_timer_consume_kick();
1458
- append_error(error, grpc_wakeup_fd_consume_wakeup(&global_wakeup_fd),
1459
- err_desc);
1460
- } else if (data_ptr == &pi->workqueue_wakeup_fd) {
1445
+ if (data_ptr == &pi->workqueue_wakeup_fd) {
1461
1446
  append_error(error,
1462
1447
  grpc_wakeup_fd_consume_wakeup(&pi->workqueue_wakeup_fd),
1463
1448
  err_desc);
@@ -1897,8 +1882,6 @@ static const grpc_event_engine_vtable vtable = {
1897
1882
  .pollset_set_add_fd = pollset_set_add_fd,
1898
1883
  .pollset_set_del_fd = pollset_set_del_fd,
1899
1884
 
1900
- .kick_poller = kick_poller,
1901
-
1902
1885
  .workqueue_ref = workqueue_ref,
1903
1886
  .workqueue_unref = workqueue_unref,
1904
1887
  .workqueue_scheduler = workqueue_scheduler,
@@ -1921,7 +1904,8 @@ static bool is_epoll_available() {
1921
1904
  return true;
1922
1905
  }
1923
1906
 
1924
- const grpc_event_engine_vtable *grpc_init_epoll_linux(void) {
1907
+ const grpc_event_engine_vtable *grpc_init_epollsig_linux(
1908
+ bool explicit_request) {
1925
1909
  /* If use of signals is disabled, we cannot use epoll engine*/
1926
1910
  if (is_grpc_wakeup_signal_initialized && grpc_wakeup_signal < 0) {
1927
1911
  return NULL;
@@ -1936,7 +1920,13 @@ const grpc_event_engine_vtable *grpc_init_epoll_linux(void) {
1936
1920
  }
1937
1921
 
1938
1922
  if (!is_grpc_wakeup_signal_initialized) {
1939
- grpc_use_signal(SIGRTMIN + 6);
1923
+ /* TODO(ctiller): when other epoll engines are ready, remove the true || to
1924
+ * force this to be explitly chosen if needed */
1925
+ if (true || explicit_request) {
1926
+ grpc_use_signal(SIGRTMIN + 6);
1927
+ } else {
1928
+ return NULL;
1929
+ }
1940
1930
  }
1941
1931
 
1942
1932
  fd_global_init();
@@ -1958,7 +1948,10 @@ const grpc_event_engine_vtable *grpc_init_epoll_linux(void) {
1958
1948
  #include "src/core/lib/iomgr/ev_posix.h"
1959
1949
  /* If GRPC_LINUX_EPOLL is not defined, it means epoll is not available. Return
1960
1950
  * NULL */
1961
- const grpc_event_engine_vtable *grpc_init_epoll_linux(void) { return NULL; }
1951
+ const grpc_event_engine_vtable *grpc_init_epollsig_linux(
1952
+ bool explicit_request) {
1953
+ return NULL;
1954
+ }
1962
1955
  #endif /* defined(GRPC_POSIX_SOCKET) */
1963
1956
 
1964
1957
  void grpc_use_signal(int signum) {}
@@ -31,13 +31,13 @@
31
31
  *
32
32
  */
33
33
 
34
- #ifndef GRPC_CORE_LIB_IOMGR_EV_EPOLL_LINUX_H
35
- #define GRPC_CORE_LIB_IOMGR_EV_EPOLL_LINUX_H
34
+ #ifndef GRPC_CORE_LIB_IOMGR_EV_EPOLLSIG_LINUX_H
35
+ #define GRPC_CORE_LIB_IOMGR_EV_EPOLLSIG_LINUX_H
36
36
 
37
37
  #include "src/core/lib/iomgr/ev_posix.h"
38
38
  #include "src/core/lib/iomgr/port.h"
39
39
 
40
- const grpc_event_engine_vtable *grpc_init_epoll_linux(void);
40
+ const grpc_event_engine_vtable *grpc_init_epollsig_linux(bool explicit_request);
41
41
 
42
42
  #ifdef GRPC_LINUX_EPOLL
43
43
  void *grpc_fd_get_polling_island(grpc_fd *fd);
@@ -45,4 +45,4 @@ void *grpc_pollset_get_polling_island(grpc_pollset *ps);
45
45
  bool grpc_are_polling_islands_equal(void *p, void *q);
46
46
  #endif /* defined(GRPC_LINUX_EPOLL) */
47
47
 
48
- #endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLL_LINUX_H */
48
+ #endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLLSIG_LINUX_H */
@@ -58,6 +58,8 @@
58
58
  #include "src/core/lib/profiling/timers.h"
59
59
  #include "src/core/lib/support/block_annotate.h"
60
60
 
61
+ #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1)
62
+
61
63
  /*******************************************************************************
62
64
  * FD declarations
63
65
  */
@@ -122,8 +124,6 @@ struct grpc_fd {
122
124
  grpc_pollset *read_notifier_pollset;
123
125
  };
124
126
 
125
- static grpc_wakeup_fd global_wakeup_fd;
126
-
127
127
  /* Begin polling on an fd.
128
128
  Registers that the given pollset is interested in this fd - so that if read
129
129
  or writability interest changes, the pollset can be kicked to pick up that
@@ -784,19 +784,14 @@ static grpc_error *pollset_kick(grpc_pollset *p,
784
784
  static grpc_error *pollset_global_init(void) {
785
785
  gpr_tls_init(&g_current_thread_poller);
786
786
  gpr_tls_init(&g_current_thread_worker);
787
- return grpc_wakeup_fd_init(&global_wakeup_fd);
787
+ return GRPC_ERROR_NONE;
788
788
  }
789
789
 
790
790
  static void pollset_global_shutdown(void) {
791
- grpc_wakeup_fd_destroy(&global_wakeup_fd);
792
791
  gpr_tls_destroy(&g_current_thread_poller);
793
792
  gpr_tls_destroy(&g_current_thread_worker);
794
793
  }
795
794
 
796
- static grpc_error *kick_poller(void) {
797
- return grpc_wakeup_fd_wakeup(&global_wakeup_fd);
798
- }
799
-
800
795
  /* main interface */
801
796
 
802
797
  static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
@@ -815,7 +810,7 @@ static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
815
810
  pollset->pollset_set_count = 0;
816
811
  }
817
812
 
818
- static void pollset_destroy(grpc_pollset *pollset) {
813
+ static void pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
819
814
  GPR_ASSERT(!pollset_has_workers(pollset));
820
815
  GPR_ASSERT(pollset->idle_jobs.head == pollset->idle_jobs.tail);
821
816
  while (pollset->local_wakeup_cache) {
@@ -952,13 +947,10 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
952
947
  }
953
948
 
954
949
  fd_count = 0;
955
- pfd_count = 2;
956
- pfds[0].fd = GRPC_WAKEUP_FD_GET_READ_FD(&global_wakeup_fd);
950
+ pfd_count = 1;
951
+ pfds[0].fd = GRPC_WAKEUP_FD_GET_READ_FD(&worker.wakeup_fd->fd);
957
952
  pfds[0].events = POLLIN;
958
953
  pfds[0].revents = 0;
959
- pfds[1].fd = GRPC_WAKEUP_FD_GET_READ_FD(&worker.wakeup_fd->fd);
960
- pfds[1].events = POLLIN;
961
- pfds[1].revents = 0;
962
954
  for (i = 0; i < pollset->fd_count; i++) {
963
955
  if (fd_is_orphaned(pollset->fds[i])) {
964
956
  GRPC_FD_UNREF(pollset->fds[i], "multipoller");
@@ -974,7 +966,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
974
966
  pollset->fd_count = fd_count;
975
967
  gpr_mu_unlock(&pollset->mu);
976
968
 
977
- for (i = 2; i < pfd_count; i++) {
969
+ for (i = 1; i < pfd_count; i++) {
978
970
  grpc_fd *fd = watchers[i].fd;
979
971
  pfds[i].events = (short)fd_begin_poll(fd, pollset, &worker, POLLIN,
980
972
  POLLOUT, &watchers[i]);
@@ -992,7 +984,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
992
984
  work_combine_error(&error, GRPC_OS_ERROR(errno, "poll"));
993
985
  }
994
986
 
995
- for (i = 2; i < pfd_count; i++) {
987
+ for (i = 1; i < pfd_count; i++) {
996
988
  if (watchers[i].fd == NULL) {
997
989
  fd_end_poll(exec_ctx, &watchers[i], 0, 0, NULL);
998
990
  } else {
@@ -1002,20 +994,15 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
1002
994
  }
1003
995
  }
1004
996
  } else if (r == 0) {
1005
- for (i = 2; i < pfd_count; i++) {
997
+ for (i = 1; i < pfd_count; i++) {
1006
998
  fd_end_poll(exec_ctx, &watchers[i], 0, 0, NULL);
1007
999
  }
1008
1000
  } else {
1009
1001
  if (pfds[0].revents & POLLIN_CHECK) {
1010
- grpc_timer_consume_kick();
1011
- work_combine_error(&error,
1012
- grpc_wakeup_fd_consume_wakeup(&global_wakeup_fd));
1013
- }
1014
- if (pfds[1].revents & POLLIN_CHECK) {
1015
1002
  work_combine_error(
1016
1003
  &error, grpc_wakeup_fd_consume_wakeup(&worker.wakeup_fd->fd));
1017
1004
  }
1018
- for (i = 2; i < pfd_count; i++) {
1005
+ for (i = 1; i < pfd_count; i++) {
1019
1006
  if (watchers[i].fd == NULL) {
1020
1007
  fd_end_poll(exec_ctx, &watchers[i], 0, 0, NULL);
1021
1008
  } else {
@@ -1560,8 +1547,6 @@ static const grpc_event_engine_vtable vtable = {
1560
1547
  .pollset_set_add_fd = pollset_set_add_fd,
1561
1548
  .pollset_set_del_fd = pollset_set_del_fd,
1562
1549
 
1563
- .kick_poller = kick_poller,
1564
-
1565
1550
  .workqueue_ref = workqueue_ref,
1566
1551
  .workqueue_unref = workqueue_unref,
1567
1552
  .workqueue_scheduler = workqueue_scheduler,
@@ -1569,7 +1554,7 @@ static const grpc_event_engine_vtable vtable = {
1569
1554
  .shutdown_engine = shutdown_engine,
1570
1555
  };
1571
1556
 
1572
- const grpc_event_engine_vtable *grpc_init_poll_posix(void) {
1557
+ const grpc_event_engine_vtable *grpc_init_poll_posix(bool explicit_request) {
1573
1558
  if (!grpc_has_wakeup_fd()) {
1574
1559
  return NULL;
1575
1560
  }
@@ -1579,7 +1564,7 @@ const grpc_event_engine_vtable *grpc_init_poll_posix(void) {
1579
1564
  return &vtable;
1580
1565
  }
1581
1566
 
1582
- const grpc_event_engine_vtable *grpc_init_poll_cv_posix(void) {
1567
+ const grpc_event_engine_vtable *grpc_init_poll_cv_posix(bool explicit_request) {
1583
1568
  global_cv_fd_table_init();
1584
1569
  grpc_enable_cv_wakeup_fds(1);
1585
1570
  if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {
@@ -36,7 +36,7 @@
36
36
 
37
37
  #include "src/core/lib/iomgr/ev_posix.h"
38
38
 
39
- const grpc_event_engine_vtable *grpc_init_poll_posix(void);
40
- const grpc_event_engine_vtable *grpc_init_poll_cv_posix(void);
39
+ const grpc_event_engine_vtable *grpc_init_poll_posix(bool explicit_request);
40
+ const grpc_event_engine_vtable *grpc_init_poll_cv_posix(bool explicit_request);
41
41
 
42
42
  #endif /* GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H */
@@ -44,10 +44,18 @@
44
44
  #include <grpc/support/string_util.h>
45
45
  #include <grpc/support/useful.h>
46
46
 
47
- #include "src/core/lib/iomgr/ev_epoll_linux.h"
47
+ #include "src/core/lib/debug/trace.h"
48
+ #include "src/core/lib/iomgr/ev_epoll1_linux.h"
49
+ #include "src/core/lib/iomgr/ev_epoll_limited_pollers_linux.h"
50
+ #include "src/core/lib/iomgr/ev_epoll_thread_pool_linux.h"
51
+ #include "src/core/lib/iomgr/ev_epollex_linux.h"
52
+ #include "src/core/lib/iomgr/ev_epollsig_linux.h"
48
53
  #include "src/core/lib/iomgr/ev_poll_posix.h"
49
54
  #include "src/core/lib/support/env.h"
50
55
 
56
+ grpc_tracer_flag grpc_polling_trace =
57
+ GRPC_TRACER_INITIALIZER(false); /* Disabled by default */
58
+
51
59
  /** Default poll() function - a pointer so that it can be overridden by some
52
60
  * tests */
53
61
  grpc_poll_function_type grpc_poll_function = poll;
@@ -57,7 +65,8 @@ grpc_wakeup_fd grpc_global_wakeup_fd;
57
65
  static const grpc_event_engine_vtable *g_event_engine;
58
66
  static const char *g_poll_strategy_name = NULL;
59
67
 
60
- typedef const grpc_event_engine_vtable *(*event_engine_factory_fn)(void);
68
+ typedef const grpc_event_engine_vtable *(*event_engine_factory_fn)(
69
+ bool explicit_request);
61
70
 
62
71
  typedef struct {
63
72
  const char *name;
@@ -65,7 +74,11 @@ typedef struct {
65
74
  } event_engine_factory;
66
75
 
67
76
  static const event_engine_factory g_factories[] = {
68
- {"epoll", grpc_init_epoll_linux},
77
+ {"epollex", grpc_init_epollex_linux},
78
+ {"epollsig", grpc_init_epollsig_linux},
79
+ {"epoll1", grpc_init_epoll1_linux},
80
+ {"epoll-threadpool", grpc_init_epoll_thread_pool_linux},
81
+ {"epoll-limited", grpc_init_epoll_limited_pollers_linux},
69
82
  {"poll", grpc_init_poll_posix},
70
83
  {"poll-cv", grpc_init_poll_cv_posix},
71
84
  };
@@ -102,7 +115,8 @@ static bool is(const char *want, const char *have) {
102
115
  static void try_engine(const char *engine) {
103
116
  for (size_t i = 0; i < GPR_ARRAY_SIZE(g_factories); i++) {
104
117
  if (is(engine, g_factories[i].name)) {
105
- if ((g_event_engine = g_factories[i].factory())) {
118
+ if ((g_event_engine = g_factories[i].factory(
119
+ 0 == strcmp(engine, g_factories[i].name)))) {
106
120
  g_poll_strategy_name = g_factories[i].name;
107
121
  gpr_log(GPR_DEBUG, "Using polling engine: %s", g_factories[i].name);
108
122
  return;
@@ -121,6 +135,8 @@ void grpc_set_event_engine_test_only(
121
135
  const char *grpc_get_poll_strategy_name() { return g_poll_strategy_name; }
122
136
 
123
137
  void grpc_event_engine_init(void) {
138
+ grpc_register_tracer("polling", &grpc_polling_trace);
139
+
124
140
  char *s = gpr_getenv("GRPC_POLL_STRATEGY");
125
141
  if (s == NULL) {
126
142
  s = gpr_strdup("all");
@@ -197,8 +213,8 @@ void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
197
213
  g_event_engine->pollset_shutdown(exec_ctx, pollset, closure);
198
214
  }
199
215
 
200
- void grpc_pollset_destroy(grpc_pollset *pollset) {
201
- g_event_engine->pollset_destroy(pollset);
216
+ void grpc_pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
217
+ g_event_engine->pollset_destroy(exec_ctx, pollset);
202
218
  }
203
219
 
204
220
  grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
@@ -260,8 +276,6 @@ void grpc_pollset_set_del_fd(grpc_exec_ctx *exec_ctx,
260
276
  g_event_engine->pollset_set_del_fd(exec_ctx, pollset_set, fd);
261
277
  }
262
278
 
263
- grpc_error *grpc_kick_poller(void) { return g_event_engine->kick_poller(); }
264
-
265
279
  #ifdef GRPC_WORKQUEUE_REFCOUNT_DEBUG
266
280
  grpc_workqueue *grpc_workqueue_ref(grpc_workqueue *workqueue, const char *file,
267
281
  int line, const char *reason) {
@@ -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