grpc 1.38.0 → 1.39.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 (199) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +50 -19
  3. data/include/grpc/event_engine/endpoint_config.h +48 -0
  4. data/include/grpc/event_engine/event_engine.h +13 -15
  5. data/include/grpc/event_engine/port.h +2 -0
  6. data/include/grpc/event_engine/slice_allocator.h +17 -7
  7. data/include/grpc/grpc.h +9 -2
  8. data/include/grpc/grpc_security.h +32 -0
  9. data/include/grpc/grpc_security_constants.h +1 -0
  10. data/include/grpc/impl/codegen/grpc_types.h +17 -13
  11. data/include/grpc/impl/codegen/port_platform.h +17 -0
  12. data/src/core/ext/filters/client_channel/client_channel.cc +2 -2
  13. data/src/core/ext/filters/client_channel/health/health_check_client.cc +2 -0
  14. data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
  15. data/src/core/ext/filters/client_channel/http_proxy.cc +16 -1
  16. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +755 -0
  17. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -0
  18. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +10 -24
  19. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +63 -95
  20. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -3
  21. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc +31 -0
  22. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc +28 -0
  23. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -3
  24. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +7 -2
  25. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +15 -3
  26. data/src/core/ext/filters/client_channel/retry_filter.cc +665 -404
  27. data/src/core/ext/filters/client_channel/retry_service_config.cc +43 -24
  28. data/src/core/ext/filters/client_channel/retry_service_config.h +8 -2
  29. data/src/core/ext/filters/client_idle/client_idle_filter.cc +1 -1
  30. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +6 -0
  31. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +2 -1
  32. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +3 -2
  33. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +10 -4
  34. data/src/core/ext/transport/chttp2/transport/internal.h +1 -0
  35. data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -2
  36. data/src/core/ext/transport/inproc/inproc_transport.cc +42 -31
  37. data/src/core/ext/xds/xds_api.cc +247 -106
  38. data/src/core/ext/xds/xds_api.h +15 -6
  39. data/src/core/lib/address_utils/sockaddr_utils.cc +13 -0
  40. data/src/core/lib/address_utils/sockaddr_utils.h +10 -0
  41. data/src/core/lib/channel/channelz.h +3 -0
  42. data/src/core/lib/event_engine/endpoint_config.cc +46 -0
  43. data/src/core/lib/event_engine/endpoint_config_internal.h +42 -0
  44. data/src/core/lib/event_engine/event_engine.cc +50 -0
  45. data/src/core/lib/event_engine/slice_allocator.cc +33 -3
  46. data/src/core/lib/event_engine/sockaddr.cc +14 -12
  47. data/src/core/lib/event_engine/sockaddr.h +44 -0
  48. data/src/core/lib/gpr/wrap_memcpy.cc +2 -1
  49. data/src/core/lib/gprpp/status_helper.h +3 -0
  50. data/src/core/lib/iomgr/endpoint_pair_event_engine.cc +33 -0
  51. data/src/core/lib/iomgr/error.cc +5 -4
  52. data/src/core/lib/iomgr/error.h +1 -1
  53. data/src/core/lib/iomgr/event_engine/closure.cc +54 -0
  54. data/src/core/lib/iomgr/event_engine/closure.h +33 -0
  55. data/src/core/lib/iomgr/event_engine/endpoint.cc +194 -0
  56. data/src/core/lib/iomgr/event_engine/endpoint.h +53 -0
  57. data/src/core/lib/iomgr/event_engine/iomgr.cc +105 -0
  58. data/src/core/lib/iomgr/event_engine/iomgr.h +24 -0
  59. data/src/core/lib/iomgr/event_engine/pollset.cc +87 -0
  60. data/{include/grpc/event_engine/channel_args.h → src/core/lib/iomgr/event_engine/pollset.h} +7 -10
  61. data/src/core/lib/iomgr/event_engine/promise.h +51 -0
  62. data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +41 -0
  63. data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +35 -0
  64. data/src/core/lib/iomgr/event_engine/resolver.cc +110 -0
  65. data/src/core/lib/iomgr/event_engine/tcp.cc +243 -0
  66. data/src/core/lib/iomgr/event_engine/timer.cc +57 -0
  67. data/src/core/lib/iomgr/exec_ctx.cc +8 -0
  68. data/src/core/lib/iomgr/exec_ctx.h +3 -4
  69. data/src/core/lib/iomgr/executor/threadpool.cc +2 -3
  70. data/src/core/lib/iomgr/executor/threadpool.h +2 -2
  71. data/src/core/lib/iomgr/iomgr.cc +1 -1
  72. data/src/core/lib/iomgr/iomgr_posix.cc +2 -0
  73. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +40 -10
  74. data/src/core/lib/iomgr/pollset_custom.cc +2 -2
  75. data/src/core/lib/iomgr/pollset_custom.h +3 -1
  76. data/src/core/lib/iomgr/pollset_uv.cc +3 -1
  77. data/src/core/lib/iomgr/pollset_uv.h +5 -1
  78. data/src/core/lib/iomgr/port.h +7 -5
  79. data/src/core/lib/iomgr/resolve_address.cc +5 -1
  80. data/src/core/lib/iomgr/resolve_address.h +6 -0
  81. data/src/core/lib/iomgr/sockaddr.h +1 -0
  82. data/src/core/lib/iomgr/socket_mutator.cc +15 -2
  83. data/src/core/lib/iomgr/socket_mutator.h +26 -2
  84. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -4
  85. data/src/core/lib/iomgr/socket_utils_posix.h +2 -2
  86. data/src/core/lib/iomgr/tcp_client_posix.cc +7 -2
  87. data/src/core/lib/iomgr/tcp_posix.cc +42 -39
  88. data/src/core/lib/iomgr/tcp_posix.h +8 -0
  89. data/src/core/lib/iomgr/tcp_server_custom.cc +3 -4
  90. data/src/core/lib/iomgr/tcp_server_posix.cc +6 -0
  91. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +2 -1
  92. data/src/core/lib/iomgr/timer.h +6 -1
  93. data/src/core/lib/security/authorization/authorization_engine.h +44 -0
  94. data/src/core/lib/security/authorization/authorization_policy_provider.h +32 -0
  95. data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +46 -0
  96. data/src/core/lib/security/authorization/evaluate_args.cc +209 -0
  97. data/src/core/lib/security/authorization/evaluate_args.h +91 -0
  98. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +3 -1
  99. data/src/core/lib/security/credentials/tls/tls_utils.cc +32 -0
  100. data/src/core/lib/security/credentials/tls/tls_utils.h +13 -0
  101. data/src/core/lib/security/security_connector/local/local_security_connector.cc +9 -6
  102. data/src/core/lib/security/security_connector/ssl_utils.cc +5 -0
  103. data/src/core/lib/surface/call.cc +21 -1
  104. data/src/core/lib/surface/call.h +11 -0
  105. data/src/core/lib/surface/completion_queue.cc +22 -22
  106. data/src/core/lib/surface/completion_queue.h +1 -1
  107. data/src/core/lib/surface/completion_queue_factory.cc +1 -2
  108. data/src/core/lib/surface/init.cc +1 -3
  109. data/src/core/lib/surface/init.h +10 -1
  110. data/src/core/lib/surface/version.cc +1 -1
  111. data/src/core/lib/transport/error_utils.cc +2 -2
  112. data/src/core/lib/transport/transport.h +2 -0
  113. data/src/core/lib/transport/transport_op_string.cc +1 -1
  114. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
  115. data/src/core/tsi/alts/crypt/gsec.h +2 -0
  116. data/src/ruby/ext/grpc/extconf.rb +2 -0
  117. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +6 -0
  118. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +10 -1
  119. data/src/ruby/lib/grpc/version.rb +1 -1
  120. data/third_party/boringssl-with-bazel/err_data.c +269 -263
  121. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +8 -6
  122. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +4 -0
  123. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +1 -1
  124. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -1
  125. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +9 -0
  126. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +0 -4
  127. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +7 -0
  128. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +87 -121
  129. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +20 -30
  130. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +19 -30
  131. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +1 -4
  132. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +0 -13
  133. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +26 -24
  134. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -7
  135. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +28 -39
  136. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +48 -66
  137. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +4 -5
  138. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +362 -371
  139. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +4 -2
  140. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +2 -2
  141. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_asn1.c +1 -2
  142. data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +101 -11
  143. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +3 -0
  144. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +2 -2
  145. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +3 -0
  146. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +1 -1
  147. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +2 -0
  148. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +14 -15
  149. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +53 -73
  150. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +31 -0
  151. data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +3 -0
  152. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +3 -0
  153. data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +5 -8
  154. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +5 -0
  155. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +3 -0
  156. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +7 -0
  157. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
  158. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +5 -8
  159. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +1 -1
  160. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +66 -1
  161. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +40 -9
  162. data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +1 -0
  163. data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +1 -1
  164. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +6 -2
  165. data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +14 -0
  166. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +19 -11
  167. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +325 -0
  168. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +23 -7
  169. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +99 -63
  170. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +139 -109
  171. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +12 -19
  172. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +48 -50
  173. data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +451 -435
  174. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +0 -1
  175. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +2 -2
  176. data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +1 -1
  177. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +773 -84
  178. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +80 -47
  179. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +24 -19
  180. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +189 -86
  181. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +45 -56
  182. data/third_party/boringssl-with-bazel/src/ssl/internal.h +272 -167
  183. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +2 -2
  184. data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
  185. data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +14 -19
  186. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +34 -102
  187. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +2 -0
  188. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +8 -31
  189. data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +3 -0
  190. data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +4 -3
  191. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +7 -3
  192. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +576 -648
  193. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +31 -3
  194. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +98 -39
  195. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +141 -94
  196. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +58 -68
  197. metadata +65 -40
  198. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +0 -267
  199. data/third_party/boringssl-with-bazel/src/crypto/x509/vpm_int.h +0 -71
@@ -399,34 +399,42 @@ class XdsApi {
399
399
  // The name to use in the EDS request.
400
400
  // If empty, the cluster name will be used.
401
401
  std::string eds_service_name;
402
+ // For cluster type LOGICAL_DNS.
403
+ // The hostname to lookup in DNS.
404
+ std::string dns_hostname;
405
+ // For cluster type AGGREGATE.
406
+ // The prioritized list of cluster names.
407
+ std::vector<std::string> prioritized_cluster_names;
408
+
402
409
  // Tls Context used by clients
403
410
  CommonTlsContext common_tls_context;
411
+
404
412
  // The LRS server to use for load reporting.
405
413
  // If not set, load reporting will be disabled.
406
414
  // If set to the empty string, will use the same server we obtained the CDS
407
415
  // data from.
408
416
  absl::optional<std::string> lrs_load_reporting_server_name;
417
+
409
418
  // The LB policy to use (e.g., "ROUND_ROBIN" or "RING_HASH").
410
419
  std::string lb_policy;
411
420
  // Used for RING_HASH LB policy only.
412
421
  uint64_t min_ring_size = 1024;
413
422
  uint64_t max_ring_size = 8388608;
414
- enum HashFunction { XX_HASH, MURMUR_HASH_2 };
415
- HashFunction hash_function;
416
423
  // Maximum number of outstanding requests can be made to the upstream
417
424
  // cluster.
418
425
  uint32_t max_concurrent_requests = 1024;
419
- // For cluster type AGGREGATE.
420
- // The prioritized list of cluster names.
421
- std::vector<std::string> prioritized_cluster_names;
422
426
 
423
427
  bool operator==(const CdsUpdate& other) const {
424
428
  return cluster_type == other.cluster_type &&
425
429
  eds_service_name == other.eds_service_name &&
430
+ dns_hostname == other.dns_hostname &&
431
+ prioritized_cluster_names == other.prioritized_cluster_names &&
426
432
  common_tls_context == other.common_tls_context &&
427
433
  lrs_load_reporting_server_name ==
428
434
  other.lrs_load_reporting_server_name &&
429
- prioritized_cluster_names == other.prioritized_cluster_names &&
435
+ lb_policy == other.lb_policy &&
436
+ min_ring_size == other.min_ring_size &&
437
+ max_ring_size == other.max_ring_size &&
430
438
  max_concurrent_requests == other.max_concurrent_requests;
431
439
  }
432
440
 
@@ -664,6 +672,7 @@ class XdsApi {
664
672
  upb::SymbolTable symtab_;
665
673
  const std::string build_version_;
666
674
  const std::string user_agent_name_;
675
+ const std::string user_agent_version_;
667
676
  };
668
677
 
669
678
  } // namespace grpc_core
@@ -29,11 +29,13 @@
29
29
  #include "absl/strings/str_cat.h"
30
30
  #include "absl/strings/str_format.h"
31
31
 
32
+ #include <grpc/event_engine/event_engine.h>
32
33
  #include <grpc/support/alloc.h>
33
34
  #include <grpc/support/log.h>
34
35
 
35
36
  #include "src/core/lib/gpr/string.h"
36
37
  #include "src/core/lib/gprpp/host_port.h"
38
+ #include "src/core/lib/iomgr/event_engine/resolved_address_internal.h"
37
39
  #include "src/core/lib/iomgr/sockaddr.h"
38
40
  #include "src/core/lib/iomgr/socket_utils.h"
39
41
  #include "src/core/lib/iomgr/unix_sockets_posix.h"
@@ -397,3 +399,14 @@ bool grpc_sockaddr_match_subnet(const grpc_resolved_address* address,
397
399
  }
398
400
  return false;
399
401
  }
402
+
403
+ namespace grpc_event_engine {
404
+ namespace experimental {
405
+
406
+ std::string ResolvedAddressToURI(const EventEngine::ResolvedAddress& addr) {
407
+ auto gra = CreateGRPCResolvedAddress(addr);
408
+ return grpc_sockaddr_to_uri(&gra);
409
+ }
410
+
411
+ } // namespace experimental
412
+ } // namespace grpc_event_engine
@@ -23,6 +23,8 @@
23
23
 
24
24
  #include <string>
25
25
 
26
+ #include <grpc/event_engine/event_engine.h>
27
+
26
28
  #include "src/core/lib/iomgr/resolve_address.h"
27
29
 
28
30
  /* Returns true if addr is an IPv4-mapped IPv6 address within the
@@ -97,4 +99,12 @@ bool grpc_sockaddr_match_subnet(const grpc_resolved_address* address,
97
99
  const grpc_resolved_address* subnet_address,
98
100
  uint32_t mask_bits);
99
101
 
102
+ namespace grpc_event_engine {
103
+ namespace experimental {
104
+
105
+ std::string ResolvedAddressToURI(const EventEngine::ResolvedAddress& addr);
106
+
107
+ } // namespace experimental
108
+ } // namespace grpc_event_engine
109
+
100
110
  #endif /* GRPC_CORE_LIB_ADDRESS_UTILS_SOCKADDR_UTILS_H */
@@ -276,6 +276,9 @@ class SocketNode : public BaseNode {
276
276
  public:
277
277
  struct Security : public RefCounted<Security> {
278
278
  struct Tls {
279
+ // This is a workaround for https://bugs.llvm.org/show_bug.cgi?id=50346
280
+ Tls() {}
281
+
279
282
  enum class NameType { kUnset = 0, kStandardName = 1, kOtherName = 2 };
280
283
  NameType type = NameType::kUnset;
281
284
  // Holds the value of standard_name or other_names if type is not kUnset.
@@ -0,0 +1,46 @@
1
+ // Copyright 2021 The gRPC Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ #include <grpc/support/port_platform.h>
15
+
16
+ #include <grpc/event_engine/endpoint_config.h>
17
+
18
+ #include <grpc/impl/codegen/grpc_types.h>
19
+ #include <grpc/impl/codegen/log.h>
20
+
21
+ #include "src/core/lib/channel/channel_args.h"
22
+ #include "src/core/lib/event_engine/endpoint_config_internal.h"
23
+ #include "src/core/lib/gpr/useful.h"
24
+
25
+ namespace grpc_event_engine {
26
+ namespace experimental {
27
+
28
+ EndpointConfig::Setting ChannelArgsEndpointConfig::Get(
29
+ absl::string_view key) const {
30
+ const grpc_arg* arg = grpc_channel_args_find(args_, std::string(key).c_str());
31
+ if (arg == nullptr) {
32
+ return absl::monostate();
33
+ }
34
+ switch (arg->type) {
35
+ case GRPC_ARG_STRING:
36
+ return absl::string_view(arg->value.string);
37
+ case GRPC_ARG_INTEGER:
38
+ return arg->value.integer;
39
+ case GRPC_ARG_POINTER:
40
+ return arg->value.pointer.p;
41
+ }
42
+ GPR_UNREACHABLE_CODE(return absl::monostate());
43
+ }
44
+
45
+ } // namespace experimental
46
+ } // namespace grpc_event_engine
@@ -0,0 +1,42 @@
1
+ // Copyright 2021 The gRPC Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ #ifndef GRPC_CORE_LIB_EVENT_ENGINE_ENDPOINT_CONFIG_INTERNAL_H
15
+ #define GRPC_CORE_LIB_EVENT_ENGINE_ENDPOINT_CONFIG_INTERNAL_H
16
+
17
+ #include <grpc/support/port_platform.h>
18
+
19
+ #include <grpc/event_engine/endpoint_config.h>
20
+
21
+ #include "src/core/lib/channel/channel_args.h"
22
+
23
+ namespace grpc_event_engine {
24
+ namespace experimental {
25
+
26
+ /// A readonly \a EndpointConfig based on grpc_channel_args. This class does not
27
+ /// take ownership of the grpc_endpoint_args*, and instances of this class
28
+ /// should not be used after the underlying args are destroyed.
29
+ class ChannelArgsEndpointConfig : public EndpointConfig {
30
+ public:
31
+ explicit ChannelArgsEndpointConfig(const grpc_channel_args* args)
32
+ : args_(args) {}
33
+ Setting Get(absl::string_view key) const override;
34
+
35
+ private:
36
+ const grpc_channel_args* args_;
37
+ };
38
+
39
+ } // namespace experimental
40
+ } // namespace grpc_event_engine
41
+
42
+ #endif // GRPC_CORE_LIB_EVENT_ENGINE_ENDPOINT_CONFIG_INTERNAL_H
@@ -0,0 +1,50 @@
1
+ // Copyright 2021 The gRPC Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ #include <grpc/support/port_platform.h>
15
+
16
+ #include <grpc/event_engine/endpoint_config.h>
17
+ #include <grpc/event_engine/event_engine.h>
18
+ #include <grpc/event_engine/port.h>
19
+ #include <grpc/impl/codegen/grpc_types.h>
20
+ #include <grpc/support/log.h>
21
+
22
+ #include "absl/strings/str_format.h"
23
+ #include "absl/strings/str_join.h"
24
+
25
+ #include "src/core/lib/event_engine/sockaddr.h"
26
+
27
+ namespace grpc_event_engine {
28
+ namespace experimental {
29
+
30
+ EventEngine::ResolvedAddress::ResolvedAddress(const sockaddr* address,
31
+ socklen_t size)
32
+ : size_(size) {
33
+ GPR_ASSERT(size <= sizeof(address_));
34
+ memcpy(&address_, address, size);
35
+ }
36
+
37
+ const struct sockaddr* EventEngine::ResolvedAddress::address() const {
38
+ return reinterpret_cast<const struct sockaddr*>(address_);
39
+ }
40
+
41
+ socklen_t EventEngine::ResolvedAddress::size() const { return size_; }
42
+
43
+ std::shared_ptr<grpc_event_engine::experimental::EventEngine>
44
+ DefaultEventEngineFactory() {
45
+ // TODO(nnoble): delete when uv-ee is merged
46
+ abort();
47
+ }
48
+
49
+ } // namespace experimental
50
+ } // namespace grpc_event_engine
@@ -29,11 +29,26 @@ SliceAllocator::SliceAllocator(grpc_resource_user* user)
29
29
  grpc_resource_user_ref(resource_user_);
30
30
  };
31
31
 
32
- SliceAllocator::~SliceAllocator() { grpc_resource_user_unref(resource_user_); };
32
+ SliceAllocator::~SliceAllocator() {
33
+ if (resource_user_ != nullptr) {
34
+ grpc_resource_user_unref(resource_user_);
35
+ }
36
+ };
37
+
38
+ SliceAllocator::SliceAllocator(SliceAllocator&& other) noexcept
39
+ : resource_user_(other.resource_user_) {
40
+ other.resource_user_ = nullptr;
41
+ }
42
+
43
+ SliceAllocator& SliceAllocator::operator=(SliceAllocator&& other) noexcept {
44
+ resource_user_ = other.resource_user_;
45
+ other.resource_user_ = nullptr;
46
+ return *this;
47
+ }
33
48
 
34
49
  absl::Status SliceAllocator::Allocate(size_t size, SliceBuffer* dest,
35
50
  SliceAllocator::AllocateCallback cb) {
36
- // TODO(hork): implement
51
+ // TODO(hork): merge the implementation from the uv-ee branch.
37
52
  (void)size;
38
53
  (void)dest;
39
54
  (void)cb;
@@ -46,7 +61,22 @@ SliceAllocatorFactory::SliceAllocatorFactory(grpc_resource_quota* quota)
46
61
  };
47
62
 
48
63
  SliceAllocatorFactory::~SliceAllocatorFactory() {
49
- grpc_resource_quota_unref_internal(resource_quota_);
64
+ if (resource_quota_ != nullptr) {
65
+ grpc_resource_quota_unref_internal(resource_quota_);
66
+ }
67
+ }
68
+
69
+ SliceAllocatorFactory::SliceAllocatorFactory(
70
+ SliceAllocatorFactory&& other) noexcept
71
+ : resource_quota_(other.resource_quota_) {
72
+ other.resource_quota_ = nullptr;
73
+ }
74
+
75
+ SliceAllocatorFactory& SliceAllocatorFactory::operator=(
76
+ SliceAllocatorFactory&& other) noexcept {
77
+ resource_quota_ = other.resource_quota_;
78
+ other.resource_quota_ = nullptr;
79
+ return *this;
50
80
  }
51
81
 
52
82
  SliceAllocator SliceAllocatorFactory::CreateSliceAllocator(
@@ -13,26 +13,28 @@
13
13
  // limitations under the License.
14
14
  #include <grpc/support/port_platform.h>
15
15
 
16
+ #ifdef GRPC_USE_EVENT_ENGINE
16
17
  #include <string.h>
17
18
 
18
19
  #include "grpc/event_engine/event_engine.h"
19
20
  #include "grpc/event_engine/port.h"
20
21
  #include "grpc/support/log.h"
21
22
 
22
- namespace grpc_event_engine {
23
- namespace experimental {
23
+ uint16_t grpc_htons(uint16_t hostshort) { return htons(hostshort); }
24
24
 
25
- EventEngine::ResolvedAddress::ResolvedAddress(const sockaddr* address,
26
- socklen_t size) {
27
- GPR_ASSERT(size <= sizeof(address_));
28
- memcpy(&address_, address, size);
29
- }
25
+ uint16_t grpc_ntohs(uint16_t netshort) { return ntohs(netshort); }
26
+
27
+ uint32_t grpc_htonl(uint32_t hostlong) { return htonl(hostlong); }
30
28
 
31
- const struct sockaddr* EventEngine::ResolvedAddress::address() const {
32
- return reinterpret_cast<const struct sockaddr*>(address_);
29
+ uint32_t grpc_ntohl(uint32_t netlong) { return ntohl(netlong); }
30
+
31
+ int grpc_inet_pton(int af, const char* src, void* dst) {
32
+ return inet_pton(af, src, dst);
33
33
  }
34
34
 
35
- socklen_t EventEngine::ResolvedAddress::size() const { return size_; }
35
+ const char* grpc_inet_ntop(int af, const void* src, char* dst, size_t size) {
36
+ inet_ntop(af, src, dst, size);
37
+ return dst;
38
+ }
36
39
 
37
- } // namespace experimental
38
- } // namespace grpc_event_engine
40
+ #endif // GRPC_USE_EVENT_ENGINE
@@ -0,0 +1,44 @@
1
+ // Copyright 2021 The gRPC Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ #ifndef GRPC_CORE_LIB_EVENT_ENGINE_SOCKADDR_H
15
+ #define GRPC_CORE_LIB_EVENT_ENGINE_SOCKADDR_H
16
+
17
+ #include <grpc/support/port_platform.h>
18
+
19
+ #ifdef GRPC_USE_EVENT_ENGINE
20
+ #include <grpc/event_engine/port.h>
21
+
22
+ #include "src/core/lib/iomgr/port.h"
23
+
24
+ typedef struct sockaddr grpc_sockaddr;
25
+ typedef struct sockaddr_in grpc_sockaddr_in;
26
+ typedef struct sockaddr_in6 grpc_sockaddr_in6;
27
+ typedef struct in_addr grpc_in_addr;
28
+ typedef struct in6_addr grpc_in6_addr;
29
+
30
+ #define GRPC_INET_ADDRSTRLEN INET_ADDRSTRLEN
31
+ #define GRPC_INET6_ADDRSTRLEN INET6_ADDRSTRLEN
32
+
33
+ #define GRPC_SOCK_STREAM SOCK_STREAM
34
+ #define GRPC_SOCK_DGRAM SOCK_DGRAM
35
+
36
+ #define GRPC_AF_UNSPEC AF_UNSPEC
37
+ #define GRPC_AF_UNIX AF_UNIX
38
+ #define GRPC_AF_INET AF_INET
39
+ #define GRPC_AF_INET6 AF_INET6
40
+
41
+ #define GRPC_AI_PASSIVE AI_PASSIVE
42
+
43
+ #endif
44
+ #endif // GRPC_CORE_LIB_EVENT_ENGINE_SOCKADDR_H
@@ -28,7 +28,8 @@
28
28
 
29
29
  extern "C" {
30
30
  #ifdef __linux__
31
- #if defined(__x86_64__) && !defined(GPR_MUSL_LIBC_COMPAT)
31
+ #if defined(__x86_64__) && !defined(GPR_MUSL_LIBC_COMPAT) && \
32
+ !defined(__ANDROID__)
32
33
  __asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
33
34
  void* __wrap_memcpy(void* destination, const void* source, size_t num) {
34
35
  return memcpy(destination, source, num);
@@ -21,8 +21,11 @@
21
21
 
22
22
  #include <grpc/support/port_platform.h>
23
23
 
24
+ #include <vector>
25
+
24
26
  #include "absl/status/status.h"
25
27
  #include "absl/time/time.h"
28
+ #include "absl/types/optional.h"
26
29
 
27
30
  #include "src/core/lib/gprpp/debug_location.h"
28
31
 
@@ -0,0 +1,33 @@
1
+ // Copyright 2021 The gRPC Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ #include <grpc/support/port_platform.h>
15
+
16
+ #ifdef GRPC_USE_EVENT_ENGINE
17
+ #include "src/core/lib/iomgr/port.h"
18
+
19
+ #include <stdlib.h>
20
+
21
+ #include <grpc/support/log.h>
22
+
23
+ #include "src/core/lib/iomgr/endpoint_pair.h"
24
+
25
+ grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(
26
+ const char* /* name */, grpc_channel_args* /* args */) {
27
+ // TODO(hork): determine what's needed here in the long run
28
+ GPR_ASSERT(
29
+ false &&
30
+ "grpc_iomgr_create_endpoint_pair is not suppoted with event_engine");
31
+ }
32
+
33
+ #endif // GRPC_USE_EVENT_ENGINE