grpc 1.18.0 → 1.19.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 (147) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +301 -33
  3. data/include/grpc/grpc_security.h +195 -0
  4. data/include/grpc/impl/codegen/grpc_types.h +17 -1
  5. data/include/grpc/impl/codegen/port_platform.h +40 -0
  6. data/include/grpc/impl/codegen/slice.h +1 -1
  7. data/src/core/ext/filters/client_channel/channel_connectivity.cc +2 -0
  8. data/src/core/ext/filters/client_channel/client_channel.cc +74 -69
  9. data/src/core/ext/filters/client_channel/client_channel.h +2 -2
  10. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +5 -6
  11. data/src/core/ext/filters/client_channel/client_channel_channelz.h +5 -4
  12. data/src/core/ext/filters/client_channel/client_channel_factory.cc +2 -2
  13. data/src/core/ext/filters/client_channel/client_channel_factory.h +4 -4
  14. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +3 -3
  15. data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +176 -0
  16. data/src/core/ext/filters/client_channel/global_subchannel_pool.h +68 -0
  17. data/src/core/ext/filters/client_channel/health/health_check_client.cc +10 -8
  18. data/src/core/ext/filters/client_channel/health/health_check_client.h +1 -1
  19. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +146 -156
  20. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +28 -30
  21. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +5 -8
  22. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +5 -8
  23. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +23 -24
  24. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +80 -15
  25. data/src/core/ext/filters/client_channel/lb_policy.cc +30 -1
  26. data/src/core/ext/filters/client_channel/lb_policy.h +29 -1
  27. data/src/core/ext/filters/client_channel/lb_policy_factory.h +6 -1
  28. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +2 -2
  29. data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
  30. data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +96 -0
  31. data/src/core/ext/filters/client_channel/local_subchannel_pool.h +56 -0
  32. data/src/core/ext/filters/client_channel/parse_address.cc +24 -5
  33. data/src/core/ext/filters/client_channel/request_routing.cc +13 -3
  34. data/src/core/ext/filters/client_channel/request_routing.h +5 -1
  35. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +11 -6
  36. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +9 -6
  37. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +2 -2
  38. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +7 -35
  39. data/src/core/ext/filters/client_channel/subchannel.cc +698 -791
  40. data/src/core/ext/filters/client_channel/subchannel.h +213 -123
  41. data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +97 -0
  42. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +94 -0
  43. data/src/core/ext/filters/http/client_authority_filter.cc +5 -2
  44. data/src/core/ext/filters/max_age/max_age_filter.cc +1 -1
  45. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +13 -12
  46. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +5 -7
  47. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +19 -27
  48. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +18 -19
  49. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +27 -6
  50. data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -1
  51. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +3 -2
  52. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +1 -1
  53. data/src/core/ext/transport/chttp2/transport/writing.cc +8 -5
  54. data/src/core/lib/channel/handshaker.cc +141 -214
  55. data/src/core/lib/channel/handshaker.h +110 -101
  56. data/src/core/lib/channel/handshaker_factory.h +11 -19
  57. data/src/core/lib/channel/handshaker_registry.cc +64 -52
  58. data/src/core/lib/channel/handshaker_registry.h +21 -16
  59. data/src/core/lib/gpr/log_posix.cc +2 -1
  60. data/src/core/lib/gpr/time.cc +8 -0
  61. data/src/core/lib/gpr/time_posix.cc +8 -2
  62. data/src/core/lib/gprpp/optional.h +47 -0
  63. data/src/core/lib/http/httpcli_security_connector.cc +13 -14
  64. data/src/core/lib/iomgr/buffer_list.cc +182 -24
  65. data/src/core/lib/iomgr/buffer_list.h +70 -8
  66. data/src/core/lib/iomgr/combiner.cc +11 -3
  67. data/src/core/lib/iomgr/error.cc +9 -5
  68. data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -0
  69. data/src/core/lib/iomgr/ev_epollex_linux.cc +136 -162
  70. data/src/core/lib/iomgr/ev_poll_posix.cc +3 -0
  71. data/src/core/lib/iomgr/ev_posix.cc +4 -0
  72. data/src/core/lib/iomgr/ev_posix.h +4 -0
  73. data/src/core/lib/iomgr/exec_ctx.cc +1 -0
  74. data/src/core/lib/iomgr/exec_ctx.h +137 -8
  75. data/src/core/lib/iomgr/executor.cc +122 -87
  76. data/src/core/lib/iomgr/executor.h +53 -48
  77. data/src/core/lib/iomgr/fork_posix.cc +6 -4
  78. data/src/core/lib/iomgr/{network_status_tracker.cc → grpc_if_nametoindex.h} +8 -14
  79. data/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc +42 -0
  80. data/src/core/lib/iomgr/{network_status_tracker.h → grpc_if_nametoindex_unsupported.cc} +15 -9
  81. data/src/core/lib/iomgr/internal_errqueue.h +105 -3
  82. data/src/core/lib/iomgr/iomgr.cc +6 -5
  83. data/src/core/lib/iomgr/iomgr.h +8 -0
  84. data/src/core/lib/iomgr/iomgr_custom.cc +6 -2
  85. data/src/core/lib/iomgr/iomgr_internal.cc +4 -0
  86. data/src/core/lib/iomgr/iomgr_internal.h +4 -0
  87. data/src/core/lib/iomgr/iomgr_posix.cc +10 -1
  88. data/src/core/lib/iomgr/iomgr_windows.cc +8 -1
  89. data/src/core/lib/iomgr/port.h +1 -0
  90. data/src/core/lib/iomgr/resolve_address_posix.cc +4 -3
  91. data/src/core/lib/iomgr/resolve_address_windows.cc +2 -1
  92. data/src/core/lib/iomgr/tcp_custom.cc +0 -4
  93. data/src/core/lib/iomgr/tcp_posix.cc +58 -44
  94. data/src/core/lib/iomgr/tcp_uv.cc +0 -1
  95. data/src/core/lib/iomgr/tcp_windows.cc +0 -4
  96. data/src/core/lib/iomgr/timer_manager.cc +8 -0
  97. data/src/core/lib/iomgr/udp_server.cc +6 -4
  98. data/src/core/lib/json/json.cc +1 -4
  99. data/src/core/lib/security/credentials/alts/alts_credentials.cc +1 -1
  100. data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +2 -2
  101. data/src/core/lib/security/credentials/composite/composite_credentials.h +4 -0
  102. data/src/core/lib/security/credentials/credentials.h +9 -1
  103. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +15 -2
  104. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +2 -0
  105. data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
  106. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +1 -0
  107. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +3 -2
  108. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +2 -2
  109. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +1 -0
  110. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +192 -0
  111. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +213 -0
  112. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +10 -8
  113. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +6 -10
  114. data/src/core/lib/security/security_connector/local/local_security_connector.cc +10 -8
  115. data/src/core/lib/security/security_connector/security_connector.h +2 -2
  116. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +4 -6
  117. data/src/core/lib/security/security_connector/ssl_utils.h +33 -0
  118. data/src/core/lib/security/transport/security_handshaker.cc +267 -300
  119. data/src/core/lib/security/transport/security_handshaker.h +11 -2
  120. data/src/core/lib/security/transport/server_auth_filter.cc +1 -0
  121. data/src/core/lib/surface/call.cc +5 -1
  122. data/src/core/lib/surface/channel_init.h +5 -0
  123. data/src/core/lib/surface/completion_queue.cc +4 -7
  124. data/src/core/lib/surface/init.cc +5 -3
  125. data/src/core/lib/surface/init_secure.cc +1 -1
  126. data/src/core/lib/surface/server.cc +19 -17
  127. data/src/core/lib/surface/version.cc +1 -1
  128. data/src/core/lib/transport/service_config.h +1 -0
  129. data/src/core/lib/transport/static_metadata.cc +279 -279
  130. data/src/core/lib/transport/transport.cc +5 -3
  131. data/src/core/tsi/ssl_transport_security.cc +10 -4
  132. data/src/ruby/ext/grpc/extconf.rb +12 -4
  133. data/src/ruby/ext/grpc/rb_call_credentials.c +8 -5
  134. data/src/ruby/ext/grpc/rb_channel.c +14 -10
  135. data/src/ruby/ext/grpc/rb_channel_credentials.c +8 -4
  136. data/src/ruby/ext/grpc/rb_compression_options.c +9 -7
  137. data/src/ruby/ext/grpc/rb_event_thread.c +2 -0
  138. data/src/ruby/ext/grpc/rb_grpc.c +22 -23
  139. data/src/ruby/ext/grpc/rb_grpc.h +4 -2
  140. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +18 -0
  141. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +27 -0
  142. data/src/ruby/ext/grpc/rb_server.c +8 -4
  143. data/src/ruby/lib/grpc/version.rb +1 -1
  144. metadata +45 -38
  145. data/src/core/ext/filters/client_channel/subchannel_index.cc +0 -248
  146. data/src/core/ext/filters/client_channel/subchannel_index.h +0 -76
  147. data/src/core/lib/channel/handshaker_factory.cc +0 -42
@@ -394,7 +394,7 @@ struct subchannel_batch_data {
394
394
 
395
395
  gpr_refcount refs;
396
396
  grpc_call_element* elem;
397
- grpc_subchannel_call* subchannel_call; // Holds a ref.
397
+ grpc_core::RefCountedPtr<grpc_core::SubchannelCall> subchannel_call;
398
398
  // The batch to use in the subchannel call.
399
399
  // Its payload field points to subchannel_call_retry_state.batch_payload.
400
400
  grpc_transport_stream_op_batch batch;
@@ -478,7 +478,7 @@ struct pending_batch {
478
478
  bool send_ops_cached;
479
479
  };
480
480
 
481
- /** Call data. Holds a pointer to grpc_subchannel_call and the
481
+ /** Call data. Holds a pointer to SubchannelCall and the
482
482
  associated machinery to create such a pointer.
483
483
  Handles queueing of stream ops until a call object is ready, waiting
484
484
  for initial metadata before trying to create a call object,
@@ -504,10 +504,6 @@ struct call_data {
504
504
  last_attempt_got_server_pushback(false) {}
505
505
 
506
506
  ~call_data() {
507
- if (GPR_LIKELY(subchannel_call != nullptr)) {
508
- GRPC_SUBCHANNEL_CALL_UNREF(subchannel_call,
509
- "client_channel_destroy_call");
510
- }
511
507
  grpc_slice_unref_internal(path);
512
508
  GRPC_ERROR_UNREF(cancel_error);
513
509
  for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches); ++i) {
@@ -536,7 +532,7 @@ struct call_data {
536
532
  grpc_core::RefCountedPtr<ServerRetryThrottleData> retry_throttle_data;
537
533
  grpc_core::RefCountedPtr<ClientChannelMethodParams> method_params;
538
534
 
539
- grpc_subchannel_call* subchannel_call = nullptr;
535
+ grpc_core::RefCountedPtr<grpc_core::SubchannelCall> subchannel_call;
540
536
 
541
537
  // Set when we get a cancel_stream op.
542
538
  grpc_error* cancel_error = GRPC_ERROR_NONE;
@@ -727,6 +723,25 @@ static void free_cached_send_op_data_for_completed_batch(
727
723
  }
728
724
  }
729
725
 
726
+ //
727
+ // LB recv_trailing_metadata_ready handling
728
+ //
729
+
730
+ void maybe_inject_recv_trailing_metadata_ready_for_lb(
731
+ const grpc_core::LoadBalancingPolicy::PickState& pick,
732
+ grpc_transport_stream_op_batch* batch) {
733
+ if (pick.recv_trailing_metadata_ready != nullptr) {
734
+ *pick.original_recv_trailing_metadata_ready =
735
+ batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready;
736
+ batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready =
737
+ pick.recv_trailing_metadata_ready;
738
+ if (pick.recv_trailing_metadata != nullptr) {
739
+ *pick.recv_trailing_metadata =
740
+ batch->payload->recv_trailing_metadata.recv_trailing_metadata;
741
+ }
742
+ }
743
+ }
744
+
730
745
  //
731
746
  // pending_batches management
732
747
  //
@@ -788,8 +803,8 @@ static void pending_batches_add(grpc_call_element* elem,
788
803
  calld->subchannel_call == nullptr
789
804
  ? nullptr
790
805
  : static_cast<subchannel_call_retry_state*>(
791
- grpc_connected_subchannel_call_get_parent_data(
792
- calld->subchannel_call));
806
+
807
+ calld->subchannel_call->GetParentData());
793
808
  retry_commit(elem, retry_state);
794
809
  // If we are not going to retry and have not yet started, pretend
795
810
  // retries are disabled so that we don't bother with retry overhead.
@@ -851,6 +866,10 @@ static void pending_batches_fail(grpc_call_element* elem, grpc_error* error,
851
866
  pending_batch* pending = &calld->pending_batches[i];
852
867
  grpc_transport_stream_op_batch* batch = pending->batch;
853
868
  if (batch != nullptr) {
869
+ if (batch->recv_trailing_metadata && calld->have_request) {
870
+ maybe_inject_recv_trailing_metadata_ready_for_lb(
871
+ *calld->request->pick(), batch);
872
+ }
854
873
  batch->handler_private.extra_arg = calld;
855
874
  GRPC_CLOSURE_INIT(&batch->handler_private.closure,
856
875
  fail_pending_batch_in_call_combiner, batch,
@@ -873,10 +892,10 @@ static void resume_pending_batch_in_call_combiner(void* arg,
873
892
  grpc_error* ignored) {
874
893
  grpc_transport_stream_op_batch* batch =
875
894
  static_cast<grpc_transport_stream_op_batch*>(arg);
876
- grpc_subchannel_call* subchannel_call =
877
- static_cast<grpc_subchannel_call*>(batch->handler_private.extra_arg);
895
+ grpc_core::SubchannelCall* subchannel_call =
896
+ static_cast<grpc_core::SubchannelCall*>(batch->handler_private.extra_arg);
878
897
  // Note: This will release the call combiner.
879
- grpc_subchannel_call_process_op(subchannel_call, batch);
898
+ subchannel_call->StartTransportStreamOpBatch(batch);
880
899
  }
881
900
 
882
901
  // This is called via the call combiner, so access to calld is synchronized.
@@ -896,14 +915,18 @@ static void pending_batches_resume(grpc_call_element* elem) {
896
915
  gpr_log(GPR_INFO,
897
916
  "chand=%p calld=%p: starting %" PRIuPTR
898
917
  " pending batches on subchannel_call=%p",
899
- chand, calld, num_batches, calld->subchannel_call);
918
+ chand, calld, num_batches, calld->subchannel_call.get());
900
919
  }
901
920
  grpc_core::CallCombinerClosureList closures;
902
921
  for (size_t i = 0; i < GPR_ARRAY_SIZE(calld->pending_batches); ++i) {
903
922
  pending_batch* pending = &calld->pending_batches[i];
904
923
  grpc_transport_stream_op_batch* batch = pending->batch;
905
924
  if (batch != nullptr) {
906
- batch->handler_private.extra_arg = calld->subchannel_call;
925
+ if (batch->recv_trailing_metadata) {
926
+ maybe_inject_recv_trailing_metadata_ready_for_lb(
927
+ *calld->request->pick(), batch);
928
+ }
929
+ batch->handler_private.extra_arg = calld->subchannel_call.get();
907
930
  GRPC_CLOSURE_INIT(&batch->handler_private.closure,
908
931
  resume_pending_batch_in_call_combiner, batch,
909
932
  grpc_schedule_on_exec_ctx);
@@ -992,12 +1015,7 @@ static void do_retry(grpc_call_element* elem,
992
1015
  const ClientChannelMethodParams::RetryPolicy* retry_policy =
993
1016
  calld->method_params->retry_policy();
994
1017
  GPR_ASSERT(retry_policy != nullptr);
995
- // Reset subchannel call and connected subchannel.
996
- if (calld->subchannel_call != nullptr) {
997
- GRPC_SUBCHANNEL_CALL_UNREF(calld->subchannel_call,
998
- "client_channel_call_retry");
999
- calld->subchannel_call = nullptr;
1000
- }
1018
+ calld->subchannel_call.reset();
1001
1019
  if (calld->have_request) {
1002
1020
  calld->have_request = false;
1003
1021
  calld->request.Destroy();
@@ -1051,8 +1069,7 @@ static bool maybe_retry(grpc_call_element* elem,
1051
1069
  subchannel_call_retry_state* retry_state = nullptr;
1052
1070
  if (batch_data != nullptr) {
1053
1071
  retry_state = static_cast<subchannel_call_retry_state*>(
1054
- grpc_connected_subchannel_call_get_parent_data(
1055
- batch_data->subchannel_call));
1072
+ batch_data->subchannel_call->GetParentData());
1056
1073
  if (retry_state->retry_dispatched) {
1057
1074
  if (grpc_client_channel_trace.enabled()) {
1058
1075
  gpr_log(GPR_INFO, "chand=%p calld=%p: retry already dispatched", chand,
@@ -1153,13 +1170,10 @@ namespace {
1153
1170
  subchannel_batch_data::subchannel_batch_data(grpc_call_element* elem,
1154
1171
  call_data* calld, int refcount,
1155
1172
  bool set_on_complete)
1156
- : elem(elem),
1157
- subchannel_call(GRPC_SUBCHANNEL_CALL_REF(calld->subchannel_call,
1158
- "batch_data_create")) {
1173
+ : elem(elem), subchannel_call(calld->subchannel_call) {
1159
1174
  subchannel_call_retry_state* retry_state =
1160
1175
  static_cast<subchannel_call_retry_state*>(
1161
- grpc_connected_subchannel_call_get_parent_data(
1162
- calld->subchannel_call));
1176
+ calld->subchannel_call->GetParentData());
1163
1177
  batch.payload = &retry_state->batch_payload;
1164
1178
  gpr_ref_init(&refs, refcount);
1165
1179
  if (set_on_complete) {
@@ -1173,7 +1187,7 @@ subchannel_batch_data::subchannel_batch_data(grpc_call_element* elem,
1173
1187
  void subchannel_batch_data::destroy() {
1174
1188
  subchannel_call_retry_state* retry_state =
1175
1189
  static_cast<subchannel_call_retry_state*>(
1176
- grpc_connected_subchannel_call_get_parent_data(subchannel_call));
1190
+ subchannel_call->GetParentData());
1177
1191
  if (batch.send_initial_metadata) {
1178
1192
  grpc_metadata_batch_destroy(&retry_state->send_initial_metadata);
1179
1193
  }
@@ -1186,7 +1200,7 @@ void subchannel_batch_data::destroy() {
1186
1200
  if (batch.recv_trailing_metadata) {
1187
1201
  grpc_metadata_batch_destroy(&retry_state->recv_trailing_metadata);
1188
1202
  }
1189
- GRPC_SUBCHANNEL_CALL_UNREF(subchannel_call, "batch_data_unref");
1203
+ subchannel_call.reset();
1190
1204
  call_data* calld = static_cast<call_data*>(elem->call_data);
1191
1205
  GRPC_CALL_STACK_UNREF(calld->owning_call, "batch_data");
1192
1206
  }
@@ -1233,8 +1247,7 @@ static void invoke_recv_initial_metadata_callback(void* arg,
1233
1247
  // Return metadata.
1234
1248
  subchannel_call_retry_state* retry_state =
1235
1249
  static_cast<subchannel_call_retry_state*>(
1236
- grpc_connected_subchannel_call_get_parent_data(
1237
- batch_data->subchannel_call));
1250
+ batch_data->subchannel_call->GetParentData());
1238
1251
  grpc_metadata_batch_move(
1239
1252
  &retry_state->recv_initial_metadata,
1240
1253
  pending->batch->payload->recv_initial_metadata.recv_initial_metadata);
@@ -1266,8 +1279,7 @@ static void recv_initial_metadata_ready(void* arg, grpc_error* error) {
1266
1279
  }
1267
1280
  subchannel_call_retry_state* retry_state =
1268
1281
  static_cast<subchannel_call_retry_state*>(
1269
- grpc_connected_subchannel_call_get_parent_data(
1270
- batch_data->subchannel_call));
1282
+ batch_data->subchannel_call->GetParentData());
1271
1283
  retry_state->completed_recv_initial_metadata = true;
1272
1284
  // If a retry was already dispatched, then we're not going to use the
1273
1285
  // result of this recv_initial_metadata op, so do nothing.
@@ -1328,8 +1340,7 @@ static void invoke_recv_message_callback(void* arg, grpc_error* error) {
1328
1340
  // Return payload.
1329
1341
  subchannel_call_retry_state* retry_state =
1330
1342
  static_cast<subchannel_call_retry_state*>(
1331
- grpc_connected_subchannel_call_get_parent_data(
1332
- batch_data->subchannel_call));
1343
+ batch_data->subchannel_call->GetParentData());
1333
1344
  *pending->batch->payload->recv_message.recv_message =
1334
1345
  std::move(retry_state->recv_message);
1335
1346
  // Update bookkeeping.
@@ -1357,8 +1368,7 @@ static void recv_message_ready(void* arg, grpc_error* error) {
1357
1368
  }
1358
1369
  subchannel_call_retry_state* retry_state =
1359
1370
  static_cast<subchannel_call_retry_state*>(
1360
- grpc_connected_subchannel_call_get_parent_data(
1361
- batch_data->subchannel_call));
1371
+ batch_data->subchannel_call->GetParentData());
1362
1372
  ++retry_state->completed_recv_message_count;
1363
1373
  // If a retry was already dispatched, then we're not going to use the
1364
1374
  // result of this recv_message op, so do nothing.
@@ -1446,8 +1456,7 @@ static void add_closure_for_recv_trailing_metadata_ready(
1446
1456
  // Return metadata.
1447
1457
  subchannel_call_retry_state* retry_state =
1448
1458
  static_cast<subchannel_call_retry_state*>(
1449
- grpc_connected_subchannel_call_get_parent_data(
1450
- batch_data->subchannel_call));
1459
+ batch_data->subchannel_call->GetParentData());
1451
1460
  grpc_metadata_batch_move(
1452
1461
  &retry_state->recv_trailing_metadata,
1453
1462
  pending->batch->payload->recv_trailing_metadata.recv_trailing_metadata);
@@ -1549,8 +1558,7 @@ static void run_closures_for_completed_call(subchannel_batch_data* batch_data,
1549
1558
  call_data* calld = static_cast<call_data*>(elem->call_data);
1550
1559
  subchannel_call_retry_state* retry_state =
1551
1560
  static_cast<subchannel_call_retry_state*>(
1552
- grpc_connected_subchannel_call_get_parent_data(
1553
- batch_data->subchannel_call));
1561
+ batch_data->subchannel_call->GetParentData());
1554
1562
  // Construct list of closures to execute.
1555
1563
  grpc_core::CallCombinerClosureList closures;
1556
1564
  // First, add closure for recv_trailing_metadata_ready.
@@ -1584,8 +1592,7 @@ static void recv_trailing_metadata_ready(void* arg, grpc_error* error) {
1584
1592
  }
1585
1593
  subchannel_call_retry_state* retry_state =
1586
1594
  static_cast<subchannel_call_retry_state*>(
1587
- grpc_connected_subchannel_call_get_parent_data(
1588
- batch_data->subchannel_call));
1595
+ batch_data->subchannel_call->GetParentData());
1589
1596
  retry_state->completed_recv_trailing_metadata = true;
1590
1597
  // Get the call's status and check for server pushback metadata.
1591
1598
  grpc_status_code status = GRPC_STATUS_OK;
@@ -1708,8 +1715,7 @@ static void on_complete(void* arg, grpc_error* error) {
1708
1715
  }
1709
1716
  subchannel_call_retry_state* retry_state =
1710
1717
  static_cast<subchannel_call_retry_state*>(
1711
- grpc_connected_subchannel_call_get_parent_data(
1712
- batch_data->subchannel_call));
1718
+ batch_data->subchannel_call->GetParentData());
1713
1719
  // Update bookkeeping in retry_state.
1714
1720
  if (batch_data->batch.send_initial_metadata) {
1715
1721
  retry_state->completed_send_initial_metadata = true;
@@ -1765,10 +1771,10 @@ static void on_complete(void* arg, grpc_error* error) {
1765
1771
  static void start_batch_in_call_combiner(void* arg, grpc_error* ignored) {
1766
1772
  grpc_transport_stream_op_batch* batch =
1767
1773
  static_cast<grpc_transport_stream_op_batch*>(arg);
1768
- grpc_subchannel_call* subchannel_call =
1769
- static_cast<grpc_subchannel_call*>(batch->handler_private.extra_arg);
1774
+ grpc_core::SubchannelCall* subchannel_call =
1775
+ static_cast<grpc_core::SubchannelCall*>(batch->handler_private.extra_arg);
1770
1776
  // Note: This will release the call combiner.
1771
- grpc_subchannel_call_process_op(subchannel_call, batch);
1777
+ subchannel_call->StartTransportStreamOpBatch(batch);
1772
1778
  }
1773
1779
 
1774
1780
  // Adds a closure to closures that will execute batch in the call combiner.
@@ -1777,7 +1783,7 @@ static void add_closure_for_subchannel_batch(
1777
1783
  grpc_core::CallCombinerClosureList* closures) {
1778
1784
  channel_data* chand = static_cast<channel_data*>(elem->channel_data);
1779
1785
  call_data* calld = static_cast<call_data*>(elem->call_data);
1780
- batch->handler_private.extra_arg = calld->subchannel_call;
1786
+ batch->handler_private.extra_arg = calld->subchannel_call.get();
1781
1787
  GRPC_CLOSURE_INIT(&batch->handler_private.closure,
1782
1788
  start_batch_in_call_combiner, batch,
1783
1789
  grpc_schedule_on_exec_ctx);
@@ -1932,6 +1938,8 @@ static void add_retriable_recv_trailing_metadata_op(
1932
1938
  batch_data->batch.payload->recv_trailing_metadata
1933
1939
  .recv_trailing_metadata_ready =
1934
1940
  &retry_state->recv_trailing_metadata_ready;
1941
+ maybe_inject_recv_trailing_metadata_ready_for_lb(*calld->request->pick(),
1942
+ &batch_data->batch);
1935
1943
  }
1936
1944
 
1937
1945
  // Helper function used to start a recv_trailing_metadata batch. This
@@ -1949,8 +1957,7 @@ static void start_internal_recv_trailing_metadata(grpc_call_element* elem) {
1949
1957
  }
1950
1958
  subchannel_call_retry_state* retry_state =
1951
1959
  static_cast<subchannel_call_retry_state*>(
1952
- grpc_connected_subchannel_call_get_parent_data(
1953
- calld->subchannel_call));
1960
+ calld->subchannel_call->GetParentData());
1954
1961
  // Create batch_data with 2 refs, since this batch will be unreffed twice:
1955
1962
  // once for the recv_trailing_metadata_ready callback when the subchannel
1956
1963
  // batch returns, and again when we actually get a recv_trailing_metadata
@@ -1960,7 +1967,7 @@ static void start_internal_recv_trailing_metadata(grpc_call_element* elem) {
1960
1967
  add_retriable_recv_trailing_metadata_op(calld, retry_state, batch_data);
1961
1968
  retry_state->recv_trailing_metadata_internal_batch = batch_data;
1962
1969
  // Note: This will release the call combiner.
1963
- grpc_subchannel_call_process_op(calld->subchannel_call, &batch_data->batch);
1970
+ calld->subchannel_call->StartTransportStreamOpBatch(&batch_data->batch);
1964
1971
  }
1965
1972
 
1966
1973
  // If there are any cached send ops that need to be replayed on the
@@ -2167,8 +2174,7 @@ static void start_retriable_subchannel_batches(void* arg, grpc_error* ignored) {
2167
2174
  }
2168
2175
  subchannel_call_retry_state* retry_state =
2169
2176
  static_cast<subchannel_call_retry_state*>(
2170
- grpc_connected_subchannel_call_get_parent_data(
2171
- calld->subchannel_call));
2177
+ calld->subchannel_call->GetParentData());
2172
2178
  // Construct list of closures to execute, one for each pending batch.
2173
2179
  grpc_core::CallCombinerClosureList closures;
2174
2180
  // Replay previously-returned send_* ops if needed.
@@ -2191,7 +2197,7 @@ static void start_retriable_subchannel_batches(void* arg, grpc_error* ignored) {
2191
2197
  gpr_log(GPR_INFO,
2192
2198
  "chand=%p calld=%p: starting %" PRIuPTR
2193
2199
  " retriable batches on subchannel_call=%p",
2194
- chand, calld, closures.size(), calld->subchannel_call);
2200
+ chand, calld, closures.size(), calld->subchannel_call.get());
2195
2201
  }
2196
2202
  // Note: This will yield the call combiner.
2197
2203
  closures.RunClosures(calld->call_combiner);
@@ -2216,22 +2222,22 @@ static void create_subchannel_call(grpc_call_element* elem, grpc_error* error) {
2216
2222
  calld->call_combiner, // call_combiner
2217
2223
  parent_data_size // parent_data_size
2218
2224
  };
2219
- grpc_error* new_error =
2220
- calld->request->pick()->connected_subchannel->CreateCall(
2221
- call_args, &calld->subchannel_call);
2225
+ grpc_error* new_error = GRPC_ERROR_NONE;
2226
+ calld->subchannel_call =
2227
+ calld->request->pick()->connected_subchannel->CreateCall(call_args,
2228
+ &new_error);
2222
2229
  if (grpc_client_channel_trace.enabled()) {
2223
2230
  gpr_log(GPR_INFO, "chand=%p calld=%p: create subchannel_call=%p: error=%s",
2224
- chand, calld, calld->subchannel_call, grpc_error_string(new_error));
2231
+ chand, calld, calld->subchannel_call.get(),
2232
+ grpc_error_string(new_error));
2225
2233
  }
2226
2234
  if (GPR_UNLIKELY(new_error != GRPC_ERROR_NONE)) {
2227
2235
  new_error = grpc_error_add_child(new_error, error);
2228
2236
  pending_batches_fail(elem, new_error, true /* yield_call_combiner */);
2229
2237
  } else {
2230
2238
  if (parent_data_size > 0) {
2231
- new (grpc_connected_subchannel_call_get_parent_data(
2232
- calld->subchannel_call))
2233
- subchannel_call_retry_state(
2234
- calld->request->pick()->subchannel_call_context);
2239
+ new (calld->subchannel_call->GetParentData()) subchannel_call_retry_state(
2240
+ calld->request->pick()->subchannel_call_context);
2235
2241
  }
2236
2242
  pending_batches_resume(elem);
2237
2243
  }
@@ -2459,7 +2465,7 @@ static void cc_start_transport_stream_op_batch(
2459
2465
  batch, GRPC_ERROR_REF(calld->cancel_error), calld->call_combiner);
2460
2466
  } else {
2461
2467
  // Note: This will release the call combiner.
2462
- grpc_subchannel_call_process_op(calld->subchannel_call, batch);
2468
+ calld->subchannel_call->StartTransportStreamOpBatch(batch);
2463
2469
  }
2464
2470
  return;
2465
2471
  }
@@ -2473,7 +2479,7 @@ static void cc_start_transport_stream_op_batch(
2473
2479
  if (grpc_client_channel_trace.enabled()) {
2474
2480
  gpr_log(GPR_INFO,
2475
2481
  "chand=%p calld=%p: starting batch on subchannel_call=%p", chand,
2476
- calld, calld->subchannel_call);
2482
+ calld, calld->subchannel_call.get());
2477
2483
  }
2478
2484
  pending_batches_resume(elem);
2479
2485
  return;
@@ -2516,8 +2522,7 @@ static void cc_destroy_call_elem(grpc_call_element* elem,
2516
2522
  grpc_closure* then_schedule_closure) {
2517
2523
  call_data* calld = static_cast<call_data*>(elem->call_data);
2518
2524
  if (GPR_LIKELY(calld->subchannel_call != nullptr)) {
2519
- grpc_subchannel_call_set_cleanup_closure(calld->subchannel_call,
2520
- then_schedule_closure);
2525
+ calld->subchannel_call->SetAfterCallStackDestroy(then_schedule_closure);
2521
2526
  then_schedule_closure = nullptr;
2522
2527
  }
2523
2528
  calld->~call_data();
@@ -2723,8 +2728,8 @@ void grpc_client_channel_watch_connectivity_state(
2723
2728
  GRPC_ERROR_NONE);
2724
2729
  }
2725
2730
 
2726
- grpc_subchannel_call* grpc_client_channel_get_subchannel_call(
2727
- grpc_call_element* elem) {
2731
+ grpc_core::RefCountedPtr<grpc_core::SubchannelCall>
2732
+ grpc_client_channel_get_subchannel_call(grpc_call_element* elem) {
2728
2733
  call_data* calld = static_cast<call_data*>(elem->call_data);
2729
2734
  return calld->subchannel_call;
2730
2735
  }
@@ -60,7 +60,7 @@ void grpc_client_channel_watch_connectivity_state(
60
60
  grpc_closure* watcher_timer_init);
61
61
 
62
62
  /* Debug helper: pull the subchannel call from a call stack element */
63
- grpc_subchannel_call* grpc_client_channel_get_subchannel_call(
64
- grpc_call_element* elem);
63
+ grpc_core::RefCountedPtr<grpc_core::SubchannelCall>
64
+ grpc_client_channel_get_subchannel_call(grpc_call_element* elem);
65
65
 
66
66
  #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_H */
@@ -113,12 +113,11 @@ RefCountedPtr<ChannelNode> ClientChannelNode::MakeClientChannelNode(
113
113
  is_top_level_channel);
114
114
  }
115
115
 
116
- SubchannelNode::SubchannelNode(grpc_subchannel* subchannel,
116
+ SubchannelNode::SubchannelNode(Subchannel* subchannel,
117
117
  size_t channel_tracer_max_nodes)
118
118
  : BaseNode(EntityType::kSubchannel),
119
119
  subchannel_(subchannel),
120
- target_(
121
- UniquePtr<char>(gpr_strdup(grpc_subchannel_get_target(subchannel_)))),
120
+ target_(UniquePtr<char>(gpr_strdup(subchannel_->GetTargetAddress()))),
122
121
  trace_(channel_tracer_max_nodes) {}
123
122
 
124
123
  SubchannelNode::~SubchannelNode() {}
@@ -128,8 +127,8 @@ void SubchannelNode::PopulateConnectivityState(grpc_json* json) {
128
127
  if (subchannel_ == nullptr) {
129
128
  state = GRPC_CHANNEL_SHUTDOWN;
130
129
  } else {
131
- state = grpc_subchannel_check_connectivity(
132
- subchannel_, nullptr, true /* inhibit_health_checking */);
130
+ state = subchannel_->CheckConnectivity(nullptr,
131
+ true /* inhibit_health_checking */);
133
132
  }
134
133
  json = grpc_json_create_child(nullptr, json, "state", nullptr,
135
134
  GRPC_JSON_OBJECT, false);
@@ -170,7 +169,7 @@ grpc_json* SubchannelNode::RenderJson() {
170
169
  call_counter_.PopulateCallCounts(json);
171
170
  json = top_level_json;
172
171
  // populate the child socket.
173
- intptr_t socket_uuid = grpc_subchannel_get_child_socket_uuid(subchannel_);
172
+ intptr_t socket_uuid = subchannel_->GetChildSocketUuid();
174
173
  if (socket_uuid != 0) {
175
174
  grpc_json* array_parent = grpc_json_create_child(
176
175
  nullptr, json, "socketRef", nullptr, GRPC_JSON_ARRAY, false);
@@ -26,9 +26,10 @@
26
26
  #include "src/core/lib/channel/channel_trace.h"
27
27
  #include "src/core/lib/channel/channelz.h"
28
28
 
29
- typedef struct grpc_subchannel grpc_subchannel;
30
-
31
29
  namespace grpc_core {
30
+
31
+ class Subchannel;
32
+
32
33
  namespace channelz {
33
34
 
34
35
  // Subtype of ChannelNode that overrides and provides client_channel specific
@@ -59,7 +60,7 @@ class ClientChannelNode : public ChannelNode {
59
60
  // Handles channelz bookkeeping for sockets
60
61
  class SubchannelNode : public BaseNode {
61
62
  public:
62
- SubchannelNode(grpc_subchannel* subchannel, size_t channel_tracer_max_nodes);
63
+ SubchannelNode(Subchannel* subchannel, size_t channel_tracer_max_nodes);
63
64
  ~SubchannelNode() override;
64
65
 
65
66
  void MarkSubchannelDestroyed() {
@@ -84,7 +85,7 @@ class SubchannelNode : public BaseNode {
84
85
  void RecordCallSucceeded() { call_counter_.RecordCallSucceeded(); }
85
86
 
86
87
  private:
87
- grpc_subchannel* subchannel_;
88
+ Subchannel* subchannel_;
88
89
  UniquePtr<char> target_;
89
90
  CallCountingHelper call_counter_;
90
91
  ChannelTrace trace_;
@@ -29,8 +29,8 @@ void grpc_client_channel_factory_unref(grpc_client_channel_factory* factory) {
29
29
  factory->vtable->unref(factory);
30
30
  }
31
31
 
32
- grpc_subchannel* grpc_client_channel_factory_create_subchannel(
33
- grpc_client_channel_factory* factory, const grpc_subchannel_args* args) {
32
+ grpc_core::Subchannel* grpc_client_channel_factory_create_subchannel(
33
+ grpc_client_channel_factory* factory, const grpc_channel_args* args) {
34
34
  return factory->vtable->create_subchannel(factory, args);
35
35
  }
36
36
 
@@ -48,8 +48,8 @@ struct grpc_client_channel_factory {
48
48
  struct grpc_client_channel_factory_vtable {
49
49
  void (*ref)(grpc_client_channel_factory* factory);
50
50
  void (*unref)(grpc_client_channel_factory* factory);
51
- grpc_subchannel* (*create_subchannel)(grpc_client_channel_factory* factory,
52
- const grpc_subchannel_args* args);
51
+ grpc_core::Subchannel* (*create_subchannel)(
52
+ grpc_client_channel_factory* factory, const grpc_channel_args* args);
53
53
  grpc_channel* (*create_client_channel)(grpc_client_channel_factory* factory,
54
54
  const char* target,
55
55
  grpc_client_channel_type type,
@@ -60,8 +60,8 @@ void grpc_client_channel_factory_ref(grpc_client_channel_factory* factory);
60
60
  void grpc_client_channel_factory_unref(grpc_client_channel_factory* factory);
61
61
 
62
62
  /** Create a new grpc_subchannel */
63
- grpc_subchannel* grpc_client_channel_factory_create_subchannel(
64
- grpc_client_channel_factory* factory, const grpc_subchannel_args* args);
63
+ grpc_core::Subchannel* grpc_client_channel_factory_create_subchannel(
64
+ grpc_client_channel_factory* factory, const grpc_channel_args* args);
65
65
 
66
66
  /** Create a new grpc_channel */
67
67
  grpc_channel* grpc_client_channel_factory_create_channel(
@@ -26,13 +26,13 @@
26
26
 
27
27
  #include "src/core/ext/filters/client_channel/client_channel.h"
28
28
  #include "src/core/ext/filters/client_channel/client_channel_channelz.h"
29
+ #include "src/core/ext/filters/client_channel/global_subchannel_pool.h"
29
30
  #include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
30
31
  #include "src/core/ext/filters/client_channel/http_proxy.h"
31
32
  #include "src/core/ext/filters/client_channel/lb_policy_registry.h"
32
33
  #include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
33
34
  #include "src/core/ext/filters/client_channel/resolver_registry.h"
34
35
  #include "src/core/ext/filters/client_channel/retry_throttle.h"
35
- #include "src/core/ext/filters/client_channel/subchannel_index.h"
36
36
  #include "src/core/lib/surface/channel_init.h"
37
37
 
38
38
  static bool append_filter(grpc_channel_stack_builder* builder, void* arg) {
@@ -54,7 +54,7 @@ void grpc_client_channel_init(void) {
54
54
  grpc_core::internal::ServerRetryThrottleMap::Init();
55
55
  grpc_proxy_mapper_registry_init();
56
56
  grpc_register_http_proxy_mapper();
57
- grpc_subchannel_index_init();
57
+ grpc_core::GlobalSubchannelPool::Init();
58
58
  grpc_channel_init_register_stage(
59
59
  GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, append_filter,
60
60
  (void*)&grpc_client_channel_filter);
@@ -62,7 +62,7 @@ void grpc_client_channel_init(void) {
62
62
  }
63
63
 
64
64
  void grpc_client_channel_shutdown(void) {
65
- grpc_subchannel_index_shutdown();
65
+ grpc_core::GlobalSubchannelPool::Shutdown();
66
66
  grpc_channel_init_shutdown();
67
67
  grpc_proxy_mapper_registry_shutdown();
68
68
  grpc_core::internal::ServerRetryThrottleMap::Shutdown();