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
@@ -45,7 +45,7 @@ extern grpc_core::TraceFlag grpc_api_trace;
45
45
  /* Due to the limitations of C89's preprocessor, the arity of the var-arg list
46
46
  'nargs' must be specified. */
47
47
  #define GRPC_API_TRACE(fmt, nargs, args) \
48
- if (grpc_api_trace.enabled()) { \
48
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace)) { \
49
49
  gpr_log(GPR_INFO, fmt GRPC_API_TRACE_UNWRAP##nargs args); \
50
50
  }
51
51
 
@@ -35,10 +35,11 @@
35
35
  #include "src/core/lib/compression/algorithm_metadata.h"
36
36
  #include "src/core/lib/debug/stats.h"
37
37
  #include "src/core/lib/gpr/alloc.h"
38
- #include "src/core/lib/gpr/arena.h"
39
38
  #include "src/core/lib/gpr/string.h"
40
39
  #include "src/core/lib/gpr/useful.h"
40
+ #include "src/core/lib/gprpp/arena.h"
41
41
  #include "src/core/lib/gprpp/manual_constructor.h"
42
+ #include "src/core/lib/gprpp/ref_counted.h"
42
43
  #include "src/core/lib/iomgr/timer.h"
43
44
  #include "src/core/lib/profiling/timers.h"
44
45
  #include "src/core/lib/slice/slice_internal.h"
@@ -124,14 +125,12 @@ struct child_call {
124
125
  #define RECV_INITIAL_METADATA_FIRST ((gpr_atm)1)
125
126
 
126
127
  struct grpc_call {
127
- grpc_call(gpr_arena* arena, const grpc_call_create_args& args)
128
+ grpc_call(grpc_core::Arena* arena, const grpc_call_create_args& args)
128
129
  : arena(arena),
129
130
  cq(args.cq),
130
131
  channel(args.channel),
131
132
  is_client(args.server_transport_data == nullptr),
132
133
  stream_op_payload(context) {
133
- gpr_ref_init(&ext_ref, 1);
134
- grpc_call_combiner_init(&call_combiner);
135
134
  for (int i = 0; i < 2; i++) {
136
135
  for (int j = 0; j < 2; j++) {
137
136
  metadata_batch[i][j].deadline = GRPC_MILLIS_INF_FUTURE;
@@ -141,12 +140,11 @@ struct grpc_call {
141
140
 
142
141
  ~grpc_call() {
143
142
  gpr_free(static_cast<void*>(const_cast<char*>(final_info.error_string)));
144
- grpc_call_combiner_destroy(&call_combiner);
145
143
  }
146
144
 
147
- gpr_refcount ext_ref;
148
- gpr_arena* arena;
149
- grpc_call_combiner call_combiner;
145
+ grpc_core::RefCount ext_ref;
146
+ grpc_core::Arena* arena;
147
+ grpc_core::CallCombiner call_combiner;
150
148
  grpc_completion_queue* cq;
151
149
  grpc_polling_entity pollent;
152
150
  grpc_channel* channel;
@@ -292,13 +290,13 @@ static void add_init_error(grpc_error** composite, grpc_error* new_err) {
292
290
  }
293
291
 
294
292
  void* grpc_call_arena_alloc(grpc_call* call, size_t size) {
295
- return gpr_arena_alloc(call->arena, size);
293
+ return call->arena->Alloc(size);
296
294
  }
297
295
 
298
296
  static parent_call* get_or_create_parent_call(grpc_call* call) {
299
297
  parent_call* p = (parent_call*)gpr_atm_acq_load(&call->parent_call_atm);
300
298
  if (p == nullptr) {
301
- p = new (gpr_arena_alloc(call->arena, sizeof(*p))) parent_call();
299
+ p = call->arena->New<parent_call>();
302
300
  if (!gpr_atm_rel_cas(&call->parent_call_atm, (gpr_atm) nullptr,
303
301
  (gpr_atm)p)) {
304
302
  p->~parent_call();
@@ -323,16 +321,23 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args,
323
321
 
324
322
  GRPC_CHANNEL_INTERNAL_REF(args->channel, "call");
325
323
 
324
+ grpc_core::Arena* arena;
325
+ grpc_call* call;
326
326
  grpc_error* error = GRPC_ERROR_NONE;
327
327
  grpc_channel_stack* channel_stack =
328
328
  grpc_channel_get_channel_stack(args->channel);
329
- grpc_call* call;
330
329
  size_t initial_size = grpc_channel_get_call_size_estimate(args->channel);
331
330
  GRPC_STATS_INC_CALL_INITIAL_SIZE(initial_size);
332
- gpr_arena* arena = gpr_arena_create(initial_size);
333
- call = new (gpr_arena_alloc(
334
- arena, GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call)) +
335
- channel_stack->call_stack_size)) grpc_call(arena, *args);
331
+ size_t call_and_stack_size =
332
+ GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call)) +
333
+ channel_stack->call_stack_size;
334
+ size_t call_alloc_size =
335
+ call_and_stack_size + (args->parent ? sizeof(child_call) : 0);
336
+
337
+ std::pair<grpc_core::Arena*, void*> arena_with_call =
338
+ grpc_core::Arena::CreateWithAlloc(initial_size, call_alloc_size);
339
+ arena = arena_with_call.first;
340
+ call = new (arena_with_call.second) grpc_call(arena, *args);
336
341
  *out_call = call;
337
342
  grpc_slice path = grpc_empty_slice();
338
343
  if (call->is_client) {
@@ -364,8 +369,8 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args,
364
369
  bool immediately_cancel = false;
365
370
 
366
371
  if (args->parent != nullptr) {
367
- call->child = new (gpr_arena_alloc(arena, sizeof(child_call)))
368
- child_call(args->parent);
372
+ call->child = new (reinterpret_cast<char*>(arena_with_call.second) +
373
+ call_and_stack_size) child_call(args->parent);
369
374
 
370
375
  GRPC_CALL_INTERNAL_REF(args->parent, "child");
371
376
  GPR_ASSERT(call->is_client);
@@ -502,9 +507,9 @@ void grpc_call_internal_unref(grpc_call* c REF_ARG) {
502
507
  static void release_call(void* call, grpc_error* error) {
503
508
  grpc_call* c = static_cast<grpc_call*>(call);
504
509
  grpc_channel* channel = c->channel;
505
- gpr_arena* arena = c->arena;
510
+ grpc_core::Arena* arena = c->arena;
506
511
  c->~grpc_call();
507
- grpc_channel_update_call_size_estimate(channel, gpr_arena_destroy(arena));
512
+ grpc_channel_update_call_size_estimate(channel, arena->Destroy());
508
513
  GRPC_CHANNEL_INTERNAL_UNREF(channel, "call");
509
514
  }
510
515
 
@@ -548,10 +553,10 @@ static void destroy_call(void* call, grpc_error* error) {
548
553
  grpc_schedule_on_exec_ctx));
549
554
  }
550
555
 
551
- void grpc_call_ref(grpc_call* c) { gpr_ref(&c->ext_ref); }
556
+ void grpc_call_ref(grpc_call* c) { c->ext_ref.Ref(); }
552
557
 
553
558
  void grpc_call_unref(grpc_call* c) {
554
- if (!gpr_unref(&c->ext_ref)) return;
559
+ if (GPR_LIKELY(!c->ext_ref.Unref())) return;
555
560
 
556
561
  GPR_TIMER_SCOPE("grpc_call_unref", 0);
557
562
 
@@ -589,7 +594,7 @@ void grpc_call_unref(grpc_call* c) {
589
594
  // holding to the call stack. Also flush the closures on exec_ctx so that
590
595
  // filters that schedule cancel notification closures on exec_ctx do not
591
596
  // need to take a ref of the call stack to guarantee closure liveness.
592
- grpc_call_combiner_set_notify_on_cancel(&c->call_combiner, nullptr);
597
+ c->call_combiner.SetNotifyOnCancel(nullptr);
593
598
  grpc_core::ExecCtx::Get()->Flush();
594
599
  }
595
600
  GRPC_CALL_INTERNAL_UNREF(c, "destroy");
@@ -685,7 +690,7 @@ static void cancel_with_error(grpc_call* c, grpc_error* error) {
685
690
  // any in-flight asynchronous actions that may be holding the call
686
691
  // combiner. This ensures that the cancel_stream batch can be sent
687
692
  // down the filter stack in a timely manner.
688
- grpc_call_combiner_cancel(&c->call_combiner, GRPC_ERROR_REF(error));
693
+ c->call_combiner.Cancel(GRPC_ERROR_REF(error));
689
694
  cancel_state* state = static_cast<cancel_state*>(gpr_malloc(sizeof(*state)));
690
695
  state->call = c;
691
696
  GRPC_CLOSURE_INIT(&state->finish_batch, done_termination, state,
@@ -718,7 +723,7 @@ static void cancel_with_status(grpc_call* c, grpc_status_code status,
718
723
  }
719
724
 
720
725
  static void set_final_status(grpc_call* call, grpc_error* error) {
721
- if (grpc_call_error_trace.enabled()) {
726
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_call_error_trace)) {
722
727
  gpr_log(GPR_DEBUG, "set_final_status %s", call->is_client ? "CLI" : "SVR");
723
728
  gpr_log(GPR_DEBUG, "%s", grpc_error_string(error));
724
729
  }
@@ -1069,7 +1074,7 @@ static void recv_trailing_filter(void* args, grpc_metadata_batch* b,
1069
1074
  publish_app_metadata(call, b, true);
1070
1075
  }
1071
1076
 
1072
- gpr_arena* grpc_call_get_arena(grpc_call* call) { return call->arena; }
1077
+ grpc_core::Arena* grpc_call_get_arena(grpc_call* call) { return call->arena; }
1073
1078
 
1074
1079
  grpc_call_stack* grpc_call_get_call_stack(grpc_call* call) {
1075
1080
  return CALL_STACK_FROM_CALL(call);
@@ -1130,8 +1135,7 @@ static batch_control* reuse_or_allocate_batch_control(grpc_call* call,
1130
1135
  bctl->~batch_control();
1131
1136
  bctl->op = {};
1132
1137
  } else {
1133
- bctl = new (gpr_arena_alloc(call->arena, sizeof(batch_control)))
1134
- batch_control();
1138
+ bctl = call->arena->New<batch_control>();
1135
1139
  *pslot = bctl;
1136
1140
  }
1137
1141
  bctl->call = call;
@@ -1221,7 +1225,7 @@ static void post_batch_completion(batch_control* bctl) {
1221
1225
  }
1222
1226
 
1223
1227
  static void finish_batch_step(batch_control* bctl) {
1224
- if (gpr_unref(&bctl->steps_to_complete)) {
1228
+ if (GPR_UNLIKELY(gpr_unref(&bctl->steps_to_complete))) {
1225
1229
  post_batch_completion(bctl);
1226
1230
  }
1227
1231
  }
@@ -1276,7 +1280,7 @@ static void receiving_slice_ready(void* bctlp, grpc_error* error) {
1276
1280
  }
1277
1281
 
1278
1282
  if (error != GRPC_ERROR_NONE) {
1279
- if (grpc_trace_operation_failures.enabled()) {
1283
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures)) {
1280
1284
  GRPC_LOG_IF_ERROR("receiving_slice_ready", GRPC_ERROR_REF(error));
1281
1285
  }
1282
1286
  call->receiving_stream.reset();
@@ -1400,7 +1404,7 @@ static void validate_filtered_metadata(batch_control* bctl) {
1400
1404
 
1401
1405
  GPR_ASSERT(call->encodings_accepted_by_peer != 0);
1402
1406
  if (!GPR_BITGET(call->encodings_accepted_by_peer, compression_algorithm)) {
1403
- if (grpc_compression_trace.enabled()) {
1407
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_compression_trace)) {
1404
1408
  const char* algo_name = nullptr;
1405
1409
  grpc_compression_algorithm_name(compression_algorithm, &algo_name);
1406
1410
  gpr_log(GPR_ERROR,
@@ -1559,7 +1563,10 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1559
1563
  goto done_with_error;
1560
1564
  }
1561
1565
  /* process compression level */
1562
- memset(&call->compression_md, 0, sizeof(call->compression_md));
1566
+ grpc_metadata& compression_md = call->compression_md;
1567
+ compression_md.key = grpc_empty_slice();
1568
+ compression_md.value = grpc_empty_slice();
1569
+ compression_md.flags = 0;
1563
1570
  size_t additional_metadata_count = 0;
1564
1571
  grpc_compression_level effective_compression_level =
1565
1572
  GRPC_COMPRESS_LEVEL_NONE;
@@ -1582,8 +1589,8 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1582
1589
  call, effective_compression_level);
1583
1590
  /* the following will be picked up by the compress filter and used
1584
1591
  * as the call's compression algorithm. */
1585
- call->compression_md.key = GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST;
1586
- call->compression_md.value = grpc_compression_algorithm_slice(calgo);
1592
+ compression_md.key = GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST;
1593
+ compression_md.value = grpc_compression_algorithm_slice(calgo);
1587
1594
  additional_metadata_count++;
1588
1595
  }
1589
1596
 
@@ -1597,8 +1604,7 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1597
1604
  if (!prepare_application_metadata(
1598
1605
  call, static_cast<int>(op->data.send_initial_metadata.count),
1599
1606
  op->data.send_initial_metadata.metadata, 0, call->is_client,
1600
- &call->compression_md,
1601
- static_cast<int>(additional_metadata_count))) {
1607
+ &compression_md, static_cast<int>(additional_metadata_count))) {
1602
1608
  error = GRPC_CALL_ERROR_INVALID_METADATA;
1603
1609
  goto done_with_error;
1604
1610
  }
@@ -23,6 +23,7 @@
23
23
 
24
24
  #include "src/core/lib/channel/channel_stack.h"
25
25
  #include "src/core/lib/channel/context.h"
26
+ #include "src/core/lib/gprpp/arena.h"
26
27
  #include "src/core/lib/surface/api_trace.h"
27
28
 
28
29
  #include <grpc/grpc.h>
@@ -72,7 +73,7 @@ void grpc_call_internal_unref(grpc_call* call);
72
73
  #define GRPC_CALL_INTERNAL_UNREF(call, reason) grpc_call_internal_unref(call)
73
74
  #endif
74
75
 
75
- gpr_arena* grpc_call_get_arena(grpc_call* call);
76
+ grpc_core::Arena* grpc_call_get_arena(grpc_call* call);
76
77
 
77
78
  grpc_call_stack* grpc_call_get_call_stack(grpc_call* call);
78
79
 
@@ -101,7 +102,11 @@ void grpc_call_context_set(grpc_call* call, grpc_context_index elem,
101
102
  void* grpc_call_context_get(grpc_call* call, grpc_context_index elem);
102
103
 
103
104
  #define GRPC_CALL_LOG_BATCH(sev, call, ops, nops, tag) \
104
- if (grpc_api_trace.enabled()) grpc_call_log_batch(sev, call, ops, nops, tag)
105
+ do { \
106
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace)) { \
107
+ grpc_call_log_batch(sev, call, ops, nops, tag); \
108
+ } \
109
+ } while (0)
105
110
 
106
111
  uint8_t grpc_call_is_client(grpc_call* call);
107
112
 
@@ -29,7 +29,6 @@
29
29
 
30
30
  void grpc_call_details_init(grpc_call_details* cd) {
31
31
  GRPC_API_TRACE("grpc_call_details_init(cd=%p)", 1, (cd));
32
- memset(cd, 0, sizeof(*cd));
33
32
  cd->method = grpc_empty_slice();
34
33
  cd->host = grpc_empty_slice();
35
34
  }
@@ -411,13 +411,16 @@ static const cq_vtable g_cq_vtable[] = {
411
411
 
412
412
  grpc_core::TraceFlag grpc_cq_pluck_trace(false, "queue_pluck");
413
413
 
414
- #define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \
415
- if (grpc_api_trace.enabled() && (grpc_cq_pluck_trace.enabled() || \
416
- (event)->type != GRPC_QUEUE_TIMEOUT)) { \
417
- char* _ev = grpc_event_string(event); \
418
- gpr_log(GPR_INFO, "RETURN_EVENT[%p]: %s", cq, _ev); \
419
- gpr_free(_ev); \
420
- }
414
+ #define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \
415
+ do { \
416
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) && \
417
+ (GRPC_TRACE_FLAG_ENABLED(grpc_cq_pluck_trace) || \
418
+ (event)->type != GRPC_QUEUE_TIMEOUT)) { \
419
+ char* _ev = grpc_event_string(event); \
420
+ gpr_log(GPR_INFO, "RETURN_EVENT[%p]: %s", cq, _ev); \
421
+ gpr_free(_ev); \
422
+ } \
423
+ } while (0)
421
424
 
422
425
  static void on_pollset_shutdown_done(void* cq, grpc_error* error);
423
426
 
@@ -572,7 +575,7 @@ int grpc_get_cq_poll_num(grpc_completion_queue* cq) {
572
575
  #ifndef NDEBUG
573
576
  void grpc_cq_internal_ref(grpc_completion_queue* cq, const char* reason,
574
577
  const char* file, int line) {
575
- if (grpc_trace_cq_refcount.enabled()) {
578
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_cq_refcount)) {
576
579
  gpr_atm val = gpr_atm_no_barrier_load(&cq->owning_refs.count);
577
580
  gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
578
581
  "CQ:%p ref %" PRIdPTR " -> %" PRIdPTR " %s", cq, val, val + 1,
@@ -592,7 +595,7 @@ static void on_pollset_shutdown_done(void* arg, grpc_error* error) {
592
595
  #ifndef NDEBUG
593
596
  void grpc_cq_internal_unref(grpc_completion_queue* cq, const char* reason,
594
597
  const char* file, int line) {
595
- if (grpc_trace_cq_refcount.enabled()) {
598
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_cq_refcount)) {
596
599
  gpr_atm val = gpr_atm_no_barrier_load(&cq->owning_refs.count);
597
600
  gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
598
601
  "CQ:%p unref %" PRIdPTR " -> %" PRIdPTR " %s", cq, val, val - 1,
@@ -678,14 +681,16 @@ static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag,
678
681
  void* done_arg, grpc_cq_completion* storage) {
679
682
  GPR_TIMER_SCOPE("cq_end_op_for_next", 0);
680
683
 
681
- if (grpc_api_trace.enabled() ||
682
- (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE)) {
684
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) ||
685
+ (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) &&
686
+ error != GRPC_ERROR_NONE)) {
683
687
  const char* errmsg = grpc_error_string(error);
684
688
  GRPC_API_TRACE(
685
689
  "cq_end_op_for_next(cq=%p, tag=%p, error=%s, "
686
690
  "done=%p, done_arg=%p, storage=%p)",
687
691
  6, (cq, tag, errmsg, done, done_arg, storage));
688
- if (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE) {
692
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) &&
693
+ error != GRPC_ERROR_NONE) {
689
694
  gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
690
695
  }
691
696
  }
@@ -759,14 +764,16 @@ static void cq_end_op_for_pluck(grpc_completion_queue* cq, void* tag,
759
764
  cq_pluck_data* cqd = static_cast<cq_pluck_data*> DATA_FROM_CQ(cq);
760
765
  int is_success = (error == GRPC_ERROR_NONE);
761
766
 
762
- if (grpc_api_trace.enabled() ||
763
- (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE)) {
767
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) ||
768
+ (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) &&
769
+ error != GRPC_ERROR_NONE)) {
764
770
  const char* errmsg = grpc_error_string(error);
765
771
  GRPC_API_TRACE(
766
772
  "cq_end_op_for_pluck(cq=%p, tag=%p, error=%s, "
767
773
  "done=%p, done_arg=%p, storage=%p)",
768
774
  6, (cq, tag, errmsg, done, done_arg, storage));
769
- if (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE) {
775
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) &&
776
+ error != GRPC_ERROR_NONE) {
770
777
  gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
771
778
  }
772
779
  }
@@ -824,14 +831,16 @@ static void cq_end_op_for_callback(
824
831
  cq_callback_data* cqd = static_cast<cq_callback_data*> DATA_FROM_CQ(cq);
825
832
  bool is_success = (error == GRPC_ERROR_NONE);
826
833
 
827
- if (grpc_api_trace.enabled() ||
828
- (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE)) {
834
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) ||
835
+ (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) &&
836
+ error != GRPC_ERROR_NONE)) {
829
837
  const char* errmsg = grpc_error_string(error);
830
838
  GRPC_API_TRACE(
831
839
  "cq_end_op_for_callback(cq=%p, tag=%p, error=%s, "
832
840
  "done=%p, done_arg=%p, storage=%p)",
833
841
  6, (cq, tag, errmsg, done, done_arg, storage));
834
- if (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE) {
842
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) &&
843
+ error != GRPC_ERROR_NONE) {
835
844
  gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
836
845
  }
837
846
  }
@@ -906,7 +915,7 @@ class ExecCtxNext : public grpc_core::ExecCtx {
906
915
 
907
916
  #ifndef NDEBUG
908
917
  static void dump_pending_tags(grpc_completion_queue* cq) {
909
- if (!grpc_trace_pending_tags.enabled()) return;
918
+ if (!GRPC_TRACE_FLAG_ENABLED(grpc_trace_pending_tags)) return;
910
919
 
911
920
  gpr_strvec v;
912
921
  gpr_strvec_init(&v);
@@ -1002,15 +1011,15 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
1002
1011
  continue;
1003
1012
  }
1004
1013
 
1005
- memset(&ret, 0, sizeof(ret));
1006
1014
  ret.type = GRPC_QUEUE_SHUTDOWN;
1015
+ ret.success = 0;
1007
1016
  break;
1008
1017
  }
1009
1018
 
1010
1019
  if (!is_finished_arg.first_loop &&
1011
1020
  grpc_core::ExecCtx::Get()->Now() >= deadline_millis) {
1012
- memset(&ret, 0, sizeof(ret));
1013
1021
  ret.type = GRPC_QUEUE_TIMEOUT;
1022
+ ret.success = 0;
1014
1023
  dump_pending_tags(cq);
1015
1024
  break;
1016
1025
  }
@@ -1027,8 +1036,8 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
1027
1036
  gpr_log(GPR_ERROR, "Completion queue next failed: %s", msg);
1028
1037
 
1029
1038
  GRPC_ERROR_UNREF(err);
1030
- memset(&ret, 0, sizeof(ret));
1031
1039
  ret.type = GRPC_QUEUE_TIMEOUT;
1040
+ ret.success = 0;
1032
1041
  dump_pending_tags(cq);
1033
1042
  break;
1034
1043
  }
@@ -1176,7 +1185,7 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
1176
1185
  grpc_pollset_worker* worker = nullptr;
1177
1186
  cq_pluck_data* cqd = static_cast<cq_pluck_data*> DATA_FROM_CQ(cq);
1178
1187
 
1179
- if (grpc_cq_pluck_trace.enabled()) {
1188
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_cq_pluck_trace)) {
1180
1189
  GRPC_API_TRACE(
1181
1190
  "grpc_completion_queue_pluck("
1182
1191
  "cq=%p, tag=%p, "
@@ -1234,8 +1243,8 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
1234
1243
  }
1235
1244
  if (cqd->shutdown.Load(grpc_core::MemoryOrder::RELAXED)) {
1236
1245
  gpr_mu_unlock(cq->mu);
1237
- memset(&ret, 0, sizeof(ret));
1238
1246
  ret.type = GRPC_QUEUE_SHUTDOWN;
1247
+ ret.success = 0;
1239
1248
  break;
1240
1249
  }
1241
1250
  if (!add_plucker(cq, tag, &worker)) {
@@ -1244,9 +1253,9 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
1244
1253
  "is %d",
1245
1254
  GRPC_MAX_COMPLETION_QUEUE_PLUCKERS);
1246
1255
  gpr_mu_unlock(cq->mu);
1247
- memset(&ret, 0, sizeof(ret));
1248
1256
  /* TODO(ctiller): should we use a different result here */
1249
1257
  ret.type = GRPC_QUEUE_TIMEOUT;
1258
+ ret.success = 0;
1250
1259
  dump_pending_tags(cq);
1251
1260
  break;
1252
1261
  }
@@ -1254,8 +1263,8 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
1254
1263
  grpc_core::ExecCtx::Get()->Now() >= deadline_millis) {
1255
1264
  del_plucker(cq, tag, &worker);
1256
1265
  gpr_mu_unlock(cq->mu);
1257
- memset(&ret, 0, sizeof(ret));
1258
1266
  ret.type = GRPC_QUEUE_TIMEOUT;
1267
+ ret.success = 0;
1259
1268
  dump_pending_tags(cq);
1260
1269
  break;
1261
1270
  }
@@ -1269,8 +1278,8 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
1269
1278
  gpr_log(GPR_ERROR, "Completion queue pluck failed: %s", msg);
1270
1279
 
1271
1280
  GRPC_ERROR_UNREF(err);
1272
- memset(&ret, 0, sizeof(ret));
1273
1281
  ret.type = GRPC_QUEUE_TIMEOUT;
1282
+ ret.success = 0;
1274
1283
  dump_pending_tags(cq);
1275
1284
  break;
1276
1285
  }