grpc 1.12.0 → 1.13.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 (245) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +314 -23
  3. data/include/grpc/impl/codegen/fork.h +4 -4
  4. data/include/grpc/impl/codegen/grpc_types.h +1 -1
  5. data/include/grpc/impl/codegen/port_platform.h +3 -0
  6. data/src/boringssl/err_data.c +256 -246
  7. data/src/core/ext/filters/client_channel/channel_connectivity.cc +1 -1
  8. data/src/core/ext/filters/client_channel/client_channel.cc +367 -272
  9. data/src/core/ext/filters/client_channel/lb_policy.h +1 -3
  10. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +11 -9
  11. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +42 -32
  12. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +36 -0
  13. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +36 -102
  14. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +37 -32
  15. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +22 -19
  16. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +1 -1
  17. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +1 -1
  18. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +1 -1
  19. data/src/core/ext/filters/client_channel/resolver.h +1 -3
  20. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +3 -3
  21. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +2 -2
  22. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +0 -1
  23. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +4 -4
  24. data/src/core/ext/filters/client_channel/subchannel.cc +3 -3
  25. data/src/core/ext/filters/http/client_authority_filter.cc +5 -4
  26. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +4 -4
  27. data/src/core/ext/filters/http/server/http_server_filter.cc +123 -131
  28. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +1 -1
  29. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +9 -8
  30. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +19 -19
  31. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +10 -6
  32. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +4 -3
  33. data/src/core/ext/transport/chttp2/transport/parsing.cc +14 -12
  34. data/src/core/ext/transport/chttp2/transport/writing.cc +6 -6
  35. data/src/core/lib/channel/channel_stack.cc +0 -5
  36. data/src/core/lib/channel/channel_stack.h +1 -1
  37. data/src/core/lib/channel/channel_stack_builder.cc +0 -3
  38. data/src/core/lib/channel/channel_stack_builder.h +0 -2
  39. data/src/core/lib/channel/channel_trace.cc +3 -3
  40. data/src/core/lib/channel/channelz_registry.cc +77 -0
  41. data/src/core/lib/channel/channelz_registry.h +99 -0
  42. data/src/core/lib/channel/handshaker.cc +20 -1
  43. data/src/core/lib/debug/stats.h +7 -0
  44. data/src/core/lib/debug/stats_data.cc +5 -0
  45. data/src/core/lib/debug/stats_data.h +120 -0
  46. data/src/core/lib/debug/trace.h +11 -9
  47. data/src/core/lib/gprpp/fork.cc +260 -0
  48. data/src/core/lib/gprpp/fork.h +79 -0
  49. data/src/core/lib/gprpp/memory.h +12 -0
  50. data/src/core/lib/gprpp/orphanable.h +2 -6
  51. data/src/core/lib/gprpp/ref_counted.h +2 -6
  52. data/src/core/lib/gprpp/thd.h +0 -3
  53. data/src/core/lib/gprpp/thd_posix.cc +4 -53
  54. data/src/core/lib/gprpp/thd_windows.cc +0 -7
  55. data/src/core/lib/http/httpcli_security_connector.cc +1 -3
  56. data/src/core/lib/iomgr/combiner.cc +19 -2
  57. data/src/core/lib/iomgr/combiner.h +1 -1
  58. data/src/core/lib/iomgr/ev_epoll1_linux.cc +2 -2
  59. data/src/core/lib/iomgr/ev_epollex_linux.cc +59 -3
  60. data/src/core/lib/iomgr/ev_epollsig_linux.cc +1 -1
  61. data/src/core/lib/iomgr/ev_poll_posix.cc +2 -2
  62. data/src/core/lib/iomgr/ev_posix.cc +11 -4
  63. data/src/core/lib/iomgr/ev_posix.h +6 -0
  64. data/src/core/lib/iomgr/exec_ctx.cc +9 -9
  65. data/src/core/lib/iomgr/exec_ctx.h +39 -20
  66. data/src/core/lib/iomgr/fork_posix.cc +30 -18
  67. data/src/core/lib/iomgr/iomgr_posix.cc +2 -2
  68. data/src/core/lib/iomgr/polling_entity.cc +11 -2
  69. data/src/core/lib/iomgr/pollset_custom.cc +2 -2
  70. data/src/core/lib/iomgr/port.h +38 -1
  71. data/src/core/lib/iomgr/resolve_address.h +1 -1
  72. data/src/core/lib/iomgr/resolve_address_posix.cc +1 -1
  73. data/src/core/lib/iomgr/resource_quota.cc +1 -1
  74. data/src/core/lib/iomgr/sockaddr_posix.h +1 -1
  75. data/src/core/lib/iomgr/socket_factory_posix.cc +1 -1
  76. data/src/core/lib/iomgr/socket_utils_common_posix.cc +1 -1
  77. data/src/core/lib/iomgr/tcp_client_custom.cc +3 -3
  78. data/src/core/lib/iomgr/tcp_client_posix.cc +3 -2
  79. data/src/core/lib/iomgr/tcp_custom.cc +1 -1
  80. data/src/core/lib/iomgr/tcp_posix.cc +18 -10
  81. data/src/core/lib/iomgr/tcp_server_posix.cc +9 -8
  82. data/src/core/lib/iomgr/tcp_server_utils_posix.h +1 -1
  83. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +16 -4
  84. data/src/core/lib/iomgr/timer.h +1 -1
  85. data/src/core/lib/iomgr/timer_generic.cc +113 -41
  86. data/src/core/lib/iomgr/timer_manager.cc +1 -1
  87. data/src/core/lib/security/credentials/credentials.h +1 -0
  88. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +88 -115
  89. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +16 -0
  90. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +10 -6
  91. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +1 -1
  92. data/src/core/lib/security/security_connector/alts_security_connector.cc +2 -1
  93. data/src/core/lib/security/security_connector/security_connector.cc +7 -7
  94. data/src/core/lib/security/transport/security_handshaker.cc +1 -0
  95. data/src/core/lib/security/util/json_util.cc +4 -0
  96. data/src/core/lib/slice/slice_buffer.cc +15 -3
  97. data/src/core/lib/surface/call.cc +31 -17
  98. data/src/core/lib/surface/call.h +5 -0
  99. data/src/core/lib/surface/channel.cc +2 -5
  100. data/src/core/lib/surface/completion_queue.cc +1 -3
  101. data/src/core/lib/surface/completion_queue.h +0 -1
  102. data/src/core/lib/surface/init.cc +7 -8
  103. data/src/core/lib/surface/version.cc +2 -2
  104. data/src/core/lib/transport/byte_stream.cc +1 -1
  105. data/src/core/lib/transport/transport.cc +2 -1
  106. data/src/core/lib/transport/transport.h +4 -8
  107. data/src/core/lib/transport/transport_op_string.cc +1 -1
  108. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +19 -7
  109. data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +10 -0
  110. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +28 -2
  111. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +3 -0
  112. data/src/core/tsi/fake_transport_security.cc +1 -0
  113. data/src/core/tsi/ssl_transport_security.cc +238 -110
  114. data/src/core/tsi/transport_security.cc +14 -0
  115. data/src/core/tsi/transport_security.h +2 -0
  116. data/src/core/tsi/transport_security_interface.h +11 -1
  117. data/src/ruby/bin/math_client.rb +17 -9
  118. data/src/ruby/lib/grpc/generic/rpc_server.rb +2 -1
  119. data/src/ruby/lib/grpc/version.rb +1 -1
  120. data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +4 -1
  121. data/third_party/boringssl/crypto/asn1/a_int.c +33 -28
  122. data/third_party/boringssl/crypto/asn1/a_mbstr.c +24 -22
  123. data/third_party/boringssl/crypto/asn1/a_utf8.c +13 -11
  124. data/third_party/boringssl/crypto/asn1/asn1_locl.h +3 -0
  125. data/third_party/boringssl/crypto/bio/fd.c +1 -0
  126. data/third_party/boringssl/crypto/bio/file.c +2 -0
  127. data/third_party/boringssl/crypto/bn_extra/convert.c +6 -5
  128. data/third_party/boringssl/crypto/bytestring/ber.c +1 -4
  129. data/third_party/boringssl/crypto/bytestring/cbb.c +116 -16
  130. data/third_party/boringssl/crypto/bytestring/cbs.c +150 -20
  131. data/third_party/boringssl/crypto/cipher_extra/e_aesccm.c +171 -0
  132. data/third_party/boringssl/crypto/cipher_extra/e_rc2.c +2 -0
  133. data/third_party/boringssl/crypto/cipher_extra/e_tls.c +1 -2
  134. data/third_party/boringssl/crypto/cpu-aarch64-fuchsia.c +55 -0
  135. data/third_party/boringssl/crypto/cpu-aarch64-linux.c +2 -1
  136. data/third_party/boringssl/crypto/dsa/dsa.c +16 -54
  137. data/third_party/boringssl/crypto/fipsmodule/bcm.c +11 -542
  138. data/third_party/boringssl/crypto/fipsmodule/bn/add.c +33 -64
  139. data/third_party/boringssl/crypto/fipsmodule/bn/asm/x86_64-gcc.c +4 -3
  140. data/third_party/boringssl/crypto/fipsmodule/bn/bn.c +122 -70
  141. data/third_party/boringssl/crypto/fipsmodule/bn/bytes.c +32 -71
  142. data/third_party/boringssl/crypto/fipsmodule/bn/cmp.c +58 -112
  143. data/third_party/boringssl/crypto/fipsmodule/bn/div.c +198 -122
  144. data/third_party/boringssl/crypto/fipsmodule/bn/exponentiation.c +31 -65
  145. data/third_party/boringssl/crypto/fipsmodule/bn/generic.c +2 -1
  146. data/third_party/boringssl/crypto/fipsmodule/bn/internal.h +98 -15
  147. data/third_party/boringssl/crypto/fipsmodule/bn/jacobi.c +1 -1
  148. data/third_party/boringssl/crypto/fipsmodule/bn/montgomery.c +124 -81
  149. data/third_party/boringssl/crypto/fipsmodule/bn/montgomery_inv.c +8 -30
  150. data/third_party/boringssl/crypto/fipsmodule/bn/mul.c +303 -347
  151. data/third_party/boringssl/crypto/fipsmodule/bn/prime.c +2 -3
  152. data/third_party/boringssl/crypto/fipsmodule/bn/random.c +3 -4
  153. data/third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.c +199 -222
  154. data/third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.h +27 -47
  155. data/third_party/boringssl/crypto/fipsmodule/bn/shift.c +45 -28
  156. data/third_party/boringssl/crypto/fipsmodule/bn/sqrt.c +1 -1
  157. data/third_party/boringssl/crypto/fipsmodule/cipher/e_aes.c +10 -10
  158. data/third_party/boringssl/crypto/fipsmodule/des/internal.h +2 -0
  159. data/third_party/boringssl/crypto/fipsmodule/ec/ec.c +78 -47
  160. data/third_party/boringssl/crypto/fipsmodule/ec/ec_key.c +35 -54
  161. data/third_party/boringssl/crypto/fipsmodule/ec/ec_montgomery.c +3 -10
  162. data/third_party/boringssl/crypto/fipsmodule/ec/internal.h +36 -22
  163. data/third_party/boringssl/crypto/fipsmodule/ec/oct.c +59 -90
  164. data/third_party/boringssl/crypto/fipsmodule/ec/p224-64.c +29 -48
  165. data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.c +17 -26
  166. data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.h +15 -11
  167. data/third_party/boringssl/crypto/fipsmodule/ec/simple.c +45 -51
  168. data/third_party/boringssl/crypto/fipsmodule/ec/{util-64.c → util.c} +0 -5
  169. data/third_party/boringssl/crypto/fipsmodule/ec/wnaf.c +144 -264
  170. data/third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.c +78 -56
  171. data/third_party/boringssl/crypto/fipsmodule/modes/ccm.c +256 -0
  172. data/third_party/boringssl/crypto/fipsmodule/modes/internal.h +36 -32
  173. data/third_party/boringssl/crypto/fipsmodule/rand/ctrdrbg.c +9 -7
  174. data/third_party/boringssl/crypto/fipsmodule/rsa/rsa.c +16 -10
  175. data/third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.c +255 -102
  176. data/third_party/boringssl/crypto/fipsmodule/self_check/self_check.c +581 -0
  177. data/third_party/boringssl/crypto/fipsmodule/tls/internal.h +39 -0
  178. data/third_party/boringssl/crypto/fipsmodule/tls/kdf.c +165 -0
  179. data/third_party/boringssl/crypto/internal.h +65 -2
  180. data/third_party/boringssl/crypto/mem.c +0 -2
  181. data/third_party/boringssl/crypto/obj/obj.c +6 -73
  182. data/third_party/boringssl/crypto/thread_pthread.c +35 -5
  183. data/third_party/boringssl/crypto/x509/a_strex.c +11 -11
  184. data/third_party/boringssl/crypto/x509/x_name.c +13 -0
  185. data/third_party/boringssl/include/openssl/aead.h +4 -0
  186. data/third_party/boringssl/include/openssl/asn1.h +1 -3
  187. data/third_party/boringssl/include/openssl/base.h +1 -14
  188. data/third_party/boringssl/include/openssl/bio.h +1 -1
  189. data/third_party/boringssl/include/openssl/bn.h +49 -15
  190. data/third_party/boringssl/include/openssl/bytestring.h +49 -24
  191. data/third_party/boringssl/include/openssl/crypto.h +4 -0
  192. data/third_party/boringssl/include/openssl/ec_key.h +7 -3
  193. data/third_party/boringssl/include/openssl/err.h +9 -9
  194. data/third_party/boringssl/include/openssl/evp.h +1 -1
  195. data/third_party/boringssl/include/openssl/rsa.h +34 -10
  196. data/third_party/boringssl/include/openssl/ssl.h +160 -17
  197. data/third_party/boringssl/include/openssl/stack.h +1 -1
  198. data/third_party/boringssl/include/openssl/tls1.h +10 -2
  199. data/third_party/boringssl/include/openssl/x509.h +3 -0
  200. data/third_party/boringssl/ssl/d1_both.cc +16 -2
  201. data/third_party/boringssl/ssl/dtls_method.cc +1 -1
  202. data/third_party/boringssl/ssl/handoff.cc +285 -0
  203. data/third_party/boringssl/ssl/handshake.cc +26 -12
  204. data/third_party/boringssl/ssl/handshake_client.cc +65 -31
  205. data/third_party/boringssl/ssl/handshake_server.cc +14 -2
  206. data/third_party/boringssl/ssl/internal.h +132 -79
  207. data/third_party/boringssl/ssl/s3_both.cc +2 -2
  208. data/third_party/boringssl/ssl/s3_lib.cc +3 -1
  209. data/third_party/boringssl/ssl/s3_pkt.cc +0 -18
  210. data/third_party/boringssl/ssl/ssl_aead_ctx.cc +1 -4
  211. data/third_party/boringssl/ssl/ssl_asn1.cc +47 -43
  212. data/third_party/boringssl/ssl/ssl_cipher.cc +8 -8
  213. data/third_party/boringssl/ssl/ssl_key_share.cc +3 -1
  214. data/third_party/boringssl/ssl/ssl_lib.cc +83 -14
  215. data/third_party/boringssl/ssl/ssl_privkey.cc +6 -0
  216. data/third_party/boringssl/ssl/ssl_stat.cc +6 -6
  217. data/third_party/boringssl/ssl/ssl_versions.cc +12 -85
  218. data/third_party/boringssl/ssl/ssl_x509.cc +59 -61
  219. data/third_party/boringssl/ssl/t1_enc.cc +73 -124
  220. data/third_party/boringssl/ssl/t1_lib.cc +367 -41
  221. data/third_party/boringssl/ssl/tls13_both.cc +8 -0
  222. data/third_party/boringssl/ssl/tls13_client.cc +98 -184
  223. data/third_party/boringssl/ssl/tls13_enc.cc +88 -158
  224. data/third_party/boringssl/ssl/tls13_server.cc +91 -137
  225. data/third_party/boringssl/ssl/tls_method.cc +0 -17
  226. data/third_party/boringssl/ssl/tls_record.cc +1 -10
  227. data/third_party/boringssl/third_party/fiat/curve25519.c +921 -2753
  228. data/third_party/boringssl/third_party/fiat/curve25519_tables.h +7880 -0
  229. data/third_party/boringssl/third_party/fiat/internal.h +32 -20
  230. data/third_party/boringssl/third_party/fiat/p256.c +1824 -0
  231. metadata +64 -64
  232. data/src/core/lib/channel/channel_trace_registry.cc +0 -80
  233. data/src/core/lib/channel/channel_trace_registry.h +0 -43
  234. data/src/core/lib/gpr/fork.cc +0 -78
  235. data/src/core/lib/gpr/fork.h +0 -35
  236. data/src/core/tsi/transport_security_adapter.cc +0 -235
  237. data/src/core/tsi/transport_security_adapter.h +0 -41
  238. data/src/ruby/bin/apis/google/protobuf/empty.rb +0 -29
  239. data/src/ruby/bin/apis/pubsub_demo.rb +0 -241
  240. data/src/ruby/bin/apis/tech/pubsub/proto/pubsub.rb +0 -159
  241. data/src/ruby/bin/apis/tech/pubsub/proto/pubsub_services.rb +0 -88
  242. data/src/ruby/pb/test/client.rb +0 -764
  243. data/src/ruby/pb/test/server.rb +0 -252
  244. data/third_party/boringssl/crypto/curve25519/x25519-x86_64.c +0 -247
  245. data/third_party/boringssl/crypto/fipsmodule/ec/p256-64.c +0 -1674
@@ -162,9 +162,7 @@ class LoadBalancingPolicy
162
162
  GRPC_ABSTRACT_BASE_CLASS
163
163
 
164
164
  protected:
165
- // So Delete() can access our protected dtor.
166
- template <typename T>
167
- friend void Delete(T*);
165
+ GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE
168
166
 
169
167
  explicit LoadBalancingPolicy(const Args& args);
170
168
  virtual ~LoadBalancingPolicy();
@@ -35,9 +35,10 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem,
35
35
  static void destroy_channel_elem(grpc_channel_element* elem) {}
36
36
 
37
37
  namespace {
38
+
38
39
  struct call_data {
39
40
  // Stats object to update.
40
- grpc_grpclb_client_stats* client_stats;
41
+ grpc_core::RefCountedPtr<grpc_core::GrpcLbClientStats> client_stats;
41
42
  // State for intercepting send_initial_metadata.
42
43
  grpc_closure on_complete_for_send;
43
44
  grpc_closure* original_on_complete_for_send;
@@ -47,6 +48,7 @@ struct call_data {
47
48
  grpc_closure* original_recv_initial_metadata_ready;
48
49
  bool recv_initial_metadata_succeeded;
49
50
  };
51
+
50
52
  } // namespace
51
53
 
52
54
  static void on_complete_for_send(void* arg, grpc_error* error) {
@@ -72,11 +74,11 @@ static grpc_error* init_call_elem(grpc_call_element* elem,
72
74
  // Get stats object from context and take a ref.
73
75
  GPR_ASSERT(args->context != nullptr);
74
76
  if (args->context[GRPC_GRPCLB_CLIENT_STATS].value != nullptr) {
75
- calld->client_stats =
76
- grpc_grpclb_client_stats_ref(static_cast<grpc_grpclb_client_stats*>(
77
- args->context[GRPC_GRPCLB_CLIENT_STATS].value));
77
+ calld->client_stats = static_cast<grpc_core::GrpcLbClientStats*>(
78
+ args->context[GRPC_GRPCLB_CLIENT_STATS].value)
79
+ ->Ref();
78
80
  // Record call started.
79
- grpc_grpclb_client_stats_add_call_started(calld->client_stats);
81
+ calld->client_stats->AddCallStarted();
80
82
  }
81
83
  return GRPC_ERROR_NONE;
82
84
  }
@@ -88,12 +90,12 @@ static void destroy_call_elem(grpc_call_element* elem,
88
90
  if (calld->client_stats != nullptr) {
89
91
  // Record call finished, optionally setting client_failed_to_send and
90
92
  // received.
91
- grpc_grpclb_client_stats_add_call_finished(
93
+ calld->client_stats->AddCallFinished(
92
94
  !calld->send_initial_metadata_succeeded /* client_failed_to_send */,
93
- calld->recv_initial_metadata_succeeded /* known_received */,
94
- calld->client_stats);
95
+ calld->recv_initial_metadata_succeeded /* known_received */);
95
96
  // All done, so unref the stats object.
96
- grpc_grpclb_client_stats_unref(calld->client_stats);
97
+ // TODO(roth): Eliminate this once filter stack is converted to C++.
98
+ calld->client_stats.reset();
97
99
  }
98
100
  }
99
101
 
@@ -76,6 +76,7 @@
76
76
  #include "src/core/ext/filters/client_channel/client_channel.h"
77
77
  #include "src/core/ext/filters/client_channel/client_channel_factory.h"
78
78
  #include "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h"
79
+ #include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h"
79
80
  #include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h"
80
81
  #include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h"
81
82
  #include "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h"
@@ -158,9 +159,8 @@ class GrpcLb : public LoadBalancingPolicy {
158
159
  // The LB token associated with the pick. This is set via user_data in
159
160
  // the pick.
160
161
  grpc_mdelem lb_token;
161
- // Stats for client-side load reporting. Note that this holds a
162
- // reference, which must be either passed on via context or unreffed.
163
- grpc_grpclb_client_stats* client_stats = nullptr;
162
+ // Stats for client-side load reporting.
163
+ RefCountedPtr<GrpcLbClientStats> client_stats;
164
164
  // Next pending pick.
165
165
  PendingPick* next = nullptr;
166
166
  };
@@ -185,7 +185,8 @@ class GrpcLb : public LoadBalancingPolicy {
185
185
 
186
186
  void StartQuery();
187
187
 
188
- grpc_grpclb_client_stats* client_stats() const { return client_stats_; }
188
+ GrpcLbClientStats* client_stats() const { return client_stats_.get(); }
189
+
189
190
  bool seen_initial_response() const { return seen_initial_response_; }
190
191
 
191
192
  private:
@@ -236,7 +237,7 @@ class GrpcLb : public LoadBalancingPolicy {
236
237
 
237
238
  // The stats for client-side load reporting associated with this LB call.
238
239
  // Created after the first serverlist is received.
239
- grpc_grpclb_client_stats* client_stats_ = nullptr;
240
+ RefCountedPtr<GrpcLbClientStats> client_stats_;
240
241
  grpc_millis client_stats_report_interval_ = 0;
241
242
  grpc_timer client_load_report_timer_;
242
243
  bool client_load_report_timer_callback_pending_ = false;
@@ -398,7 +399,7 @@ grpc_lb_addresses* ExtractBackendAddresses(const grpc_lb_addresses* addresses) {
398
399
  bool IsServerValid(const grpc_grpclb_server* server, size_t idx, bool log) {
399
400
  if (server->drop) return false;
400
401
  const grpc_grpclb_ip_address* ip = &server->ip_address;
401
- if (server->port >> 16 != 0) {
402
+ if (GPR_UNLIKELY(server->port >> 16 != 0)) {
402
403
  if (log) {
403
404
  gpr_log(GPR_ERROR,
404
405
  "Invalid port '%d' at index %lu of serverlist. Ignoring.",
@@ -406,7 +407,7 @@ bool IsServerValid(const grpc_grpclb_server* server, size_t idx, bool log) {
406
407
  }
407
408
  return false;
408
409
  }
409
- if (ip->size != 4 && ip->size != 16) {
410
+ if (GPR_UNLIKELY(ip->size != 4 && ip->size != 16)) {
410
411
  if (log) {
411
412
  gpr_log(GPR_ERROR,
412
413
  "Expected IP to be 4 or 16 bytes, got %d at index %lu of "
@@ -547,9 +548,6 @@ GrpcLb::BalancerCallState::~BalancerCallState() {
547
548
  grpc_byte_buffer_destroy(send_message_payload_);
548
549
  grpc_byte_buffer_destroy(recv_message_payload_);
549
550
  grpc_slice_unref_internal(lb_call_status_details_);
550
- if (client_stats_ != nullptr) {
551
- grpc_grpclb_client_stats_unref(client_stats_);
552
- }
553
551
  }
554
552
 
555
553
  void GrpcLb::BalancerCallState::Orphan() {
@@ -672,22 +670,22 @@ void GrpcLb::BalancerCallState::MaybeSendClientLoadReportLocked(
672
670
 
673
671
  bool GrpcLb::BalancerCallState::LoadReportCountersAreZero(
674
672
  grpc_grpclb_request* request) {
675
- grpc_grpclb_dropped_call_counts* drop_entries =
676
- static_cast<grpc_grpclb_dropped_call_counts*>(
673
+ GrpcLbClientStats::DroppedCallCounts* drop_entries =
674
+ static_cast<GrpcLbClientStats::DroppedCallCounts*>(
677
675
  request->client_stats.calls_finished_with_drop.arg);
678
676
  return request->client_stats.num_calls_started == 0 &&
679
677
  request->client_stats.num_calls_finished == 0 &&
680
678
  request->client_stats.num_calls_finished_with_client_failed_to_send ==
681
679
  0 &&
682
680
  request->client_stats.num_calls_finished_known_received == 0 &&
683
- (drop_entries == nullptr || drop_entries->num_entries == 0);
681
+ (drop_entries == nullptr || drop_entries->size() == 0);
684
682
  }
685
683
 
686
684
  void GrpcLb::BalancerCallState::SendClientLoadReportLocked() {
687
685
  // Construct message payload.
688
686
  GPR_ASSERT(send_message_payload_ == nullptr);
689
687
  grpc_grpclb_request* request =
690
- grpc_grpclb_load_report_request_create_locked(client_stats_);
688
+ grpc_grpclb_load_report_request_create_locked(client_stats_.get());
691
689
  // Skip client load report if the counters were all zero in the last
692
690
  // report and they are still zero in this one.
693
691
  if (LoadReportCountersAreZero(request)) {
@@ -714,7 +712,7 @@ void GrpcLb::BalancerCallState::SendClientLoadReportLocked() {
714
712
  this, grpc_combiner_scheduler(grpclb_policy()->combiner()));
715
713
  grpc_call_error call_error = grpc_call_start_batch_and_execute(
716
714
  lb_call_, &op, 1, &client_load_report_closure_);
717
- if (call_error != GRPC_CALL_OK) {
715
+ if (GPR_UNLIKELY(call_error != GRPC_CALL_OK)) {
718
716
  gpr_log(GPR_ERROR, "[grpclb %p] call_error=%d", grpclb_policy_.get(),
719
717
  call_error);
720
718
  GPR_ASSERT(GRPC_CALL_OK == call_error);
@@ -778,7 +776,7 @@ void GrpcLb::BalancerCallState::OnBalancerMessageReceivedLocked(
778
776
  if (grpc_lb_glb_trace.enabled()) {
779
777
  gpr_log(GPR_INFO,
780
778
  "[grpclb %p] Received initial LB response message; "
781
- "client load reporting interval = %" PRIdPTR " milliseconds",
779
+ "client load reporting interval = %" PRId64 " milliseconds",
782
780
  grpclb_policy, lb_calld->client_stats_report_interval_);
783
781
  }
784
782
  } else if (grpc_lb_glb_trace.enabled()) {
@@ -813,7 +811,7 @@ void GrpcLb::BalancerCallState::OnBalancerMessageReceivedLocked(
813
811
  // serverlist returned from the current LB call.
814
812
  if (lb_calld->client_stats_report_interval_ > 0 &&
815
813
  lb_calld->client_stats_ == nullptr) {
816
- lb_calld->client_stats_ = grpc_grpclb_client_stats_create();
814
+ lb_calld->client_stats_.reset(New<GrpcLbClientStats>());
817
815
  // TODO(roth): We currently track this ref manually. Once the
818
816
  // ClosureRef API is ready, we should pass the RefCountedPtr<> along
819
817
  // with the callback.
@@ -936,7 +934,7 @@ grpc_lb_addresses* ExtractBalancerAddresses(
936
934
  size_t lb_addresses_idx = 0;
937
935
  for (size_t i = 0; i < addresses->num_addresses; ++i) {
938
936
  if (!addresses->addresses[i].is_balancer) continue;
939
- if (addresses->addresses[i].user_data != nullptr) {
937
+ if (GPR_UNLIKELY(addresses->addresses[i].user_data != nullptr)) {
940
938
  gpr_log(GPR_ERROR,
941
939
  "This LB policy doesn't support user data. It will be ignored");
942
940
  }
@@ -1003,6 +1001,9 @@ grpc_channel_args* BuildBalancerChannelArgs(
1003
1001
  // address updates into the LB channel.
1004
1002
  grpc_core::FakeResolverResponseGenerator::MakeChannelArg(
1005
1003
  response_generator),
1004
+ // A channel arg indicating the target is a grpclb load balancer.
1005
+ grpc_channel_arg_integer_create(
1006
+ const_cast<char*>(GRPC_ARG_ADDRESS_IS_GRPCLB_LOAD_BALANCER), 1),
1006
1007
  };
1007
1008
  // Construct channel args.
1008
1009
  grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(
@@ -1284,7 +1285,7 @@ void GrpcLb::NotifyOnStateChangeLocked(grpc_connectivity_state* current,
1284
1285
 
1285
1286
  void GrpcLb::ProcessChannelArgsLocked(const grpc_channel_args& args) {
1286
1287
  const grpc_arg* arg = grpc_channel_args_find(&args, GRPC_ARG_LB_ADDRESSES);
1287
- if (arg == nullptr || arg->type != GRPC_ARG_POINTER) {
1288
+ if (GPR_UNLIKELY(arg == nullptr || arg->type != GRPC_ARG_POINTER)) {
1288
1289
  // Ignore this update.
1289
1290
  gpr_log(
1290
1291
  GPR_ERROR,
@@ -1416,7 +1417,7 @@ void GrpcLb::StartBalancerCallRetryTimerLocked() {
1416
1417
  gpr_log(GPR_INFO, "[grpclb %p] Connection to LB server lost...", this);
1417
1418
  grpc_millis timeout = next_try - ExecCtx::Get()->Now();
1418
1419
  if (timeout > 0) {
1419
- gpr_log(GPR_INFO, "[grpclb %p] ... retry_timer_active in %" PRIuPTR "ms.",
1420
+ gpr_log(GPR_INFO, "[grpclb %p] ... retry_timer_active in %" PRId64 "ms.",
1420
1421
  this, timeout);
1421
1422
  } else {
1422
1423
  gpr_log(GPR_INFO, "[grpclb %p] ... retry_timer_active immediately.",
@@ -1512,7 +1513,7 @@ grpc_error* AddLbTokenToInitialMetadata(
1512
1513
 
1513
1514
  // Destroy function used when embedding client stats in call context.
1514
1515
  void DestroyClientStats(void* arg) {
1515
- grpc_grpclb_client_stats_unref(static_cast<grpc_grpclb_client_stats*>(arg));
1516
+ static_cast<GrpcLbClientStats*>(arg)->Unref();
1516
1517
  }
1517
1518
 
1518
1519
  void GrpcLb::PendingPickSetMetadataAndContext(PendingPick* pp) {
@@ -1520,7 +1521,7 @@ void GrpcLb::PendingPickSetMetadataAndContext(PendingPick* pp) {
1520
1521
  * policy (e.g., all addresses failed to connect). There won't be any
1521
1522
  * user_data/token available */
1522
1523
  if (pp->pick->connected_subchannel != nullptr) {
1523
- if (!GRPC_MDISNULL(pp->lb_token)) {
1524
+ if (GPR_LIKELY(!GRPC_MDISNULL(pp->lb_token))) {
1524
1525
  AddLbTokenToInitialMetadata(GRPC_MDELEM_REF(pp->lb_token),
1525
1526
  &pp->pick->lb_token_mdelem_storage,
1526
1527
  pp->pick->initial_metadata);
@@ -1533,14 +1534,12 @@ void GrpcLb::PendingPickSetMetadataAndContext(PendingPick* pp) {
1533
1534
  // Pass on client stats via context. Passes ownership of the reference.
1534
1535
  if (pp->client_stats != nullptr) {
1535
1536
  pp->pick->subchannel_call_context[GRPC_GRPCLB_CLIENT_STATS].value =
1536
- pp->client_stats;
1537
+ pp->client_stats.release();
1537
1538
  pp->pick->subchannel_call_context[GRPC_GRPCLB_CLIENT_STATS].destroy =
1538
1539
  DestroyClientStats;
1539
1540
  }
1540
1541
  } else {
1541
- if (pp->client_stats != nullptr) {
1542
- grpc_grpclb_client_stats_unref(pp->client_stats);
1543
- }
1542
+ pp->client_stats.reset();
1544
1543
  }
1545
1544
  }
1546
1545
 
@@ -1606,8 +1605,8 @@ bool GrpcLb::PickFromRoundRobinPolicyLocked(bool force_async, PendingPick* pp) {
1606
1605
  // subchannel call (and therefore no client_load_reporting filter)
1607
1606
  // for dropped calls.
1608
1607
  if (lb_calld_ != nullptr && lb_calld_->client_stats() != nullptr) {
1609
- grpc_grpclb_client_stats_add_call_dropped_locked(
1610
- server->load_balance_token, lb_calld_->client_stats());
1608
+ lb_calld_->client_stats()->AddCallDroppedLocked(
1609
+ server->load_balance_token);
1611
1610
  }
1612
1611
  if (force_async) {
1613
1612
  GRPC_CLOSURE_SCHED(pp->original_on_complete, GRPC_ERROR_NONE);
@@ -1620,7 +1619,7 @@ bool GrpcLb::PickFromRoundRobinPolicyLocked(bool force_async, PendingPick* pp) {
1620
1619
  }
1621
1620
  // Set client_stats and user_data.
1622
1621
  if (lb_calld_ != nullptr && lb_calld_->client_stats() != nullptr) {
1623
- pp->client_stats = grpc_grpclb_client_stats_ref(lb_calld_->client_stats());
1622
+ pp->client_stats = lb_calld_->client_stats()->Ref();
1624
1623
  }
1625
1624
  GPR_ASSERT(pp->pick->user_data == nullptr);
1626
1625
  pp->pick->user_data = (void**)&pp->lb_token;
@@ -1645,7 +1644,7 @@ void GrpcLb::CreateRoundRobinPolicyLocked(const Args& args) {
1645
1644
  GPR_ASSERT(rr_policy_ == nullptr);
1646
1645
  rr_policy_ = LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
1647
1646
  "round_robin", args);
1648
- if (rr_policy_ == nullptr) {
1647
+ if (GPR_UNLIKELY(rr_policy_ == nullptr)) {
1649
1648
  gpr_log(GPR_ERROR, "[grpclb %p] Failure creating a RoundRobin policy",
1650
1649
  this);
1651
1650
  return;
@@ -1698,9 +1697,11 @@ void GrpcLb::CreateRoundRobinPolicyLocked(const Args& args) {
1698
1697
 
1699
1698
  grpc_channel_args* GrpcLb::CreateRoundRobinPolicyArgsLocked() {
1700
1699
  grpc_lb_addresses* addresses;
1700
+ bool is_backend_from_grpclb_load_balancer = false;
1701
1701
  if (serverlist_ != nullptr) {
1702
1702
  GPR_ASSERT(serverlist_->num_servers > 0);
1703
1703
  addresses = ProcessServerlist(serverlist_);
1704
+ is_backend_from_grpclb_load_balancer = true;
1704
1705
  } else {
1705
1706
  // If CreateOrUpdateRoundRobinPolicyLocked() is invoked when we haven't
1706
1707
  // received any serverlist from the balancer, we use the fallback backends
@@ -1714,9 +1715,18 @@ grpc_channel_args* GrpcLb::CreateRoundRobinPolicyArgsLocked() {
1714
1715
  // Replace the LB addresses in the channel args that we pass down to
1715
1716
  // the subchannel.
1716
1717
  static const char* keys_to_remove[] = {GRPC_ARG_LB_ADDRESSES};
1717
- const grpc_arg arg = grpc_lb_addresses_create_channel_arg(addresses);
1718
+ const grpc_arg args_to_add[] = {
1719
+ grpc_lb_addresses_create_channel_arg(addresses),
1720
+ // A channel arg indicating if the target is a backend inferred from a
1721
+ // grpclb load balancer.
1722
+ grpc_channel_arg_integer_create(
1723
+ const_cast<char*>(
1724
+ GRPC_ARG_ADDRESS_IS_BACKEND_FROM_GRPCLB_LOAD_BALANCER),
1725
+ is_backend_from_grpclb_load_balancer),
1726
+ };
1718
1727
  grpc_channel_args* args = grpc_channel_args_copy_and_add_and_remove(
1719
- args_, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), &arg, 1);
1728
+ args_, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), args_to_add,
1729
+ GPR_ARRAY_SIZE(args_to_add));
1720
1730
  grpc_lb_addresses_destroy(addresses);
1721
1731
  return args;
1722
1732
  }
@@ -0,0 +1,36 @@
1
+ /*
2
+ *
3
+ * Copyright 2018 gRPC authors.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_GRPCLB_H
20
+ #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_GRPCLB_H
21
+
22
+ #include <grpc/support/port_platform.h>
23
+
24
+ /** Channel arg indicating if a target corresponding to the address is grpclb
25
+ * loadbalancer. The type of this arg is an integer and the value is treated as
26
+ * a bool. */
27
+ #define GRPC_ARG_ADDRESS_IS_GRPCLB_LOAD_BALANCER \
28
+ "grpc.address_is_grpclb_load_balancer"
29
+ /** Channel arg indicating if a target corresponding to the address is a backend
30
+ * received from a balancer. The type of this arg is an integer and the value is
31
+ * treated as a bool. */
32
+ #define GRPC_ARG_ADDRESS_IS_BACKEND_FROM_GRPCLB_LOAD_BALANCER \
33
+ "grpc.address_is_backend_from_grpclb_load_balancer"
34
+
35
+ #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_GRPCLB_H \
36
+ */
@@ -22,131 +22,65 @@
22
22
 
23
23
  #include <string.h>
24
24
 
25
- #include <grpc/support/alloc.h>
26
25
  #include <grpc/support/atm.h>
27
26
  #include <grpc/support/string_util.h>
28
- #include <grpc/support/sync.h>
29
27
 
30
- #include "src/core/lib/channel/channel_args.h"
28
+ namespace grpc_core {
31
29
 
32
- #define GRPC_ARG_GRPCLB_CLIENT_STATS "grpc.grpclb_client_stats"
33
-
34
- struct grpc_grpclb_client_stats {
35
- gpr_refcount refs;
36
- // This field must only be accessed via *_locked() methods.
37
- grpc_grpclb_dropped_call_counts* drop_token_counts;
38
- // These fields may be accessed from multiple threads at a time.
39
- gpr_atm num_calls_started;
40
- gpr_atm num_calls_finished;
41
- gpr_atm num_calls_finished_with_client_failed_to_send;
42
- gpr_atm num_calls_finished_known_received;
43
- };
44
-
45
- grpc_grpclb_client_stats* grpc_grpclb_client_stats_create() {
46
- grpc_grpclb_client_stats* client_stats =
47
- static_cast<grpc_grpclb_client_stats*>(gpr_zalloc(sizeof(*client_stats)));
48
- gpr_ref_init(&client_stats->refs, 1);
49
- return client_stats;
50
- }
51
-
52
- grpc_grpclb_client_stats* grpc_grpclb_client_stats_ref(
53
- grpc_grpclb_client_stats* client_stats) {
54
- gpr_ref(&client_stats->refs);
55
- return client_stats;
56
- }
57
-
58
- void grpc_grpclb_client_stats_unref(grpc_grpclb_client_stats* client_stats) {
59
- if (gpr_unref(&client_stats->refs)) {
60
- grpc_grpclb_dropped_call_counts_destroy(client_stats->drop_token_counts);
61
- gpr_free(client_stats);
62
- }
63
- }
64
-
65
- void grpc_grpclb_client_stats_add_call_started(
66
- grpc_grpclb_client_stats* client_stats) {
67
- gpr_atm_full_fetch_add(&client_stats->num_calls_started, (gpr_atm)1);
30
+ void GrpcLbClientStats::AddCallStarted() {
31
+ gpr_atm_full_fetch_add(&num_calls_started_, (gpr_atm)1);
68
32
  }
69
33
 
70
- void grpc_grpclb_client_stats_add_call_finished(
71
- bool finished_with_client_failed_to_send, bool finished_known_received,
72
- grpc_grpclb_client_stats* client_stats) {
73
- gpr_atm_full_fetch_add(&client_stats->num_calls_finished, (gpr_atm)1);
34
+ void GrpcLbClientStats::AddCallFinished(
35
+ bool finished_with_client_failed_to_send, bool finished_known_received) {
36
+ gpr_atm_full_fetch_add(&num_calls_finished_, (gpr_atm)1);
74
37
  if (finished_with_client_failed_to_send) {
75
- gpr_atm_full_fetch_add(
76
- &client_stats->num_calls_finished_with_client_failed_to_send,
77
- (gpr_atm)1);
38
+ gpr_atm_full_fetch_add(&num_calls_finished_with_client_failed_to_send_,
39
+ (gpr_atm)1);
78
40
  }
79
41
  if (finished_known_received) {
80
- gpr_atm_full_fetch_add(&client_stats->num_calls_finished_known_received,
81
- (gpr_atm)1);
42
+ gpr_atm_full_fetch_add(&num_calls_finished_known_received_, (gpr_atm)1);
82
43
  }
83
44
  }
84
45
 
85
- void grpc_grpclb_client_stats_add_call_dropped_locked(
86
- char* token, grpc_grpclb_client_stats* client_stats) {
46
+ void GrpcLbClientStats::AddCallDroppedLocked(char* token) {
87
47
  // Increment num_calls_started and num_calls_finished.
88
- gpr_atm_full_fetch_add(&client_stats->num_calls_started, (gpr_atm)1);
89
- gpr_atm_full_fetch_add(&client_stats->num_calls_finished, (gpr_atm)1);
48
+ gpr_atm_full_fetch_add(&num_calls_started_, (gpr_atm)1);
49
+ gpr_atm_full_fetch_add(&num_calls_finished_, (gpr_atm)1);
90
50
  // Record the drop.
91
- if (client_stats->drop_token_counts == nullptr) {
92
- client_stats->drop_token_counts =
93
- static_cast<grpc_grpclb_dropped_call_counts*>(
94
- gpr_zalloc(sizeof(grpc_grpclb_dropped_call_counts)));
51
+ if (drop_token_counts_ == nullptr) {
52
+ drop_token_counts_.reset(New<DroppedCallCounts>());
95
53
  }
96
- grpc_grpclb_dropped_call_counts* drop_token_counts =
97
- client_stats->drop_token_counts;
98
- for (size_t i = 0; i < drop_token_counts->num_entries; ++i) {
99
- if (strcmp(drop_token_counts->token_counts[i].token, token) == 0) {
100
- ++drop_token_counts->token_counts[i].count;
54
+ for (size_t i = 0; i < drop_token_counts_->size(); ++i) {
55
+ if (strcmp((*drop_token_counts_)[i].token.get(), token) == 0) {
56
+ ++(*drop_token_counts_)[i].count;
101
57
  return;
102
58
  }
103
59
  }
104
- // Not found, so add a new entry. We double the size of the array each time.
105
- size_t new_num_entries = 2;
106
- while (new_num_entries < drop_token_counts->num_entries + 1) {
107
- new_num_entries *= 2;
108
- }
109
- drop_token_counts->token_counts = static_cast<grpc_grpclb_drop_token_count*>(
110
- gpr_realloc(drop_token_counts->token_counts,
111
- new_num_entries * sizeof(grpc_grpclb_drop_token_count)));
112
- grpc_grpclb_drop_token_count* new_entry =
113
- &drop_token_counts->token_counts[drop_token_counts->num_entries++];
114
- new_entry->token = gpr_strdup(token);
115
- new_entry->count = 1;
60
+ // Not found, so add a new entry.
61
+ drop_token_counts_->emplace_back(UniquePtr<char>(gpr_strdup(token)), 1);
116
62
  }
117
63
 
118
- static void atomic_get_and_reset_counter(int64_t* value, gpr_atm* counter) {
119
- *value = static_cast<int64_t>(gpr_atm_acq_load(counter));
120
- gpr_atm_full_fetch_add(counter, (gpr_atm)(-*value));
64
+ namespace {
65
+
66
+ void AtomicGetAndResetCounter(int64_t* value, gpr_atm* counter) {
67
+ *value = static_cast<int64_t>(gpr_atm_full_xchg(counter, (gpr_atm)0));
121
68
  }
122
69
 
123
- void grpc_grpclb_client_stats_get_locked(
124
- grpc_grpclb_client_stats* client_stats, int64_t* num_calls_started,
125
- int64_t* num_calls_finished,
70
+ } // namespace
71
+
72
+ void GrpcLbClientStats::GetLocked(
73
+ int64_t* num_calls_started, int64_t* num_calls_finished,
126
74
  int64_t* num_calls_finished_with_client_failed_to_send,
127
75
  int64_t* num_calls_finished_known_received,
128
- grpc_grpclb_dropped_call_counts** drop_token_counts) {
129
- atomic_get_and_reset_counter(num_calls_started,
130
- &client_stats->num_calls_started);
131
- atomic_get_and_reset_counter(num_calls_finished,
132
- &client_stats->num_calls_finished);
133
- atomic_get_and_reset_counter(
134
- num_calls_finished_with_client_failed_to_send,
135
- &client_stats->num_calls_finished_with_client_failed_to_send);
136
- atomic_get_and_reset_counter(
137
- num_calls_finished_known_received,
138
- &client_stats->num_calls_finished_known_received);
139
- *drop_token_counts = client_stats->drop_token_counts;
140
- client_stats->drop_token_counts = nullptr;
76
+ UniquePtr<DroppedCallCounts>* drop_token_counts) {
77
+ AtomicGetAndResetCounter(num_calls_started, &num_calls_started_);
78
+ AtomicGetAndResetCounter(num_calls_finished, &num_calls_finished_);
79
+ AtomicGetAndResetCounter(num_calls_finished_with_client_failed_to_send,
80
+ &num_calls_finished_with_client_failed_to_send_);
81
+ AtomicGetAndResetCounter(num_calls_finished_known_received,
82
+ &num_calls_finished_known_received_);
83
+ *drop_token_counts = std::move(drop_token_counts_);
141
84
  }
142
85
 
143
- void grpc_grpclb_dropped_call_counts_destroy(
144
- grpc_grpclb_dropped_call_counts* drop_entries) {
145
- if (drop_entries != nullptr) {
146
- for (size_t i = 0; i < drop_entries->num_entries; ++i) {
147
- gpr_free(drop_entries->token_counts[i].token);
148
- }
149
- gpr_free(drop_entries->token_counts);
150
- gpr_free(drop_entries);
151
- }
152
- }
86
+ } // namespace grpc_core