grpc 1.20.0 → 1.21.0
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 +500 -29
- data/etc/roots.pem +146 -0
- data/include/grpc/grpc_security.h +1 -1
- data/include/grpc/impl/codegen/grpc_types.h +10 -7
- data/include/grpc/impl/codegen/port_platform.h +11 -1
- data/include/grpc/impl/codegen/slice.h +1 -21
- data/include/grpc/impl/codegen/status.h +2 -1
- data/include/grpc/slice.h +1 -1
- data/src/core/ext/filters/client_channel/backup_poller.cc +19 -13
- data/src/core/ext/filters/client_channel/backup_poller.h +3 -0
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +1 -1
- data/src/core/ext/filters/client_channel/client_channel.cc +2084 -1673
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +2 -3
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +4 -0
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +54 -49
- data/src/core/ext/filters/client_channel/health/health_check_client.h +20 -9
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -2
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy.cc +3 -30
- data/src/core/ext/filters/client_channel/lb_policy.h +16 -25
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +106 -81
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +6 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +8 -12
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +2 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +57 -49
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +47 -41
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +24 -20
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +989 -284
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +4 -1
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +105 -2
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +9 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +79 -36
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +84 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +3 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +179 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +15 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +80 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +7 -13
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +39 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +0 -6
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +2 -64
- data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc +28 -0
- data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h +29 -0
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +4 -4
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +367 -232
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +55 -76
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +50 -39
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +18 -12
- data/src/core/ext/filters/client_channel/service_config.cc +247 -27
- data/src/core/ext/filters/client_channel/service_config.h +119 -166
- data/src/core/ext/filters/client_channel/subchannel.cc +46 -84
- data/src/core/ext/filters/client_channel/subchannel.h +7 -7
- data/src/core/ext/filters/deadline/deadline_filter.cc +3 -4
- data/src/core/ext/filters/deadline/deadline_filter.h +3 -2
- data/src/core/ext/filters/http/client/http_client_filter.cc +7 -5
- data/src/core/ext/filters/http/client/http_client_filter.h +1 -1
- data/src/core/ext/filters/http/client_authority_filter.cc +1 -1
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +4 -3
- data/src/core/ext/filters/http/server/http_server_filter.cc +18 -12
- data/src/core/ext/filters/message_size/message_size_filter.cc +118 -76
- data/src/core/ext/filters/message_size/message_size_filter.h +33 -0
- data/src/core/ext/transport/chttp2/alpn/alpn.h +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +9 -7
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +93 -60
- data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +4 -3
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +3 -3
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +8 -2
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +3 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +35 -23
- data/src/core/ext/transport/chttp2/transport/parsing.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +3 -3
- data/src/core/ext/transport/chttp2/transport/writing.cc +61 -27
- data/src/core/ext/transport/inproc/inproc_transport.cc +18 -18
- data/src/core/lib/channel/channel_args.cc +0 -101
- data/src/core/lib/channel/channel_args.h +0 -37
- data/src/core/lib/channel/channel_stack.h +9 -5
- data/src/core/lib/channel/channelz_registry.cc +1 -1
- data/src/core/lib/channel/connected_channel.cc +2 -2
- data/src/core/lib/channel/context.h +3 -0
- data/src/core/lib/channel/handshaker.cc +4 -4
- data/src/core/lib/channel/handshaker.h +1 -1
- data/src/core/lib/compression/compression_args.cc +127 -0
- data/src/core/lib/compression/compression_args.h +55 -0
- data/src/core/lib/debug/trace.cc +13 -7
- data/src/core/lib/debug/trace.h +12 -0
- data/src/core/lib/gpr/arena.h +13 -9
- data/src/core/lib/gpr/env.h +2 -5
- data/src/core/lib/gpr/env_linux.cc +6 -1
- data/src/core/lib/gpr/env_posix.cc +5 -0
- data/src/core/lib/gpr/env_windows.cc +7 -5
- data/src/core/lib/gpr/log.cc +9 -13
- data/src/core/lib/gpr/string.cc +12 -6
- data/src/core/lib/gpr/string.h +4 -2
- data/src/core/lib/gpr/time_posix.cc +13 -0
- data/src/core/lib/gprpp/arena.cc +103 -0
- data/src/core/lib/gprpp/arena.h +121 -0
- data/src/core/lib/gprpp/fork.cc +12 -29
- data/src/core/lib/gprpp/global_config.h +87 -0
- data/src/core/lib/gprpp/global_config_custom.h +29 -0
- data/src/core/lib/gprpp/global_config_env.cc +135 -0
- data/src/core/lib/gprpp/global_config_env.h +131 -0
- data/src/core/lib/gprpp/global_config_generic.h +44 -0
- data/src/core/lib/gprpp/map.h +419 -0
- data/src/core/lib/gprpp/optional.h +1 -0
- data/src/core/lib/gprpp/orphanable.h +2 -2
- data/src/core/lib/gprpp/{mutex_lock.h → pair.h} +15 -19
- data/src/core/lib/gprpp/ref_counted.h +18 -2
- data/src/core/lib/gprpp/sync.h +126 -0
- data/src/core/lib/http/parser.cc +1 -1
- data/src/core/lib/iomgr/call_combiner.cc +84 -90
- data/src/core/lib/iomgr/call_combiner.h +75 -82
- data/src/core/lib/iomgr/cfstream_handle.cc +202 -0
- data/src/core/lib/iomgr/cfstream_handle.h +82 -0
- data/src/core/lib/iomgr/combiner.h +1 -1
- data/src/core/lib/iomgr/endpoint_cfstream.cc +375 -0
- data/src/core/lib/iomgr/endpoint_cfstream.h +49 -0
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
- data/src/core/lib/iomgr/error.h +23 -0
- data/src/core/lib/iomgr/error_cfstream.cc +52 -0
- data/src/core/lib/iomgr/error_cfstream.h +31 -0
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +34 -27
- data/src/core/lib/iomgr/ev_epollex_linux.cc +33 -33
- data/src/core/lib/iomgr/ev_poll_posix.cc +7 -7
- data/src/core/lib/iomgr/ev_posix.cc +15 -13
- data/src/core/lib/iomgr/ev_posix.h +4 -1
- data/src/core/lib/iomgr/executor.cc +13 -9
- data/src/core/lib/iomgr/fork_posix.cc +0 -1
- data/src/core/lib/iomgr/internal_errqueue.cc +1 -1
- data/src/core/lib/iomgr/iomgr.cc +6 -5
- data/src/core/lib/iomgr/iomgr_custom.cc +3 -0
- data/src/core/lib/iomgr/iomgr_custom.h +2 -0
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +93 -0
- data/src/core/lib/iomgr/iomgr_windows.cc +1 -0
- data/src/core/lib/iomgr/lockfree_event.cc +3 -3
- data/src/core/lib/iomgr/port.h +11 -0
- data/src/core/lib/iomgr/resource_quota.cc +40 -37
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +6 -2
- data/src/core/lib/iomgr/socket_windows.cc +19 -0
- data/src/core/lib/iomgr/socket_windows.h +8 -0
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +216 -0
- data/src/core/lib/iomgr/tcp_client_custom.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +3 -3
- data/src/core/lib/iomgr/tcp_client_windows.cc +1 -1
- data/src/core/lib/iomgr/tcp_custom.cc +9 -9
- data/src/core/lib/iomgr/tcp_posix.cc +41 -41
- data/src/core/lib/iomgr/tcp_server_custom.cc +3 -3
- data/src/core/lib/iomgr/tcp_server_posix.cc +14 -1
- data/src/core/lib/iomgr/tcp_server_windows.cc +2 -2
- data/src/core/lib/iomgr/tcp_windows.cc +7 -9
- data/src/core/lib/iomgr/timer_generic.cc +16 -16
- data/src/core/lib/iomgr/timer_manager.cc +12 -11
- data/src/core/lib/profiling/basic_timers.cc +10 -4
- data/src/core/lib/security/context/security_context.cc +6 -7
- data/src/core/lib/security/context/security_context.h +3 -4
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +2 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -1
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +7 -7
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +7 -5
- data/src/core/lib/security/security_connector/security_connector.cc +0 -1
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +3 -2
- data/src/core/lib/security/security_connector/ssl_utils.cc +30 -26
- data/src/core/lib/security/security_connector/ssl_utils.h +5 -1
- data/src/core/lib/security/transport/client_auth_filter.cc +7 -11
- data/src/core/lib/security/transport/secure_endpoint.cc +4 -4
- data/src/core/lib/security/transport/server_auth_filter.cc +2 -3
- data/src/core/lib/slice/slice.cc +99 -116
- data/src/core/lib/slice/slice_buffer.cc +5 -0
- data/src/core/lib/slice/slice_intern.cc +38 -95
- data/src/core/lib/slice/slice_internal.h +200 -2
- data/src/core/lib/surface/api_trace.h +1 -1
- data/src/core/lib/surface/call.cc +41 -35
- data/src/core/lib/surface/call.h +7 -2
- data/src/core/lib/surface/call_details.cc +0 -1
- data/src/core/lib/surface/completion_queue.cc +36 -27
- data/src/core/lib/surface/init.cc +3 -4
- data/src/core/lib/surface/lame_client.cc +1 -1
- data/src/core/lib/surface/server.cc +18 -25
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/bdp_estimator.cc +3 -3
- data/src/core/lib/transport/bdp_estimator.h +2 -2
- data/src/core/lib/transport/connectivity_state.cc +10 -40
- data/src/core/lib/transport/connectivity_state.h +0 -8
- data/src/core/lib/transport/error_utils.cc +12 -0
- data/src/core/lib/transport/metadata.cc +206 -278
- data/src/core/lib/transport/metadata.h +205 -10
- data/src/core/lib/transport/static_metadata.cc +108 -116
- data/src/core/lib/transport/static_metadata.h +1 -2
- data/src/core/lib/transport/status_metadata.cc +3 -3
- data/src/core/lib/transport/transport.cc +29 -66
- data/src/core/lib/transport/transport.h +36 -8
- data/src/core/lib/transport/transport_impl.h +1 -1
- data/src/core/tsi/fake_transport_security.cc +4 -4
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +1 -1
- data/src/core/tsi/ssl_transport_security.cc +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +1 -1
- data/src/ruby/lib/grpc/errors.rb +22 -3
- data/src/ruby/lib/grpc/generic/bidi_call.rb +1 -1
- data/src/ruby/lib/grpc/generic/rpc_server.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/errors_spec.rb +141 -0
- metadata +57 -33
- data/src/core/lib/gpr/arena.cc +0 -192
@@ -256,12 +256,11 @@ extern const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT];
|
|
256
256
|
#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \
|
257
257
|
(grpc_static_slice_table[106])
|
258
258
|
|
259
|
-
extern const grpc_slice_refcount_vtable grpc_static_metadata_vtable;
|
260
259
|
extern grpc_slice_refcount
|
261
260
|
grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT];
|
262
261
|
#define GRPC_IS_STATIC_METADATA_STRING(slice) \
|
263
262
|
((slice).refcount != NULL && \
|
264
|
-
(slice).refcount->
|
263
|
+
(slice).refcount->GetType() == grpc_slice_refcount::Type::STATIC)
|
265
264
|
|
266
265
|
#define GRPC_STATIC_METADATA_INDEX(static_slice) \
|
267
266
|
((int)((static_slice).refcount - grpc_static_metadata_refcounts))
|
@@ -31,13 +31,13 @@
|
|
31
31
|
static void destroy_status(void* ignored) {}
|
32
32
|
|
33
33
|
grpc_status_code grpc_get_status_code_from_metadata(grpc_mdelem md) {
|
34
|
-
if (
|
34
|
+
if (grpc_mdelem_static_value_eq(md, GRPC_MDELEM_GRPC_STATUS_0)) {
|
35
35
|
return GRPC_STATUS_OK;
|
36
36
|
}
|
37
|
-
if (
|
37
|
+
if (grpc_mdelem_static_value_eq(md, GRPC_MDELEM_GRPC_STATUS_1)) {
|
38
38
|
return GRPC_STATUS_CANCELLED;
|
39
39
|
}
|
40
|
-
if (
|
40
|
+
if (grpc_mdelem_static_value_eq(md, GRPC_MDELEM_GRPC_STATUS_2)) {
|
41
41
|
return GRPC_STATUS_UNKNOWN;
|
42
42
|
}
|
43
43
|
void* user_data = grpc_mdelem_get_user_data(md, destroy_status);
|
@@ -39,72 +39,39 @@
|
|
39
39
|
grpc_core::DebugOnlyTraceFlag grpc_trace_stream_refcount(false,
|
40
40
|
"stream_refcount");
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
42
|
+
void grpc_stream_destroy(grpc_stream_refcount* refcount) {
|
43
|
+
if (!grpc_iomgr_is_any_background_poller_thread() &&
|
44
|
+
(grpc_core::ExecCtx::Get()->flags() &
|
45
|
+
GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP)) {
|
46
|
+
/* Ick.
|
47
|
+
The thread we're running on MAY be owned (indirectly) by a call-stack.
|
48
|
+
If that's the case, destroying the call-stack MAY try to destroy the
|
49
|
+
thread, which is a tangled mess that we just don't want to ever have to
|
50
|
+
cope with.
|
51
|
+
Throw this over to the executor (on a core-owned thread) and process it
|
52
|
+
there. */
|
53
|
+
refcount->destroy.scheduler =
|
54
|
+
grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT);
|
49
55
|
}
|
50
|
-
|
51
|
-
void grpc_stream_ref(grpc_stream_refcount* refcount) {
|
52
|
-
#endif
|
53
|
-
gpr_ref_non_zero(&refcount->refs);
|
56
|
+
GRPC_CLOSURE_SCHED(&refcount->destroy, GRPC_ERROR_NONE);
|
54
57
|
}
|
55
58
|
|
56
|
-
|
57
|
-
|
58
|
-
if (grpc_trace_stream_refcount.enabled()) {
|
59
|
-
gpr_atm val = gpr_atm_no_barrier_load(&refcount->refs.count);
|
60
|
-
gpr_log(GPR_DEBUG, "%s %p:%p UNREF %" PRIdPTR "->%" PRIdPTR " %s",
|
61
|
-
refcount->object_type, refcount, refcount->destroy.cb_arg, val,
|
62
|
-
val - 1, reason);
|
63
|
-
}
|
64
|
-
#else
|
65
|
-
void grpc_stream_unref(grpc_stream_refcount* refcount) {
|
66
|
-
#endif
|
67
|
-
if (gpr_unref(&refcount->refs)) {
|
68
|
-
if (!grpc_iomgr_is_any_background_poller_thread() &&
|
69
|
-
(grpc_core::ExecCtx::Get()->flags() &
|
70
|
-
GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP)) {
|
71
|
-
/* Ick.
|
72
|
-
The thread we're running on MAY be owned (indirectly) by a call-stack.
|
73
|
-
If that's the case, destroying the call-stack MAY try to destroy the
|
74
|
-
thread, which is a tangled mess that we just don't want to ever have to
|
75
|
-
cope with.
|
76
|
-
Throw this over to the executor (on a core-owned thread) and process it
|
77
|
-
there. */
|
78
|
-
refcount->destroy.scheduler =
|
79
|
-
grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT);
|
80
|
-
}
|
81
|
-
GRPC_CLOSURE_SCHED(&refcount->destroy, GRPC_ERROR_NONE);
|
82
|
-
}
|
59
|
+
void slice_stream_destroy(void* arg) {
|
60
|
+
grpc_stream_destroy(static_cast<grpc_stream_refcount*>(arg));
|
83
61
|
}
|
84
62
|
|
85
63
|
#define STREAM_REF_FROM_SLICE_REF(p) \
|
86
64
|
((grpc_stream_refcount*)(((uint8_t*)p) - \
|
87
65
|
offsetof(grpc_stream_refcount, slice_refcount)))
|
88
66
|
|
89
|
-
|
90
|
-
|
91
|
-
grpc_stream_ref(STREAM_REF_FROM_SLICE_REF(p), "slice");
|
92
|
-
#else
|
93
|
-
grpc_stream_ref(STREAM_REF_FROM_SLICE_REF(p));
|
94
|
-
#endif
|
95
|
-
}
|
96
|
-
|
97
|
-
static void slice_stream_unref(void* p) {
|
67
|
+
grpc_slice grpc_slice_from_stream_owned_buffer(grpc_stream_refcount* refcount,
|
68
|
+
void* buffer, size_t length) {
|
98
69
|
#ifndef NDEBUG
|
99
|
-
|
70
|
+
grpc_stream_ref(STREAM_REF_FROM_SLICE_REF(&refcount->slice_refcount),
|
71
|
+
"slice");
|
100
72
|
#else
|
101
|
-
|
73
|
+
grpc_stream_ref(STREAM_REF_FROM_SLICE_REF(&refcount->slice_refcount));
|
102
74
|
#endif
|
103
|
-
}
|
104
|
-
|
105
|
-
grpc_slice grpc_slice_from_stream_owned_buffer(grpc_stream_refcount* refcount,
|
106
|
-
void* buffer, size_t length) {
|
107
|
-
slice_stream_ref(&refcount->slice_refcount);
|
108
75
|
grpc_slice res;
|
109
76
|
res.refcount = &refcount->slice_refcount;
|
110
77
|
res.data.refcounted.bytes = static_cast<uint8_t*>(buffer);
|
@@ -112,13 +79,6 @@ grpc_slice grpc_slice_from_stream_owned_buffer(grpc_stream_refcount* refcount,
|
|
112
79
|
return res;
|
113
80
|
}
|
114
81
|
|
115
|
-
static const grpc_slice_refcount_vtable stream_ref_slice_vtable = {
|
116
|
-
slice_stream_ref, /* ref */
|
117
|
-
slice_stream_unref, /* unref */
|
118
|
-
grpc_slice_default_eq_impl, /* eq */
|
119
|
-
grpc_slice_default_hash_impl /* hash */
|
120
|
-
};
|
121
|
-
|
122
82
|
#ifndef NDEBUG
|
123
83
|
void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
|
124
84
|
grpc_iomgr_cb_func cb, void* cb_arg,
|
@@ -128,10 +88,12 @@ void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
|
|
128
88
|
void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
|
129
89
|
grpc_iomgr_cb_func cb, void* cb_arg) {
|
130
90
|
#endif
|
131
|
-
gpr_ref_init(&refcount->refs, initial_refs);
|
132
91
|
GRPC_CLOSURE_INIT(&refcount->destroy, cb, cb_arg, grpc_schedule_on_exec_ctx);
|
133
|
-
|
134
|
-
|
92
|
+
|
93
|
+
new (&refcount->refs) grpc_core::RefCount();
|
94
|
+
new (&refcount->slice_refcount) grpc_slice_refcount(
|
95
|
+
grpc_slice_refcount::Type::REGULAR, &refcount->refs, slice_stream_destroy,
|
96
|
+
refcount, &refcount->slice_refcount);
|
135
97
|
}
|
136
98
|
|
137
99
|
static void move64(uint64_t* from, uint64_t* to) {
|
@@ -162,7 +124,8 @@ void grpc_transport_destroy(grpc_transport* transport) {
|
|
162
124
|
|
163
125
|
int grpc_transport_init_stream(grpc_transport* transport, grpc_stream* stream,
|
164
126
|
grpc_stream_refcount* refcount,
|
165
|
-
const void* server_data,
|
127
|
+
const void* server_data,
|
128
|
+
grpc_core::Arena* arena) {
|
166
129
|
return transport->vtable->init_stream(transport, stream, refcount,
|
167
130
|
server_data, arena);
|
168
131
|
}
|
@@ -212,7 +175,7 @@ grpc_endpoint* grpc_transport_get_endpoint(grpc_transport* transport) {
|
|
212
175
|
// it's grpc_transport_stream_op_batch_finish_with_failure
|
213
176
|
void grpc_transport_stream_op_batch_finish_with_failure(
|
214
177
|
grpc_transport_stream_op_batch* batch, grpc_error* error,
|
215
|
-
|
178
|
+
grpc_core::CallCombiner* call_combiner) {
|
216
179
|
if (batch->send_message) {
|
217
180
|
batch->payload->send_message.send_message.reset();
|
218
181
|
}
|
@@ -24,12 +24,13 @@
|
|
24
24
|
#include <stddef.h>
|
25
25
|
|
26
26
|
#include "src/core/lib/channel/context.h"
|
27
|
-
#include "src/core/lib/
|
27
|
+
#include "src/core/lib/gprpp/arena.h"
|
28
28
|
#include "src/core/lib/iomgr/call_combiner.h"
|
29
29
|
#include "src/core/lib/iomgr/endpoint.h"
|
30
30
|
#include "src/core/lib/iomgr/polling_entity.h"
|
31
31
|
#include "src/core/lib/iomgr/pollset.h"
|
32
32
|
#include "src/core/lib/iomgr/pollset_set.h"
|
33
|
+
#include "src/core/lib/slice/slice_internal.h"
|
33
34
|
#include "src/core/lib/transport/byte_stream.h"
|
34
35
|
#include "src/core/lib/transport/metadata_batch.h"
|
35
36
|
|
@@ -51,7 +52,7 @@ typedef struct grpc_stream grpc_stream;
|
|
51
52
|
extern grpc_core::DebugOnlyTraceFlag grpc_trace_stream_refcount;
|
52
53
|
|
53
54
|
typedef struct grpc_stream_refcount {
|
54
|
-
|
55
|
+
grpc_core::RefCount refs;
|
55
56
|
grpc_closure destroy;
|
56
57
|
#ifndef NDEBUG
|
57
58
|
const char* object_type;
|
@@ -63,19 +64,45 @@ typedef struct grpc_stream_refcount {
|
|
63
64
|
void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
|
64
65
|
grpc_iomgr_cb_func cb, void* cb_arg,
|
65
66
|
const char* object_type);
|
66
|
-
void grpc_stream_ref(grpc_stream_refcount* refcount, const char* reason);
|
67
|
-
void grpc_stream_unref(grpc_stream_refcount* refcount, const char* reason);
|
68
67
|
#define GRPC_STREAM_REF_INIT(rc, ir, cb, cb_arg, objtype) \
|
69
68
|
grpc_stream_ref_init(rc, ir, cb, cb_arg, objtype)
|
70
69
|
#else
|
71
70
|
void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
|
72
71
|
grpc_iomgr_cb_func cb, void* cb_arg);
|
73
|
-
void grpc_stream_ref(grpc_stream_refcount* refcount);
|
74
|
-
void grpc_stream_unref(grpc_stream_refcount* refcount);
|
75
72
|
#define GRPC_STREAM_REF_INIT(rc, ir, cb, cb_arg, objtype) \
|
76
73
|
grpc_stream_ref_init(rc, ir, cb, cb_arg)
|
77
74
|
#endif
|
78
75
|
|
76
|
+
#ifndef NDEBUG
|
77
|
+
inline void grpc_stream_ref(grpc_stream_refcount* refcount,
|
78
|
+
const char* reason) {
|
79
|
+
if (grpc_trace_stream_refcount.enabled()) {
|
80
|
+
gpr_log(GPR_DEBUG, "%s %p:%p REF %s", refcount->object_type, refcount,
|
81
|
+
refcount->destroy.cb_arg, reason);
|
82
|
+
}
|
83
|
+
#else
|
84
|
+
inline void grpc_stream_ref(grpc_stream_refcount* refcount) {
|
85
|
+
#endif
|
86
|
+
refcount->refs.RefNonZero();
|
87
|
+
}
|
88
|
+
|
89
|
+
void grpc_stream_destroy(grpc_stream_refcount* refcount);
|
90
|
+
|
91
|
+
#ifndef NDEBUG
|
92
|
+
inline void grpc_stream_unref(grpc_stream_refcount* refcount,
|
93
|
+
const char* reason) {
|
94
|
+
if (grpc_trace_stream_refcount.enabled()) {
|
95
|
+
gpr_log(GPR_DEBUG, "%s %p:%p UNREF %s", refcount->object_type, refcount,
|
96
|
+
refcount->destroy.cb_arg, reason);
|
97
|
+
}
|
98
|
+
#else
|
99
|
+
inline void grpc_stream_unref(grpc_stream_refcount* refcount) {
|
100
|
+
#endif
|
101
|
+
if (GPR_UNLIKELY(refcount->refs.Unref())) {
|
102
|
+
grpc_stream_destroy(refcount);
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
79
106
|
/* Wrap a buffer that is owned by some stream object into a slice that shares
|
80
107
|
the same refcount */
|
81
108
|
grpc_slice grpc_slice_from_stream_owned_buffer(grpc_stream_refcount* refcount,
|
@@ -331,7 +358,8 @@ size_t grpc_transport_stream_size(grpc_transport* transport);
|
|
331
358
|
supplied from the accept_stream callback function */
|
332
359
|
int grpc_transport_init_stream(grpc_transport* transport, grpc_stream* stream,
|
333
360
|
grpc_stream_refcount* refcount,
|
334
|
-
const void* server_data,
|
361
|
+
const void* server_data,
|
362
|
+
grpc_core::Arena* arena);
|
335
363
|
|
336
364
|
void grpc_transport_set_pops(grpc_transport* transport, grpc_stream* stream,
|
337
365
|
grpc_polling_entity* pollent);
|
@@ -352,7 +380,7 @@ void grpc_transport_destroy_stream(grpc_transport* transport,
|
|
352
380
|
|
353
381
|
void grpc_transport_stream_op_batch_finish_with_failure(
|
354
382
|
grpc_transport_stream_op_batch* op, grpc_error* error,
|
355
|
-
|
383
|
+
grpc_core::CallCombiner* call_combiner);
|
356
384
|
|
357
385
|
char* grpc_transport_stream_op_batch_string(grpc_transport_stream_op_batch* op);
|
358
386
|
char* grpc_transport_op_string(grpc_transport_op* op);
|
@@ -34,7 +34,7 @@ typedef struct grpc_transport_vtable {
|
|
34
34
|
/* implementation of grpc_transport_init_stream */
|
35
35
|
int (*init_stream)(grpc_transport* self, grpc_stream* stream,
|
36
36
|
grpc_stream_refcount* refcount, const void* server_data,
|
37
|
-
|
37
|
+
grpc_core::Arena* arena);
|
38
38
|
|
39
39
|
/* implementation of grpc_transport_set_pollset */
|
40
40
|
void (*set_pollset)(grpc_transport* self, grpc_stream* stream,
|
@@ -585,7 +585,7 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
|
|
585
585
|
if (next_message_to_send > TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
|
586
586
|
next_message_to_send = TSI_FAKE_HANDSHAKE_MESSAGE_MAX;
|
587
587
|
}
|
588
|
-
if (tsi_tracing_enabled
|
588
|
+
if (GRPC_TRACE_FLAG_ENABLED(tsi_tracing_enabled)) {
|
589
589
|
gpr_log(GPR_INFO, "%s prepared %s.",
|
590
590
|
impl->is_client ? "Client" : "Server",
|
591
591
|
tsi_fake_handshake_message_to_string(impl->next_message_to_send));
|
@@ -597,7 +597,7 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
|
|
597
597
|
if (!impl->is_client &&
|
598
598
|
impl->next_message_to_send == TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
|
599
599
|
/* We're done. */
|
600
|
-
if (tsi_tracing_enabled
|
600
|
+
if (GRPC_TRACE_FLAG_ENABLED(tsi_tracing_enabled)) {
|
601
601
|
gpr_log(GPR_INFO, "Server is done.");
|
602
602
|
}
|
603
603
|
impl->result = TSI_OK;
|
@@ -636,7 +636,7 @@ static tsi_result fake_handshaker_process_bytes_from_peer(
|
|
636
636
|
tsi_fake_handshake_message_to_string(received_msg),
|
637
637
|
tsi_fake_handshake_message_to_string(expected_msg));
|
638
638
|
}
|
639
|
-
if (tsi_tracing_enabled
|
639
|
+
if (GRPC_TRACE_FLAG_ENABLED(tsi_tracing_enabled)) {
|
640
640
|
gpr_log(GPR_INFO, "%s received %s.", impl->is_client ? "Client" : "Server",
|
641
641
|
tsi_fake_handshake_message_to_string(received_msg));
|
642
642
|
}
|
@@ -644,7 +644,7 @@ static tsi_result fake_handshaker_process_bytes_from_peer(
|
|
644
644
|
impl->needs_incoming_message = 0;
|
645
645
|
if (impl->next_message_to_send == TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
|
646
646
|
/* We're done. */
|
647
|
-
if (tsi_tracing_enabled
|
647
|
+
if (GRPC_TRACE_FLAG_ENABLED(tsi_tracing_enabled)) {
|
648
648
|
gpr_log(GPR_INFO, "%s is done.", impl->is_client ? "Client" : "Server");
|
649
649
|
}
|
650
650
|
impl->result = TSI_OK;
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
#include <grpc/support/port_platform.h>
|
20
20
|
|
21
|
-
#include "src/core/lib/gprpp/
|
21
|
+
#include "src/core/lib/gprpp/sync.h"
|
22
22
|
#include "src/core/lib/slice/slice_internal.h"
|
23
23
|
#include "src/core/tsi/ssl/session_cache/ssl_session.h"
|
24
24
|
#include "src/core/tsi/ssl/session_cache/ssl_session_cache.h"
|
@@ -213,7 +213,7 @@ static const char* ssl_error_string(int error) {
|
|
213
213
|
/* TODO(jboeuf): Remove when we are past the debugging phase with this code. */
|
214
214
|
static void ssl_log_where_info(const SSL* ssl, int where, int flag,
|
215
215
|
const char* msg) {
|
216
|
-
if ((where & flag) && tsi_tracing_enabled
|
216
|
+
if ((where & flag) && GRPC_TRACE_FLAG_ENABLED(tsi_tracing_enabled)) {
|
217
217
|
gpr_log(GPR_INFO, "%20.20s - %30.30s - %5.10s", msg,
|
218
218
|
SSL_state_string_long(ssl), SSL_state_string(ssl));
|
219
219
|
}
|
data/src/ruby/ext/grpc/rb_grpc.c
CHANGED
@@ -304,7 +304,7 @@ static VALUE bg_thread_init_rb_mu = Qundef;
|
|
304
304
|
static int bg_thread_init_done = 0;
|
305
305
|
|
306
306
|
static void grpc_ruby_init_threads() {
|
307
|
-
// Avoid calling
|
307
|
+
// Avoid calling into ruby library (when creating threads here)
|
308
308
|
// in gpr_once_init. In general, it appears to be unsafe to call
|
309
309
|
// into the ruby library while holding a non-ruby mutex, because a gil yield
|
310
310
|
// could end up trying to lock onto that same mutex and deadlocking.
|
data/src/ruby/lib/grpc/errors.rb
CHANGED
@@ -42,12 +42,31 @@ module GRPC
|
|
42
42
|
@metadata = metadata
|
43
43
|
end
|
44
44
|
|
45
|
-
# Converts the exception to a
|
45
|
+
# Converts the exception to a {Struct::Status} for use in the networking
|
46
46
|
# wrapper layer.
|
47
47
|
#
|
48
|
-
# @return [Status] with the same code and details
|
48
|
+
# @return [Struct::Status] with the same code and details
|
49
49
|
def to_status
|
50
|
-
Struct::Status.new(code, details,
|
50
|
+
Struct::Status.new(code, details, metadata)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Converts the exception to a deserialized {Google::Rpc::Status} object.
|
54
|
+
# Returns `nil` if the `grpc-status-details-bin` trailer could not be
|
55
|
+
# converted to a {Google::Rpc::Status} due to the server not providing
|
56
|
+
# the necessary trailers.
|
57
|
+
#
|
58
|
+
# @return [Google::Rpc::Status, nil]
|
59
|
+
def to_rpc_status
|
60
|
+
# Lazily require google_rpc_status_utils to scope
|
61
|
+
# loading protobuf_c.so to the users of this method.
|
62
|
+
require_relative './google_rpc_status_utils'
|
63
|
+
status = to_status
|
64
|
+
return if status.nil?
|
65
|
+
GoogleRpcStatusUtils.extract_google_rpc_status(status)
|
66
|
+
rescue Google::Protobuf::ParseError => parse_error
|
67
|
+
GRPC.logger.warn('parse error: to_rpc_status failed')
|
68
|
+
GRPC.logger.warn(parse_error)
|
69
|
+
nil
|
51
70
|
end
|
52
71
|
|
53
72
|
def self.new_status_exception(code, details = 'unknown cause',
|
@@ -224,7 +224,7 @@ module GRPC
|
|
224
224
|
set_input_stream_done.call
|
225
225
|
end
|
226
226
|
GRPC.logger.debug('bidi-read-loop: finished')
|
227
|
-
# Make sure that the write loop is done
|
227
|
+
# Make sure that the write loop is done before finishing the call.
|
228
228
|
# Note that blocking is ok at this point because we've already received
|
229
229
|
# a status
|
230
230
|
@enq_th.join if is_client
|
@@ -202,7 +202,7 @@ module GRPC
|
|
202
202
|
# forcing an abrupt exit to each thread.
|
203
203
|
#
|
204
204
|
# * connect_md_proc:
|
205
|
-
# when non-nil is a proc for determining metadata to
|
205
|
+
# when non-nil is a proc for determining metadata to send back the client
|
206
206
|
# on receiving an invocation req. The proc signature is:
|
207
207
|
# {key: val, ..} func(method_name, {key: val, ...})
|
208
208
|
#
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# Copyright 2015 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
|
+
|
15
|
+
require 'spec_helper'
|
16
|
+
require 'google/protobuf/well_known_types'
|
17
|
+
require_relative '../pb/src/proto/grpc/testing/messages_pb'
|
18
|
+
|
19
|
+
describe GRPC::BadStatus do
|
20
|
+
describe :attributes do
|
21
|
+
it 'has attributes' do
|
22
|
+
code = 1
|
23
|
+
details = 'details'
|
24
|
+
metadata = { 'key' => 'val' }
|
25
|
+
|
26
|
+
exception = GRPC::BadStatus.new(code, details, metadata)
|
27
|
+
|
28
|
+
expect(exception.code).to eq code
|
29
|
+
expect(exception.details).to eq details
|
30
|
+
expect(exception.metadata).to eq metadata
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe :new_status_exception do
|
35
|
+
let(:codes_and_classes) do
|
36
|
+
[
|
37
|
+
[GRPC::Core::StatusCodes::OK, GRPC::Ok],
|
38
|
+
[GRPC::Core::StatusCodes::CANCELLED, GRPC::Cancelled],
|
39
|
+
[GRPC::Core::StatusCodes::UNKNOWN, GRPC::Unknown],
|
40
|
+
[GRPC::Core::StatusCodes::INVALID_ARGUMENT, GRPC::InvalidArgument],
|
41
|
+
[GRPC::Core::StatusCodes::DEADLINE_EXCEEDED, GRPC::DeadlineExceeded],
|
42
|
+
[GRPC::Core::StatusCodes::NOT_FOUND, GRPC::NotFound],
|
43
|
+
[GRPC::Core::StatusCodes::ALREADY_EXISTS, GRPC::AlreadyExists],
|
44
|
+
[GRPC::Core::StatusCodes::PERMISSION_DENIED, GRPC::PermissionDenied],
|
45
|
+
[GRPC::Core::StatusCodes::UNAUTHENTICATED, GRPC::Unauthenticated],
|
46
|
+
[GRPC::Core::StatusCodes::RESOURCE_EXHAUSTED, GRPC::ResourceExhausted],
|
47
|
+
[GRPC::Core::StatusCodes::FAILED_PRECONDITION, GRPC::FailedPrecondition],
|
48
|
+
[GRPC::Core::StatusCodes::ABORTED, GRPC::Aborted],
|
49
|
+
[GRPC::Core::StatusCodes::OUT_OF_RANGE, GRPC::OutOfRange],
|
50
|
+
[GRPC::Core::StatusCodes::UNIMPLEMENTED, GRPC::Unimplemented],
|
51
|
+
[GRPC::Core::StatusCodes::INTERNAL, GRPC::Internal],
|
52
|
+
[GRPC::Core::StatusCodes::UNAVAILABLE, GRPC::Unavailable],
|
53
|
+
[GRPC::Core::StatusCodes::DATA_LOSS, GRPC::DataLoss],
|
54
|
+
[99, GRPC::BadStatus] # Unknown codes default to BadStatus
|
55
|
+
]
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'maps codes to the correct error class' do
|
59
|
+
codes_and_classes.each do |code, grpc_error_class|
|
60
|
+
exception = GRPC::BadStatus.new_status_exception(code)
|
61
|
+
|
62
|
+
expect(exception).to be_a grpc_error_class
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe :to_status do
|
68
|
+
it 'gets status' do
|
69
|
+
code = 1
|
70
|
+
details = 'details'
|
71
|
+
metadata = { 'key' => 'val' }
|
72
|
+
|
73
|
+
exception = GRPC::BadStatus.new(code, details, metadata)
|
74
|
+
status = Struct::Status.new(code, details, metadata)
|
75
|
+
|
76
|
+
expect(exception.to_status).to eq status
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe :to_rpc_status do
|
81
|
+
let(:simple_request_any) do
|
82
|
+
Google::Protobuf::Any.new.tap do |any|
|
83
|
+
any.pack(
|
84
|
+
Grpc::Testing::SimpleRequest.new(
|
85
|
+
payload: Grpc::Testing::Payload.new(body: 'request')
|
86
|
+
)
|
87
|
+
)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
let(:simple_response_any) do
|
91
|
+
Google::Protobuf::Any.new.tap do |any|
|
92
|
+
any.pack(
|
93
|
+
Grpc::Testing::SimpleResponse.new(
|
94
|
+
payload: Grpc::Testing::Payload.new(body: 'response')
|
95
|
+
)
|
96
|
+
)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
let(:payload_any) do
|
100
|
+
Google::Protobuf::Any.new.tap do |any|
|
101
|
+
any.pack(Grpc::Testing::Payload.new(body: 'payload'))
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'decodes proto values' do
|
106
|
+
rpc_status = Google::Rpc::Status.new(
|
107
|
+
code: 1,
|
108
|
+
message: 'matching message',
|
109
|
+
details: [simple_request_any, simple_response_any, payload_any]
|
110
|
+
)
|
111
|
+
rpc_status_proto = Google::Rpc::Status.encode(rpc_status)
|
112
|
+
|
113
|
+
code = 1
|
114
|
+
details = 'details'
|
115
|
+
metadata = { 'grpc-status-details-bin' => rpc_status_proto }
|
116
|
+
|
117
|
+
exception = GRPC::BadStatus.new(code, details, metadata)
|
118
|
+
|
119
|
+
expect(exception.to_rpc_status).to eq rpc_status
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'does not raise when decoding a bad proto' do
|
123
|
+
code = 1
|
124
|
+
details = 'details'
|
125
|
+
metadata = { 'grpc-status-details-bin' => 'notavalidprotostream' }
|
126
|
+
|
127
|
+
exception = GRPC::BadStatus.new(code, details, metadata)
|
128
|
+
|
129
|
+
expect(exception.to_rpc_status).to be nil
|
130
|
+
|
131
|
+
error_msg = 'parse error: to_rpc_status failed'
|
132
|
+
error_desc = '<Google::Protobuf::ParseError> ' \
|
133
|
+
'Error occurred during parsing: Invalid wire type'
|
134
|
+
|
135
|
+
# Check that the parse error was logged correctly
|
136
|
+
log_contents = @log_output.read
|
137
|
+
expect(log_contents).to include "WARN GRPC : #{error_msg}"
|
138
|
+
expect(log_contents).to include "WARN GRPC : #{error_desc}"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|