wearefair-grpc 1.3.1.pre.c → 1.4.0.fair
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +418 -126
- data/include/grpc/grpc.h +15 -69
- data/include/grpc/grpc_security.h +1 -1
- data/include/grpc/impl/codegen/compression_types.h +3 -4
- data/include/grpc/impl/codegen/gpr_types.h +0 -1
- data/include/grpc/impl/codegen/grpc_types.h +69 -3
- data/include/grpc/impl/codegen/port_platform.h +6 -0
- data/include/grpc/impl/codegen/slice.h +2 -1
- data/include/grpc/load_reporting.h +6 -6
- data/include/grpc/slice.h +25 -3
- data/include/grpc/slice_buffer.h +4 -0
- data/src/core/ext/census/context.c +1 -1
- data/src/core/ext/census/resource.c +3 -1
- data/src/core/ext/filters/client_channel/channel_connectivity.c +1 -1
- data/src/core/ext/filters/client_channel/client_channel.c +158 -100
- data/src/core/ext/filters/client_channel/client_channel_plugin.c +3 -2
- data/src/core/ext/filters/client_channel/lb_policy.c +2 -1
- data/src/core/ext/filters/client_channel/lb_policy.h +5 -6
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +153 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +42 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +344 -88
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +133 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +65 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +47 -5
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +6 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +19 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +63 -34
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +2 -1
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +13 -12
- data/src/core/ext/filters/client_channel/lb_policy_factory.c +28 -5
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +18 -4
- data/src/core/ext/filters/client_channel/parse_address.c +37 -7
- data/src/core/ext/filters/client_channel/parse_address.h +11 -8
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c +3 -3
- data/src/core/ext/filters/client_channel/subchannel.c +19 -16
- data/src/core/ext/filters/client_channel/subchannel.h +1 -0
- data/src/core/ext/filters/client_channel/uri_parser.c +36 -22
- data/src/core/ext/filters/client_channel/uri_parser.h +1 -1
- data/src/core/{lib/channel → ext/filters/deadline}/deadline_filter.c +42 -17
- data/src/core/{lib/channel → ext/filters/deadline}/deadline_filter.h +8 -9
- data/src/core/{lib/channel → ext/filters/http/client}/http_client_filter.c +19 -11
- data/src/core/{lib/channel → ext/filters/http/client}/http_client_filter.h +3 -6
- data/src/core/ext/filters/http/http_filters_plugin.c +104 -0
- data/src/core/{lib/channel/compress_filter.c → ext/filters/http/message_compress/message_compress_filter.c} +124 -23
- data/src/core/{lib/channel/compress_filter.h → ext/filters/http/message_compress/message_compress_filter.h} +5 -6
- data/src/core/{lib/channel → ext/filters/http/server}/http_server_filter.c +4 -6
- data/src/core/{lib/channel → ext/filters/http/server}/http_server_filter.h +3 -3
- data/src/core/ext/filters/load_reporting/load_reporting.c +2 -25
- data/src/core/ext/filters/load_reporting/load_reporting_filter.c +26 -1
- data/src/core/ext/filters/max_age/max_age_filter.c +14 -14
- data/src/core/{lib/channel → ext/filters/message_size}/message_size_filter.c +91 -47
- data/src/core/{lib/channel → ext/filters/message_size}/message_size_filter.h +3 -3
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +1 -1
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +2 -2
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +2 -2
- data/src/core/ext/transport/chttp2/transport/bin_encoder.c +3 -3
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +296 -172
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +3 -2
- data/src/core/ext/transport/chttp2/transport/frame_data.c +203 -164
- data/src/core/ext/transport/chttp2/transport/frame_data.h +8 -14
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +5 -5
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +4 -4
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +2 -4
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +4 -3
- data/src/core/ext/transport/chttp2/transport/internal.h +50 -33
- data/src/core/ext/transport/chttp2/transport/parsing.c +10 -11
- data/src/core/ext/transport/chttp2/transport/writing.c +32 -13
- data/src/core/lib/channel/channel_args.c +28 -9
- data/src/core/lib/channel/channel_args.h +5 -1
- data/src/core/lib/channel/channel_stack.c +1 -1
- data/src/core/lib/channel/channel_stack.h +2 -2
- data/src/core/lib/channel/channel_stack_builder.c +13 -1
- data/src/core/lib/channel/channel_stack_builder.h +5 -1
- data/src/core/lib/channel/connected_channel.c +3 -1
- data/src/core/lib/channel/context.h +2 -2
- data/src/core/lib/compression/message_compress.c +2 -2
- data/src/core/lib/debug/trace.c +13 -6
- data/src/core/lib/debug/trace.h +27 -1
- data/src/core/lib/http/httpcli.c +1 -1
- data/src/core/lib/http/httpcli_security_connector.c +6 -10
- data/src/core/lib/http/parser.c +2 -2
- data/src/core/lib/http/parser.h +2 -1
- data/src/core/lib/iomgr/combiner.c +6 -6
- data/src/core/lib/iomgr/combiner.h +2 -1
- data/src/core/lib/iomgr/error.c +12 -5
- data/src/core/lib/iomgr/error.h +13 -13
- data/src/core/lib/iomgr/ev_epoll1_linux.c +984 -0
- data/src/core/lib/iomgr/ev_epoll1_linux.h +44 -0
- data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +2146 -0
- data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.h +43 -0
- data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +1337 -0
- data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.h +43 -0
- data/src/core/lib/iomgr/ev_epollex_linux.c +1511 -0
- data/src/core/lib/iomgr/ev_epollex_linux.h +43 -0
- data/src/core/lib/iomgr/{ev_epoll_linux.c → ev_epollsig_linux.c} +24 -31
- data/src/core/lib/iomgr/{ev_epoll_linux.h → ev_epollsig_linux.h} +4 -4
- data/src/core/lib/iomgr/ev_poll_posix.c +12 -27
- data/src/core/lib/iomgr/ev_poll_posix.h +2 -2
- data/src/core/lib/iomgr/ev_posix.c +22 -8
- data/src/core/lib/iomgr/ev_posix.h +4 -3
- data/src/core/lib/iomgr/exec_ctx.c +5 -0
- data/src/core/lib/iomgr/exec_ctx.h +2 -0
- data/src/core/lib/iomgr/iomgr.c +4 -0
- data/src/core/lib/iomgr/iomgr.h +3 -0
- data/src/core/lib/iomgr/is_epollexclusive_available.c +116 -0
- data/src/core/lib/iomgr/is_epollexclusive_available.h +41 -0
- data/src/core/lib/iomgr/lockfree_event.c +16 -0
- data/src/core/lib/iomgr/pollset.h +2 -5
- data/src/core/lib/iomgr/pollset_uv.c +1 -1
- data/src/core/lib/iomgr/pollset_windows.c +3 -3
- data/src/core/lib/iomgr/resource_quota.c +9 -8
- data/src/core/lib/iomgr/resource_quota.h +2 -1
- data/src/core/lib/iomgr/sockaddr_utils.h +1 -1
- data/src/core/lib/iomgr/socket_mutator.h +2 -0
- data/src/core/lib/iomgr/sys_epoll_wrapper.h +43 -0
- data/src/core/lib/iomgr/tcp_client_posix.c +6 -6
- data/src/core/lib/iomgr/tcp_client_uv.c +3 -3
- data/src/core/lib/iomgr/tcp_posix.c +7 -7
- data/src/core/lib/iomgr/tcp_posix.h +2 -1
- data/src/core/lib/iomgr/tcp_server_posix.c +1 -1
- data/src/core/lib/iomgr/tcp_uv.c +6 -6
- data/src/core/lib/iomgr/tcp_uv.h +2 -1
- data/src/core/lib/iomgr/tcp_windows.c +1 -1
- data/src/core/lib/iomgr/timer_generic.c +24 -25
- data/src/core/lib/iomgr/timer_manager.c +276 -0
- data/src/core/lib/iomgr/timer_manager.h +52 -0
- data/src/core/lib/iomgr/timer_uv.c +6 -0
- data/src/core/lib/iomgr/udp_server.c +42 -9
- data/src/core/lib/iomgr/udp_server.h +3 -1
- data/src/core/lib/security/credentials/credentials.c +0 -1
- data/src/core/lib/security/credentials/fake/fake_credentials.c +23 -0
- data/src/core/lib/security/credentials/fake/fake_credentials.h +12 -9
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +1 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +1 -1
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +24 -53
- data/src/core/lib/security/transport/client_auth_filter.c +9 -3
- data/src/core/lib/security/transport/secure_endpoint.c +7 -7
- data/src/core/lib/security/transport/secure_endpoint.h +1 -1
- data/src/core/lib/security/transport/security_connector.c +32 -51
- data/src/core/lib/security/transport/security_connector.h +10 -14
- data/src/core/lib/slice/b64.c +1 -1
- data/src/core/lib/slice/percent_encoding.c +3 -3
- data/src/core/lib/slice/slice.c +66 -33
- data/src/core/lib/slice/slice_buffer.c +25 -6
- data/src/core/lib/slice/slice_hash_table.c +33 -35
- data/src/core/lib/slice/slice_hash_table.h +7 -12
- data/src/core/lib/support/atomic.h +45 -0
- data/src/core/lib/support/atomic_with_atm.h +70 -0
- data/src/core/lib/support/atomic_with_std.h +48 -0
- data/src/core/lib/support/avl.c +14 -14
- data/src/core/lib/support/memory.h +74 -0
- data/src/core/lib/support/mpscq.c +12 -1
- data/src/core/lib/support/mpscq.h +4 -0
- data/src/core/lib/support/stack_lockfree.c +3 -36
- data/src/core/lib/support/time_posix.c +8 -0
- data/src/core/lib/support/tmpfile_posix.c +10 -10
- data/src/core/lib/surface/alarm.c +3 -1
- data/src/core/lib/surface/api_trace.c +2 -1
- data/src/core/lib/surface/api_trace.h +2 -2
- data/src/core/lib/surface/byte_buffer_reader.c +1 -1
- data/src/core/lib/surface/call.c +65 -22
- data/src/core/lib/surface/call.h +4 -2
- data/src/core/lib/surface/channel_init.c +2 -19
- data/src/core/lib/surface/channel_stack_type.c +18 -0
- data/src/core/lib/surface/channel_stack_type.h +2 -0
- data/src/core/lib/surface/completion_queue.c +249 -83
- data/src/core/lib/surface/completion_queue.h +18 -13
- data/src/core/lib/surface/completion_queue_factory.c +24 -9
- data/src/core/lib/surface/init.c +1 -52
- data/src/core/lib/surface/{lame_client.c → lame_client.cc} +37 -26
- data/src/core/lib/surface/server.c +50 -27
- data/src/core/lib/surface/server.h +2 -1
- data/src/core/lib/surface/version.c +2 -2
- data/src/core/lib/transport/bdp_estimator.c +20 -9
- data/src/core/lib/transport/bdp_estimator.h +5 -1
- data/src/core/lib/transport/byte_stream.c +23 -9
- data/src/core/lib/transport/byte_stream.h +15 -6
- data/src/core/lib/transport/connectivity_state.c +6 -6
- data/src/core/lib/transport/connectivity_state.h +2 -1
- data/src/core/lib/transport/service_config.c +6 -13
- data/src/core/lib/transport/service_config.h +2 -2
- data/src/core/lib/transport/static_metadata.c +403 -389
- data/src/core/lib/transport/static_metadata.h +127 -114
- data/src/core/plugin_registry/grpc_plugin_registry.c +12 -0
- data/src/core/tsi/fake_transport_security.c +5 -4
- data/src/core/tsi/ssl_transport_security.c +71 -82
- data/src/core/tsi/ssl_transport_security.h +39 -61
- data/src/core/tsi/transport_security.c +83 -2
- data/src/core/tsi/transport_security.h +27 -2
- data/src/core/tsi/transport_security_adapter.c +236 -0
- data/src/core/tsi/transport_security_adapter.h +62 -0
- data/src/core/tsi/transport_security_interface.h +179 -66
- data/src/ruby/ext/grpc/extconf.rb +2 -1
- data/src/ruby/ext/grpc/rb_byte_buffer.c +8 -6
- data/src/ruby/ext/grpc/rb_call.c +56 -48
- data/src/ruby/ext/grpc/rb_call.h +3 -4
- data/src/ruby/ext/grpc/rb_call_credentials.c +23 -22
- data/src/ruby/ext/grpc/rb_channel.c +45 -29
- data/src/ruby/ext/grpc/rb_channel_args.c +11 -9
- data/src/ruby/ext/grpc/rb_channel_credentials.c +16 -12
- data/src/ruby/ext/grpc/rb_completion_queue.c +7 -9
- data/src/ruby/ext/grpc/rb_compression_options.c +7 -6
- data/src/ruby/ext/grpc/rb_event_thread.c +10 -12
- data/src/ruby/ext/grpc/rb_event_thread.h +1 -2
- data/src/ruby/ext/grpc/rb_grpc.c +11 -15
- data/src/ruby/ext/grpc/rb_grpc.h +2 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +14 -6
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +22 -10
- data/src/ruby/ext/grpc/rb_server.c +26 -28
- data/src/ruby/lib/grpc/version.rb +1 -1
- metadata +40 -18
- data/src/ruby/lib/grpc/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/grpc_c.so +0 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2017, Google Inc.
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are
|
8
|
+
* met:
|
9
|
+
*
|
10
|
+
* * Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
* * Redistributions in binary form must reproduce the above
|
13
|
+
* copyright notice, this list of conditions and the following disclaimer
|
14
|
+
* in the documentation and/or other materials provided with the
|
15
|
+
* distribution.
|
16
|
+
* * Neither the name of Google Inc. nor the names of its
|
17
|
+
* contributors may be used to endorse or promote products derived from
|
18
|
+
* this software without specific prior written permission.
|
19
|
+
*
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
21
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
22
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
23
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
24
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
27
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
28
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
|
34
|
+
#ifndef GRPC_CORE_LIB_IOMGR_TIMER_MANAGER_H
|
35
|
+
#define GRPC_CORE_LIB_IOMGR_TIMER_MANAGER_H
|
36
|
+
|
37
|
+
#include <stdbool.h>
|
38
|
+
|
39
|
+
/* Timer Manager tries to keep one thread waiting for the next timeout at all
|
40
|
+
times */
|
41
|
+
|
42
|
+
void grpc_timer_manager_init(void);
|
43
|
+
void grpc_timer_manager_shutdown(void);
|
44
|
+
|
45
|
+
/* enable/disable threading - must be called after grpc_timer_manager_init and
|
46
|
+
* before grpc_timer_manager_shutdown */
|
47
|
+
void grpc_timer_manager_set_threading(bool enabled);
|
48
|
+
/* explicitly perform one tick of the timer system - for when threading is
|
49
|
+
* disabled */
|
50
|
+
void grpc_timer_manager_tick(void);
|
51
|
+
|
52
|
+
#endif /* GRPC_CORE_LIB_IOMGR_TIMER_MANAGER_H */
|
@@ -38,10 +38,14 @@
|
|
38
38
|
#include <grpc/support/alloc.h>
|
39
39
|
#include <grpc/support/log.h>
|
40
40
|
|
41
|
+
#include "src/core/lib/debug/trace.h"
|
41
42
|
#include "src/core/lib/iomgr/timer.h"
|
42
43
|
|
43
44
|
#include <uv.h>
|
44
45
|
|
46
|
+
grpc_tracer_flag grpc_timer_trace = GRPC_TRACER_INITIALIZER(false);
|
47
|
+
grpc_tracer_flag grpc_timer_check_trace = GRPC_TRACER_INITIALIZER(false);
|
48
|
+
|
45
49
|
static void timer_close_callback(uv_handle_t *handle) { gpr_free(handle); }
|
46
50
|
|
47
51
|
static void stop_uv_timer(uv_timer_t *handle) {
|
@@ -100,4 +104,6 @@ bool grpc_timer_check(grpc_exec_ctx *exec_ctx, gpr_timespec now,
|
|
100
104
|
void grpc_timer_list_init(gpr_timespec now) {}
|
101
105
|
void grpc_timer_list_shutdown(grpc_exec_ctx *exec_ctx) {}
|
102
106
|
|
107
|
+
void grpc_timer_consume_kick(void) {}
|
108
|
+
|
103
109
|
#endif /* GRPC_UV */
|
@@ -79,14 +79,24 @@ struct grpc_udp_listener {
|
|
79
79
|
grpc_resolved_address addr;
|
80
80
|
grpc_closure read_closure;
|
81
81
|
grpc_closure write_closure;
|
82
|
+
// To be called when corresponding QuicGrpcServer closes all active
|
83
|
+
// connections.
|
84
|
+
grpc_closure orphan_fd_closure;
|
82
85
|
grpc_closure destroyed_closure;
|
83
86
|
grpc_udp_server_read_cb read_cb;
|
84
87
|
grpc_udp_server_write_cb write_cb;
|
85
88
|
grpc_udp_server_orphan_cb orphan_cb;
|
89
|
+
// True if orphan_cb is trigered.
|
90
|
+
bool orphan_notified;
|
86
91
|
|
87
92
|
struct grpc_udp_listener *next;
|
88
93
|
};
|
89
94
|
|
95
|
+
struct shutdown_fd_args {
|
96
|
+
grpc_fd *fd;
|
97
|
+
gpr_mu *server_mu;
|
98
|
+
};
|
99
|
+
|
90
100
|
/* the overall server */
|
91
101
|
struct grpc_udp_server {
|
92
102
|
gpr_mu mu;
|
@@ -146,6 +156,19 @@ grpc_udp_server *grpc_udp_server_create(const grpc_channel_args *args) {
|
|
146
156
|
return s;
|
147
157
|
}
|
148
158
|
|
159
|
+
static void shutdown_fd(grpc_exec_ctx *exec_ctx, void *args,
|
160
|
+
grpc_error *error) {
|
161
|
+
struct shutdown_fd_args *shutdown_args = (struct shutdown_fd_args *)args;
|
162
|
+
gpr_mu_lock(shutdown_args->server_mu);
|
163
|
+
grpc_fd_shutdown(exec_ctx, shutdown_args->fd, GRPC_ERROR_REF(error));
|
164
|
+
gpr_mu_unlock(shutdown_args->server_mu);
|
165
|
+
gpr_free(shutdown_args);
|
166
|
+
}
|
167
|
+
|
168
|
+
static void dummy_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
|
169
|
+
// No-op.
|
170
|
+
}
|
171
|
+
|
149
172
|
static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
|
150
173
|
if (s->shutdown_complete != NULL) {
|
151
174
|
grpc_closure_sched(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE);
|
@@ -195,12 +218,16 @@ static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
|
|
195
218
|
|
196
219
|
grpc_closure_init(&sp->destroyed_closure, destroyed_port, s,
|
197
220
|
grpc_schedule_on_exec_ctx);
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
221
|
+
if (!sp->orphan_notified) {
|
222
|
+
/* Call the orphan_cb to signal that the FD is about to be closed and
|
223
|
+
* should no longer be used. Because at this point, all listening ports
|
224
|
+
* have been shutdown already, no need to shutdown again.*/
|
225
|
+
grpc_closure_init(&sp->orphan_fd_closure, dummy_cb, sp->emfd,
|
226
|
+
grpc_schedule_on_exec_ctx);
|
227
|
+
GPR_ASSERT(sp->orphan_cb);
|
228
|
+
sp->orphan_cb(exec_ctx, sp->emfd, &sp->orphan_fd_closure,
|
229
|
+
sp->server->user_data);
|
230
|
+
}
|
204
231
|
grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL,
|
205
232
|
"udp_listener_shutdown");
|
206
233
|
}
|
@@ -225,9 +252,14 @@ void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *s,
|
|
225
252
|
if (s->active_ports) {
|
226
253
|
for (sp = s->head; sp; sp = sp->next) {
|
227
254
|
GPR_ASSERT(sp->orphan_cb);
|
228
|
-
|
229
|
-
|
230
|
-
|
255
|
+
struct shutdown_fd_args *args = gpr_malloc(sizeof(*args));
|
256
|
+
args->fd = sp->emfd;
|
257
|
+
args->server_mu = &s->mu;
|
258
|
+
grpc_closure_init(&sp->orphan_fd_closure, shutdown_fd, args,
|
259
|
+
grpc_schedule_on_exec_ctx);
|
260
|
+
sp->orphan_cb(exec_ctx, sp->emfd, &sp->orphan_fd_closure,
|
261
|
+
sp->server->user_data);
|
262
|
+
sp->orphan_notified = true;
|
231
263
|
}
|
232
264
|
gpr_mu_unlock(&s->mu);
|
233
265
|
} else {
|
@@ -391,6 +423,7 @@ static int add_socket_to_server(grpc_udp_server *s, int fd,
|
|
391
423
|
sp->read_cb = read_cb;
|
392
424
|
sp->write_cb = write_cb;
|
393
425
|
sp->orphan_cb = orphan_cb;
|
426
|
+
sp->orphan_notified = false;
|
394
427
|
GPR_ASSERT(sp->emfd);
|
395
428
|
gpr_mu_unlock(&s->mu);
|
396
429
|
gpr_free(name);
|
@@ -55,7 +55,9 @@ typedef void (*grpc_udp_server_write_cb)(grpc_exec_ctx *exec_ctx, grpc_fd *emfd,
|
|
55
55
|
|
56
56
|
/* Called when the grpc_fd is about to be orphaned (and the FD closed). */
|
57
57
|
typedef void (*grpc_udp_server_orphan_cb)(grpc_exec_ctx *exec_ctx,
|
58
|
-
grpc_fd *emfd,
|
58
|
+
grpc_fd *emfd,
|
59
|
+
grpc_closure *shutdown_fd_callback,
|
60
|
+
void *user_data);
|
59
61
|
|
60
62
|
/* Create a server, initially not bound to any ports */
|
61
63
|
grpc_udp_server *grpc_udp_server_create(const grpc_channel_args *args);
|
@@ -39,11 +39,15 @@
|
|
39
39
|
#include <grpc/support/log.h>
|
40
40
|
#include <grpc/support/string_util.h>
|
41
41
|
|
42
|
+
#include "src/core/lib/channel/channel_args.h"
|
42
43
|
#include "src/core/lib/iomgr/executor.h"
|
43
44
|
#include "src/core/lib/support/string.h"
|
44
45
|
|
45
46
|
/* -- Fake transport security credentials. -- */
|
46
47
|
|
48
|
+
#define GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS \
|
49
|
+
"grpc.fake_security.expected_targets"
|
50
|
+
|
47
51
|
static grpc_security_status fake_transport_security_create_security_connector(
|
48
52
|
grpc_exec_ctx *exec_ctx, grpc_channel_credentials *c,
|
49
53
|
grpc_call_credentials *call_creds, const char *target,
|
@@ -88,6 +92,25 @@ grpc_server_credentials *grpc_fake_transport_security_server_credentials_create(
|
|
88
92
|
return c;
|
89
93
|
}
|
90
94
|
|
95
|
+
grpc_arg grpc_fake_transport_expected_targets_arg(char *expected_targets) {
|
96
|
+
grpc_arg arg;
|
97
|
+
arg.type = GRPC_ARG_STRING;
|
98
|
+
arg.key = GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS;
|
99
|
+
arg.value.string = expected_targets;
|
100
|
+
return arg;
|
101
|
+
}
|
102
|
+
|
103
|
+
const char *grpc_fake_transport_get_expected_targets(
|
104
|
+
const grpc_channel_args *args) {
|
105
|
+
const grpc_arg *expected_target_arg =
|
106
|
+
grpc_channel_args_find(args, GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS);
|
107
|
+
if (expected_target_arg != NULL &&
|
108
|
+
expected_target_arg->type == GRPC_ARG_STRING) {
|
109
|
+
return expected_target_arg->value.string;
|
110
|
+
}
|
111
|
+
return NULL;
|
112
|
+
}
|
113
|
+
|
91
114
|
/* -- Metadata-only test credentials. -- */
|
92
115
|
|
93
116
|
static void md_only_test_destruct(grpc_exec_ctx *exec_ctx,
|
@@ -38,10 +38,17 @@
|
|
38
38
|
|
39
39
|
/* -- Fake transport security credentials. -- */
|
40
40
|
|
41
|
+
/* Creates a fake transport security credentials object for testing. */
|
42
|
+
grpc_channel_credentials *grpc_fake_transport_security_credentials_create(void);
|
43
|
+
|
44
|
+
/* Creates a fake server transport security credentials object for testing. */
|
45
|
+
grpc_server_credentials *grpc_fake_transport_security_server_credentials_create(
|
46
|
+
void);
|
47
|
+
|
41
48
|
/* Used to verify the target names given to the fake transport security
|
42
49
|
* connector.
|
43
50
|
*
|
44
|
-
*
|
51
|
+
* The syntax of \a expected_targets by example:
|
45
52
|
* For LB channels:
|
46
53
|
* "backend_target_1,backend_target_2,...;lb_target_1,lb_target_2,..."
|
47
54
|
* For regular channels:
|
@@ -50,15 +57,11 @@
|
|
50
57
|
* That is to say, LB channels have a heading list of LB targets separated from
|
51
58
|
* the list of backend targets by a semicolon. For non-LB channels, only the
|
52
59
|
* latter is present. */
|
53
|
-
|
54
|
-
"grpc.test_only.fake_security.expected_target"
|
60
|
+
grpc_arg grpc_fake_transport_expected_targets_arg(char *expected_targets);
|
55
61
|
|
56
|
-
/*
|
57
|
-
|
58
|
-
|
59
|
-
/* Creates a fake server transport security credentials object for testing. */
|
60
|
-
grpc_server_credentials *grpc_fake_transport_security_server_credentials_create(
|
61
|
-
void);
|
62
|
+
/* Return the value associated with the expected targets channel arg or NULL */
|
63
|
+
const char *grpc_fake_transport_get_expected_targets(
|
64
|
+
const grpc_channel_args *args);
|
62
65
|
|
63
66
|
/* -- Metadata-only Test credentials. -- */
|
64
67
|
|
@@ -99,7 +99,7 @@ static void on_compute_engine_detection_http_response(grpc_exec_ctx *exec_ctx,
|
|
99
99
|
}
|
100
100
|
|
101
101
|
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, grpc_error *e) {
|
102
|
-
grpc_pollset_destroy(p);
|
102
|
+
grpc_pollset_destroy(exec_ctx, p);
|
103
103
|
}
|
104
104
|
|
105
105
|
static int is_stack_running_on_compute_engine(grpc_exec_ctx *exec_ctx) {
|
@@ -171,7 +171,7 @@ static char *redact_private_key(const char *json_key) {
|
|
171
171
|
|
172
172
|
grpc_call_credentials *grpc_service_account_jwt_access_credentials_create(
|
173
173
|
const char *json_key, gpr_timespec token_lifetime, void *reserved) {
|
174
|
-
if (grpc_api_trace) {
|
174
|
+
if (GRPC_TRACER_ON(grpc_api_trace)) {
|
175
175
|
char *clean_json = redact_private_key(json_key);
|
176
176
|
gpr_log(GPR_INFO,
|
177
177
|
"grpc_service_account_jwt_access_credentials_create("
|
@@ -412,7 +412,7 @@ grpc_call_credentials *grpc_google_refresh_token_credentials_create(
|
|
412
412
|
const char *json_refresh_token, void *reserved) {
|
413
413
|
grpc_auth_refresh_token token =
|
414
414
|
grpc_auth_refresh_token_create_from_string(json_refresh_token);
|
415
|
-
if (grpc_api_trace) {
|
415
|
+
if (GRPC_TRACER_ON(grpc_api_trace)) {
|
416
416
|
char *loggable_token = create_loggable_refresh_token(&token);
|
417
417
|
gpr_log(GPR_INFO,
|
418
418
|
"grpc_refresh_token_credentials_create(json_refresh_token=%s, "
|
@@ -36,33 +36,28 @@
|
|
36
36
|
#include <string.h>
|
37
37
|
|
38
38
|
#include "src/core/lib/channel/channel_args.h"
|
39
|
-
#include "src/core/lib/channel/http_client_filter.h"
|
40
39
|
#include "src/core/lib/surface/api_trace.h"
|
41
40
|
|
42
41
|
#include <grpc/support/alloc.h>
|
43
42
|
#include <grpc/support/log.h>
|
43
|
+
#include <grpc/support/string_util.h>
|
44
44
|
|
45
45
|
//
|
46
|
-
//
|
46
|
+
// SSL Channel Credentials.
|
47
47
|
//
|
48
48
|
|
49
|
-
static void
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
static void ssl_config_pem_key_cert_pair_destroy(
|
50
|
+
tsi_ssl_pem_key_cert_pair *kp) {
|
51
|
+
if (kp == NULL) return;
|
52
|
+
gpr_free((void *)kp->private_key);
|
53
|
+
gpr_free((void *)kp->cert_chain);
|
54
54
|
}
|
55
55
|
|
56
|
-
//
|
57
|
-
// SSL Channel Credentials.
|
58
|
-
//
|
59
|
-
|
60
56
|
static void ssl_destruct(grpc_exec_ctx *exec_ctx,
|
61
57
|
grpc_channel_credentials *creds) {
|
62
58
|
grpc_ssl_credentials *c = (grpc_ssl_credentials *)creds;
|
63
|
-
|
64
|
-
|
65
|
-
if (c->config.pem_cert_chain != NULL) gpr_free(c->config.pem_cert_chain);
|
59
|
+
gpr_free(c->config.pem_root_certs);
|
60
|
+
ssl_config_pem_key_cert_pair_destroy(&c->config.pem_key_cert_pair);
|
66
61
|
}
|
67
62
|
|
68
63
|
static grpc_security_status ssl_create_security_connector(
|
@@ -103,18 +98,15 @@ static void ssl_build_config(const char *pem_root_certs,
|
|
103
98
|
grpc_ssl_pem_key_cert_pair *pem_key_cert_pair,
|
104
99
|
grpc_ssl_config *config) {
|
105
100
|
if (pem_root_certs != NULL) {
|
106
|
-
|
107
|
-
&config->pem_root_certs_size);
|
101
|
+
config->pem_root_certs = gpr_strdup(pem_root_certs);
|
108
102
|
}
|
109
103
|
if (pem_key_cert_pair != NULL) {
|
110
104
|
GPR_ASSERT(pem_key_cert_pair->private_key != NULL);
|
111
105
|
GPR_ASSERT(pem_key_cert_pair->cert_chain != NULL);
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
&config->pem_cert_chain,
|
117
|
-
&config->pem_cert_chain_size);
|
106
|
+
config->pem_key_cert_pair.cert_chain =
|
107
|
+
gpr_strdup(pem_key_cert_pair->cert_chain);
|
108
|
+
config->pem_key_cert_pair.private_key =
|
109
|
+
gpr_strdup(pem_key_cert_pair->private_key);
|
118
110
|
}
|
119
111
|
}
|
120
112
|
|
@@ -144,22 +136,10 @@ static void ssl_server_destruct(grpc_exec_ctx *exec_ctx,
|
|
144
136
|
grpc_ssl_server_credentials *c = (grpc_ssl_server_credentials *)creds;
|
145
137
|
size_t i;
|
146
138
|
for (i = 0; i < c->config.num_key_cert_pairs; i++) {
|
147
|
-
|
148
|
-
gpr_free(c->config.pem_private_keys[i]);
|
149
|
-
}
|
150
|
-
if (c->config.pem_cert_chains[i] != NULL) {
|
151
|
-
gpr_free(c->config.pem_cert_chains[i]);
|
152
|
-
}
|
153
|
-
}
|
154
|
-
if (c->config.pem_private_keys != NULL) gpr_free(c->config.pem_private_keys);
|
155
|
-
if (c->config.pem_private_keys_sizes != NULL) {
|
156
|
-
gpr_free(c->config.pem_private_keys_sizes);
|
157
|
-
}
|
158
|
-
if (c->config.pem_cert_chains != NULL) gpr_free(c->config.pem_cert_chains);
|
159
|
-
if (c->config.pem_cert_chains_sizes != NULL) {
|
160
|
-
gpr_free(c->config.pem_cert_chains_sizes);
|
139
|
+
ssl_config_pem_key_cert_pair_destroy(&c->config.pem_key_cert_pairs[i]);
|
161
140
|
}
|
162
|
-
|
141
|
+
gpr_free(c->config.pem_key_cert_pairs);
|
142
|
+
gpr_free(c->config.pem_root_certs);
|
163
143
|
}
|
164
144
|
|
165
145
|
static grpc_security_status ssl_server_create_security_connector(
|
@@ -180,30 +160,21 @@ static void ssl_build_server_config(
|
|
180
160
|
size_t i;
|
181
161
|
config->client_certificate_request = client_certificate_request;
|
182
162
|
if (pem_root_certs != NULL) {
|
183
|
-
|
184
|
-
&config->pem_root_certs_size);
|
163
|
+
config->pem_root_certs = gpr_strdup(pem_root_certs);
|
185
164
|
}
|
186
165
|
if (num_key_cert_pairs > 0) {
|
187
166
|
GPR_ASSERT(pem_key_cert_pairs != NULL);
|
188
|
-
config->
|
189
|
-
|
190
|
-
config->pem_cert_chains =
|
191
|
-
gpr_malloc(num_key_cert_pairs * sizeof(unsigned char *));
|
192
|
-
config->pem_private_keys_sizes =
|
193
|
-
gpr_malloc(num_key_cert_pairs * sizeof(size_t));
|
194
|
-
config->pem_cert_chains_sizes =
|
195
|
-
gpr_malloc(num_key_cert_pairs * sizeof(size_t));
|
167
|
+
config->pem_key_cert_pairs =
|
168
|
+
gpr_zalloc(num_key_cert_pairs * sizeof(tsi_ssl_pem_key_cert_pair));
|
196
169
|
}
|
197
170
|
config->num_key_cert_pairs = num_key_cert_pairs;
|
198
171
|
for (i = 0; i < num_key_cert_pairs; i++) {
|
199
172
|
GPR_ASSERT(pem_key_cert_pairs[i].private_key != NULL);
|
200
173
|
GPR_ASSERT(pem_key_cert_pairs[i].cert_chain != NULL);
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
&config->pem_cert_chains[i],
|
206
|
-
&config->pem_cert_chains_sizes[i]);
|
174
|
+
config->pem_key_cert_pairs[i].cert_chain =
|
175
|
+
gpr_strdup(pem_key_cert_pairs[i].cert_chain);
|
176
|
+
config->pem_key_cert_pairs[i].private_key =
|
177
|
+
gpr_strdup(pem_key_cert_pairs[i].private_key);
|
207
178
|
}
|
208
179
|
}
|
209
180
|
|
@@ -253,7 +253,7 @@ static void auth_start_transport_op(grpc_exec_ctx *exec_ctx,
|
|
253
253
|
grpc_linked_mdelem *l;
|
254
254
|
grpc_client_security_context *sec_ctx = NULL;
|
255
255
|
|
256
|
-
if (calld->security_context_set == 0
|
256
|
+
if (!op->cancel_stream && calld->security_context_set == 0) {
|
257
257
|
calld->security_context_set = 1;
|
258
258
|
GPR_ASSERT(op->payload->context != NULL);
|
259
259
|
if (op->payload->context[GRPC_CONTEXT_SECURITY].value == NULL) {
|
@@ -343,8 +343,16 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
|
|
343
343
|
grpc_channel_element_args *args) {
|
344
344
|
grpc_security_connector *sc =
|
345
345
|
grpc_security_connector_find_in_args(args->channel_args);
|
346
|
+
if (sc == NULL) {
|
347
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
348
|
+
"Security connector missing from client auth filter args");
|
349
|
+
}
|
346
350
|
grpc_auth_context *auth_context =
|
347
351
|
grpc_find_auth_context_in_args(args->channel_args);
|
352
|
+
if (auth_context == NULL) {
|
353
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
354
|
+
"Auth context missing from client auth filter args");
|
355
|
+
}
|
348
356
|
|
349
357
|
/* grab pointers to our data from the channel element */
|
350
358
|
channel_data *chand = elem->channel_data;
|
@@ -353,8 +361,6 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
|
|
353
361
|
handle the case that there's no 'next' filter to call on the up or down
|
354
362
|
path */
|
355
363
|
GPR_ASSERT(!args->is_last);
|
356
|
-
GPR_ASSERT(sc != NULL);
|
357
|
-
GPR_ASSERT(auth_context != NULL);
|
358
364
|
|
359
365
|
/* initialize members */
|
360
366
|
chand->security_connector =
|