grpc 1.36.0 → 1.37.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.
- checksums.yaml +4 -4
- data/Makefile +65 -37
- data/include/grpc/grpc.h +15 -1
- data/include/grpc/impl/codegen/port_platform.h +2 -0
- data/src/core/ext/filters/client_channel/client_channel.cc +327 -305
- data/src/core/ext/filters/client_channel/client_channel_factory.h +2 -1
- data/src/core/ext/filters/client_channel/config_selector.h +8 -0
- data/src/core/ext/filters/client_channel/dynamic_filters.cc +9 -4
- data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +24 -142
- data/src/core/ext/filters/client_channel/global_subchannel_pool.h +15 -10
- data/src/core/ext/filters/client_channel/lb_policy.cc +3 -0
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +23 -0
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +27 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +7 -22
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +2 -2
- data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +27 -67
- data/src/core/ext/filters/client_channel/local_subchannel_pool.h +10 -9
- data/src/core/ext/filters/client_channel/resolver.cc +3 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +3 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +5 -9
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +18 -3
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +295 -91
- data/src/core/ext/filters/client_channel/server_address.cc +3 -0
- data/src/core/ext/filters/client_channel/subchannel.cc +69 -146
- data/src/core/ext/filters/client_channel/subchannel.h +63 -95
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +16 -2
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +10 -8
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +1 -1
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +495 -0
- data/src/core/ext/filters/fault_injection/fault_injection_filter.h +39 -0
- data/src/core/ext/filters/fault_injection/service_config_parser.cc +189 -0
- data/src/core/ext/filters/fault_injection/service_config_parser.h +85 -0
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +1 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +1 -1
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +3 -2
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +1 -1
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +3 -2
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +457 -170
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +39 -7
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +12 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +5 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/internal.h +1 -0
- data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.c +406 -0
- data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.h +1459 -0
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +350 -0
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +1348 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +6 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +25 -0
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.c +144 -0
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.h +488 -0
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +141 -0
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +452 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +15 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +44 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.c +79 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.h +268 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +78 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +281 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +41 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +113 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +6 -5
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +13 -9
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +93 -0
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +323 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.c +36 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.h +90 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.c +46 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.h +124 -0
- data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.c +33 -0
- data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.h +77 -0
- data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.c +354 -0
- data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.h +140 -0
- data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +383 -0
- data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +115 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +10 -7
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.c +141 -0
- data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.h +70 -0
- data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.c +141 -0
- data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.h +70 -0
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +13 -7
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.c +102 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.h +55 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +120 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.h +45 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +76 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.h +35 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +21 -20
- data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +130 -0
- data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.h +50 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.c +56 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.h +35 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.c +63 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.h +40 -0
- data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.c +44 -0
- data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.h +35 -0
- data/src/core/ext/xds/xds_api.cc +1591 -279
- data/src/core/ext/xds/xds_api.h +279 -39
- data/src/core/ext/xds/xds_bootstrap.cc +21 -5
- data/src/core/ext/xds/xds_bootstrap.h +5 -1
- data/src/core/ext/xds/xds_client.cc +168 -23
- data/src/core/ext/xds/xds_client.h +26 -0
- data/src/core/ext/xds/xds_client_stats.h +2 -2
- data/src/core/ext/xds/xds_http_fault_filter.cc +226 -0
- data/src/core/ext/xds/xds_http_fault_filter.h +63 -0
- data/src/core/ext/xds/xds_http_filters.cc +114 -0
- data/src/core/ext/xds/xds_http_filters.h +130 -0
- data/src/core/ext/xds/xds_server_config_fetcher.cc +391 -126
- data/src/core/lib/channel/channel_stack.cc +12 -0
- data/src/core/lib/channel/channel_stack.h +7 -0
- data/src/core/lib/channel/channelz.cc +92 -4
- data/src/core/lib/channel/channelz.h +30 -1
- data/src/core/lib/channel/channelz_registry.cc +14 -0
- data/src/core/lib/channel/handshaker.cc +0 -39
- data/src/core/lib/channel/handshaker.h +0 -17
- data/src/core/lib/channel/status_util.cc +12 -2
- data/src/core/lib/channel/status_util.h +5 -0
- data/src/core/lib/gpr/sync_abseil.cc +3 -6
- data/src/core/lib/gpr/sync_windows.cc +2 -2
- data/src/core/lib/gprpp/atomic.h +3 -3
- data/src/core/lib/gprpp/dual_ref_counted.h +3 -3
- data/src/core/lib/gprpp/ref_counted_ptr.h +2 -0
- data/src/core/lib/gprpp/thd.h +1 -1
- data/src/core/lib/iomgr/buffer_list.h +1 -1
- data/src/core/lib/iomgr/cfstream_handle.cc +2 -2
- data/src/core/lib/iomgr/error.h +1 -1
- data/src/core/lib/iomgr/ev_apple.cc +1 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -3
- data/src/core/lib/iomgr/ev_posix.cc +3 -3
- data/src/core/lib/iomgr/exec_ctx.cc +6 -2
- data/src/core/lib/iomgr/resource_quota.cc +1 -1
- data/src/core/lib/iomgr/sockaddr_utils.cc +120 -0
- data/src/core/lib/iomgr/sockaddr_utils.h +25 -0
- data/src/core/lib/iomgr/tcp_posix.cc +1 -4
- data/src/core/lib/iomgr/tcp_uv.cc +2 -2
- data/src/core/lib/iomgr/timer_generic.cc +2 -2
- data/src/core/lib/iomgr/timer_manager.cc +1 -1
- data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +1 -1
- data/src/core/lib/{security/authorization → matchers}/matchers.cc +8 -8
- data/src/core/lib/{security/authorization → matchers}/matchers.h +14 -12
- data/src/core/lib/security/security_connector/ssl_utils.cc +6 -4
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +6 -0
- data/src/core/lib/security/transport/security_handshaker.cc +32 -2
- data/src/core/lib/slice/slice_intern.cc +6 -7
- data/src/core/lib/surface/channel.h +3 -3
- data/src/core/lib/surface/completion_queue.cc +1 -1
- data/src/core/lib/surface/lame_client.cc +38 -19
- data/src/core/lib/surface/lame_client.h +4 -3
- data/src/core/lib/surface/server.cc +40 -33
- data/src/core/lib/surface/server.h +74 -15
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/metadata_batch.cc +27 -0
- data/src/core/lib/transport/metadata_batch.h +14 -0
- data/src/core/plugin_registry/grpc_plugin_registry.cc +6 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -4
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +1 -1
- data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +1 -3
- data/src/core/tsi/fake_transport_security.cc +10 -1
- data/src/ruby/ext/grpc/extconf.rb +9 -1
- data/src/ruby/ext/grpc/rb_channel.c +10 -1
- data/src/ruby/ext/grpc/rb_channel_credentials.c +11 -1
- data/src/ruby/ext/grpc/rb_channel_credentials.h +4 -0
- data/src/ruby/ext/grpc/rb_compression_options.c +1 -1
- data/src/ruby/ext/grpc/rb_enable_cpp.cc +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +4 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -1
- data/src/ruby/ext/grpc/rb_server.c +13 -1
- data/src/ruby/ext/grpc/rb_server_credentials.c +19 -3
- data/src/ruby/ext/grpc/rb_server_credentials.h +4 -0
- data/src/ruby/ext/grpc/rb_xds_channel_credentials.c +215 -0
- data/src/ruby/ext/grpc/rb_xds_channel_credentials.h +35 -0
- data/src/ruby/ext/grpc/rb_xds_server_credentials.c +169 -0
- data/src/ruby/ext/grpc/rb_xds_server_credentials.h +35 -0
- data/src/ruby/lib/grpc/generic/client_stub.rb +4 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/call_spec.rb +1 -1
- data/src/ruby/spec/channel_credentials_spec.rb +32 -0
- data/src/ruby/spec/channel_spec.rb +17 -6
- data/src/ruby/spec/client_auth_spec.rb +27 -1
- data/src/ruby/spec/errors_spec.rb +1 -1
- data/src/ruby/spec/generic/active_call_spec.rb +2 -2
- data/src/ruby/spec/generic/client_stub_spec.rb +4 -4
- data/src/ruby/spec/generic/rpc_server_spec.rb +1 -1
- data/src/ruby/spec/server_credentials_spec.rb +25 -0
- data/src/ruby/spec/server_spec.rb +22 -0
- data/third_party/boringssl-with-bazel/err_data.c +255 -255
- data/third_party/boringssl-with-bazel/src/crypto/cpu-arm-linux.c +11 -2
- data/third_party/boringssl-with-bazel/src/crypto/cpu-arm.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +21 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +7 -5
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +0 -28
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +22 -17
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +3 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +4 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/cpu.h +22 -32
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +25 -9
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +0 -1
- data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +33 -19
- data/third_party/xxhash/xxhash.h +5443 -0
- metadata +93 -49
- data/src/core/lib/security/authorization/authorization_engine.cc +0 -177
- data/src/core/lib/security/authorization/authorization_engine.h +0 -84
- data/src/core/lib/security/authorization/evaluate_args.cc +0 -148
- data/src/core/lib/security/authorization/evaluate_args.h +0 -59
- data/src/core/lib/security/authorization/mock_cel/activation.h +0 -57
- data/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +0 -44
- data/src/core/lib/security/authorization/mock_cel/cel_expression.h +0 -69
- data/src/core/lib/security/authorization/mock_cel/cel_value.h +0 -99
- data/src/core/lib/security/authorization/mock_cel/evaluator_core.h +0 -67
- data/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +0 -57
- data/third_party/abseil-cpp/absl/container/flat_hash_set.h +0 -504
- data/third_party/upb/upb/json_decode.c +0 -1443
- data/third_party/upb/upb/json_decode.h +0 -23
- data/third_party/upb/upb/json_encode.c +0 -713
- data/third_party/upb/upb/json_encode.h +0 -36
data/src/core/lib/gprpp/atomic.h
CHANGED
@@ -81,8 +81,8 @@ class Atomic {
|
|
81
81
|
|
82
82
|
// Atomically increment a counter only if the counter value is not zero.
|
83
83
|
// Returns true if increment took place; false if counter is zero.
|
84
|
-
bool IncrementIfNonzero(
|
85
|
-
T count = storage_.load(
|
84
|
+
bool IncrementIfNonzero() {
|
85
|
+
T count = storage_.load(std::memory_order_acquire);
|
86
86
|
do {
|
87
87
|
// If zero, we are done (without an increment). If not, we must do a CAS
|
88
88
|
// to maintain the contract: do not increment the counter if it is already
|
@@ -91,7 +91,7 @@ class Atomic {
|
|
91
91
|
return false;
|
92
92
|
}
|
93
93
|
} while (!CompareExchangeWeak(&count, count + 1, MemoryOrder::ACQ_REL,
|
94
|
-
|
94
|
+
MemoryOrder::ACQUIRE));
|
95
95
|
return true;
|
96
96
|
}
|
97
97
|
|
@@ -170,8 +170,8 @@ class DualRefCounted : public Orphanable {
|
|
170
170
|
#endif
|
171
171
|
const uint64_t prev_ref_pair =
|
172
172
|
refs_.FetchSub(MakeRefPair(0, 1), MemoryOrder::ACQ_REL);
|
173
|
-
const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
|
174
173
|
#ifndef NDEBUG
|
174
|
+
const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
|
175
175
|
const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
|
176
176
|
if (trace != nullptr) {
|
177
177
|
gpr_log(GPR_INFO, "%s:%p weak_unref %d -> %d (refs=%d)", trace, this,
|
@@ -192,10 +192,10 @@ class DualRefCounted : public Orphanable {
|
|
192
192
|
#endif
|
193
193
|
const uint64_t prev_ref_pair =
|
194
194
|
refs_.FetchSub(MakeRefPair(0, 1), MemoryOrder::ACQ_REL);
|
195
|
-
const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
|
196
195
|
#ifndef NDEBUG
|
196
|
+
const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
|
197
197
|
const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
|
198
|
-
if (
|
198
|
+
if (trace != nullptr) {
|
199
199
|
gpr_log(GPR_INFO, "%s:%p %s:%d weak_unref %d -> %d (refs=%d) %s", trace,
|
200
200
|
this, location.file(), location.line(), weak_refs, weak_refs - 1,
|
201
201
|
strong_refs, reason);
|
@@ -83,6 +83,7 @@ class RefCountedPtr {
|
|
83
83
|
}
|
84
84
|
|
85
85
|
// Copy assignment.
|
86
|
+
// NOLINTNEXTLINE(bugprone-unhandled-self-assignment)
|
86
87
|
RefCountedPtr& operator=(const RefCountedPtr& other) {
|
87
88
|
// Note: Order of reffing and unreffing is important here in case value_
|
88
89
|
// and other.value_ are the same object.
|
@@ -235,6 +236,7 @@ class WeakRefCountedPtr {
|
|
235
236
|
}
|
236
237
|
|
237
238
|
// Copy assignment.
|
239
|
+
// NOLINTNEXTLINE(bugprone-unhandled-self-assignment)
|
238
240
|
WeakRefCountedPtr& operator=(const WeakRefCountedPtr& other) {
|
239
241
|
// Note: Order of reffing and unreffing is important here in case value_
|
240
242
|
// and other.value_ are the same object.
|
data/src/core/lib/gprpp/thd.h
CHANGED
@@ -157,7 +157,7 @@ class Thread {
|
|
157
157
|
Thread& operator=(const Thread&) = delete;
|
158
158
|
|
159
159
|
/// The thread states are as follows:
|
160
|
-
/// FAKE -- just a
|
160
|
+
/// FAKE -- just a phony placeholder Thread created by the default constructor
|
161
161
|
/// ALIVE -- an actual thread of control exists associated with this thread
|
162
162
|
/// STARTED -- the thread of control has been started
|
163
163
|
/// DONE -- the thread of control has completed and been joined
|
@@ -146,7 +146,7 @@ class TracedBuffer {
|
|
146
146
|
#else /* GRPC_LINUX_ERRQUEUE */
|
147
147
|
class TracedBuffer {
|
148
148
|
public:
|
149
|
-
/*
|
149
|
+
/* Phony shutdown function */
|
150
150
|
static void Shutdown(grpc_core::TracedBuffer** /*head*/, void* /*remaining*/,
|
151
151
|
grpc_error* shutdown_err) {
|
152
152
|
GRPC_ERROR_UNREF(shutdown_err);
|
@@ -202,9 +202,9 @@ void CFStreamHandle::Unref(const char* file, int line, const char* reason) {
|
|
202
202
|
|
203
203
|
#else
|
204
204
|
|
205
|
-
/* Creating a
|
205
|
+
/* Creating a phony function so that the grpc_cfstream library will be
|
206
206
|
* non-empty.
|
207
207
|
*/
|
208
|
-
void
|
208
|
+
void CFStreamPhony() {}
|
209
209
|
|
210
210
|
#endif
|
data/src/core/lib/iomgr/error.h
CHANGED
@@ -219,7 +219,7 @@ static grpc_error* grpc_error_create_from_vector(const char* file, int line,
|
|
219
219
|
|
220
220
|
grpc_error* grpc_error_set_int(grpc_error* src, grpc_error_ints which,
|
221
221
|
intptr_t value) GRPC_MUST_USE_RESULT;
|
222
|
-
/// It is an error to pass nullptr as `p`. Caller should allocate a
|
222
|
+
/// It is an error to pass nullptr as `p`. Caller should allocate a phony
|
223
223
|
/// intptr_t for `p`, even if the value of `p` is not used.
|
224
224
|
bool grpc_error_get_int(grpc_error* error, grpc_error_ints which, intptr_t* p);
|
225
225
|
/// This call takes ownership of the slice; the error is responsible for
|
@@ -20,7 +20,7 @@
|
|
20
20
|
/// is enabled (see iomgr_posix_cfstream.cc), a global thread is started to
|
21
21
|
/// handle and trigger all the CFStream events. The CFStream streams register
|
22
22
|
/// themselves with the run loop with functions grpc_apple_register_read_stream
|
23
|
-
/// and grpc_apple_register_read_stream. Pollsets are
|
23
|
+
/// and grpc_apple_register_read_stream. Pollsets are phony and block on a
|
24
24
|
/// condition variable in pollset_work().
|
25
25
|
|
26
26
|
#include <grpc/support/port_platform.h>
|
@@ -388,9 +388,9 @@ static void fd_shutdown_internal(grpc_fd* fd, grpc_error* why,
|
|
388
388
|
if (!releasing_fd) {
|
389
389
|
shutdown(fd->fd, SHUT_RDWR);
|
390
390
|
} else {
|
391
|
-
/* we need a
|
392
|
-
epoll_event
|
393
|
-
if (epoll_ctl(g_epoll_set.epfd, EPOLL_CTL_DEL, fd->fd, &
|
391
|
+
/* we need a phony event for earlier linux versions. */
|
392
|
+
epoll_event phony_event;
|
393
|
+
if (epoll_ctl(g_epoll_set.epfd, EPOLL_CTL_DEL, fd->fd, &phony_event) !=
|
394
394
|
0) {
|
395
395
|
gpr_log(GPR_ERROR, "epoll_ctl failed: %s", strerror(errno));
|
396
396
|
}
|
@@ -89,7 +89,7 @@ namespace {
|
|
89
89
|
|
90
90
|
grpc_poll_function_type real_poll_function;
|
91
91
|
|
92
|
-
int
|
92
|
+
int phony_poll(struct pollfd fds[], nfds_t nfds, int timeout) {
|
93
93
|
if (timeout == 0) {
|
94
94
|
return real_poll_function(fds, nfds, 0);
|
95
95
|
} else {
|
@@ -103,10 +103,10 @@ const grpc_event_engine_vtable* init_non_polling(bool explicit_request) {
|
|
103
103
|
if (!explicit_request) {
|
104
104
|
return nullptr;
|
105
105
|
}
|
106
|
-
// return the simplest engine as a
|
106
|
+
// return the simplest engine as a phony but also override the poller
|
107
107
|
auto ret = grpc_init_poll_posix(explicit_request);
|
108
108
|
real_poll_function = grpc_poll_function;
|
109
|
-
grpc_poll_function =
|
109
|
+
grpc_poll_function = phony_poll;
|
110
110
|
|
111
111
|
return ret;
|
112
112
|
}
|
@@ -58,7 +58,9 @@ static grpc_millis timespan_to_millis_round_down(gpr_timespec ts) {
|
|
58
58
|
double x = GPR_MS_PER_SEC * static_cast<double>(ts.tv_sec) +
|
59
59
|
static_cast<double>(ts.tv_nsec) / GPR_NS_PER_MS;
|
60
60
|
if (x < 0) return 0;
|
61
|
-
if (x > GRPC_MILLIS_INF_FUTURE)
|
61
|
+
if (x > static_cast<double>(GRPC_MILLIS_INF_FUTURE)) {
|
62
|
+
return GRPC_MILLIS_INF_FUTURE;
|
63
|
+
}
|
62
64
|
return static_cast<grpc_millis>(x);
|
63
65
|
}
|
64
66
|
|
@@ -72,7 +74,9 @@ static grpc_millis timespan_to_millis_round_up(gpr_timespec ts) {
|
|
72
74
|
static_cast<double>(GPR_NS_PER_SEC - 1) /
|
73
75
|
static_cast<double>(GPR_NS_PER_SEC);
|
74
76
|
if (x < 0) return 0;
|
75
|
-
if (x > GRPC_MILLIS_INF_FUTURE)
|
77
|
+
if (x > static_cast<double>(GRPC_MILLIS_INF_FUTURE)) {
|
78
|
+
return GRPC_MILLIS_INF_FUTURE;
|
79
|
+
}
|
76
80
|
return static_cast<grpc_millis>(x);
|
77
81
|
}
|
78
82
|
|
@@ -132,7 +132,7 @@ struct grpc_resource_quota {
|
|
132
132
|
scaled to the range [0..RESOURCE_USAGE_ESTIMATION_MAX] */
|
133
133
|
gpr_atm memory_usage_estimation;
|
134
134
|
|
135
|
-
/*
|
135
|
+
/* Main combiner lock: all activity on a quota executes under this combiner
|
136
136
|
* (so no mutex is needed for this data structure) */
|
137
137
|
grpc_core::Combiner* combiner;
|
138
138
|
/* Size of the resource quota */
|
@@ -215,6 +215,25 @@ void grpc_string_to_sockaddr(grpc_resolved_address* out, const char* addr,
|
|
215
215
|
grpc_sockaddr_set_port(out, port);
|
216
216
|
}
|
217
217
|
|
218
|
+
grpc_error* grpc_string_to_sockaddr_new(grpc_resolved_address* out,
|
219
|
+
const char* addr, int port) {
|
220
|
+
memset(out, 0, sizeof(grpc_resolved_address));
|
221
|
+
grpc_sockaddr_in6* addr6 = reinterpret_cast<grpc_sockaddr_in6*>(out->addr);
|
222
|
+
grpc_sockaddr_in* addr4 = reinterpret_cast<grpc_sockaddr_in*>(out->addr);
|
223
|
+
if (grpc_inet_pton(GRPC_AF_INET6, addr, &addr6->sin6_addr) == 1) {
|
224
|
+
addr6->sin6_family = GRPC_AF_INET6;
|
225
|
+
out->len = sizeof(grpc_sockaddr_in6);
|
226
|
+
} else if (grpc_inet_pton(GRPC_AF_INET, addr, &addr4->sin_addr) == 1) {
|
227
|
+
addr4->sin_family = GRPC_AF_INET;
|
228
|
+
out->len = sizeof(grpc_sockaddr_in);
|
229
|
+
} else {
|
230
|
+
return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
|
231
|
+
absl::StrCat("Failed to parse address:", addr).c_str());
|
232
|
+
}
|
233
|
+
grpc_sockaddr_set_port(out, port);
|
234
|
+
return GRPC_ERROR_NONE;
|
235
|
+
}
|
236
|
+
|
218
237
|
std::string grpc_sockaddr_to_uri(const grpc_resolved_address* resolved_addr) {
|
219
238
|
if (resolved_addr->len == 0) return "";
|
220
239
|
grpc_resolved_address addr_normalized;
|
@@ -294,3 +313,104 @@ int grpc_sockaddr_set_port(grpc_resolved_address* resolved_addr, int port) {
|
|
294
313
|
return 0;
|
295
314
|
}
|
296
315
|
}
|
316
|
+
|
317
|
+
std::string grpc_sockaddr_get_packed_host(
|
318
|
+
const grpc_resolved_address* resolved_addr) {
|
319
|
+
const grpc_sockaddr* addr =
|
320
|
+
reinterpret_cast<const grpc_sockaddr*>(resolved_addr->addr);
|
321
|
+
if (addr->sa_family == GRPC_AF_INET) {
|
322
|
+
const grpc_sockaddr_in* addr4 =
|
323
|
+
reinterpret_cast<const grpc_sockaddr_in*>(addr);
|
324
|
+
const char* addr_bytes = reinterpret_cast<const char*>(&addr4->sin_addr);
|
325
|
+
return std::string(addr_bytes, 4);
|
326
|
+
} else if (addr->sa_family == GRPC_AF_INET6) {
|
327
|
+
const grpc_sockaddr_in6* addr6 =
|
328
|
+
reinterpret_cast<const grpc_sockaddr_in6*>(addr);
|
329
|
+
const char* addr_bytes = reinterpret_cast<const char*>(&addr6->sin6_addr);
|
330
|
+
return std::string(addr_bytes, 16);
|
331
|
+
} else {
|
332
|
+
GPR_ASSERT(false);
|
333
|
+
}
|
334
|
+
}
|
335
|
+
|
336
|
+
void grpc_sockaddr_mask_bits(grpc_resolved_address* address,
|
337
|
+
uint32_t mask_bits) {
|
338
|
+
grpc_sockaddr* addr = reinterpret_cast<grpc_sockaddr*>(address->addr);
|
339
|
+
if (addr->sa_family == GRPC_AF_INET) {
|
340
|
+
grpc_sockaddr_in* addr4 = reinterpret_cast<grpc_sockaddr_in*>(addr);
|
341
|
+
if (mask_bits == 0) {
|
342
|
+
memset(&addr4->sin_addr, 0, sizeof(addr4->sin_addr));
|
343
|
+
return;
|
344
|
+
} else if (mask_bits >= 32) {
|
345
|
+
return;
|
346
|
+
}
|
347
|
+
uint32_t mask_ip_addr = (~(uint32_t(0))) << (32 - mask_bits);
|
348
|
+
addr4->sin_addr.s_addr &= grpc_htonl(mask_ip_addr);
|
349
|
+
} else if (addr->sa_family == GRPC_AF_INET6) {
|
350
|
+
grpc_sockaddr_in6* addr6 = reinterpret_cast<grpc_sockaddr_in6*>(addr);
|
351
|
+
if (mask_bits == 0) {
|
352
|
+
memset(&addr6->sin6_addr, 0, sizeof(addr6->sin6_addr));
|
353
|
+
return;
|
354
|
+
} else if (mask_bits >= 128) {
|
355
|
+
return;
|
356
|
+
}
|
357
|
+
// We cannot use s6_addr32 since it is not defined on all platforms that we
|
358
|
+
// need it on.
|
359
|
+
uint32_t address_parts[4];
|
360
|
+
GPR_ASSERT(sizeof(addr6->sin6_addr) == sizeof(address_parts));
|
361
|
+
memcpy(address_parts, &addr6->sin6_addr, sizeof(grpc_in6_addr));
|
362
|
+
if (mask_bits <= 32) {
|
363
|
+
uint32_t mask_ip_addr = (~(uint32_t(0))) << (32 - mask_bits);
|
364
|
+
address_parts[0] &= grpc_htonl(mask_ip_addr);
|
365
|
+
memset(&address_parts[1], 0, sizeof(uint32_t));
|
366
|
+
memset(&address_parts[2], 0, sizeof(uint32_t));
|
367
|
+
memset(&address_parts[3], 0, sizeof(uint32_t));
|
368
|
+
} else if (mask_bits <= 64) {
|
369
|
+
mask_bits -= 32;
|
370
|
+
uint32_t mask_ip_addr = (~(uint32_t(0))) << (32 - mask_bits);
|
371
|
+
address_parts[1] &= grpc_htonl(mask_ip_addr);
|
372
|
+
memset(&address_parts[2], 0, sizeof(uint32_t));
|
373
|
+
memset(&address_parts[3], 0, sizeof(uint32_t));
|
374
|
+
} else if (mask_bits <= 96) {
|
375
|
+
mask_bits -= 64;
|
376
|
+
uint32_t mask_ip_addr = (~(uint32_t(0))) << (32 - mask_bits);
|
377
|
+
address_parts[2] &= grpc_htonl(mask_ip_addr);
|
378
|
+
memset(&address_parts[3], 0, sizeof(uint32_t));
|
379
|
+
} else {
|
380
|
+
mask_bits -= 96;
|
381
|
+
uint32_t mask_ip_addr = (~(uint32_t(0))) << (32 - mask_bits);
|
382
|
+
address_parts[3] &= grpc_htonl(mask_ip_addr);
|
383
|
+
}
|
384
|
+
memcpy(&addr6->sin6_addr, address_parts, sizeof(grpc_in6_addr));
|
385
|
+
}
|
386
|
+
}
|
387
|
+
|
388
|
+
bool grpc_sockaddr_match_subnet(const grpc_resolved_address* address,
|
389
|
+
const grpc_resolved_address* subnet_address,
|
390
|
+
uint32_t mask_bits) {
|
391
|
+
auto* addr = reinterpret_cast<const grpc_sockaddr*>(address->addr);
|
392
|
+
auto* subnet_addr =
|
393
|
+
reinterpret_cast<const grpc_sockaddr*>(subnet_address->addr);
|
394
|
+
if (addr->sa_family != subnet_addr->sa_family) return false;
|
395
|
+
grpc_resolved_address masked_address;
|
396
|
+
memcpy(&masked_address, address, sizeof(grpc_resolved_address));
|
397
|
+
addr = reinterpret_cast<grpc_sockaddr*>((&masked_address)->addr);
|
398
|
+
grpc_sockaddr_mask_bits(&masked_address, mask_bits);
|
399
|
+
if (addr->sa_family == GRPC_AF_INET) {
|
400
|
+
auto* addr4 = reinterpret_cast<const grpc_sockaddr_in*>(addr);
|
401
|
+
auto* subnet_addr4 = reinterpret_cast<const grpc_sockaddr_in*>(subnet_addr);
|
402
|
+
if (memcmp(&addr4->sin_addr, &subnet_addr4->sin_addr,
|
403
|
+
sizeof(addr4->sin_addr)) == 0) {
|
404
|
+
return true;
|
405
|
+
}
|
406
|
+
} else if (addr->sa_family == GRPC_AF_INET6) {
|
407
|
+
auto* addr6 = reinterpret_cast<const grpc_sockaddr_in6*>(addr);
|
408
|
+
auto* subnet_addr6 =
|
409
|
+
reinterpret_cast<const grpc_sockaddr_in6*>(subnet_addr);
|
410
|
+
if (memcmp(&addr6->sin6_addr, &subnet_addr6->sin6_addr,
|
411
|
+
sizeof(addr6->sin6_addr)) == 0) {
|
412
|
+
return true;
|
413
|
+
}
|
414
|
+
}
|
415
|
+
return false;
|
416
|
+
}
|
@@ -66,9 +66,16 @@ int grpc_sockaddr_set_port(grpc_resolved_address* addr, int port);
|
|
66
66
|
std::string grpc_sockaddr_to_string(const grpc_resolved_address* addr,
|
67
67
|
bool normalize);
|
68
68
|
|
69
|
+
// TODO(yashykt): Remove this function and replace usages with
|
70
|
+
// `grpc_string_to_sockaddr_new`
|
69
71
|
void grpc_string_to_sockaddr(grpc_resolved_address* out, const char* addr,
|
70
72
|
int port);
|
71
73
|
|
74
|
+
// Newer form of grpc_string_to_sockaddr which returns an error instead of
|
75
|
+
// crashing if \a addr is not IPv6/IPv6
|
76
|
+
grpc_error* grpc_string_to_sockaddr_new(grpc_resolved_address* out,
|
77
|
+
const char* addr, int port);
|
78
|
+
|
72
79
|
/* Returns the URI string corresponding to \a addr */
|
73
80
|
std::string grpc_sockaddr_to_uri(const grpc_resolved_address* addr);
|
74
81
|
|
@@ -77,4 +84,22 @@ const char* grpc_sockaddr_get_uri_scheme(const grpc_resolved_address* addr);
|
|
77
84
|
|
78
85
|
int grpc_sockaddr_get_family(const grpc_resolved_address* resolved_addr);
|
79
86
|
|
87
|
+
std::string grpc_sockaddr_get_packed_host(
|
88
|
+
const grpc_resolved_address* resolved_addr);
|
89
|
+
|
90
|
+
// Applies a mask of \a mask_bits to IPv4/IPv6 addresses. Has no effect if the
|
91
|
+
// address type is not IPv4/IPv6.
|
92
|
+
void grpc_sockaddr_mask_bits(grpc_resolved_address* address,
|
93
|
+
uint32_t mask_bits);
|
94
|
+
|
95
|
+
// If \a address is IPv4/IPv6, checks if the IP address falls in the CIDR
|
96
|
+
// specified by \a subnet_address and \a mask_bits.
|
97
|
+
// Returns false if \a address is not an IPv4/IPv6 address. The ports (if set)
|
98
|
+
// are ignored for matching purposes. Note that, \a subnet_address should be
|
99
|
+
// normalized, i.e., `grpc_sockaddr_mask_bits` should have been called on it if
|
100
|
+
// necessary.
|
101
|
+
bool grpc_sockaddr_match_subnet(const grpc_resolved_address* address,
|
102
|
+
const grpc_resolved_address* subnet_address,
|
103
|
+
uint32_t mask_bits);
|
104
|
+
|
80
105
|
#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_UTILS_H */
|
@@ -1673,10 +1673,7 @@ static bool tcp_can_track_err(grpc_endpoint* ep) {
|
|
1673
1673
|
if (getsockname(tcp->fd, &addr, &len) < 0) {
|
1674
1674
|
return false;
|
1675
1675
|
}
|
1676
|
-
|
1677
|
-
return true;
|
1678
|
-
}
|
1679
|
-
return false;
|
1676
|
+
return addr.sa_family == AF_INET || addr.sa_family == AF_INET6;
|
1680
1677
|
}
|
1681
1678
|
|
1682
1679
|
static const grpc_endpoint_vtable vtable = {tcp_read,
|
@@ -252,8 +252,8 @@ static void accept_new_connection(grpc_custom_socket* socket) {
|
|
252
252
|
uv_socket->accept_error = GRPC_ERROR_NONE;
|
253
253
|
uv_socket->pending_connections -= 1;
|
254
254
|
if (uv_socket->accept_error != GRPC_ERROR_NONE) {
|
255
|
-
uv_stream_t
|
256
|
-
uv_accept((uv_stream_t*)uv_socket->handle, &
|
255
|
+
uv_stream_t phony_handle;
|
256
|
+
uv_accept((uv_stream_t*)uv_socket->handle, &phony_handle);
|
257
257
|
uv_socket->accept_cb(socket, new_socket, error);
|
258
258
|
} else {
|
259
259
|
uv_socket_t* uv_new_socket = (uv_socket_t*)gpr_malloc(sizeof(uv_socket_t));
|
@@ -409,7 +409,7 @@ static void timer_init(grpc_timer* timer, grpc_millis deadline,
|
|
409
409
|
}
|
410
410
|
gpr_mu_unlock(&shard->mu);
|
411
411
|
|
412
|
-
/* Deadline may have decreased, we need to adjust the
|
412
|
+
/* Deadline may have decreased, we need to adjust the main queue. Note
|
413
413
|
that there is a potential racy unlocked region here. There could be a
|
414
414
|
reordering of multiple grpc_timer_init calls, at this point, but the < test
|
415
415
|
below should ensure that we err on the side of caution. There could
|
@@ -639,7 +639,7 @@ static grpc_timer_check_result run_some_expired_timers(grpc_millis now,
|
|
639
639
|
|
640
640
|
/* An grpc_timer_init() on the shard could intervene here, adding a new
|
641
641
|
timer that is earlier than new_min_deadline. However,
|
642
|
-
grpc_timer_init() will block on the
|
642
|
+
grpc_timer_init() will block on the mutex before it can call
|
643
643
|
set_min_deadline, so this one will complete first and then the Addtimer
|
644
644
|
will reduce the min_deadline (perhaps unnecessarily). */
|
645
645
|
g_shard_queue[0]->min_deadline = new_min_deadline;
|
@@ -133,7 +133,7 @@ static void run_some_timers() {
|
|
133
133
|
}
|
134
134
|
grpc_core::ExecCtx::Get()->Flush();
|
135
135
|
gpr_mu_lock(&g_mu);
|
136
|
-
// garbage collect any threads
|
136
|
+
// garbage collect any threads that are dead
|
137
137
|
gc_completed_threads();
|
138
138
|
// get ready to wait again
|
139
139
|
++g_waiter_count;
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
#include <grpc/support/port_platform.h>
|
16
16
|
|
17
|
-
#include "src/core/lib/
|
17
|
+
#include "src/core/lib/matchers/matchers.h"
|
18
18
|
|
19
19
|
#include "absl/memory/memory.h"
|
20
20
|
#include "absl/strings/str_cat.h"
|
@@ -29,12 +29,12 @@ namespace grpc_core {
|
|
29
29
|
//
|
30
30
|
|
31
31
|
absl::StatusOr<StringMatcher> StringMatcher::Create(Type type,
|
32
|
-
|
32
|
+
absl::string_view matcher,
|
33
33
|
bool case_sensitive) {
|
34
34
|
if (type == Type::SAFE_REGEX) {
|
35
35
|
RE2::Options options;
|
36
36
|
options.set_case_sensitive(case_sensitive);
|
37
|
-
auto regex_matcher = absl::make_unique<RE2>(matcher, options);
|
37
|
+
auto regex_matcher = absl::make_unique<RE2>(std::string(matcher), options);
|
38
38
|
if (!regex_matcher->ok()) {
|
39
39
|
return absl::InvalidArgumentError(
|
40
40
|
"Invalid regex string specified in matcher.");
|
@@ -45,7 +45,7 @@ absl::StatusOr<StringMatcher> StringMatcher::Create(Type type,
|
|
45
45
|
}
|
46
46
|
}
|
47
47
|
|
48
|
-
StringMatcher::StringMatcher(Type type,
|
48
|
+
StringMatcher::StringMatcher(Type type, absl::string_view matcher,
|
49
49
|
bool case_sensitive)
|
50
50
|
: type_(type), string_matcher_(matcher), case_sensitive_(case_sensitive) {}
|
51
51
|
|
@@ -164,7 +164,7 @@ std::string StringMatcher::ToString() const {
|
|
164
164
|
//
|
165
165
|
|
166
166
|
absl::StatusOr<HeaderMatcher> HeaderMatcher::Create(
|
167
|
-
|
167
|
+
absl::string_view name, Type type, absl::string_view matcher,
|
168
168
|
int64_t range_start, int64_t range_end, bool present_match,
|
169
169
|
bool invert_match) {
|
170
170
|
if (static_cast<int>(type) < 5) {
|
@@ -189,14 +189,14 @@ absl::StatusOr<HeaderMatcher> HeaderMatcher::Create(
|
|
189
189
|
}
|
190
190
|
}
|
191
191
|
|
192
|
-
HeaderMatcher::HeaderMatcher(
|
192
|
+
HeaderMatcher::HeaderMatcher(absl::string_view name, Type type,
|
193
193
|
StringMatcher string_matcher, bool invert_match)
|
194
194
|
: name_(name),
|
195
195
|
type_(type),
|
196
196
|
matcher_(std::move(string_matcher)),
|
197
197
|
invert_match_(invert_match) {}
|
198
198
|
|
199
|
-
HeaderMatcher::HeaderMatcher(
|
199
|
+
HeaderMatcher::HeaderMatcher(absl::string_view name, int64_t range_start,
|
200
200
|
int64_t range_end, bool invert_match)
|
201
201
|
: name_(name),
|
202
202
|
type_(Type::RANGE),
|
@@ -204,7 +204,7 @@ HeaderMatcher::HeaderMatcher(const std::string& name, int64_t range_start,
|
|
204
204
|
range_end_(range_end),
|
205
205
|
invert_match_(invert_match) {}
|
206
206
|
|
207
|
-
HeaderMatcher::HeaderMatcher(
|
207
|
+
HeaderMatcher::HeaderMatcher(absl::string_view name, bool present_match,
|
208
208
|
bool invert_match)
|
209
209
|
: name_(name),
|
210
210
|
type_(Type::PRESENT),
|