grpc 1.20.0 → 1.21.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 (209) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +500 -29
  3. data/etc/roots.pem +146 -0
  4. data/include/grpc/grpc_security.h +1 -1
  5. data/include/grpc/impl/codegen/grpc_types.h +10 -7
  6. data/include/grpc/impl/codegen/port_platform.h +11 -1
  7. data/include/grpc/impl/codegen/slice.h +1 -21
  8. data/include/grpc/impl/codegen/status.h +2 -1
  9. data/include/grpc/slice.h +1 -1
  10. data/src/core/ext/filters/client_channel/backup_poller.cc +19 -13
  11. data/src/core/ext/filters/client_channel/backup_poller.h +3 -0
  12. data/src/core/ext/filters/client_channel/channel_connectivity.cc +1 -1
  13. data/src/core/ext/filters/client_channel/client_channel.cc +2084 -1673
  14. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +2 -3
  15. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +4 -0
  16. data/src/core/ext/filters/client_channel/health/health_check_client.cc +54 -49
  17. data/src/core/ext/filters/client_channel/health/health_check_client.h +20 -9
  18. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -2
  19. data/src/core/ext/filters/client_channel/http_connect_handshaker.h +1 -1
  20. data/src/core/ext/filters/client_channel/lb_policy.cc +3 -30
  21. data/src/core/ext/filters/client_channel/lb_policy.h +16 -25
  22. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +106 -81
  23. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +6 -2
  24. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +8 -12
  25. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +2 -2
  26. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +1 -1
  27. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +57 -49
  28. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +47 -41
  29. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +24 -20
  30. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +989 -284
  31. data/src/core/ext/filters/client_channel/lb_policy_factory.h +4 -1
  32. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +105 -2
  33. data/src/core/ext/filters/client_channel/lb_policy_registry.h +9 -2
  34. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +79 -36
  35. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +84 -2
  36. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +3 -0
  37. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +179 -0
  38. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +15 -3
  39. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +80 -4
  40. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +7 -13
  41. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +2 -2
  42. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +39 -0
  43. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +0 -6
  44. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +2 -64
  45. data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc +28 -0
  46. data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h +29 -0
  47. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +4 -4
  48. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +367 -232
  49. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +55 -76
  50. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +50 -39
  51. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +18 -12
  52. data/src/core/ext/filters/client_channel/service_config.cc +247 -27
  53. data/src/core/ext/filters/client_channel/service_config.h +119 -166
  54. data/src/core/ext/filters/client_channel/subchannel.cc +46 -84
  55. data/src/core/ext/filters/client_channel/subchannel.h +7 -7
  56. data/src/core/ext/filters/deadline/deadline_filter.cc +3 -4
  57. data/src/core/ext/filters/deadline/deadline_filter.h +3 -2
  58. data/src/core/ext/filters/http/client/http_client_filter.cc +7 -5
  59. data/src/core/ext/filters/http/client/http_client_filter.h +1 -1
  60. data/src/core/ext/filters/http/client_authority_filter.cc +1 -1
  61. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +4 -3
  62. data/src/core/ext/filters/http/server/http_server_filter.cc +18 -12
  63. data/src/core/ext/filters/message_size/message_size_filter.cc +118 -76
  64. data/src/core/ext/filters/message_size/message_size_filter.h +33 -0
  65. data/src/core/ext/transport/chttp2/alpn/alpn.h +1 -1
  66. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +9 -7
  67. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +93 -60
  68. data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -1
  69. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +4 -3
  70. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +3 -3
  71. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +8 -2
  72. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +2 -2
  73. data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +1 -1
  74. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +3 -2
  75. data/src/core/ext/transport/chttp2/transport/internal.h +35 -23
  76. data/src/core/ext/transport/chttp2/transport/parsing.cc +4 -4
  77. data/src/core/ext/transport/chttp2/transport/stream_lists.cc +3 -3
  78. data/src/core/ext/transport/chttp2/transport/writing.cc +61 -27
  79. data/src/core/ext/transport/inproc/inproc_transport.cc +18 -18
  80. data/src/core/lib/channel/channel_args.cc +0 -101
  81. data/src/core/lib/channel/channel_args.h +0 -37
  82. data/src/core/lib/channel/channel_stack.h +9 -5
  83. data/src/core/lib/channel/channelz_registry.cc +1 -1
  84. data/src/core/lib/channel/connected_channel.cc +2 -2
  85. data/src/core/lib/channel/context.h +3 -0
  86. data/src/core/lib/channel/handshaker.cc +4 -4
  87. data/src/core/lib/channel/handshaker.h +1 -1
  88. data/src/core/lib/compression/compression_args.cc +127 -0
  89. data/src/core/lib/compression/compression_args.h +55 -0
  90. data/src/core/lib/debug/trace.cc +13 -7
  91. data/src/core/lib/debug/trace.h +12 -0
  92. data/src/core/lib/gpr/arena.h +13 -9
  93. data/src/core/lib/gpr/env.h +2 -5
  94. data/src/core/lib/gpr/env_linux.cc +6 -1
  95. data/src/core/lib/gpr/env_posix.cc +5 -0
  96. data/src/core/lib/gpr/env_windows.cc +7 -5
  97. data/src/core/lib/gpr/log.cc +9 -13
  98. data/src/core/lib/gpr/string.cc +12 -6
  99. data/src/core/lib/gpr/string.h +4 -2
  100. data/src/core/lib/gpr/time_posix.cc +13 -0
  101. data/src/core/lib/gprpp/arena.cc +103 -0
  102. data/src/core/lib/gprpp/arena.h +121 -0
  103. data/src/core/lib/gprpp/fork.cc +12 -29
  104. data/src/core/lib/gprpp/global_config.h +87 -0
  105. data/src/core/lib/gprpp/global_config_custom.h +29 -0
  106. data/src/core/lib/gprpp/global_config_env.cc +135 -0
  107. data/src/core/lib/gprpp/global_config_env.h +131 -0
  108. data/src/core/lib/gprpp/global_config_generic.h +44 -0
  109. data/src/core/lib/gprpp/map.h +419 -0
  110. data/src/core/lib/gprpp/optional.h +1 -0
  111. data/src/core/lib/gprpp/orphanable.h +2 -2
  112. data/src/core/lib/gprpp/{mutex_lock.h → pair.h} +15 -19
  113. data/src/core/lib/gprpp/ref_counted.h +18 -2
  114. data/src/core/lib/gprpp/sync.h +126 -0
  115. data/src/core/lib/http/parser.cc +1 -1
  116. data/src/core/lib/iomgr/call_combiner.cc +84 -90
  117. data/src/core/lib/iomgr/call_combiner.h +75 -82
  118. data/src/core/lib/iomgr/cfstream_handle.cc +202 -0
  119. data/src/core/lib/iomgr/cfstream_handle.h +82 -0
  120. data/src/core/lib/iomgr/combiner.h +1 -1
  121. data/src/core/lib/iomgr/endpoint_cfstream.cc +375 -0
  122. data/src/core/lib/iomgr/endpoint_cfstream.h +49 -0
  123. data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
  124. data/src/core/lib/iomgr/error.h +23 -0
  125. data/src/core/lib/iomgr/error_cfstream.cc +52 -0
  126. data/src/core/lib/iomgr/error_cfstream.h +31 -0
  127. data/src/core/lib/iomgr/ev_epoll1_linux.cc +34 -27
  128. data/src/core/lib/iomgr/ev_epollex_linux.cc +33 -33
  129. data/src/core/lib/iomgr/ev_poll_posix.cc +7 -7
  130. data/src/core/lib/iomgr/ev_posix.cc +15 -13
  131. data/src/core/lib/iomgr/ev_posix.h +4 -1
  132. data/src/core/lib/iomgr/executor.cc +13 -9
  133. data/src/core/lib/iomgr/fork_posix.cc +0 -1
  134. data/src/core/lib/iomgr/internal_errqueue.cc +1 -1
  135. data/src/core/lib/iomgr/iomgr.cc +6 -5
  136. data/src/core/lib/iomgr/iomgr_custom.cc +3 -0
  137. data/src/core/lib/iomgr/iomgr_custom.h +2 -0
  138. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +93 -0
  139. data/src/core/lib/iomgr/iomgr_windows.cc +1 -0
  140. data/src/core/lib/iomgr/lockfree_event.cc +3 -3
  141. data/src/core/lib/iomgr/port.h +11 -0
  142. data/src/core/lib/iomgr/resource_quota.cc +40 -37
  143. data/src/core/lib/iomgr/socket_utils_common_posix.cc +6 -2
  144. data/src/core/lib/iomgr/socket_windows.cc +19 -0
  145. data/src/core/lib/iomgr/socket_windows.h +8 -0
  146. data/src/core/lib/iomgr/tcp_client_cfstream.cc +216 -0
  147. data/src/core/lib/iomgr/tcp_client_custom.cc +2 -2
  148. data/src/core/lib/iomgr/tcp_client_posix.cc +3 -3
  149. data/src/core/lib/iomgr/tcp_client_windows.cc +1 -1
  150. data/src/core/lib/iomgr/tcp_custom.cc +9 -9
  151. data/src/core/lib/iomgr/tcp_posix.cc +41 -41
  152. data/src/core/lib/iomgr/tcp_server_custom.cc +3 -3
  153. data/src/core/lib/iomgr/tcp_server_posix.cc +14 -1
  154. data/src/core/lib/iomgr/tcp_server_windows.cc +2 -2
  155. data/src/core/lib/iomgr/tcp_windows.cc +7 -9
  156. data/src/core/lib/iomgr/timer_generic.cc +16 -16
  157. data/src/core/lib/iomgr/timer_manager.cc +12 -11
  158. data/src/core/lib/profiling/basic_timers.cc +10 -4
  159. data/src/core/lib/security/context/security_context.cc +6 -7
  160. data/src/core/lib/security/context/security_context.h +3 -4
  161. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +1 -1
  162. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +2 -3
  163. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -1
  164. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +7 -7
  165. data/src/core/lib/security/security_connector/load_system_roots_linux.cc +7 -5
  166. data/src/core/lib/security/security_connector/security_connector.cc +0 -1
  167. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +3 -2
  168. data/src/core/lib/security/security_connector/ssl_utils.cc +30 -26
  169. data/src/core/lib/security/security_connector/ssl_utils.h +5 -1
  170. data/src/core/lib/security/transport/client_auth_filter.cc +7 -11
  171. data/src/core/lib/security/transport/secure_endpoint.cc +4 -4
  172. data/src/core/lib/security/transport/server_auth_filter.cc +2 -3
  173. data/src/core/lib/slice/slice.cc +99 -116
  174. data/src/core/lib/slice/slice_buffer.cc +5 -0
  175. data/src/core/lib/slice/slice_intern.cc +38 -95
  176. data/src/core/lib/slice/slice_internal.h +200 -2
  177. data/src/core/lib/surface/api_trace.h +1 -1
  178. data/src/core/lib/surface/call.cc +41 -35
  179. data/src/core/lib/surface/call.h +7 -2
  180. data/src/core/lib/surface/call_details.cc +0 -1
  181. data/src/core/lib/surface/completion_queue.cc +36 -27
  182. data/src/core/lib/surface/init.cc +3 -4
  183. data/src/core/lib/surface/lame_client.cc +1 -1
  184. data/src/core/lib/surface/server.cc +18 -25
  185. data/src/core/lib/surface/version.cc +1 -1
  186. data/src/core/lib/transport/bdp_estimator.cc +3 -3
  187. data/src/core/lib/transport/bdp_estimator.h +2 -2
  188. data/src/core/lib/transport/connectivity_state.cc +10 -40
  189. data/src/core/lib/transport/connectivity_state.h +0 -8
  190. data/src/core/lib/transport/error_utils.cc +12 -0
  191. data/src/core/lib/transport/metadata.cc +206 -278
  192. data/src/core/lib/transport/metadata.h +205 -10
  193. data/src/core/lib/transport/static_metadata.cc +108 -116
  194. data/src/core/lib/transport/static_metadata.h +1 -2
  195. data/src/core/lib/transport/status_metadata.cc +3 -3
  196. data/src/core/lib/transport/transport.cc +29 -66
  197. data/src/core/lib/transport/transport.h +36 -8
  198. data/src/core/lib/transport/transport_impl.h +1 -1
  199. data/src/core/tsi/fake_transport_security.cc +4 -4
  200. data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +1 -1
  201. data/src/core/tsi/ssl_transport_security.cc +1 -1
  202. data/src/ruby/ext/grpc/rb_grpc.c +1 -1
  203. data/src/ruby/lib/grpc/errors.rb +22 -3
  204. data/src/ruby/lib/grpc/generic/bidi_call.rb +1 -1
  205. data/src/ruby/lib/grpc/generic/rpc_server.rb +1 -1
  206. data/src/ruby/lib/grpc/version.rb +1 -1
  207. data/src/ruby/spec/errors_spec.rb +141 -0
  208. metadata +57 -33
  209. data/src/core/lib/gpr/arena.cc +0 -192
@@ -35,9 +35,11 @@
35
35
  #include "src/core/lib/transport/error_utils.h"
36
36
  #include "src/core/lib/transport/transport_impl.h"
37
37
 
38
- #define INPROC_LOG(...) \
39
- do { \
40
- if (grpc_inproc_trace.enabled()) gpr_log(__VA_ARGS__); \
38
+ #define INPROC_LOG(...) \
39
+ do { \
40
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_inproc_trace)) { \
41
+ gpr_log(__VA_ARGS__); \
42
+ } \
41
43
  } while (0)
42
44
 
43
45
  namespace {
@@ -120,7 +122,7 @@ struct inproc_transport {
120
122
 
121
123
  struct inproc_stream {
122
124
  inproc_stream(inproc_transport* t, grpc_stream_refcount* refcount,
123
- const void* server_data, gpr_arena* arena)
125
+ const void* server_data, grpc_core::Arena* arena)
124
126
  : t(t), refs(refcount), arena(arena) {
125
127
  // Ref this stream right now for ctor and list.
126
128
  ref("inproc_init_stream:init");
@@ -250,7 +252,7 @@ struct inproc_stream {
250
252
  grpc_stream_refcount* refs;
251
253
  grpc_closure* closure_at_destroy = nullptr;
252
254
 
253
- gpr_arena* arena;
255
+ grpc_core::Arena* arena;
254
256
 
255
257
  grpc_transport_stream_op_batch* send_message_op = nullptr;
256
258
  grpc_transport_stream_op_batch* send_trailing_md_op = nullptr;
@@ -296,7 +298,7 @@ grpc_error* fill_in_metadata(inproc_stream* s,
296
298
  const grpc_metadata_batch* metadata,
297
299
  uint32_t flags, grpc_metadata_batch* out_md,
298
300
  uint32_t* outflags, bool* markfilled) {
299
- if (grpc_inproc_trace.enabled()) {
301
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_inproc_trace)) {
300
302
  log_metadata(metadata, s->t->is_client, outflags != nullptr);
301
303
  }
302
304
 
@@ -309,8 +311,8 @@ grpc_error* fill_in_metadata(inproc_stream* s,
309
311
  grpc_error* error = GRPC_ERROR_NONE;
310
312
  for (grpc_linked_mdelem* elem = metadata->list.head;
311
313
  (elem != nullptr) && (error == GRPC_ERROR_NONE); elem = elem->next) {
312
- grpc_linked_mdelem* nelem = static_cast<grpc_linked_mdelem*>(
313
- gpr_arena_alloc(s->arena, sizeof(*nelem)));
314
+ grpc_linked_mdelem* nelem =
315
+ static_cast<grpc_linked_mdelem*>(s->arena->Alloc(sizeof(*nelem)));
314
316
  nelem->md =
315
317
  grpc_mdelem_from_slices(grpc_slice_intern(GRPC_MDKEY(elem->md)),
316
318
  grpc_slice_intern(GRPC_MDVALUE(elem->md)));
@@ -322,7 +324,7 @@ grpc_error* fill_in_metadata(inproc_stream* s,
322
324
 
323
325
  int init_stream(grpc_transport* gt, grpc_stream* gs,
324
326
  grpc_stream_refcount* refcount, const void* server_data,
325
- gpr_arena* arena) {
327
+ grpc_core::Arena* arena) {
326
328
  INPROC_LOG(GPR_INFO, "init_stream %p %p %p", gt, gs, server_data);
327
329
  inproc_transport* t = reinterpret_cast<inproc_transport*>(gt);
328
330
  new (gs) inproc_stream(t, refcount, server_data, arena);
@@ -436,13 +438,13 @@ void fail_helper_locked(inproc_stream* s, grpc_error* error) {
436
438
  // since it expects that as well as no error yet
437
439
  grpc_metadata_batch fake_md;
438
440
  grpc_metadata_batch_init(&fake_md);
439
- grpc_linked_mdelem* path_md = static_cast<grpc_linked_mdelem*>(
440
- gpr_arena_alloc(s->arena, sizeof(*path_md)));
441
+ grpc_linked_mdelem* path_md =
442
+ static_cast<grpc_linked_mdelem*>(s->arena->Alloc(sizeof(*path_md)));
441
443
  path_md->md = grpc_mdelem_from_slices(g_fake_path_key, g_fake_path_value);
442
444
  GPR_ASSERT(grpc_metadata_batch_link_tail(&fake_md, path_md) ==
443
445
  GRPC_ERROR_NONE);
444
- grpc_linked_mdelem* auth_md = static_cast<grpc_linked_mdelem*>(
445
- gpr_arena_alloc(s->arena, sizeof(*auth_md)));
446
+ grpc_linked_mdelem* auth_md =
447
+ static_cast<grpc_linked_mdelem*>(s->arena->Alloc(sizeof(*auth_md)));
446
448
  auth_md->md = grpc_mdelem_from_slices(g_fake_auth_key, g_fake_auth_value);
447
449
  GPR_ASSERT(grpc_metadata_batch_link_tail(&fake_md, auth_md) ==
448
450
  GRPC_ERROR_NONE);
@@ -907,7 +909,7 @@ void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
907
909
  gpr_mu* mu = &s->t->mu->mu; // save aside in case s gets closed
908
910
  gpr_mu_lock(mu);
909
911
 
910
- if (grpc_inproc_trace.enabled()) {
912
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_inproc_trace)) {
911
913
  if (op->send_initial_metadata) {
912
914
  log_metadata(op->payload->send_initial_metadata.send_initial_metadata,
913
915
  s->t->is_client, true);
@@ -1088,10 +1090,8 @@ void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
1088
1090
 
1089
1091
  void close_transport_locked(inproc_transport* t) {
1090
1092
  INPROC_LOG(GPR_INFO, "close_transport %p %d", t, t->is_closed);
1091
- grpc_connectivity_state_set(
1092
- &t->connectivity, GRPC_CHANNEL_SHUTDOWN,
1093
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Closing transport."),
1094
- "close transport");
1093
+ grpc_connectivity_state_set(&t->connectivity, GRPC_CHANNEL_SHUTDOWN,
1094
+ "close transport");
1095
1095
  if (!t->is_closed) {
1096
1096
  t->is_closed = true;
1097
1097
  /* Also end all streams on this transport */
@@ -21,7 +21,6 @@
21
21
  #include <limits.h>
22
22
  #include <string.h>
23
23
 
24
- #include <grpc/compression.h>
25
24
  #include <grpc/grpc.h>
26
25
  #include <grpc/support/alloc.h>
27
26
  #include <grpc/support/log.h>
@@ -213,106 +212,6 @@ void grpc_channel_args_destroy(grpc_channel_args* a) {
213
212
  gpr_free(a);
214
213
  }
215
214
 
216
- grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
217
- const grpc_channel_args* a) {
218
- size_t i;
219
- if (a == nullptr) return GRPC_COMPRESS_NONE;
220
- for (i = 0; i < a->num_args; ++i) {
221
- if (a->args[i].type == GRPC_ARG_INTEGER &&
222
- !strcmp(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM, a->args[i].key)) {
223
- return static_cast<grpc_compression_algorithm>(a->args[i].value.integer);
224
- break;
225
- }
226
- }
227
- return GRPC_COMPRESS_NONE;
228
- }
229
-
230
- grpc_channel_args* grpc_channel_args_set_compression_algorithm(
231
- grpc_channel_args* a, grpc_compression_algorithm algorithm) {
232
- GPR_ASSERT(algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT);
233
- grpc_arg tmp;
234
- tmp.type = GRPC_ARG_INTEGER;
235
- tmp.key = (char*)GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM;
236
- tmp.value.integer = algorithm;
237
- return grpc_channel_args_copy_and_add(a, &tmp, 1);
238
- }
239
-
240
- /** Returns 1 if the argument for compression algorithm's enabled states bitset
241
- * was found in \a a, returning the arg's value in \a states. Otherwise, returns
242
- * 0. */
243
- static int find_compression_algorithm_states_bitset(const grpc_channel_args* a,
244
- int** states_arg) {
245
- if (a != nullptr) {
246
- size_t i;
247
- for (i = 0; i < a->num_args; ++i) {
248
- if (a->args[i].type == GRPC_ARG_INTEGER &&
249
- !strcmp(GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET,
250
- a->args[i].key)) {
251
- *states_arg = &a->args[i].value.integer;
252
- **states_arg |= 0x1; /* forcefully enable support for no compression */
253
- return 1;
254
- }
255
- }
256
- }
257
- return 0; /* GPR_FALSE */
258
- }
259
-
260
- grpc_channel_args* grpc_channel_args_compression_algorithm_set_state(
261
- grpc_channel_args** a, grpc_compression_algorithm algorithm, int state) {
262
- int* states_arg = nullptr;
263
- grpc_channel_args* result = *a;
264
- const int states_arg_found =
265
- find_compression_algorithm_states_bitset(*a, &states_arg);
266
-
267
- if (grpc_channel_args_get_compression_algorithm(*a) == algorithm &&
268
- state == 0) {
269
- const char* algo_name = nullptr;
270
- GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algo_name) != 0);
271
- gpr_log(GPR_ERROR,
272
- "Tried to disable default compression algorithm '%s'. The "
273
- "operation has been ignored.",
274
- algo_name);
275
- } else if (states_arg_found) {
276
- if (state != 0) {
277
- GPR_BITSET((unsigned*)states_arg, algorithm);
278
- } else if (algorithm != GRPC_COMPRESS_NONE) {
279
- GPR_BITCLEAR((unsigned*)states_arg, algorithm);
280
- }
281
- } else {
282
- /* create a new arg */
283
- grpc_arg tmp;
284
- tmp.type = GRPC_ARG_INTEGER;
285
- tmp.key = (char*)GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET;
286
- /* all enabled by default */
287
- tmp.value.integer = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1;
288
- if (state != 0) {
289
- GPR_BITSET((unsigned*)&tmp.value.integer, algorithm);
290
- } else if (algorithm != GRPC_COMPRESS_NONE) {
291
- GPR_BITCLEAR((unsigned*)&tmp.value.integer, algorithm);
292
- }
293
- result = grpc_channel_args_copy_and_add(*a, &tmp, 1);
294
- grpc_channel_args_destroy(*a);
295
- *a = result;
296
- }
297
- return result;
298
- }
299
-
300
- uint32_t grpc_channel_args_compression_algorithm_get_states(
301
- const grpc_channel_args* a) {
302
- int* states_arg;
303
- if (find_compression_algorithm_states_bitset(a, &states_arg)) {
304
- return static_cast<uint32_t>(*states_arg);
305
- } else {
306
- return (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1; /* All algs. enabled */
307
- }
308
- }
309
-
310
- grpc_channel_args* grpc_channel_args_set_socket_mutator(
311
- grpc_channel_args* a, grpc_socket_mutator* mutator) {
312
- grpc_arg tmp = grpc_socket_mutator_to_arg(mutator);
313
- return grpc_channel_args_copy_and_add(a, &tmp, 1);
314
- }
315
-
316
215
  int grpc_channel_args_compare(const grpc_channel_args* a,
317
216
  const grpc_channel_args* b) {
318
217
  int c = GPR_ICMP(a->num_args, b->num_args);
@@ -21,9 +21,7 @@
21
21
 
22
22
  #include <grpc/support/port_platform.h>
23
23
 
24
- #include <grpc/compression.h>
25
24
  #include <grpc/grpc.h>
26
- #include "src/core/lib/iomgr/socket_mutator.h"
27
25
 
28
26
  // Channel args are intentionally immutable, to avoid the need for locking.
29
27
 
@@ -60,44 +58,9 @@ inline void grpc_channel_args_destroy(const grpc_channel_args* a) {
60
58
  grpc_channel_args_destroy(const_cast<grpc_channel_args*>(a));
61
59
  }
62
60
 
63
- /** Returns the compression algorithm set in \a a. */
64
- grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
65
- const grpc_channel_args* a);
66
-
67
- /** Returns a channel arg instance with compression enabled. If \a a is
68
- * non-NULL, its args are copied. N.B. GRPC_COMPRESS_NONE disables compression
69
- * for the channel. */
70
- grpc_channel_args* grpc_channel_args_set_compression_algorithm(
71
- grpc_channel_args* a, grpc_compression_algorithm algorithm);
72
-
73
- /** Sets the support for the given compression algorithm. By default, all
74
- * compression algorithms are enabled. It's an error to disable an algorithm set
75
- * by grpc_channel_args_set_compression_algorithm.
76
- *
77
- * Returns an instance with the updated algorithm states. The \a a pointer is
78
- * modified to point to the returned instance (which may be different from the
79
- * input value of \a a). */
80
- grpc_channel_args* grpc_channel_args_compression_algorithm_set_state(
81
- grpc_channel_args** a, grpc_compression_algorithm algorithm, int enabled);
82
-
83
- /** Returns the bitset representing the support state (true for enabled, false
84
- * for disabled) for compression algorithms.
85
- *
86
- * The i-th bit of the returned bitset corresponds to the i-th entry in the
87
- * grpc_compression_algorithm enum. */
88
- uint32_t grpc_channel_args_compression_algorithm_get_states(
89
- const grpc_channel_args* a);
90
-
91
61
  int grpc_channel_args_compare(const grpc_channel_args* a,
92
62
  const grpc_channel_args* b);
93
63
 
94
- /** Returns a channel arg instance with socket mutator added. The socket mutator
95
- * will perform its mutate_fd method on all file descriptors used by the
96
- * channel.
97
- * If \a a is non-MULL, its args are copied. */
98
- grpc_channel_args* grpc_channel_args_set_socket_mutator(
99
- grpc_channel_args* a, grpc_socket_mutator* mutator);
100
-
101
64
  /** Returns the value of argument \a name from \a args, or NULL if not found. */
102
65
  const grpc_arg* grpc_channel_args_find(const grpc_channel_args* args,
103
66
  const char* name);
@@ -42,7 +42,7 @@
42
42
  #include <grpc/support/time.h>
43
43
 
44
44
  #include "src/core/lib/debug/trace.h"
45
- #include "src/core/lib/gpr/arena.h"
45
+ #include "src/core/lib/gprpp/arena.h"
46
46
  #include "src/core/lib/iomgr/call_combiner.h"
47
47
  #include "src/core/lib/iomgr/polling_entity.h"
48
48
  #include "src/core/lib/transport/transport.h"
@@ -69,8 +69,8 @@ typedef struct {
69
69
  const grpc_slice& path;
70
70
  gpr_timespec start_time;
71
71
  grpc_millis deadline;
72
- gpr_arena* arena;
73
- grpc_call_combiner* call_combiner;
72
+ grpc_core::Arena* arena;
73
+ grpc_core::CallCombiner* call_combiner;
74
74
  } grpc_call_element_args;
75
75
 
76
76
  typedef struct {
@@ -274,7 +274,11 @@ void grpc_call_log_op(const char* file, int line, gpr_log_severity severity,
274
274
 
275
275
  extern grpc_core::TraceFlag grpc_trace_channel;
276
276
 
277
- #define GRPC_CALL_LOG_OP(sev, elem, op) \
278
- if (grpc_trace_channel.enabled()) grpc_call_log_op(sev, elem, op)
277
+ #define GRPC_CALL_LOG_OP(sev, elem, op) \
278
+ do { \
279
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_channel)) { \
280
+ grpc_call_log_op(sev, elem, op); \
281
+ } \
282
+ } while (0)
279
283
 
280
284
  #endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_H */
@@ -23,7 +23,7 @@
23
23
  #include "src/core/lib/channel/channelz_registry.h"
24
24
  #include "src/core/lib/gpr/useful.h"
25
25
  #include "src/core/lib/gprpp/memory.h"
26
- #include "src/core/lib/gprpp/mutex_lock.h"
26
+ #include "src/core/lib/gprpp/sync.h"
27
27
 
28
28
  #include <grpc/support/alloc.h>
29
29
  #include <grpc/support/log.h>
@@ -41,12 +41,12 @@ typedef struct connected_channel_channel_data {
41
41
  typedef struct {
42
42
  grpc_closure closure;
43
43
  grpc_closure* original_closure;
44
- grpc_call_combiner* call_combiner;
44
+ grpc_core::CallCombiner* call_combiner;
45
45
  const char* reason;
46
46
  } callback_state;
47
47
 
48
48
  typedef struct connected_channel_call_data {
49
- grpc_call_combiner* call_combiner;
49
+ grpc_core::CallCombiner* call_combiner;
50
50
  // Closures used for returning results on the call combiner.
51
51
  callback_state on_complete[6]; // Max number of pending batches.
52
52
  callback_state recv_initial_metadata_ready;
@@ -35,6 +35,9 @@ typedef enum {
35
35
  /// Reserved for traffic_class_context.
36
36
  GRPC_CONTEXT_TRAFFIC,
37
37
 
38
+ /// Holds a pointer to ServiceConfig::CallData associated with this call.
39
+ GRPC_SERVICE_CONFIG_CALL_DATA,
40
+
38
41
  GRPC_CONTEXT_COUNT
39
42
  } grpc_context_index;
40
43
 
@@ -94,7 +94,7 @@ void HandshakeManager::ShutdownAllPending(grpc_error* why) {
94
94
  }
95
95
 
96
96
  void HandshakeManager::Add(RefCountedPtr<Handshaker> handshaker) {
97
- if (grpc_handshaker_trace.enabled()) {
97
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_handshaker_trace)) {
98
98
  gpr_log(
99
99
  GPR_INFO,
100
100
  "handshake_manager %p: adding handshaker %s [%p] at index %" PRIuPTR,
@@ -125,7 +125,7 @@ void HandshakeManager::Shutdown(grpc_error* why) {
125
125
  // on_handshake_done callback.
126
126
  // Returns true if we've scheduled the on_handshake_done callback.
127
127
  bool HandshakeManager::CallNextHandshakerLocked(grpc_error* error) {
128
- if (grpc_handshaker_trace.enabled()) {
128
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_handshaker_trace)) {
129
129
  char* args_str = HandshakerArgsString(&args_);
130
130
  gpr_log(GPR_INFO,
131
131
  "handshake_manager %p: error=%s shutdown=%d index=%" PRIuPTR
@@ -159,7 +159,7 @@ bool HandshakeManager::CallNextHandshakerLocked(grpc_error* error) {
159
159
  args_.read_buffer = nullptr;
160
160
  }
161
161
  }
162
- if (grpc_handshaker_trace.enabled()) {
162
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_handshaker_trace)) {
163
163
  gpr_log(GPR_INFO,
164
164
  "handshake_manager %p: handshaking complete -- scheduling "
165
165
  "on_handshake_done with error=%s",
@@ -172,7 +172,7 @@ bool HandshakeManager::CallNextHandshakerLocked(grpc_error* error) {
172
172
  is_shutdown_ = true;
173
173
  } else {
174
174
  auto handshaker = handshakers_[index_];
175
- if (grpc_handshaker_trace.enabled()) {
175
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_handshaker_trace)) {
176
176
  gpr_log(
177
177
  GPR_INFO,
178
178
  "handshake_manager %p: calling handshaker %s [%p] at index %" PRIuPTR,
@@ -27,8 +27,8 @@
27
27
 
28
28
  #include "src/core/lib/channel/channel_args.h"
29
29
  #include "src/core/lib/gprpp/inlined_vector.h"
30
- #include "src/core/lib/gprpp/mutex_lock.h"
31
30
  #include "src/core/lib/gprpp/ref_counted.h"
31
+ #include "src/core/lib/gprpp/sync.h"
32
32
  #include "src/core/lib/iomgr/closure.h"
33
33
  #include "src/core/lib/iomgr/endpoint.h"
34
34
  #include "src/core/lib/iomgr/exec_ctx.h"
@@ -0,0 +1,127 @@
1
+ /*
2
+ *
3
+ * Copyright 2015 gRPC authors.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ #include <grpc/support/port_platform.h>
20
+
21
+ #include <limits.h>
22
+ #include <string.h>
23
+
24
+ #include <grpc/compression.h>
25
+ #include <grpc/grpc.h>
26
+ #include <grpc/support/alloc.h>
27
+ #include <grpc/support/log.h>
28
+ #include <grpc/support/string_util.h>
29
+
30
+ #include "src/core/lib/channel/channel_args.h"
31
+ #include "src/core/lib/compression/compression_args.h"
32
+ #include "src/core/lib/gpr/string.h"
33
+ #include "src/core/lib/gpr/useful.h"
34
+
35
+ grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
36
+ const grpc_channel_args* a) {
37
+ size_t i;
38
+ if (a == nullptr) return GRPC_COMPRESS_NONE;
39
+ for (i = 0; i < a->num_args; ++i) {
40
+ if (a->args[i].type == GRPC_ARG_INTEGER &&
41
+ !strcmp(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM, a->args[i].key)) {
42
+ return static_cast<grpc_compression_algorithm>(a->args[i].value.integer);
43
+ break;
44
+ }
45
+ }
46
+ return GRPC_COMPRESS_NONE;
47
+ }
48
+
49
+ grpc_channel_args* grpc_channel_args_set_compression_algorithm(
50
+ grpc_channel_args* a, grpc_compression_algorithm algorithm) {
51
+ GPR_ASSERT(algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT);
52
+ grpc_arg tmp;
53
+ tmp.type = GRPC_ARG_INTEGER;
54
+ tmp.key = (char*)GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM;
55
+ tmp.value.integer = algorithm;
56
+ return grpc_channel_args_copy_and_add(a, &tmp, 1);
57
+ }
58
+
59
+ /** Returns 1 if the argument for compression algorithm's enabled states bitset
60
+ * was found in \a a, returning the arg's value in \a states. Otherwise, returns
61
+ * 0. */
62
+ static int find_compression_algorithm_states_bitset(const grpc_channel_args* a,
63
+ int** states_arg) {
64
+ if (a != nullptr) {
65
+ size_t i;
66
+ for (i = 0; i < a->num_args; ++i) {
67
+ if (a->args[i].type == GRPC_ARG_INTEGER &&
68
+ !strcmp(GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET,
69
+ a->args[i].key)) {
70
+ *states_arg = &a->args[i].value.integer;
71
+ **states_arg |= 0x1; /* forcefully enable support for no compression */
72
+ return 1;
73
+ }
74
+ }
75
+ }
76
+ return 0; /* GPR_FALSE */
77
+ }
78
+
79
+ grpc_channel_args* grpc_channel_args_compression_algorithm_set_state(
80
+ grpc_channel_args** a, grpc_compression_algorithm algorithm, int state) {
81
+ int* states_arg = nullptr;
82
+ grpc_channel_args* result = *a;
83
+ const int states_arg_found =
84
+ find_compression_algorithm_states_bitset(*a, &states_arg);
85
+
86
+ if (grpc_channel_args_get_compression_algorithm(*a) == algorithm &&
87
+ state == 0) {
88
+ const char* algo_name = nullptr;
89
+ GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algo_name) != 0);
90
+ gpr_log(GPR_ERROR,
91
+ "Tried to disable default compression algorithm '%s'. The "
92
+ "operation has been ignored.",
93
+ algo_name);
94
+ } else if (states_arg_found) {
95
+ if (state != 0) {
96
+ GPR_BITSET((unsigned*)states_arg, algorithm);
97
+ } else if (algorithm != GRPC_COMPRESS_NONE) {
98
+ GPR_BITCLEAR((unsigned*)states_arg, algorithm);
99
+ }
100
+ } else {
101
+ /* create a new arg */
102
+ grpc_arg tmp;
103
+ tmp.type = GRPC_ARG_INTEGER;
104
+ tmp.key = (char*)GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET;
105
+ /* all enabled by default */
106
+ tmp.value.integer = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1;
107
+ if (state != 0) {
108
+ GPR_BITSET((unsigned*)&tmp.value.integer, algorithm);
109
+ } else if (algorithm != GRPC_COMPRESS_NONE) {
110
+ GPR_BITCLEAR((unsigned*)&tmp.value.integer, algorithm);
111
+ }
112
+ result = grpc_channel_args_copy_and_add(*a, &tmp, 1);
113
+ grpc_channel_args_destroy(*a);
114
+ *a = result;
115
+ }
116
+ return result;
117
+ }
118
+
119
+ uint32_t grpc_channel_args_compression_algorithm_get_states(
120
+ const grpc_channel_args* a) {
121
+ int* states_arg;
122
+ if (find_compression_algorithm_states_bitset(a, &states_arg)) {
123
+ return static_cast<uint32_t>(*states_arg);
124
+ } else {
125
+ return (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1; /* All algs. enabled */
126
+ }
127
+ }