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
@@ -67,6 +67,9 @@
67
67
 
68
68
  #define MAX_SEND_EXTRA_METADATA_COUNT 3
69
69
 
70
+ // Used to create arena for the first call.
71
+ #define ESTIMATED_MDELEM_COUNT 16
72
+
70
73
  /* Status data for a request can come from several sources; this
71
74
  enumerates them all, and acts as a priority sorting for which
72
75
  status to return to the application - earlier entries override
@@ -323,6 +326,11 @@ static parent_call* get_parent_call(grpc_call* call) {
323
326
  return (parent_call*)gpr_atm_acq_load(&call->parent_call_atm);
324
327
  }
325
328
 
329
+ size_t grpc_call_get_initial_size_estimate() {
330
+ return sizeof(grpc_call) + sizeof(batch_control) * MAX_CONCURRENT_BATCHES +
331
+ sizeof(grpc_linked_mdelem) * ESTIMATED_MDELEM_COUNT;
332
+ }
333
+
326
334
  grpc_error* grpc_call_create(const grpc_call_create_args* args,
327
335
  grpc_call** out_call) {
328
336
  GPR_TIMER_SCOPE("grpc_call_create", 0);
@@ -508,7 +516,6 @@ static void release_call(void* call, grpc_error* error) {
508
516
  grpc_call* c = static_cast<grpc_call*>(call);
509
517
  grpc_channel* channel = c->channel;
510
518
  grpc_call_combiner_destroy(&c->call_combiner);
511
- gpr_free((char*)c->peer_string);
512
519
  grpc_channel_update_call_size_estimate(channel, gpr_arena_destroy(c->arena));
513
520
  GRPC_CHANNEL_INTERNAL_UNREF(channel, "call");
514
521
  }
@@ -1124,7 +1131,7 @@ static bool are_initial_metadata_flags_valid(uint32_t flags, bool is_client) {
1124
1131
  return !(flags & invalid_positions);
1125
1132
  }
1126
1133
 
1127
- static int batch_slot_for_op(grpc_op_type type) {
1134
+ static size_t batch_slot_for_op(grpc_op_type type) {
1128
1135
  switch (type) {
1129
1136
  case GRPC_OP_SEND_INITIAL_METADATA:
1130
1137
  return 0;
@@ -1144,20 +1151,23 @@ static int batch_slot_for_op(grpc_op_type type) {
1144
1151
  GPR_UNREACHABLE_CODE(return 123456789);
1145
1152
  }
1146
1153
 
1147
- static batch_control* allocate_batch_control(grpc_call* call,
1148
- const grpc_op* ops,
1149
- size_t num_ops) {
1150
- int slot = batch_slot_for_op(ops[0].op);
1151
- batch_control** pslot = &call->active_batches[slot];
1152
- if (*pslot == nullptr) {
1153
- *pslot = static_cast<batch_control*>(
1154
+ static batch_control* reuse_or_allocate_batch_control(grpc_call* call,
1155
+ const grpc_op* ops,
1156
+ size_t num_ops) {
1157
+ size_t slot_idx = batch_slot_for_op(ops[0].op);
1158
+ batch_control** pslot = &call->active_batches[slot_idx];
1159
+ batch_control* bctl;
1160
+ if (*pslot != nullptr) {
1161
+ bctl = *pslot;
1162
+ if (bctl->call != nullptr) {
1163
+ return nullptr;
1164
+ }
1165
+ memset(bctl, 0, sizeof(*bctl));
1166
+ } else {
1167
+ bctl = static_cast<batch_control*>(
1154
1168
  gpr_arena_alloc(call->arena, sizeof(batch_control)));
1169
+ *pslot = bctl;
1155
1170
  }
1156
- batch_control* bctl = *pslot;
1157
- if (bctl->call != nullptr) {
1158
- return nullptr;
1159
- }
1160
- memset(bctl, 0, sizeof(*bctl));
1161
1171
  bctl->call = call;
1162
1172
  bctl->op.payload = &call->stream_op_payload;
1163
1173
  return bctl;
@@ -1259,8 +1269,12 @@ static void post_batch_completion(batch_control* bctl) {
1259
1269
  if (bctl->completion_data.notify_tag.is_closure) {
1260
1270
  /* unrefs bctl->error */
1261
1271
  bctl->call = nullptr;
1262
- GRPC_CLOSURE_RUN((grpc_closure*)bctl->completion_data.notify_tag.tag,
1263
- error);
1272
+ /* This closure may be meant to be run within some combiner. Since we aren't
1273
+ * running in any combiner here, we need to use GRPC_CLOSURE_SCHED instead
1274
+ * of GRPC_CLOSURE_RUN.
1275
+ */
1276
+ GRPC_CLOSURE_SCHED((grpc_closure*)bctl->completion_data.notify_tag.tag,
1277
+ error);
1264
1278
  GRPC_CALL_INTERNAL_UNREF(call, "completion");
1265
1279
  } else {
1266
1280
  /* unrefs bctl->error */
@@ -1565,7 +1579,7 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1565
1579
  goto done;
1566
1580
  }
1567
1581
 
1568
- bctl = allocate_batch_control(call, ops, nops);
1582
+ bctl = reuse_or_allocate_batch_control(call, ops, nops);
1569
1583
  if (bctl == nullptr) {
1570
1584
  return GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
1571
1585
  }
@@ -98,6 +98,11 @@ void* grpc_call_context_get(grpc_call* call, grpc_context_index elem);
98
98
 
99
99
  uint8_t grpc_call_is_client(grpc_call* call);
100
100
 
101
+ /* Get the estimated memory size for a call BESIDES the call stack. Combined
102
+ * with the size of the call stack, it helps estimate the arena size for the
103
+ * initial call. */
104
+ size_t grpc_call_get_initial_size_estimate();
105
+
101
106
  /* Return an appropriate compression algorithm for the requested compression \a
102
107
  * level in the context of \a call. */
103
108
  grpc_compression_algorithm grpc_call_compression_for_level(
@@ -72,10 +72,6 @@ struct grpc_channel {
72
72
  };
73
73
 
74
74
  #define CHANNEL_STACK_FROM_CHANNEL(c) ((grpc_channel_stack*)((c) + 1))
75
- #define CHANNEL_FROM_CHANNEL_STACK(channel_stack) \
76
- (((grpc_channel*)(channel_stack)) - 1)
77
- #define CHANNEL_FROM_TOP_ELEM(top_elem) \
78
- CHANNEL_FROM_CHANNEL_STACK(grpc_channel_stack_from_top_element(top_elem))
79
75
 
80
76
  static void destroy_channel(void* arg, grpc_error* error);
81
77
 
@@ -112,7 +108,8 @@ grpc_channel* grpc_channel_create_with_builder(
112
108
 
113
109
  gpr_atm_no_barrier_store(
114
110
  &channel->call_size_estimate,
115
- (gpr_atm)CHANNEL_STACK_FROM_CHANNEL(channel)->call_stack_size);
111
+ (gpr_atm)CHANNEL_STACK_FROM_CHANNEL(channel)->call_stack_size +
112
+ grpc_call_get_initial_size_estimate());
116
113
 
117
114
  grpc_compression_options_init(&channel->compression_options);
118
115
  for (size_t i = 0; i < args->num_args; i++) {
@@ -321,8 +321,7 @@ static const cq_vtable g_cq_vtable[] = {
321
321
  #define POLLSET_FROM_CQ(cq) \
322
322
  ((grpc_pollset*)(cq->vtable->data_size + (char*)DATA_FROM_CQ(cq)))
323
323
 
324
- grpc_core::TraceFlag grpc_cq_pluck_trace(true, "queue_pluck");
325
- grpc_core::TraceFlag grpc_cq_event_timeout_trace(true, "queue_timeout");
324
+ grpc_core::TraceFlag grpc_cq_pluck_trace(false, "queue_pluck");
326
325
 
327
326
  #define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \
328
327
  if (grpc_api_trace.enabled() && (grpc_cq_pluck_trace.enabled() || \
@@ -390,7 +389,6 @@ static bool cq_event_queue_push(grpc_cq_event_queue* q, grpc_cq_completion* c) {
390
389
 
391
390
  static grpc_cq_completion* cq_event_queue_pop(grpc_cq_event_queue* q) {
392
391
  grpc_cq_completion* c = nullptr;
393
- grpc_core::ExecCtx exec_ctx;
394
392
 
395
393
  if (gpr_spinlock_trylock(&q->queue_lock)) {
396
394
  GRPC_STATS_INC_CQ_EV_QUEUE_TRYLOCK_SUCCESSES();
@@ -30,7 +30,6 @@
30
30
  /* These trace flags default to 1. The corresponding lines are only traced
31
31
  if grpc_api_trace is also truthy */
32
32
  extern grpc_core::TraceFlag grpc_cq_pluck_trace;
33
- extern grpc_core::TraceFlag grpc_cq_event_timeout_trace;
34
33
  extern grpc_core::TraceFlag grpc_trace_operation_failures;
35
34
  extern grpc_core::DebugOnlyTraceFlag grpc_trace_pending_tags;
36
35
  extern grpc_core::DebugOnlyTraceFlag grpc_trace_cq_refcount;
@@ -27,13 +27,12 @@
27
27
  #include <grpc/support/log.h>
28
28
  #include <grpc/support/time.h>
29
29
  #include "src/core/lib/channel/channel_stack.h"
30
- #include "src/core/lib/channel/channel_trace_registry.h"
30
+ #include "src/core/lib/channel/channelz_registry.h"
31
31
  #include "src/core/lib/channel/connected_channel.h"
32
32
  #include "src/core/lib/channel/handshaker_registry.h"
33
33
  #include "src/core/lib/debug/stats.h"
34
34
  #include "src/core/lib/debug/trace.h"
35
- #include "src/core/lib/gpr/fork.h"
36
- #include "src/core/lib/gprpp/thd.h"
35
+ #include "src/core/lib/gprpp/fork.h"
37
36
  #include "src/core/lib/http/parser.h"
38
37
  #include "src/core/lib/iomgr/call_combiner.h"
39
38
  #include "src/core/lib/iomgr/combiner.h"
@@ -65,12 +64,10 @@ static int g_initializations;
65
64
 
66
65
  static void do_basic_init(void) {
67
66
  gpr_log_verbosity_init();
68
- grpc_fork_support_init();
69
67
  gpr_mu_init(&g_init_mu);
70
68
  grpc_register_built_in_plugins();
71
69
  grpc_cq_global_init();
72
70
  g_initializations = 0;
73
- grpc_fork_handlers_auto_register();
74
71
  }
75
72
 
76
73
  static bool append_filter(grpc_channel_stack_builder* builder, void* arg) {
@@ -123,13 +120,14 @@ void grpc_init(void) {
123
120
 
124
121
  gpr_mu_lock(&g_init_mu);
125
122
  if (++g_initializations == 1) {
123
+ grpc_core::Fork::GlobalInit();
124
+ grpc_fork_handlers_auto_register();
126
125
  gpr_time_init();
127
- grpc_core::Thread::Init();
128
126
  grpc_stats_init();
129
127
  grpc_slice_intern_init();
130
128
  grpc_mdctx_global_init();
131
129
  grpc_channel_init_init();
132
- grpc_channel_trace_registry_init();
130
+ grpc_core::ChannelzRegistry::Init();
133
131
  grpc_security_pre_init();
134
132
  grpc_core::ExecCtx::GlobalInit();
135
133
  grpc_iomgr_init();
@@ -178,8 +176,9 @@ void grpc_shutdown(void) {
178
176
  grpc_mdctx_global_shutdown();
179
177
  grpc_handshaker_factory_registry_shutdown();
180
178
  grpc_slice_intern_shutdown();
181
- grpc_channel_trace_registry_shutdown();
179
+ grpc_core::ChannelzRegistry::Shutdown();
182
180
  grpc_stats_shutdown();
181
+ grpc_core::Fork::GlobalShutdown();
183
182
  }
184
183
  grpc_core::ExecCtx::GlobalShutdown();
185
184
  }
@@ -23,6 +23,6 @@
23
23
 
24
24
  #include <grpc/grpc.h>
25
25
 
26
- const char* grpc_version_string(void) { return "6.0.0"; }
26
+ const char* grpc_version_string(void) { return "6.0.0-pre1"; }
27
27
 
28
- const char* grpc_g_stands_for(void) { return "glorious"; }
28
+ const char* grpc_g_stands_for(void) { return "gloriosa"; }
@@ -45,7 +45,7 @@ SliceBufferByteStream::SliceBufferByteStream(grpc_slice_buffer* slice_buffer,
45
45
  SliceBufferByteStream::~SliceBufferByteStream() {}
46
46
 
47
47
  void SliceBufferByteStream::Orphan() {
48
- grpc_slice_buffer_destroy(&backing_buffer_);
48
+ grpc_slice_buffer_destroy_internal(&backing_buffer_);
49
49
  GRPC_ERROR_UNREF(shutdown_error_);
50
50
  // Note: We do not actually delete the object here, since
51
51
  // SliceBufferByteStream is usually allocated as part of a larger
@@ -184,7 +184,8 @@ void grpc_transport_set_pops(grpc_transport* transport, grpc_stream* stream,
184
184
  nullptr) {
185
185
  transport->vtable->set_pollset_set(transport, stream, pollset_set);
186
186
  } else {
187
- abort();
187
+ // No-op for empty pollset. Empty pollset is possible when using
188
+ // non-fd-based event engines such as CFStream.
188
189
  }
189
190
  }
190
191
 
@@ -168,13 +168,11 @@ struct grpc_transport_stream_op_batch_payload {
168
168
  /** Iff send_initial_metadata != NULL, flags associated with
169
169
  send_initial_metadata: a bitfield of GRPC_INITIAL_METADATA_xxx */
170
170
  uint32_t send_initial_metadata_flags;
171
- // If non-NULL, will be set by the transport to the peer string
172
- // (a char*, which the caller takes ownership of).
171
+ // If non-NULL, will be set by the transport to the peer string (a char*).
172
+ // The transport retains ownership of the string.
173
173
  // Note: This pointer may be used by the transport after the
174
174
  // send_initial_metadata op is completed. It must remain valid
175
175
  // until the call is destroyed.
176
- // Note: When a transport sets this, it must free the previous
177
- // value, if any.
178
176
  gpr_atm* peer_string;
179
177
  } send_initial_metadata;
180
178
 
@@ -202,13 +200,11 @@ struct grpc_transport_stream_op_batch_payload {
202
200
  // immediately available. This may be a signal that we received a
203
201
  // Trailers-Only response.
204
202
  bool* trailing_metadata_available;
205
- // If non-NULL, will be set by the transport to the peer string
206
- // (a char*, which the caller takes ownership of).
203
+ // If non-NULL, will be set by the transport to the peer string (a char*).
204
+ // The transport retains ownership of the string.
207
205
  // Note: This pointer may be used by the transport after the
208
206
  // recv_initial_metadata op is completed. It must remain valid
209
207
  // until the call is destroyed.
210
- // Note: When a transport sets this, it must free the previous
211
- // value, if any.
212
208
  gpr_atm* peer_string;
213
209
  } recv_initial_metadata;
214
210
 
@@ -52,7 +52,7 @@ static void put_metadata_list(gpr_strvec* b, grpc_metadata_batch md) {
52
52
  }
53
53
  if (md.deadline != GRPC_MILLIS_INF_FUTURE) {
54
54
  char* tmp;
55
- gpr_asprintf(&tmp, " deadline=%" PRIdPTR, md.deadline);
55
+ gpr_asprintf(&tmp, " deadline=%" PRId64, md.deadline);
56
56
  gpr_strvec_add(b, tmp);
57
57
  }
58
58
  }
@@ -118,8 +118,7 @@ static grpc_byte_buffer* get_serialized_start_client(alts_tsi_event* event) {
118
118
  static tsi_result handshaker_client_start_client(alts_handshaker_client* client,
119
119
  alts_tsi_event* event) {
120
120
  if (client == nullptr || event == nullptr) {
121
- gpr_log(GPR_ERROR,
122
- "Invalid arguments to alts_grpc_handshaker_client_start_client()");
121
+ gpr_log(GPR_ERROR, "Invalid arguments to handshaker_client_start_client()");
123
122
  return TSI_INVALID_ARGUMENT;
124
123
  }
125
124
  grpc_byte_buffer* buffer = get_serialized_start_client(event);
@@ -167,8 +166,7 @@ static tsi_result handshaker_client_start_server(alts_handshaker_client* client,
167
166
  alts_tsi_event* event,
168
167
  grpc_slice* bytes_received) {
169
168
  if (client == nullptr || event == nullptr || bytes_received == nullptr) {
170
- gpr_log(GPR_ERROR,
171
- "Invalid arguments to alts_grpc_handshaker_client_start_server()");
169
+ gpr_log(GPR_ERROR, "Invalid arguments to handshaker_client_start_server()");
172
170
  return TSI_INVALID_ARGUMENT;
173
171
  }
174
172
  grpc_byte_buffer* buffer = get_serialized_start_server(event, bytes_received);
@@ -206,8 +204,7 @@ static tsi_result handshaker_client_next(alts_handshaker_client* client,
206
204
  alts_tsi_event* event,
207
205
  grpc_slice* bytes_received) {
208
206
  if (client == nullptr || event == nullptr || bytes_received == nullptr) {
209
- gpr_log(GPR_ERROR,
210
- "Invalid arguments to alts_grpc_handshaker_client_next()");
207
+ gpr_log(GPR_ERROR, "Invalid arguments to handshaker_client_next()");
211
208
  return TSI_INVALID_ARGUMENT;
212
209
  }
213
210
  grpc_byte_buffer* buffer = get_serialized_next(bytes_received);
@@ -223,6 +220,13 @@ static tsi_result handshaker_client_next(alts_handshaker_client* client,
223
220
  return result;
224
221
  }
225
222
 
223
+ static void handshaker_client_shutdown(alts_handshaker_client* client) {
224
+ GPR_ASSERT(client != nullptr);
225
+ alts_grpc_handshaker_client* grpc_client =
226
+ reinterpret_cast<alts_grpc_handshaker_client*>(client);
227
+ GPR_ASSERT(grpc_call_cancel(grpc_client->call, nullptr) == GRPC_CALL_OK);
228
+ }
229
+
226
230
  static void handshaker_client_destruct(alts_handshaker_client* client) {
227
231
  if (client == nullptr) {
228
232
  return;
@@ -234,7 +238,8 @@ static void handshaker_client_destruct(alts_handshaker_client* client) {
234
238
 
235
239
  static const alts_handshaker_client_vtable vtable = {
236
240
  handshaker_client_start_client, handshaker_client_start_server,
237
- handshaker_client_next, handshaker_client_destruct};
241
+ handshaker_client_next, handshaker_client_shutdown,
242
+ handshaker_client_destruct};
238
243
 
239
244
  alts_handshaker_client* alts_grpc_handshaker_client_create(
240
245
  grpc_channel* channel, grpc_completion_queue* queue,
@@ -306,6 +311,13 @@ tsi_result alts_handshaker_client_next(alts_handshaker_client* client,
306
311
  return TSI_INVALID_ARGUMENT;
307
312
  }
308
313
 
314
+ void alts_handshaker_client_shutdown(alts_handshaker_client* client) {
315
+ if (client != nullptr && client->vtable != nullptr &&
316
+ client->vtable->shutdown != nullptr) {
317
+ client->vtable->shutdown(client);
318
+ }
319
+ }
320
+
309
321
  void alts_handshaker_client_destroy(alts_handshaker_client* client) {
310
322
  if (client != nullptr) {
311
323
  if (client->vtable != nullptr && client->vtable->destruct != nullptr) {
@@ -51,6 +51,7 @@ typedef struct alts_handshaker_client_vtable {
51
51
  alts_tsi_event* event, grpc_slice* bytes_received);
52
52
  tsi_result (*next)(alts_handshaker_client* client, alts_tsi_event* event,
53
53
  grpc_slice* bytes_received);
54
+ void (*shutdown)(alts_handshaker_client* client);
54
55
  void (*destruct)(alts_handshaker_client* client);
55
56
  } alts_handshaker_client_vtable;
56
57
 
@@ -99,6 +100,15 @@ tsi_result alts_handshaker_client_next(alts_handshaker_client* client,
99
100
  alts_tsi_event* event,
100
101
  grpc_slice* bytes_received);
101
102
 
103
+ /**
104
+ * This method cancels previously scheduled, but yet executed handshaker
105
+ * requests to ALTS handshaker service. After this operation, the handshake
106
+ * will be shutdown, and no more handshaker requests will get scheduled.
107
+ *
108
+ * - client: ALTS handshaker client instance.
109
+ */
110
+ void alts_handshaker_client_shutdown(alts_handshaker_client* client);
111
+
102
112
  /**
103
113
  * This method destroys a ALTS handshaker client.
104
114
  *
@@ -241,6 +241,10 @@ static tsi_result handshaker_next(
241
241
  gpr_log(GPR_ERROR, "Invalid arguments to handshaker_next()");
242
242
  return TSI_INVALID_ARGUMENT;
243
243
  }
244
+ if (self->handshake_shutdown) {
245
+ gpr_log(GPR_ERROR, "TSI handshake shutdown");
246
+ return TSI_HANDSHAKE_SHUTDOWN;
247
+ }
244
248
  alts_tsi_handshaker* handshaker =
245
249
  reinterpret_cast<alts_tsi_handshaker*>(self);
246
250
  tsi_result ok = TSI_OK;
@@ -277,6 +281,16 @@ static tsi_result handshaker_next(
277
281
  return TSI_ASYNC;
278
282
  }
279
283
 
284
+ static void handshaker_shutdown(tsi_handshaker* self) {
285
+ GPR_ASSERT(self != nullptr);
286
+ if (self->handshake_shutdown) {
287
+ return;
288
+ }
289
+ alts_tsi_handshaker* handshaker =
290
+ reinterpret_cast<alts_tsi_handshaker*>(self);
291
+ alts_handshaker_client_shutdown(handshaker->client);
292
+ }
293
+
280
294
  static void handshaker_destroy(tsi_handshaker* self) {
281
295
  if (self == nullptr) {
282
296
  return;
@@ -292,8 +306,10 @@ static void handshaker_destroy(tsi_handshaker* self) {
292
306
  }
293
307
 
294
308
  static const tsi_handshaker_vtable handshaker_vtable = {
295
- nullptr, nullptr, nullptr, nullptr, nullptr, handshaker_destroy,
296
- handshaker_next};
309
+ nullptr, nullptr,
310
+ nullptr, nullptr,
311
+ nullptr, handshaker_destroy,
312
+ handshaker_next, handshaker_shutdown};
297
313
 
298
314
  static void thread_worker(void* arg) {
299
315
  while (true) {
@@ -401,6 +417,11 @@ void alts_tsi_handshaker_handle_response(alts_tsi_handshaker* handshaker,
401
417
  cb(TSI_INTERNAL_ERROR, user_data, nullptr, 0, nullptr);
402
418
  return;
403
419
  }
420
+ if (handshaker->base.handshake_shutdown) {
421
+ gpr_log(GPR_ERROR, "TSI handshake shutdown");
422
+ cb(TSI_HANDSHAKE_SHUTDOWN, user_data, nullptr, 0, nullptr);
423
+ return;
424
+ }
404
425
  /* Failed grpc call check. */
405
426
  if (!is_ok || status != GRPC_STATUS_OK) {
406
427
  gpr_log(GPR_ERROR, "grpc call made to handshaker service failed");
@@ -479,5 +500,10 @@ void alts_tsi_handshaker_set_client_for_testing(
479
500
  handshaker->client = client;
480
501
  }
481
502
 
503
+ alts_handshaker_client* alts_tsi_handshaker_get_client_for_testing(
504
+ alts_tsi_handshaker* handshaker) {
505
+ return handshaker->client;
506
+ }
507
+
482
508
  } // namespace internal
483
509
  } // namespace grpc_core
@@ -33,6 +33,9 @@ namespace internal {
33
33
  void alts_tsi_handshaker_set_client_for_testing(alts_tsi_handshaker* handshaker,
34
34
  alts_handshaker_client* client);
35
35
 
36
+ alts_handshaker_client* alts_tsi_handshaker_get_client_for_testing(
37
+ alts_tsi_handshaker* handshaker);
38
+
36
39
  /* For testing only. */
37
40
  bool alts_tsi_handshaker_get_has_sent_start_message_for_testing(
38
41
  alts_tsi_handshaker* handshaker);