grpc 1.18.0 → 1.19.0.pre1

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 (146) 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 +36 -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.cc +30 -1
  21. data/src/core/ext/filters/client_channel/lb_policy.h +29 -1
  22. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +28 -30
  23. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +5 -8
  24. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +5 -8
  25. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +23 -24
  26. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +80 -15
  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_wrapper.cc +2 -2
  37. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +7 -35
  38. data/src/core/ext/filters/client_channel/subchannel.cc +698 -791
  39. data/src/core/ext/filters/client_channel/subchannel.h +213 -123
  40. data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +97 -0
  41. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +94 -0
  42. data/src/core/ext/filters/http/client_authority_filter.cc +5 -2
  43. data/src/core/ext/filters/max_age/max_age_filter.cc +1 -1
  44. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +13 -12
  45. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +5 -7
  46. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +19 -27
  47. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +18 -19
  48. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +27 -6
  49. data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -1
  50. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +3 -2
  51. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +1 -1
  52. data/src/core/ext/transport/chttp2/transport/writing.cc +8 -5
  53. data/src/core/lib/channel/handshaker.cc +141 -214
  54. data/src/core/lib/channel/handshaker.h +110 -101
  55. data/src/core/lib/channel/handshaker_factory.h +11 -19
  56. data/src/core/lib/channel/handshaker_registry.cc +64 -52
  57. data/src/core/lib/channel/handshaker_registry.h +21 -16
  58. data/src/core/lib/gpr/log_posix.cc +2 -1
  59. data/src/core/lib/gpr/time.cc +8 -0
  60. data/src/core/lib/gpr/time_posix.cc +8 -2
  61. data/src/core/lib/gprpp/optional.h +47 -0
  62. data/src/core/lib/http/httpcli_security_connector.cc +13 -14
  63. data/src/core/lib/iomgr/buffer_list.cc +182 -24
  64. data/src/core/lib/iomgr/buffer_list.h +70 -8
  65. data/src/core/lib/iomgr/combiner.cc +11 -3
  66. data/src/core/lib/iomgr/error.cc +9 -5
  67. data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -0
  68. data/src/core/lib/iomgr/ev_epollex_linux.cc +136 -162
  69. data/src/core/lib/iomgr/ev_poll_posix.cc +3 -0
  70. data/src/core/lib/iomgr/ev_posix.cc +4 -0
  71. data/src/core/lib/iomgr/ev_posix.h +4 -0
  72. data/src/core/lib/iomgr/exec_ctx.cc +1 -0
  73. data/src/core/lib/iomgr/exec_ctx.h +137 -8
  74. data/src/core/lib/iomgr/executor.cc +122 -87
  75. data/src/core/lib/iomgr/executor.h +53 -48
  76. data/src/core/lib/iomgr/fork_posix.cc +6 -4
  77. data/src/core/lib/iomgr/{network_status_tracker.cc → grpc_if_nametoindex.h} +8 -14
  78. data/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc +42 -0
  79. data/src/core/lib/iomgr/{network_status_tracker.h → grpc_if_nametoindex_unsupported.cc} +15 -9
  80. data/src/core/lib/iomgr/internal_errqueue.h +105 -3
  81. data/src/core/lib/iomgr/iomgr.cc +6 -5
  82. data/src/core/lib/iomgr/iomgr.h +8 -0
  83. data/src/core/lib/iomgr/iomgr_custom.cc +6 -2
  84. data/src/core/lib/iomgr/iomgr_internal.cc +4 -0
  85. data/src/core/lib/iomgr/iomgr_internal.h +4 -0
  86. data/src/core/lib/iomgr/iomgr_posix.cc +10 -1
  87. data/src/core/lib/iomgr/iomgr_windows.cc +8 -1
  88. data/src/core/lib/iomgr/port.h +1 -0
  89. data/src/core/lib/iomgr/resolve_address_posix.cc +4 -3
  90. data/src/core/lib/iomgr/resolve_address_windows.cc +2 -1
  91. data/src/core/lib/iomgr/tcp_custom.cc +0 -4
  92. data/src/core/lib/iomgr/tcp_posix.cc +58 -44
  93. data/src/core/lib/iomgr/tcp_uv.cc +0 -1
  94. data/src/core/lib/iomgr/tcp_windows.cc +0 -4
  95. data/src/core/lib/iomgr/timer_manager.cc +8 -0
  96. data/src/core/lib/iomgr/udp_server.cc +6 -4
  97. data/src/core/lib/json/json.cc +1 -4
  98. data/src/core/lib/security/credentials/alts/alts_credentials.cc +1 -1
  99. data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +2 -2
  100. data/src/core/lib/security/credentials/composite/composite_credentials.h +4 -0
  101. data/src/core/lib/security/credentials/credentials.h +9 -1
  102. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +15 -2
  103. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +2 -0
  104. data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
  105. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +1 -0
  106. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +3 -2
  107. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +2 -2
  108. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +1 -0
  109. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +192 -0
  110. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +213 -0
  111. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +10 -8
  112. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +6 -10
  113. data/src/core/lib/security/security_connector/local/local_security_connector.cc +10 -8
  114. data/src/core/lib/security/security_connector/security_connector.h +2 -2
  115. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +4 -6
  116. data/src/core/lib/security/security_connector/ssl_utils.h +33 -0
  117. data/src/core/lib/security/transport/security_handshaker.cc +267 -300
  118. data/src/core/lib/security/transport/security_handshaker.h +11 -2
  119. data/src/core/lib/security/transport/server_auth_filter.cc +1 -0
  120. data/src/core/lib/surface/call.cc +5 -1
  121. data/src/core/lib/surface/channel_init.h +5 -0
  122. data/src/core/lib/surface/completion_queue.cc +4 -7
  123. data/src/core/lib/surface/init.cc +5 -3
  124. data/src/core/lib/surface/init_secure.cc +1 -1
  125. data/src/core/lib/surface/server.cc +19 -17
  126. data/src/core/lib/surface/version.cc +1 -1
  127. data/src/core/lib/transport/service_config.h +1 -0
  128. data/src/core/lib/transport/static_metadata.cc +279 -279
  129. data/src/core/lib/transport/transport.cc +5 -3
  130. data/src/core/tsi/ssl_transport_security.cc +10 -4
  131. data/src/ruby/ext/grpc/extconf.rb +12 -4
  132. data/src/ruby/ext/grpc/rb_call_credentials.c +8 -5
  133. data/src/ruby/ext/grpc/rb_channel.c +14 -10
  134. data/src/ruby/ext/grpc/rb_channel_credentials.c +8 -4
  135. data/src/ruby/ext/grpc/rb_compression_options.c +9 -7
  136. data/src/ruby/ext/grpc/rb_event_thread.c +2 -0
  137. data/src/ruby/ext/grpc/rb_grpc.c +22 -23
  138. data/src/ruby/ext/grpc/rb_grpc.h +4 -2
  139. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +18 -0
  140. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +27 -0
  141. data/src/ruby/ext/grpc/rb_server.c +8 -4
  142. data/src/ruby/lib/grpc/version.rb +1 -1
  143. metadata +46 -39
  144. data/src/core/ext/filters/client_channel/subchannel_index.cc +0 -248
  145. data/src/core/ext/filters/client_channel/subchannel_index.h +0 -76
  146. data/src/core/lib/channel/handshaker_factory.cc +0 -42
@@ -609,6 +609,201 @@ GRPCAPI grpc_channel_credentials* grpc_local_credentials_create(
609
609
  GRPCAPI grpc_server_credentials* grpc_local_server_credentials_create(
610
610
  grpc_local_connect_type type);
611
611
 
612
+ /** --- SPIFFE and HTTPS-based TLS channel/server credentials ---
613
+ * It is used for experimental purpose for now and subject to change. */
614
+
615
+ /** Config for TLS key materials. It is used for
616
+ * experimental purpose for now and subject to change. */
617
+ typedef struct grpc_tls_key_materials_config grpc_tls_key_materials_config;
618
+
619
+ /** Config for TLS credential reload. It is used for
620
+ * experimental purpose for now and subject to change. */
621
+ typedef struct grpc_tls_credential_reload_config
622
+ grpc_tls_credential_reload_config;
623
+
624
+ /** Config for TLS server authorization check. It is used for
625
+ * experimental purpose for now and subject to change. */
626
+ typedef struct grpc_tls_server_authorization_check_config
627
+ grpc_tls_server_authorization_check_config;
628
+
629
+ /** TLS credentials options. It is used for
630
+ * experimental purpose for now and subject to change. */
631
+ typedef struct grpc_tls_credentials_options grpc_tls_credentials_options;
632
+
633
+ /** Create an empty TLS credentials options. It is used for
634
+ * experimental purpose for now and subject to change. */
635
+ GRPCAPI grpc_tls_credentials_options* grpc_tls_credentials_options_create();
636
+
637
+ /** Set grpc_ssl_client_certificate_request_type field in credentials options
638
+ with the provided type. options should not be NULL.
639
+ It returns 1 on success and 0 on failure. It is used for
640
+ experimental purpose for now and subject to change. */
641
+ GRPCAPI int grpc_tls_credentials_options_set_cert_request_type(
642
+ grpc_tls_credentials_options* options,
643
+ grpc_ssl_client_certificate_request_type type);
644
+
645
+ /** Set grpc_tls_key_materials_config field in credentials options
646
+ with the provided config struct whose ownership is transferred.
647
+ Both parameters should not be NULL.
648
+ It returns 1 on success and 0 on failure. It is used for
649
+ experimental purpose for now and subject to change. */
650
+ GRPCAPI int grpc_tls_credentials_options_set_key_materials_config(
651
+ grpc_tls_credentials_options* options,
652
+ grpc_tls_key_materials_config* config);
653
+
654
+ /** Set grpc_tls_credential_reload_config field in credentials options
655
+ with the provided config struct whose ownership is transferred.
656
+ Both parameters should not be NULL.
657
+ It returns 1 on success and 0 on failure. It is used for
658
+ experimental purpose for now and subject to change. */
659
+ GRPCAPI int grpc_tls_credentials_options_set_credential_reload_config(
660
+ grpc_tls_credentials_options* options,
661
+ grpc_tls_credential_reload_config* config);
662
+
663
+ /** Set grpc_tls_server_authorization_check_config field in credentials options
664
+ with the provided config struct whose ownership is transferred.
665
+ Both parameters should not be NULL.
666
+ It returns 1 on success and 0 on failure. It is used for
667
+ experimental purpose for now and subject to change. */
668
+ GRPCAPI int grpc_tls_credentials_options_set_server_authorization_check_config(
669
+ grpc_tls_credentials_options* options,
670
+ grpc_tls_server_authorization_check_config* config);
671
+
672
+ /** --- TLS key materials config. ---
673
+ It is used for experimental purpose for now and subject to change. */
674
+
675
+ /** Create an empty grpc_tls_key_materials_config instance.
676
+ * It is used for experimental purpose for now and subject to change. */
677
+ GRPCAPI grpc_tls_key_materials_config* grpc_tls_key_materials_config_create();
678
+
679
+ /** Set grpc_tls_key_materials_config instance with provided a TLS certificate.
680
+ config will take the ownership of pem_root_certs and pem_key_cert_pairs.
681
+ It's valid for the caller to provide nullptr pem_root_certs, in which case
682
+ the gRPC-provided root cert will be used. pem_key_cert_pairs should not be
683
+ NULL. It returns 1 on success and 0 on failure. It is used for
684
+ experimental purpose for now and subject to change.
685
+ */
686
+ GRPCAPI int grpc_tls_key_materials_config_set_key_materials(
687
+ grpc_tls_key_materials_config* config, const char* pem_root_certs,
688
+ const grpc_ssl_pem_key_cert_pair** pem_key_cert_pairs,
689
+ size_t num_key_cert_pairs);
690
+
691
+ /** --- TLS credential reload config. ---
692
+ It is used for experimental purpose for now and subject to change.*/
693
+
694
+ typedef struct grpc_tls_credential_reload_arg grpc_tls_credential_reload_arg;
695
+
696
+ /** A callback function provided by gRPC to handle the result of credential
697
+ reload. It is used when schedule API is implemented asynchronously and
698
+ serves to bring the control back to grpc C core. It is used for
699
+ experimental purpose for now and subject to change. */
700
+ typedef void (*grpc_tls_on_credential_reload_done_cb)(
701
+ grpc_tls_credential_reload_arg* arg);
702
+
703
+ /** A struct containing all information necessary to schedule/cancel
704
+ a credential reload request. cb and cb_user_data represent a gRPC-provided
705
+ callback and an argument passed to it. key_materials is an in/output
706
+ parameter containing currently used/newly reloaded credentials. status and
707
+ error_details are used to hold information about errors occurred when a
708
+ credential reload request is scheduled/cancelled. It is used for
709
+ experimental purpose for now and subject to change. */
710
+ struct grpc_tls_credential_reload_arg {
711
+ grpc_tls_on_credential_reload_done_cb cb;
712
+ void* cb_user_data;
713
+ grpc_tls_key_materials_config* key_materials_config;
714
+ grpc_status_code status;
715
+ const char* error_details;
716
+ };
717
+
718
+ /** Create a grpc_tls_credential_reload_config instance.
719
+ - config_user_data is config-specific, read-only user data
720
+ that works for all channels created with a credential using the config.
721
+ - schedule is a pointer to an application-provided callback used to invoke
722
+ credential reload API. The implementation of this method has to be
723
+ non-blocking, but can be performed synchronously or asynchronously.
724
+ 1) If processing occurs synchronously, it populates arg->key_materials,
725
+ arg->status, and arg->error_details and returns zero.
726
+ 2) If processing occurs asynchronously, it returns a non-zero value.
727
+ The application then invokes arg->cb when processing is completed. Note
728
+ that arg->cb cannot be invoked before schedule API returns.
729
+ - cancel is a pointer to an application-provided callback used to cancel
730
+ a credential reload request scheduled via an asynchronous schedule API.
731
+ arg is used to pinpoint an exact reloading request to be cancelled.
732
+ The operation may not have any effect if the request has already been
733
+ processed.
734
+ - destruct is a pointer to an application-provided callback used to clean up
735
+ any data associated with the config.
736
+ It is used for experimental purpose for now and subject to change.
737
+ */
738
+ GRPCAPI grpc_tls_credential_reload_config*
739
+ grpc_tls_credential_reload_config_create(
740
+ const void* config_user_data,
741
+ int (*schedule)(void* config_user_data,
742
+ grpc_tls_credential_reload_arg* arg),
743
+ void (*cancel)(void* config_user_data, grpc_tls_credential_reload_arg* arg),
744
+ void (*destruct)(void* config_user_data));
745
+
746
+ /** --- TLS server authorization check config. ---
747
+ * It is used for experimental purpose for now and subject to change. */
748
+
749
+ typedef struct grpc_tls_server_authorization_check_arg
750
+ grpc_tls_server_authorization_check_arg;
751
+
752
+ /** callback function provided by gRPC used to handle the result of server
753
+ authorization check. It is used when schedule API is implemented
754
+ asynchronously, and serves to bring the control back to gRPC C core. It is
755
+ used for experimental purpose for now and subject to change. */
756
+ typedef void (*grpc_tls_on_server_authorization_check_done_cb)(
757
+ grpc_tls_server_authorization_check_arg* arg);
758
+
759
+ /** A struct containing all information necessary to schedule/cancel a server
760
+ authorization check request. cb and cb_user_data represent a gRPC-provided
761
+ callback and an argument passed to it. result will store the result of
762
+ server authorization check. target_name is the name of an endpoint the
763
+ channel is connecting to and certificate represents a complete certificate
764
+ chain including both signing and leaf certificates. status and error_details
765
+ contain information about errors occurred when a server authorization check
766
+ request is scheduled/cancelled. It is used for experimental purpose for now
767
+ and subject to change.*/
768
+ struct grpc_tls_server_authorization_check_arg {
769
+ grpc_tls_on_server_authorization_check_done_cb cb;
770
+ void* cb_user_data;
771
+ int result;
772
+ const char* target_name;
773
+ const char* peer_cert;
774
+ grpc_status_code status;
775
+ const char* error_details;
776
+ };
777
+
778
+ /** Create a grpc_tls_server_authorization_check_config instance.
779
+ - config_user_data is config-specific, read-only user data
780
+ that works for all channels created with a credential using the config.
781
+ - schedule is a pointer to an application-provided callback used to invoke
782
+ server authorization check API. The implementation of this method has to
783
+ be non-blocking, but can be performed synchronously or asynchronously.
784
+ 1)If processing occurs synchronously, it populates arg->result,
785
+ arg->status, and arg->error_details and returns zero.
786
+ 2) If processing occurs asynchronously, it returns a non-zero value. The
787
+ application then invokes arg->cb when processing is completed. Note that
788
+ arg->cb cannot be invoked before schedule API returns.
789
+ - cancel is a pointer to an application-provided callback used to cancel a
790
+ server authorization check request scheduled via an asynchronous schedule
791
+ API. arg is used to pinpoint an exact check request to be cancelled. The
792
+ operation may not have any effect if the request has already been
793
+ processed.
794
+ - destruct is a pointer to an application-provided callback used to clean up
795
+ any data associated with the config.
796
+ It is used for experimental purpose for now and subject to change.
797
+ */
798
+ GRPCAPI grpc_tls_server_authorization_check_config*
799
+ grpc_tls_server_authorization_check_config_create(
800
+ const void* config_user_data,
801
+ int (*schedule)(void* config_user_data,
802
+ grpc_tls_server_authorization_check_arg* arg),
803
+ void (*cancel)(void* config_user_data,
804
+ grpc_tls_server_authorization_check_arg* arg),
805
+ void (*destruct)(void* config_user_data));
806
+
612
807
  #ifdef __cplusplus
613
808
  }
614
809
  #endif
@@ -163,7 +163,7 @@ typedef struct {
163
163
  /** Maximum time that a channel may exist. Int valued, milliseconds.
164
164
  * INT_MAX means unlimited. */
165
165
  #define GRPC_ARG_MAX_CONNECTION_AGE_MS "grpc.max_connection_age_ms"
166
- /** Grace period after the chennel reaches its max age. Int valued,
166
+ /** Grace period after the channel reaches its max age. Int valued,
167
167
  milliseconds. INT_MAX means unlimited. */
168
168
  #define GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS "grpc.max_connection_age_grace_ms"
169
169
  /** Enable/disable support for per-message compression. Defaults to 1, unless
@@ -350,11 +350,23 @@ typedef struct {
350
350
  /** If set, inhibits health checking (which may be enabled via the
351
351
  * service config.) */
352
352
  #define GRPC_ARG_INHIBIT_HEALTH_CHECKING "grpc.inhibit_health_checking"
353
+ /** If set, the channel's resolver is allowed to query for SRV records.
354
+ * For example, this is useful as a way to enable the "grpclb"
355
+ * load balancing policy. Note that this only works with the "ares"
356
+ * DNS resolver, and isn't supported by the "native" DNS resolver. */
357
+ #define GRPC_ARG_DNS_ENABLE_SRV_QUERIES "grpc.dns_enable_srv_queries"
353
358
  /** If set, determines the number of milliseconds that the c-ares based
354
359
  * DNS resolver will wait on queries before cancelling them. The default value
355
360
  * is 10000. Setting this to "0" will disable c-ares query timeouts
356
361
  * entirely. */
357
362
  #define GRPC_ARG_DNS_ARES_QUERY_TIMEOUT_MS "grpc.dns_ares_query_timeout"
363
+ /** If set, uses a local subchannel pool within the channel. Otherwise, uses the
364
+ * global subchannel pool. */
365
+ #define GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL "grpc.use_local_subchannel_pool"
366
+ /** gRPC Objective-C channel pooling domain string. */
367
+ #define GRPC_ARG_CHANNEL_POOL_DOMAIN "grpc.channel_pooling_domain"
368
+ /** gRPC Objective-C channel pooling id. */
369
+ #define GRPC_ARG_CHANNEL_ID "grpc.channel_id"
358
370
  /** \} */
359
371
 
360
372
  /** Result of a grpc call. If the caller satisfies the prerequisites of a
@@ -681,6 +693,10 @@ typedef struct grpc_experimental_completion_queue_functor {
681
693
  pointer to this functor and a boolean that indicates whether the
682
694
  operation succeeded (non-zero) or failed (zero) */
683
695
  void (*functor_run)(struct grpc_experimental_completion_queue_functor*, int);
696
+
697
+ /** The following fields are not API. They are meant for internal use. */
698
+ int internal_success;
699
+ struct grpc_experimental_completion_queue_functor* internal_next;
684
700
  } grpc_experimental_completion_queue_functor;
685
701
 
686
702
  /* The upgrade to version 2 is currently experimental. */
@@ -121,6 +121,7 @@
121
121
  #else /* _LP64 */
122
122
  #define GPR_ARCH_32 1
123
123
  #endif /* _LP64 */
124
+ #include <linux/version.h>
124
125
  #elif defined(ANDROID) || defined(__ANDROID__)
125
126
  #define GPR_PLATFORM_STRING "android"
126
127
  #define GPR_ANDROID 1
@@ -188,6 +189,8 @@
188
189
  #define GPR_PLATFORM_STRING "ios"
189
190
  #define GPR_CPU_IPHONE 1
190
191
  #define GPR_PTHREAD_TLS 1
192
+ /* the c-ares resolver isnt safe to enable on iOS */
193
+ #define GRPC_ARES 0
191
194
  #else /* TARGET_OS_IPHONE */
192
195
  #define GPR_PLATFORM_STRING "osx"
193
196
  #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
@@ -465,6 +468,10 @@ typedef unsigned __int64 uint64_t;
465
468
  #define GRPC_ARES 1
466
469
  #endif
467
470
 
471
+ #ifndef GRPC_IF_NAMETOINDEX
472
+ #define GRPC_IF_NAMETOINDEX 1
473
+ #endif
474
+
468
475
  #ifndef GRPC_MUST_USE_RESULT
469
476
  #if defined(__GNUC__) && !defined(__MINGW32__)
470
477
  #define GRPC_MUST_USE_RESULT __attribute__((warn_unused_result))
@@ -515,6 +522,35 @@ typedef unsigned __int64 uint64_t;
515
522
  #define CENSUSAPI GRPCAPI
516
523
  #endif
517
524
 
525
+ #ifndef GPR_HAS_ATTRIBUTE
526
+ #ifdef __has_attribute
527
+ #define GPR_HAS_ATTRIBUTE(a) __has_attribute(a)
528
+ #else
529
+ #define GPR_HAS_ATTRIBUTE(a) 0
530
+ #endif
531
+ #endif /* GPR_HAS_ATTRIBUTE */
532
+
533
+ #ifndef GPR_ATTRIBUTE_NOINLINE
534
+ #if GPR_HAS_ATTRIBUTE(noinline) || (defined(__GNUC__) && !defined(__clang__))
535
+ #define GPR_ATTRIBUTE_NOINLINE __attribute__((noinline))
536
+ #define GPR_HAS_ATTRIBUTE_NOINLINE 1
537
+ #else
538
+ #define GPR_ATTRIBUTE_NOINLINE
539
+ #endif
540
+ #endif /* GPR_ATTRIBUTE_NOINLINE */
541
+
542
+ #ifndef GPR_ATTRIBUTE_WEAK
543
+ /* Attribute weak is broken on LLVM/windows:
544
+ * https://bugs.llvm.org/show_bug.cgi?id=37598 */
545
+ #if (GPR_HAS_ATTRIBUTE(weak) || (defined(__GNUC__) && !defined(__clang__))) && \
546
+ !(defined(__llvm__) && defined(_WIN32))
547
+ #define GPR_ATTRIBUTE_WEAK __attribute__((weak))
548
+ #define GPR_HAS_ATTRIBUTE_WEAK 1
549
+ #else
550
+ #define GPR_ATTRIBUTE_WEAK
551
+ #endif
552
+ #endif /* GPR_ATTRIBUTE_WEAK */
553
+
518
554
  #ifndef GPR_ATTRIBUTE_NO_TSAN /* (1) */
519
555
  #if defined(__has_feature)
520
556
  #if __has_feature(thread_sanitizer)
@@ -81,8 +81,8 @@ struct grpc_slice {
81
81
  struct grpc_slice_refcount* refcount;
82
82
  union grpc_slice_data {
83
83
  struct grpc_slice_refcounted {
84
- uint8_t* bytes;
85
84
  size_t length;
85
+ uint8_t* bytes;
86
86
  } refcounted;
87
87
  struct grpc_slice_inlined {
88
88
  uint8_t length;
@@ -35,6 +35,7 @@ grpc_connectivity_state grpc_channel_check_connectivity_state(
35
35
  /* forward through to the underlying client channel */
36
36
  grpc_channel_element* client_channel_elem =
37
37
  grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
38
+ grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
38
39
  grpc_core::ExecCtx exec_ctx;
39
40
  grpc_connectivity_state state;
40
41
  GRPC_API_TRACE(
@@ -202,6 +203,7 @@ void grpc_channel_watch_connectivity_state(
202
203
  gpr_timespec deadline, grpc_completion_queue* cq, void* tag) {
203
204
  grpc_channel_element* client_channel_elem =
204
205
  grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
206
+ grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
205
207
  grpc_core::ExecCtx exec_ctx;
206
208
  state_watcher* w = static_cast<state_watcher*>(gpr_malloc(sizeof(*w)));
207
209
 
@@ -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
  }