grpc 1.22.1 → 1.23.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 +487 -649
- data/include/grpc/grpc_security.h +25 -0
- data/include/grpc/impl/codegen/grpc_types.h +11 -2
- data/include/grpc/impl/codegen/port_platform.h +12 -0
- data/src/core/ext/filters/client_channel/backup_poller.cc +4 -2
- data/src/core/ext/filters/client_channel/client_channel.cc +477 -182
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +25 -16
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +11 -6
- data/src/core/ext/filters/client_channel/connector.h +10 -2
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +3 -3
- data/src/core/ext/filters/client_channel/http_proxy.cc +9 -10
- data/src/core/ext/filters/client_channel/lb_policy.cc +2 -17
- data/src/core/ext/filters/client_channel/lb_policy.h +36 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +22 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +86 -52
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +7 -0
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +73 -72
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +8 -12
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +25 -101
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +5 -5
- data/src/core/ext/filters/client_channel/parse_address.cc +29 -26
- data/src/core/ext/filters/client_channel/resolver.h +3 -11
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +5 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +405 -82
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +44 -51
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +0 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +0 -1
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +11 -6
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +130 -65
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +8 -3
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +31 -14
- data/src/core/ext/filters/client_channel/resolver_factory.h +4 -0
- data/src/core/ext/filters/client_channel/resolver_registry.cc +11 -0
- data/src/core/ext/filters/client_channel/resolver_registry.h +3 -0
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +10 -49
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +1 -14
- data/src/core/ext/filters/client_channel/retry_throttle.h +2 -3
- data/src/core/ext/filters/client_channel/subchannel.cc +65 -58
- data/src/core/ext/filters/client_channel/subchannel.h +65 -45
- data/src/core/ext/filters/client_channel/subchannel_interface.h +15 -30
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +264 -0
- data/src/core/ext/filters/http/client/http_client_filter.cc +4 -5
- data/src/core/ext/filters/http/client_authority_filter.cc +2 -2
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +140 -152
- data/src/core/ext/filters/max_age/max_age_filter.cc +3 -3
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +3 -4
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +7 -6
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +41 -60
- data/src/core/ext/transport/chttp2/transport/context_list.cc +3 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +0 -1
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +0 -8
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +0 -7
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +0 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +37 -22
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +137 -80
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +8 -0
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +7 -166
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +41 -15
- data/src/core/ext/transport/chttp2/transport/internal.h +6 -9
- data/src/core/ext/transport/chttp2/transport/parsing.cc +37 -20
- data/src/core/ext/transport/chttp2/transport/stream_map.cc +28 -18
- data/src/core/ext/transport/chttp2/transport/writing.cc +0 -1
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -1
- data/src/core/lib/channel/channelz.cc +80 -33
- data/src/core/lib/channel/channelz.h +28 -13
- data/src/core/lib/compression/compression.cc +1 -2
- data/src/core/lib/compression/compression_args.cc +13 -6
- data/src/core/lib/compression/compression_args.h +3 -2
- data/src/core/lib/compression/compression_internal.cc +1 -1
- data/src/core/lib/gpr/env_linux.cc +10 -21
- data/src/core/lib/gpr/env_posix.cc +0 -5
- data/src/core/lib/gpr/string.cc +7 -2
- data/src/core/lib/gpr/string.h +1 -0
- data/src/core/lib/gpr/sync_posix.cc +0 -129
- data/src/core/lib/gprpp/debug_location.h +3 -2
- data/src/core/lib/gprpp/fork.cc +14 -21
- data/src/core/lib/gprpp/fork.h +15 -4
- data/src/core/lib/gprpp/host_port.cc +118 -0
- data/src/core/lib/{gpr → gprpp}/host_port.h +27 -11
- data/src/core/lib/gprpp/map.h +25 -0
- data/src/core/lib/gprpp/memory.h +26 -9
- data/src/core/lib/gprpp/ref_counted.h +63 -21
- data/src/core/lib/gprpp/string_view.h +143 -0
- data/src/core/lib/gprpp/thd.h +10 -1
- data/src/core/lib/gprpp/thd_posix.cc +25 -0
- data/src/core/lib/gprpp/thd_windows.cc +9 -1
- data/src/core/lib/http/httpcli_security_connector.cc +3 -1
- data/src/core/lib/iomgr/cfstream_handle.cc +6 -1
- data/src/core/lib/iomgr/cfstream_handle.h +8 -2
- data/src/core/lib/iomgr/combiner.cc +4 -4
- data/src/core/lib/iomgr/error.cc +18 -8
- data/src/core/lib/iomgr/error.h +2 -0
- data/src/core/lib/iomgr/ev_posix.cc +4 -2
- data/src/core/lib/iomgr/executor.cc +4 -1
- data/src/core/lib/iomgr/executor/mpmcqueue.cc +183 -0
- data/src/core/lib/iomgr/executor/mpmcqueue.h +178 -0
- data/src/core/lib/iomgr/executor/threadpool.cc +138 -0
- data/src/core/lib/iomgr/executor/threadpool.h +153 -0
- data/src/core/lib/iomgr/fork_posix.cc +4 -2
- data/src/core/lib/iomgr/iocp_windows.cc +2 -2
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +14 -0
- data/src/core/lib/iomgr/iomgr_uv.cc +3 -0
- data/src/core/lib/iomgr/lockfree_event.cc +3 -3
- data/src/core/lib/iomgr/resolve_address_custom.cc +16 -20
- data/src/core/lib/iomgr/resolve_address_posix.cc +8 -10
- data/src/core/lib/iomgr/resolve_address_windows.cc +6 -8
- data/src/core/lib/iomgr/sockaddr_utils.cc +5 -3
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +0 -1
- data/src/core/lib/iomgr/socket_windows.h +1 -1
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +7 -6
- data/src/core/lib/iomgr/tcp_client_custom.cc +1 -0
- data/src/core/lib/iomgr/tcp_custom.cc +4 -0
- data/src/core/lib/iomgr/tcp_posix.cc +8 -2
- data/src/core/lib/iomgr/tcp_server_custom.cc +1 -0
- data/src/core/lib/iomgr/tcp_server_windows.cc +1 -1
- data/src/core/lib/iomgr/tcp_windows.cc +7 -7
- data/src/core/lib/iomgr/timer_custom.cc +1 -0
- data/src/core/lib/iomgr/timer_manager.cc +0 -29
- data/src/core/lib/security/credentials/credentials.cc +84 -0
- data/src/core/lib/security/credentials/credentials.h +58 -2
- data/src/core/lib/security/credentials/jwt/json_token.cc +6 -2
- data/src/core/lib/security/credentials/jwt/json_token.h +1 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +245 -24
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +16 -0
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +3 -2
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +21 -25
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +3 -2
- data/src/core/lib/security/security_connector/security_connector.cc +1 -1
- data/src/core/lib/security/security_connector/security_connector.h +1 -1
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +19 -19
- data/src/core/lib/security/security_connector/ssl_utils.cc +26 -31
- data/src/core/lib/security/security_connector/ssl_utils.h +11 -8
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +16 -20
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +4 -3
- data/src/core/lib/security/transport/client_auth_filter.cc +1 -2
- data/src/core/lib/security/util/json_util.cc +19 -5
- data/src/core/lib/security/util/json_util.h +3 -1
- data/src/core/lib/slice/slice.cc +69 -50
- data/src/core/lib/slice/slice_buffer.cc +6 -5
- data/src/core/lib/slice/slice_hash_table.h +3 -7
- data/src/core/lib/slice/slice_intern.cc +130 -39
- data/src/core/lib/slice/slice_internal.h +8 -0
- data/src/core/lib/slice/slice_utils.h +120 -0
- data/src/core/lib/slice/slice_weak_hash_table.h +2 -7
- data/src/core/lib/surface/call.cc +8 -3
- data/src/core/lib/surface/channel.cc +31 -8
- data/src/core/lib/surface/completion_queue.cc +17 -7
- data/src/core/lib/surface/init_secure.cc +4 -1
- data/src/core/lib/surface/lame_client.cc +2 -2
- data/src/core/lib/surface/server.cc +34 -35
- data/src/core/lib/surface/server.h +8 -17
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/byte_stream.cc +3 -5
- data/src/core/lib/transport/byte_stream.h +1 -2
- data/src/core/lib/transport/error_utils.cc +10 -1
- data/src/core/lib/transport/metadata.cc +202 -35
- data/src/core/lib/transport/metadata.h +81 -6
- data/src/core/lib/transport/static_metadata.cc +1257 -465
- data/src/core/lib/transport/static_metadata.h +190 -347
- data/src/core/lib/transport/timeout_encoding.cc +7 -0
- data/src/core/lib/transport/timeout_encoding.h +3 -2
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +0 -1
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +2 -7
- data/src/core/tsi/ssl_transport_security.cc +35 -43
- data/src/core/tsi/ssl_transport_security.h +2 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
- data/src/ruby/lib/grpc/generic/rpc_server.rb +1 -1
- data/src/ruby/lib/grpc/grpc.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- metadata +38 -32
- data/src/core/lib/gpr/host_port.cc +0 -98
@@ -30,6 +30,7 @@
|
|
30
30
|
#include "src/core/lib/gpr/murmur_hash.h"
|
31
31
|
#include "src/core/lib/gprpp/memory.h"
|
32
32
|
#include "src/core/lib/gprpp/ref_counted.h"
|
33
|
+
#include "src/core/lib/slice/slice_utils.h"
|
33
34
|
#include "src/core/lib/transport/static_metadata.h"
|
34
35
|
|
35
36
|
// Interned slices have specific fast-path operations for hashing. To inline
|
@@ -95,6 +96,8 @@ extern uint32_t g_hash_seed;
|
|
95
96
|
// In total, this saves us roughly 1-2% latency for unary calls, with smaller
|
96
97
|
// calls benefitting. The effect is present, but not as useful, for larger calls
|
97
98
|
// where the cost of sending the data dominates.
|
99
|
+
// TODO(arjunroy): Investigate if this can be removed with strongly typed
|
100
|
+
// grpc_slices.
|
98
101
|
struct grpc_slice_refcount {
|
99
102
|
public:
|
100
103
|
enum class Type {
|
@@ -171,6 +174,8 @@ struct grpc_slice_refcount {
|
|
171
174
|
|
172
175
|
namespace grpc_core {
|
173
176
|
|
177
|
+
extern grpc_slice_refcount kNoopRefcount;
|
178
|
+
|
174
179
|
struct InternedSliceRefcount {
|
175
180
|
static void Destroy(void* arg) {
|
176
181
|
auto* rc = static_cast<InternedSliceRefcount*>(arg);
|
@@ -312,4 +317,7 @@ grpc_slice grpc_slice_from_moved_string(grpc_core::UniquePtr<char> p);
|
|
312
317
|
// 0. All other slices will return the size of the allocated chars.
|
313
318
|
size_t grpc_slice_memory_usage(grpc_slice s);
|
314
319
|
|
320
|
+
grpc_core::UnmanagedMemorySlice grpc_slice_sub_no_ref(
|
321
|
+
const grpc_core::UnmanagedMemorySlice& source, size_t begin, size_t end);
|
322
|
+
|
315
323
|
#endif /* GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H */
|
@@ -21,6 +21,8 @@
|
|
21
21
|
|
22
22
|
#include <grpc/support/port_platform.h>
|
23
23
|
|
24
|
+
#include <cstring>
|
25
|
+
|
24
26
|
#include <grpc/slice.h>
|
25
27
|
|
26
28
|
// When we compare two slices, and we know the latter is not inlined, we can
|
@@ -36,6 +38,7 @@
|
|
36
38
|
// x86-64/clang with differs().
|
37
39
|
int grpc_slice_differs_refcounted(const grpc_slice& a,
|
38
40
|
const grpc_slice& b_not_inline);
|
41
|
+
|
39
42
|
// When we compare two slices, and we *know* that one of them is static or
|
40
43
|
// interned, we can short circuit our slice equality function. The second slice
|
41
44
|
// here must be static or interned; slice a can be any slice, inlined or not.
|
@@ -47,4 +50,121 @@ inline bool grpc_slice_eq_static_interned(const grpc_slice& a,
|
|
47
50
|
return !grpc_slice_differs_refcounted(a, b_static_interned);
|
48
51
|
}
|
49
52
|
|
53
|
+
// TODO(arjunroy): These type declarations ought to be in
|
54
|
+
// src/core/lib/slice/slice_internal.h instead; they are here due to a circular
|
55
|
+
// header depedency between slice_internal.h and
|
56
|
+
// src/core/lib/transport/metadata.h. We need to fix this circular reference and
|
57
|
+
// when we do, move these type declarations.
|
58
|
+
//
|
59
|
+
// Internal slice type declarations.
|
60
|
+
// Externally, a grpc_slice is a grpc_slice is a grpc_slice.
|
61
|
+
// Internally, we may have heap allocated slices, static slices, interned
|
62
|
+
// slices, and inlined slices. If we know the specific type of slice
|
63
|
+
// we're dealing with, we can save cycles (e.g. fast-paths when we know we don't
|
64
|
+
// need to take a reference on a slice). Rather than introducing new methods
|
65
|
+
// ad-hoc in these cases, we rely on type-system backed overloads to keep
|
66
|
+
// internal APIs clean.
|
67
|
+
//
|
68
|
+
// For each overload, the definition and layout of the underlying slice does not
|
69
|
+
// change; this is purely type-system information.
|
70
|
+
namespace grpc_core {
|
71
|
+
|
72
|
+
// There are two main types of slices: those that have their memory
|
73
|
+
// managed by the slice library and those that do not.
|
74
|
+
//
|
75
|
+
// The following types of slices are not managed:
|
76
|
+
// - inlined slices (i.e., refcount is null)
|
77
|
+
// - slices that have a custom refcount type (i.e., not STATIC or INTERNED)
|
78
|
+
// - slices where the memory is managed by some external agent. The slice is not
|
79
|
+
// ref-counted by grpc, and the programmer is responsible for ensuring the
|
80
|
+
// data is valid for the duration of the period that grpc may access it.
|
81
|
+
//
|
82
|
+
// The following types of slices are managed:
|
83
|
+
// - static metadata slices (i.e., refcount type is STATIC)
|
84
|
+
// - interned slices (i.e., refcount type is INTERNED)
|
85
|
+
//
|
86
|
+
// This categorization is reflected in the following hierarchy:
|
87
|
+
//
|
88
|
+
// - grpc_slice
|
89
|
+
// > - UnmanagedMemorySlice
|
90
|
+
// > - ExternallyManagedSlice
|
91
|
+
// - ManagedMemorySlice
|
92
|
+
// > - InternedSlice
|
93
|
+
// - StaticMetadataSlice
|
94
|
+
//
|
95
|
+
struct ManagedMemorySlice : public grpc_slice {
|
96
|
+
ManagedMemorySlice() {
|
97
|
+
refcount = nullptr;
|
98
|
+
data.refcounted.bytes = nullptr;
|
99
|
+
data.refcounted.length = 0;
|
100
|
+
}
|
101
|
+
explicit ManagedMemorySlice(const char* string);
|
102
|
+
ManagedMemorySlice(const char* buf, size_t len);
|
103
|
+
explicit ManagedMemorySlice(const grpc_slice* slice);
|
104
|
+
bool Equals(const grpc_slice& other) const {
|
105
|
+
if (refcount == other.refcount) {
|
106
|
+
return true;
|
107
|
+
}
|
108
|
+
return !grpc_slice_differs_refcounted(other, *this);
|
109
|
+
}
|
110
|
+
bool Equals(const char* buf, const size_t len) const {
|
111
|
+
return data.refcounted.length == len &&
|
112
|
+
memcmp(buf, data.refcounted.bytes, len) == 0;
|
113
|
+
}
|
114
|
+
};
|
115
|
+
struct UnmanagedMemorySlice : public grpc_slice {
|
116
|
+
// TODO(arjunroy): Can we use a default=false param instead of this enum?
|
117
|
+
enum class ForceHeapAllocation {};
|
118
|
+
UnmanagedMemorySlice() {
|
119
|
+
refcount = nullptr;
|
120
|
+
data.inlined.length = 0;
|
121
|
+
}
|
122
|
+
explicit UnmanagedMemorySlice(const char* source);
|
123
|
+
UnmanagedMemorySlice(const char* source, size_t length);
|
124
|
+
// The first constructor creates a slice that may be heap allocated, or
|
125
|
+
// inlined in the slice structure if length is small enough
|
126
|
+
// (< GRPC_SLICE_INLINED_SIZE). The second constructor forces heap alloc.
|
127
|
+
explicit UnmanagedMemorySlice(size_t length);
|
128
|
+
explicit UnmanagedMemorySlice(size_t length, const ForceHeapAllocation&) {
|
129
|
+
HeapInit(length);
|
130
|
+
}
|
131
|
+
|
132
|
+
private:
|
133
|
+
void HeapInit(size_t length);
|
134
|
+
};
|
135
|
+
|
136
|
+
extern grpc_slice_refcount kNoopRefcount;
|
137
|
+
|
138
|
+
struct ExternallyManagedSlice : public UnmanagedMemorySlice {
|
139
|
+
ExternallyManagedSlice()
|
140
|
+
: ExternallyManagedSlice(&kNoopRefcount, 0, nullptr) {}
|
141
|
+
explicit ExternallyManagedSlice(const char* s)
|
142
|
+
: ExternallyManagedSlice(s, strlen(s)) {}
|
143
|
+
ExternallyManagedSlice(const void* s, size_t len)
|
144
|
+
: ExternallyManagedSlice(
|
145
|
+
&kNoopRefcount, len,
|
146
|
+
reinterpret_cast<uint8_t*>(const_cast<void*>(s))) {}
|
147
|
+
ExternallyManagedSlice(grpc_slice_refcount* ref, size_t length,
|
148
|
+
uint8_t* bytes) {
|
149
|
+
refcount = ref;
|
150
|
+
data.refcounted.length = length;
|
151
|
+
data.refcounted.bytes = bytes;
|
152
|
+
}
|
153
|
+
};
|
154
|
+
|
155
|
+
struct StaticMetadataSlice : public ManagedMemorySlice {
|
156
|
+
StaticMetadataSlice(grpc_slice_refcount* ref, size_t length, uint8_t* bytes) {
|
157
|
+
refcount = ref;
|
158
|
+
data.refcounted.length = length;
|
159
|
+
data.refcounted.bytes = bytes;
|
160
|
+
}
|
161
|
+
};
|
162
|
+
|
163
|
+
struct InternedSliceRefcount;
|
164
|
+
struct InternedSlice : public ManagedMemorySlice {
|
165
|
+
explicit InternedSlice(InternedSliceRefcount* s);
|
166
|
+
};
|
167
|
+
|
168
|
+
} // namespace grpc_core
|
169
|
+
|
50
170
|
#endif /* GRPC_CORE_LIB_SLICE_SLICE_UTILS_H */
|
@@ -61,13 +61,8 @@ class SliceWeakHashTable : public RefCounted<SliceWeakHashTable<T, Size>> {
|
|
61
61
|
}
|
62
62
|
|
63
63
|
private:
|
64
|
-
|
65
|
-
|
66
|
-
friend T2* New(Args&&... args);
|
67
|
-
|
68
|
-
// So Delete() can call our private dtor.
|
69
|
-
template <typename T2>
|
70
|
-
friend void Delete(T2*);
|
64
|
+
GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW
|
65
|
+
GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE
|
71
66
|
|
72
67
|
SliceWeakHashTable() = default;
|
73
68
|
~SliceWeakHashTable() = default;
|
@@ -1568,6 +1568,10 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1568
1568
|
error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
|
1569
1569
|
goto done_with_error;
|
1570
1570
|
}
|
1571
|
+
// TODO(juanlishen): If the user has already specified a compression
|
1572
|
+
// algorithm by setting the initial metadata with key of
|
1573
|
+
// GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY, we shouldn't override that
|
1574
|
+
// with the compression algorithm mapped from compression level.
|
1571
1575
|
/* process compression level */
|
1572
1576
|
grpc_metadata& compression_md = call->compression_md;
|
1573
1577
|
compression_md.key = grpc_empty_slice();
|
@@ -1589,17 +1593,18 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1589
1593
|
effective_compression_level = copts.default_level.level;
|
1590
1594
|
}
|
1591
1595
|
}
|
1596
|
+
// Currently, only server side supports compression level setting.
|
1592
1597
|
if (level_set && !call->is_client) {
|
1593
1598
|
const grpc_compression_algorithm calgo =
|
1594
1599
|
compression_algorithm_for_level_locked(
|
1595
1600
|
call, effective_compression_level);
|
1596
|
-
|
1597
|
-
|
1601
|
+
// The following metadata will be checked and removed by the message
|
1602
|
+
// compression filter. It will be used as the call's compression
|
1603
|
+
// algorithm.
|
1598
1604
|
compression_md.key = GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST;
|
1599
1605
|
compression_md.value = grpc_compression_algorithm_slice(calgo);
|
1600
1606
|
additional_metadata_count++;
|
1601
1607
|
}
|
1602
|
-
|
1603
1608
|
if (op->data.send_initial_metadata.count + additional_metadata_count >
|
1604
1609
|
INT_MAX) {
|
1605
1610
|
error = GRPC_CALL_ERROR_INVALID_METADATA;
|
@@ -235,6 +235,23 @@ grpc_channel* grpc_channel_create(const char* target,
|
|
235
235
|
grpc_channel_stack_type channel_stack_type,
|
236
236
|
grpc_transport* optional_transport,
|
237
237
|
grpc_resource_user* resource_user) {
|
238
|
+
// We need to make sure that grpc_shutdown() does not shut things down
|
239
|
+
// until after the channel is destroyed. However, the channel may not
|
240
|
+
// actually be destroyed by the time grpc_channel_destroy() returns,
|
241
|
+
// since there may be other existing refs to the channel. If those
|
242
|
+
// refs are held by things that are visible to the wrapped language
|
243
|
+
// (such as outstanding calls on the channel), then the wrapped
|
244
|
+
// language can be responsible for making sure that grpc_shutdown()
|
245
|
+
// does not run until after those refs are released. However, the
|
246
|
+
// channel may also have refs to itself held internally for various
|
247
|
+
// things that need to be cleaned up at channel destruction (e.g.,
|
248
|
+
// LB policies, subchannels, etc), and because these refs are not
|
249
|
+
// visible to the wrapped language, it cannot be responsible for
|
250
|
+
// deferring grpc_shutdown() until after they are released. To
|
251
|
+
// accommodate that, we call grpc_init() here and then call
|
252
|
+
// grpc_shutdown() when the channel is actually destroyed, thus
|
253
|
+
// ensuring that shutdown is deferred until that point.
|
254
|
+
grpc_init();
|
238
255
|
grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create();
|
239
256
|
const grpc_core::UniquePtr<char> default_authority =
|
240
257
|
get_default_authority(input_args);
|
@@ -250,6 +267,7 @@ grpc_channel* grpc_channel_create(const char* target,
|
|
250
267
|
if (resource_user != nullptr) {
|
251
268
|
grpc_resource_user_free(resource_user, GRPC_RESOURCE_QUOTA_CHANNEL_SIZE);
|
252
269
|
}
|
270
|
+
grpc_shutdown(); // Since we won't call destroy_channel().
|
253
271
|
return nullptr;
|
254
272
|
}
|
255
273
|
// We only need to do this for clients here. For servers, this will be
|
@@ -257,7 +275,12 @@ grpc_channel* grpc_channel_create(const char* target,
|
|
257
275
|
if (grpc_channel_stack_type_is_client(channel_stack_type)) {
|
258
276
|
CreateChannelzNode(builder);
|
259
277
|
}
|
260
|
-
|
278
|
+
grpc_channel* channel =
|
279
|
+
grpc_channel_create_with_builder(builder, channel_stack_type);
|
280
|
+
if (channel == nullptr) {
|
281
|
+
grpc_shutdown(); // Since we won't call destroy_channel().
|
282
|
+
}
|
283
|
+
return channel;
|
261
284
|
}
|
262
285
|
|
263
286
|
size_t grpc_channel_get_call_size_estimate(grpc_channel* channel) {
|
@@ -393,13 +416,11 @@ void* grpc_channel_register_call(grpc_channel* channel, const char* method,
|
|
393
416
|
GPR_ASSERT(!reserved);
|
394
417
|
grpc_core::ExecCtx exec_ctx;
|
395
418
|
|
396
|
-
rc->path = grpc_mdelem_from_slices(
|
397
|
-
|
398
|
-
grpc_slice_intern(grpc_slice_from_static_string(method)));
|
419
|
+
rc->path = grpc_mdelem_from_slices(GRPC_MDSTR_PATH,
|
420
|
+
grpc_core::ManagedMemorySlice(method));
|
399
421
|
rc->authority =
|
400
|
-
host ? grpc_mdelem_from_slices(
|
401
|
-
|
402
|
-
grpc_slice_intern(grpc_slice_from_static_string(host)))
|
422
|
+
host ? grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY,
|
423
|
+
grpc_core::ManagedMemorySlice(host))
|
403
424
|
: GRPC_MDNULL;
|
404
425
|
gpr_mu_lock(&channel->registered_call_mu);
|
405
426
|
rc->next = channel->registered_calls;
|
@@ -468,6 +489,8 @@ static void destroy_channel(void* arg, grpc_error* error) {
|
|
468
489
|
gpr_mu_destroy(&channel->registered_call_mu);
|
469
490
|
gpr_free(channel->target);
|
470
491
|
gpr_free(channel);
|
492
|
+
// See comment in grpc_channel_create() for why we do this.
|
493
|
+
grpc_shutdown();
|
471
494
|
}
|
472
495
|
|
473
496
|
void grpc_channel_destroy(grpc_channel* channel) {
|
@@ -488,5 +511,5 @@ grpc_mdelem grpc_channel_get_reffed_status_elem_slowpath(grpc_channel* channel,
|
|
488
511
|
char tmp[GPR_LTOA_MIN_BUFSIZE];
|
489
512
|
gpr_ltoa(i, tmp);
|
490
513
|
return grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_STATUS,
|
491
|
-
|
514
|
+
grpc_core::UnmanagedMemorySlice(tmp));
|
492
515
|
}
|
@@ -857,17 +857,20 @@ static void cq_end_op_for_callback(
|
|
857
857
|
}
|
858
858
|
|
859
859
|
auto* functor = static_cast<grpc_experimental_completion_queue_functor*>(tag);
|
860
|
-
if (internal) {
|
860
|
+
if (internal || grpc_iomgr_is_any_background_poller_thread()) {
|
861
861
|
grpc_core::ApplicationCallbackExecCtx::Enqueue(functor,
|
862
862
|
(error == GRPC_ERROR_NONE));
|
863
863
|
GRPC_ERROR_UNREF(error);
|
864
|
-
|
865
|
-
GRPC_CLOSURE_SCHED(
|
866
|
-
GRPC_CLOSURE_CREATE(
|
867
|
-
functor_callback, functor,
|
868
|
-
grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)),
|
869
|
-
error);
|
864
|
+
return;
|
870
865
|
}
|
866
|
+
|
867
|
+
// Schedule the callback on a closure if not internal or triggered
|
868
|
+
// from a background poller thread.
|
869
|
+
GRPC_CLOSURE_SCHED(
|
870
|
+
GRPC_CLOSURE_CREATE(
|
871
|
+
functor_callback, functor,
|
872
|
+
grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)),
|
873
|
+
error);
|
871
874
|
}
|
872
875
|
|
873
876
|
void grpc_cq_end_op(grpc_completion_queue* cq, void* tag, grpc_error* error,
|
@@ -1352,6 +1355,13 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) {
|
|
1352
1355
|
GPR_ASSERT(cqd->shutdown_called);
|
1353
1356
|
|
1354
1357
|
cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done);
|
1358
|
+
if (grpc_iomgr_is_any_background_poller_thread()) {
|
1359
|
+
grpc_core::ApplicationCallbackExecCtx::Enqueue(callback, true);
|
1360
|
+
return;
|
1361
|
+
}
|
1362
|
+
|
1363
|
+
// Schedule the callback on a closure if not internal or triggered
|
1364
|
+
// from a background poller thread.
|
1355
1365
|
GRPC_CLOSURE_SCHED(
|
1356
1366
|
GRPC_CLOSURE_CREATE(
|
1357
1367
|
functor_callback, callback,
|
@@ -78,4 +78,7 @@ void grpc_register_security_filters(void) {
|
|
78
78
|
maybe_prepend_server_auth_filter, nullptr);
|
79
79
|
}
|
80
80
|
|
81
|
-
void grpc_security_init() {
|
81
|
+
void grpc_security_init() {
|
82
|
+
grpc_core::SecurityRegisterHandshakerFactories();
|
83
|
+
grpc_control_plane_credentials_init();
|
84
|
+
}
|
@@ -61,10 +61,10 @@ static void fill_metadata(grpc_call_element* elem, grpc_metadata_batch* mdb) {
|
|
61
61
|
char tmp[GPR_LTOA_MIN_BUFSIZE];
|
62
62
|
gpr_ltoa(chand->error_code, tmp);
|
63
63
|
calld->status.md = grpc_mdelem_from_slices(
|
64
|
-
GRPC_MDSTR_GRPC_STATUS,
|
64
|
+
GRPC_MDSTR_GRPC_STATUS, grpc_core::UnmanagedMemorySlice(tmp));
|
65
65
|
calld->details.md = grpc_mdelem_from_slices(
|
66
66
|
GRPC_MDSTR_GRPC_MESSAGE,
|
67
|
-
|
67
|
+
grpc_core::UnmanagedMemorySlice(chand->error_message));
|
68
68
|
calld->status.prev = calld->details.next = nullptr;
|
69
69
|
calld->status.next = &calld->details;
|
70
70
|
calld->details.prev = &calld->status;
|
@@ -31,6 +31,7 @@
|
|
31
31
|
#include <utility>
|
32
32
|
|
33
33
|
#include "src/core/lib/channel/channel_args.h"
|
34
|
+
#include "src/core/lib/channel/channelz.h"
|
34
35
|
#include "src/core/lib/channel/connected_channel.h"
|
35
36
|
#include "src/core/lib/debug/stats.h"
|
36
37
|
#include "src/core/lib/gpr/mpscq.h"
|
@@ -111,7 +112,7 @@ struct channel_data {
|
|
111
112
|
uint32_t registered_method_max_probes;
|
112
113
|
grpc_closure finish_destroy_channel_closure;
|
113
114
|
grpc_closure channel_connectivity_changed;
|
114
|
-
|
115
|
+
intptr_t channelz_socket_uuid;
|
115
116
|
};
|
116
117
|
|
117
118
|
typedef struct shutdown_tag {
|
@@ -710,8 +711,10 @@ static void maybe_finish_shutdown(grpc_server* server) {
|
|
710
711
|
return;
|
711
712
|
}
|
712
713
|
|
714
|
+
gpr_mu_lock(&server->mu_call);
|
713
715
|
kill_pending_work_locked(
|
714
716
|
server, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
|
717
|
+
gpr_mu_unlock(&server->mu_call);
|
715
718
|
|
716
719
|
if (server->root_channel_data.next != &server->root_channel_data ||
|
717
720
|
server->listeners_destroyed < num_listeners(server)) {
|
@@ -941,7 +944,6 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem,
|
|
941
944
|
static void destroy_channel_elem(grpc_channel_element* elem) {
|
942
945
|
size_t i;
|
943
946
|
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
944
|
-
chand->socket_node.reset();
|
945
947
|
if (chand->registered_methods) {
|
946
948
|
for (i = 0; i < chand->registered_method_slots; i++) {
|
947
949
|
grpc_slice_unref_internal(chand->registered_methods[i].method);
|
@@ -952,6 +954,11 @@ static void destroy_channel_elem(grpc_channel_element* elem) {
|
|
952
954
|
gpr_free(chand->registered_methods);
|
953
955
|
}
|
954
956
|
if (chand->server) {
|
957
|
+
if (chand->server->channelz_server != nullptr &&
|
958
|
+
chand->channelz_socket_uuid != 0) {
|
959
|
+
chand->server->channelz_server->RemoveChildSocket(
|
960
|
+
chand->channelz_socket_uuid);
|
961
|
+
}
|
955
962
|
gpr_mu_lock(&chand->server->mu_global);
|
956
963
|
chand->next->prev = chand->prev;
|
957
964
|
chand->prev->next = chand->next;
|
@@ -1144,7 +1151,8 @@ void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets,
|
|
1144
1151
|
void grpc_server_setup_transport(
|
1145
1152
|
grpc_server* s, grpc_transport* transport, grpc_pollset* accepting_pollset,
|
1146
1153
|
const grpc_channel_args* args,
|
1147
|
-
grpc_core::RefCountedPtr<grpc_core::channelz::SocketNode
|
1154
|
+
const grpc_core::RefCountedPtr<grpc_core::channelz::SocketNode>&
|
1155
|
+
socket_node,
|
1148
1156
|
grpc_resource_user* resource_user) {
|
1149
1157
|
size_t num_registered_methods;
|
1150
1158
|
size_t alloc;
|
@@ -1166,7 +1174,12 @@ void grpc_server_setup_transport(
|
|
1166
1174
|
chand->server = s;
|
1167
1175
|
server_ref(s);
|
1168
1176
|
chand->channel = channel;
|
1169
|
-
|
1177
|
+
if (socket_node != nullptr) {
|
1178
|
+
chand->channelz_socket_uuid = socket_node->uuid();
|
1179
|
+
s->channelz_server->AddChildSocket(socket_node);
|
1180
|
+
} else {
|
1181
|
+
chand->channelz_socket_uuid = 0;
|
1182
|
+
}
|
1170
1183
|
|
1171
1184
|
size_t cq_idx;
|
1172
1185
|
for (cq_idx = 0; cq_idx < s->cq_count; cq_idx++) {
|
@@ -1241,28 +1254,6 @@ void grpc_server_setup_transport(
|
|
1241
1254
|
grpc_transport_perform_op(transport, op);
|
1242
1255
|
}
|
1243
1256
|
|
1244
|
-
void grpc_server_populate_server_sockets(
|
1245
|
-
grpc_server* s, grpc_core::channelz::ChildSocketsList* server_sockets,
|
1246
|
-
intptr_t start_idx) {
|
1247
|
-
gpr_mu_lock(&s->mu_global);
|
1248
|
-
channel_data* c = nullptr;
|
1249
|
-
for (c = s->root_channel_data.next; c != &s->root_channel_data; c = c->next) {
|
1250
|
-
if (c->socket_node != nullptr && c->socket_node->uuid() >= start_idx) {
|
1251
|
-
server_sockets->push_back(c->socket_node.get());
|
1252
|
-
}
|
1253
|
-
}
|
1254
|
-
gpr_mu_unlock(&s->mu_global);
|
1255
|
-
}
|
1256
|
-
|
1257
|
-
void grpc_server_populate_listen_sockets(
|
1258
|
-
grpc_server* server, grpc_core::channelz::ChildRefsList* listen_sockets) {
|
1259
|
-
gpr_mu_lock(&server->mu_global);
|
1260
|
-
for (listener* l = server->listeners; l != nullptr; l = l->next) {
|
1261
|
-
listen_sockets->push_back(l->socket_uuid);
|
1262
|
-
}
|
1263
|
-
gpr_mu_unlock(&server->mu_global);
|
1264
|
-
}
|
1265
|
-
|
1266
1257
|
void done_published_shutdown(void* done_arg, grpc_cq_completion* storage) {
|
1267
1258
|
(void)done_arg;
|
1268
1259
|
gpr_free(storage);
|
@@ -1350,6 +1341,9 @@ void grpc_server_shutdown_and_notify(grpc_server* server,
|
|
1350
1341
|
GRPC_CLOSURE_INIT(&l->destroy_done, listener_destroy_done, server,
|
1351
1342
|
grpc_schedule_on_exec_ctx);
|
1352
1343
|
l->destroy(server, l->arg, &l->destroy_done);
|
1344
|
+
if (server->channelz_server != nullptr && l->socket_uuid != 0) {
|
1345
|
+
server->channelz_server->RemoveChildListenSocket(l->socket_uuid);
|
1346
|
+
}
|
1353
1347
|
}
|
1354
1348
|
|
1355
1349
|
channel_broadcaster_shutdown(&broadcaster, true /* send_goaway */,
|
@@ -1401,18 +1395,23 @@ void grpc_server_destroy(grpc_server* server) {
|
|
1401
1395
|
server_unref(server);
|
1402
1396
|
}
|
1403
1397
|
|
1404
|
-
void grpc_server_add_listener(
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
intptr_t socket_uuid) {
|
1398
|
+
void grpc_server_add_listener(
|
1399
|
+
grpc_server* server, void* listener_arg,
|
1400
|
+
void (*start)(grpc_server* server, void* arg, grpc_pollset** pollsets,
|
1401
|
+
size_t pollset_count),
|
1402
|
+
void (*destroy)(grpc_server* server, void* arg, grpc_closure* on_done),
|
1403
|
+
grpc_core::RefCountedPtr<grpc_core::channelz::ListenSocketNode> node) {
|
1411
1404
|
listener* l = static_cast<listener*>(gpr_malloc(sizeof(listener)));
|
1412
|
-
l->arg =
|
1405
|
+
l->arg = listener_arg;
|
1413
1406
|
l->start = start;
|
1414
1407
|
l->destroy = destroy;
|
1415
|
-
l->socket_uuid =
|
1408
|
+
l->socket_uuid = 0;
|
1409
|
+
if (node != nullptr) {
|
1410
|
+
l->socket_uuid = node->uuid();
|
1411
|
+
if (server->channelz_server != nullptr) {
|
1412
|
+
server->channelz_server->AddChildListenSocket(std::move(node));
|
1413
|
+
}
|
1414
|
+
}
|
1416
1415
|
l->next = server->listeners;
|
1417
1416
|
server->listeners = l;
|
1418
1417
|
}
|