grpc 1.1.2 → 1.2.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 +1257 -404
- data/etc/roots.pem +189 -102
- data/include/grpc/census.h +7 -7
- data/include/grpc/compression.h +4 -4
- data/include/grpc/grpc.h +13 -7
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +26 -9
- data/include/grpc/impl/codegen/grpc_types.h +39 -30
- data/include/grpc/impl/codegen/slice.h +24 -6
- data/include/grpc/impl/codegen/sync.h +8 -0
- data/include/grpc/load_reporting.h +63 -0
- data/include/grpc/slice.h +37 -1
- data/include/grpc/slice_buffer.h +7 -0
- data/include/grpc/support/alloc.h +3 -0
- data/include/grpc/support/useful.h +3 -0
- data/src/core/ext/census/gen/census.pb.h +1 -1
- data/src/core/ext/census/gen/trace_context.pb.c +9 -36
- data/src/core/ext/census/gen/trace_context.pb.h +20 -26
- data/src/core/ext/census/grpc_filter.c +3 -5
- data/src/core/ext/census/trace_context.c +1 -1
- data/src/core/ext/census/trace_context.h +3 -0
- data/src/core/ext/census/trace_label.h +61 -0
- data/src/core/ext/census/trace_propagation.h +63 -0
- data/src/core/ext/census/trace_status.h +45 -0
- data/src/core/ext/census/trace_string.h +50 -0
- data/src/core/ext/census/tracing.c +31 -11
- data/src/core/ext/census/tracing.h +124 -0
- data/src/core/ext/client_channel/client_channel.c +456 -368
- data/src/core/ext/client_channel/client_channel.h +4 -0
- data/src/core/ext/client_channel/client_channel_plugin.c +6 -1
- data/src/core/ext/client_channel/connector.c +3 -3
- data/src/core/ext/client_channel/connector.h +4 -3
- data/src/core/ext/client_channel/http_connect_handshaker.c +62 -72
- data/src/core/ext/client_channel/http_connect_handshaker.h +7 -10
- data/src/core/ext/client_channel/http_proxy.c +125 -0
- data/src/core/ext/client_channel/http_proxy.h +39 -0
- data/src/core/ext/client_channel/lb_policy.c +56 -35
- data/src/core/ext/client_channel/lb_policy.h +46 -39
- data/src/core/ext/client_channel/lb_policy_factory.h +1 -0
- data/src/core/ext/client_channel/parse_address.c +32 -6
- data/src/core/ext/client_channel/proxy_mapper.c +63 -0
- data/src/core/ext/client_channel/proxy_mapper.h +89 -0
- data/src/core/ext/client_channel/proxy_mapper_registry.c +133 -0
- data/src/core/ext/client_channel/proxy_mapper_registry.h +59 -0
- data/src/core/ext/client_channel/resolver.c +16 -9
- data/src/core/ext/client_channel/resolver.h +23 -12
- data/src/core/ext/client_channel/resolver_factory.h +1 -0
- data/src/core/ext/client_channel/resolver_registry.c +15 -11
- data/src/core/ext/client_channel/resolver_registry.h +5 -3
- data/src/core/ext/client_channel/subchannel.c +44 -27
- data/src/core/ext/client_channel/subchannel.h +6 -2
- data/src/core/ext/client_channel/uri_parser.c +26 -14
- data/src/core/ext/client_channel/uri_parser.h +3 -1
- data/src/core/ext/lb_policy/grpclb/grpclb.c +220 -209
- data/src/core/ext/lb_policy/grpclb/grpclb_channel.h +56 -0
- data/src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c +107 -0
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +3 -6
- data/src/core/ext/lb_policy/pick_first/pick_first.c +71 -116
- data/src/core/ext/lb_policy/round_robin/round_robin.c +52 -67
- data/src/core/ext/load_reporting/load_reporting.c +20 -0
- data/src/core/ext/load_reporting/load_reporting.h +1 -16
- data/src/core/ext/load_reporting/load_reporting_filter.c +28 -54
- data/src/core/ext/resolver/dns/native/dns_resolver.c +31 -45
- data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +20 -29
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +11 -8
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +11 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +143 -46
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +12 -50
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +1 -1
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +1 -1
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +7 -7
- data/src/core/ext/transport/chttp2/transport/bin_encoder.c +1 -2
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +1 -2
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +0 -3
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +606 -374
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +17 -5
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +9 -13
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +12 -11
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +5 -6
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +100 -53
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +126 -70
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +13 -7
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +22 -19
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +6 -6
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +23 -11
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +6 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +169 -42
- data/src/core/ext/transport/chttp2/transport/parsing.c +98 -41
- data/src/core/ext/transport/chttp2/transport/stream_lists.c +29 -14
- data/src/core/ext/transport/chttp2/transport/writing.c +137 -15
- data/src/core/lib/channel/channel_stack.c +14 -44
- data/src/core/lib/channel/channel_stack.h +10 -17
- data/src/core/lib/channel/channel_stack_builder.c +2 -3
- data/src/core/lib/channel/compress_filter.c +54 -46
- data/src/core/lib/channel/connected_channel.c +4 -4
- data/src/core/lib/channel/connected_channel.h +5 -0
- data/src/core/lib/channel/context.h +3 -0
- data/src/core/lib/channel/deadline_filter.c +61 -61
- data/src/core/lib/channel/deadline_filter.h +8 -5
- data/src/core/lib/channel/handshaker.c +47 -7
- data/src/core/lib/channel/handshaker.h +21 -3
- data/src/core/lib/channel/http_client_filter.c +149 -99
- data/src/core/lib/channel/http_server_filter.c +163 -147
- data/src/core/lib/channel/message_size_filter.c +15 -10
- data/src/core/lib/compression/algorithm_metadata.h +4 -4
- data/src/core/lib/compression/compression.c +17 -23
- data/src/core/lib/http/httpcli.c +3 -2
- data/src/core/lib/http/httpcli.h +2 -1
- data/src/core/lib/http/httpcli_security_connector.c +2 -3
- data/src/core/lib/http/parser.c +2 -2
- data/src/core/lib/iomgr/closure.c +6 -3
- data/src/core/lib/iomgr/closure.h +4 -2
- data/src/core/lib/iomgr/combiner.c +35 -5
- data/src/core/lib/iomgr/combiner.h +21 -2
- data/src/core/lib/iomgr/endpoint.c +3 -2
- data/src/core/lib/iomgr/endpoint.h +3 -2
- data/src/core/lib/iomgr/error.c +60 -94
- data/src/core/lib/iomgr/error.h +7 -10
- data/src/core/lib/iomgr/error_internal.h +54 -0
- data/src/core/lib/iomgr/ev_epoll_linux.c +253 -109
- data/src/core/lib/iomgr/ev_poll_posix.c +61 -29
- data/src/core/lib/iomgr/ev_posix.c +7 -8
- data/src/core/lib/iomgr/ev_posix.h +4 -4
- data/src/core/lib/iomgr/exec_ctx.c +11 -6
- data/src/core/lib/iomgr/exec_ctx.h +11 -14
- data/src/core/lib/iomgr/executor.c +2 -2
- data/src/core/lib/iomgr/load_file.c +1 -1
- data/src/core/lib/iomgr/network_status_tracker.c +5 -81
- data/src/core/lib/iomgr/pollset.h +1 -3
- data/src/core/lib/iomgr/pollset_set.h +2 -1
- data/src/core/lib/iomgr/pollset_set_uv.c +2 -1
- data/src/core/lib/iomgr/pollset_set_windows.c +2 -1
- data/src/core/lib/iomgr/pollset_uv.c +25 -11
- data/src/core/lib/iomgr/pollset_windows.c +0 -11
- data/src/core/lib/iomgr/resolve_address_uv.c +50 -2
- data/src/core/lib/iomgr/resource_quota.c +41 -11
- data/src/core/lib/iomgr/resource_quota.h +6 -0
- data/src/core/lib/iomgr/sockaddr_utils.c +33 -17
- data/src/core/lib/iomgr/sockaddr_utils.h +4 -0
- data/src/core/lib/iomgr/tcp_client_posix.c +2 -3
- data/src/core/lib/iomgr/tcp_client_uv.c +1 -3
- data/src/core/lib/iomgr/tcp_client_windows.c +21 -6
- data/src/core/lib/iomgr/tcp_posix.c +4 -5
- data/src/core/lib/iomgr/tcp_server_posix.c +269 -94
- data/src/core/lib/iomgr/tcp_server_windows.c +1 -1
- data/src/core/lib/iomgr/tcp_uv.c +11 -5
- data/src/core/lib/iomgr/tcp_windows.c +20 -7
- data/src/core/lib/iomgr/timer_generic.c +15 -22
- data/src/core/lib/iomgr/timer_generic.h +1 -1
- data/src/core/lib/iomgr/timer_uv.c +10 -6
- data/src/core/lib/iomgr/timer_uv.h +1 -1
- data/src/core/lib/iomgr/udp_server.c +45 -6
- data/src/core/lib/iomgr/udp_server.h +7 -1
- data/src/core/lib/iomgr/unix_sockets_posix.c +11 -1
- data/src/core/lib/json/json.c +1 -2
- data/src/core/lib/profiling/basic_timers.c +17 -3
- data/src/core/lib/security/context/security_context.c +3 -10
- data/src/core/lib/security/credentials/composite/composite_credentials.c +4 -8
- data/src/core/lib/security/credentials/credentials.c +48 -2
- data/src/core/lib/security/credentials/credentials.h +13 -0
- data/src/core/lib/security/credentials/credentials_metadata.c +1 -2
- data/src/core/lib/security/credentials/fake/fake_credentials.c +6 -8
- data/src/core/lib/security/credentials/fake/fake_credentials.h +15 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +3 -3
- data/src/core/lib/security/credentials/iam/iam_credentials.c +1 -2
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +1 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +5 -8
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +3 -5
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +15 -13
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +2 -4
- data/src/core/lib/security/transport/client_auth_filter.c +72 -47
- data/src/core/lib/security/transport/lb_targets_info.c +70 -0
- data/src/core/lib/security/transport/lb_targets_info.h +47 -0
- data/src/core/lib/security/transport/secure_endpoint.c +3 -3
- data/src/core/lib/security/transport/security_connector.c +125 -28
- data/src/core/lib/security/transport/security_connector.h +4 -3
- data/src/core/lib/security/transport/security_handshaker.c +13 -9
- data/src/core/lib/security/transport/server_auth_filter.c +31 -40
- data/src/core/lib/security/util/b64.c +1 -1
- data/src/core/lib/slice/slice.c +110 -20
- data/src/core/lib/slice/slice_buffer.c +92 -39
- data/src/core/lib/{transport/mdstr_hash_table.c → slice/slice_hash_table.c} +40 -33
- data/src/core/lib/{transport/mdstr_hash_table.h → slice/slice_hash_table.h} +21 -21
- data/src/core/lib/slice/slice_intern.c +346 -0
- data/src/core/lib/slice/slice_internal.h +15 -0
- data/src/core/lib/slice/slice_string_helpers.c +5 -0
- data/src/core/lib/slice/slice_string_helpers.h +5 -0
- data/src/core/lib/support/alloc.c +26 -1
- data/src/core/lib/support/cmdline.c +2 -4
- data/src/core/lib/support/cpu_posix.c +2 -7
- data/src/core/lib/support/histogram.c +1 -2
- data/src/core/lib/support/log_posix.c +8 -4
- data/src/core/lib/support/spinlock.h +52 -0
- data/src/core/lib/support/subprocess_posix.c +1 -2
- data/src/core/lib/support/sync.c +7 -1
- data/src/core/lib/support/sync_posix.c +9 -0
- data/src/core/lib/support/time_windows.c +7 -1
- data/src/core/lib/surface/call.c +647 -629
- data/src/core/lib/surface/call.h +4 -1
- data/src/core/lib/surface/call_details.c +8 -2
- data/src/core/lib/surface/call_log_batch.c +17 -6
- data/src/core/lib/surface/channel.c +49 -59
- data/src/core/lib/surface/channel.h +5 -6
- data/src/core/lib/surface/completion_queue.c +16 -45
- data/src/core/lib/surface/completion_queue.h +0 -3
- data/src/core/lib/surface/init.c +6 -2
- data/src/core/lib/surface/init_secure.c +1 -1
- data/src/core/lib/surface/lame_client.c +14 -4
- data/src/core/lib/surface/server.c +79 -82
- data/src/core/lib/surface/validate_metadata.c +46 -15
- data/src/core/lib/surface/validate_metadata.h +43 -0
- data/src/core/lib/surface/version.c +2 -2
- data/src/core/lib/transport/bdp_estimator.c +104 -0
- data/src/core/lib/transport/bdp_estimator.h +76 -0
- data/src/core/lib/transport/connectivity_state.c +33 -13
- data/src/core/lib/transport/connectivity_state.h +15 -5
- data/src/core/lib/transport/error_utils.c +124 -0
- data/src/core/lib/transport/error_utils.h +56 -0
- data/src/core/{ext/transport/chttp2 → lib}/transport/http2_errors.h +18 -18
- data/src/core/lib/transport/metadata.c +259 -503
- data/src/core/lib/transport/metadata.h +69 -68
- data/src/core/lib/transport/metadata_batch.c +183 -63
- data/src/core/lib/transport/metadata_batch.h +50 -26
- data/src/core/lib/transport/pid_controller.c +28 -8
- data/src/core/lib/transport/pid_controller.h +15 -2
- data/src/core/lib/transport/service_config.c +21 -18
- data/src/core/lib/transport/service_config.h +5 -5
- data/src/core/lib/transport/static_metadata.c +753 -112
- data/src/core/lib/transport/static_metadata.h +403 -264
- data/src/core/{ext/transport/chttp2 → lib}/transport/status_conversion.c +18 -20
- data/src/core/{ext/transport/chttp2 → lib}/transport/status_conversion.h +9 -10
- data/src/core/lib/transport/timeout_encoding.c +11 -9
- data/src/core/lib/transport/timeout_encoding.h +3 -1
- data/src/core/lib/transport/transport.c +47 -87
- data/src/core/lib/transport/transport.h +20 -25
- data/src/core/lib/transport/transport_op_string.c +7 -19
- data/src/core/lib/tsi/fake_transport_security.c +2 -4
- data/src/core/lib/tsi/ssl_transport_security.c +7 -16
- data/src/core/lib/tsi/transport_security.c +2 -4
- data/src/ruby/ext/grpc/extconf.rb +4 -1
- data/src/ruby/ext/grpc/rb_byte_buffer.c +7 -0
- data/src/ruby/ext/grpc/rb_byte_buffer.h +3 -0
- data/src/ruby/ext/grpc/rb_call.c +47 -46
- data/src/ruby/ext/grpc/rb_channel.c +21 -6
- data/src/ruby/ext/grpc/rb_compression_options.c +9 -6
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +36 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +59 -8
- data/src/ruby/ext/grpc/rb_server.c +6 -4
- data/src/ruby/lib/grpc/generic/client_stub.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- metadata +33 -9
@@ -45,6 +45,7 @@
|
|
45
45
|
|
46
46
|
#include <grpc/support/alloc.h>
|
47
47
|
#include <grpc/support/log.h>
|
48
|
+
#include <grpc/support/useful.h>
|
48
49
|
|
49
50
|
void grpc_create_socketpair_if_unix(int sv[2]) {
|
50
51
|
GPR_ASSERT(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0);
|
@@ -53,7 +54,16 @@ void grpc_create_socketpair_if_unix(int sv[2]) {
|
|
53
54
|
grpc_error *grpc_resolve_unix_domain_address(const char *name,
|
54
55
|
grpc_resolved_addresses **addrs) {
|
55
56
|
struct sockaddr_un *un;
|
56
|
-
|
57
|
+
if (strlen(name) > GPR_ARRAY_SIZE(((struct sockaddr_un *)0)->sun_path) - 1) {
|
58
|
+
char *err_msg;
|
59
|
+
grpc_error *err;
|
60
|
+
gpr_asprintf(&err_msg,
|
61
|
+
"Path name should not have more than %" PRIuPTR " characters.",
|
62
|
+
GPR_ARRAY_SIZE(un->sun_path) - 1);
|
63
|
+
err = GRPC_ERROR_CREATE(err_msg);
|
64
|
+
gpr_free(err_msg);
|
65
|
+
return err;
|
66
|
+
}
|
57
67
|
*addrs = gpr_malloc(sizeof(grpc_resolved_addresses));
|
58
68
|
(*addrs)->naddrs = 1;
|
59
69
|
(*addrs)->addrs = gpr_malloc(sizeof(grpc_resolved_address));
|
data/src/core/lib/json/json.c
CHANGED
@@ -38,8 +38,7 @@
|
|
38
38
|
#include "src/core/lib/json/json.h"
|
39
39
|
|
40
40
|
grpc_json* grpc_json_create(grpc_json_type type) {
|
41
|
-
grpc_json* json =
|
42
|
-
memset(json, 0, sizeof(*json));
|
41
|
+
grpc_json* json = gpr_zalloc(sizeof(*json));
|
43
42
|
json->type = type;
|
44
43
|
|
45
44
|
return json;
|
@@ -43,6 +43,9 @@
|
|
43
43
|
#include <grpc/support/thd.h>
|
44
44
|
#include <grpc/support/time.h>
|
45
45
|
#include <stdio.h>
|
46
|
+
#include <string.h>
|
47
|
+
|
48
|
+
#include "src/core/lib/support/env.h"
|
46
49
|
|
47
50
|
typedef enum { BEGIN = '{', END = '}', MARK = '.' } marker_type;
|
48
51
|
|
@@ -74,7 +77,7 @@ typedef struct gpr_timer_log_list {
|
|
74
77
|
static __thread gpr_timer_log *g_thread_log;
|
75
78
|
static gpr_once g_once_init = GPR_ONCE_INIT;
|
76
79
|
static FILE *output_file;
|
77
|
-
static const char *
|
80
|
+
static const char *output_filename_or_null = NULL;
|
78
81
|
static pthread_mutex_t g_mu;
|
79
82
|
static pthread_cond_t g_cv;
|
80
83
|
static gpr_timer_log_list g_in_progress_logs;
|
@@ -85,6 +88,17 @@ static __thread int g_thread_id;
|
|
85
88
|
static int g_next_thread_id;
|
86
89
|
static int g_writing_enabled = 1;
|
87
90
|
|
91
|
+
static const char *output_filename() {
|
92
|
+
if (output_filename_or_null == NULL) {
|
93
|
+
output_filename_or_null = gpr_getenv("LATENCY_TRACE");
|
94
|
+
if (output_filename_or_null == NULL ||
|
95
|
+
strlen(output_filename_or_null) == 0) {
|
96
|
+
output_filename_or_null = "latency_trace.txt";
|
97
|
+
}
|
98
|
+
}
|
99
|
+
return output_filename_or_null;
|
100
|
+
}
|
101
|
+
|
88
102
|
static int timer_log_push_back(gpr_timer_log_list *list, gpr_timer_log *log) {
|
89
103
|
if (list->head == NULL) {
|
90
104
|
list->head = list->tail = log;
|
@@ -134,7 +148,7 @@ static void timer_log_remove(gpr_timer_log_list *list, gpr_timer_log *log) {
|
|
134
148
|
static void write_log(gpr_timer_log *log) {
|
135
149
|
size_t i;
|
136
150
|
if (output_file == NULL) {
|
137
|
-
output_file = fopen(output_filename, "w");
|
151
|
+
output_file = fopen(output_filename(), "w");
|
138
152
|
}
|
139
153
|
for (i = 0; i < log->num_entries; i++) {
|
140
154
|
gpr_timer_entry *entry = &(log->log[i]);
|
@@ -198,7 +212,7 @@ static void finish_writing(void) {
|
|
198
212
|
}
|
199
213
|
|
200
214
|
void gpr_timers_set_log_filename(const char *filename) {
|
201
|
-
|
215
|
+
output_filename_or_null = filename;
|
202
216
|
}
|
203
217
|
|
204
218
|
static void init_output() {
|
@@ -91,10 +91,7 @@ void grpc_auth_context_release(grpc_auth_context *context) {
|
|
91
91
|
/* --- grpc_client_security_context --- */
|
92
92
|
|
93
93
|
grpc_client_security_context *grpc_client_security_context_create(void) {
|
94
|
-
grpc_client_security_context
|
95
|
-
gpr_malloc(sizeof(grpc_client_security_context));
|
96
|
-
memset(ctx, 0, sizeof(grpc_client_security_context));
|
97
|
-
return ctx;
|
94
|
+
return gpr_zalloc(sizeof(grpc_client_security_context));
|
98
95
|
}
|
99
96
|
|
100
97
|
void grpc_client_security_context_destroy(void *ctx) {
|
@@ -112,10 +109,7 @@ void grpc_client_security_context_destroy(void *ctx) {
|
|
112
109
|
/* --- grpc_server_security_context --- */
|
113
110
|
|
114
111
|
grpc_server_security_context *grpc_server_security_context_create(void) {
|
115
|
-
grpc_server_security_context
|
116
|
-
gpr_malloc(sizeof(grpc_server_security_context));
|
117
|
-
memset(ctx, 0, sizeof(grpc_server_security_context));
|
118
|
-
return ctx;
|
112
|
+
return gpr_zalloc(sizeof(grpc_server_security_context));
|
119
113
|
}
|
120
114
|
|
121
115
|
void grpc_server_security_context_destroy(void *ctx) {
|
@@ -132,8 +126,7 @@ void grpc_server_security_context_destroy(void *ctx) {
|
|
132
126
|
static grpc_auth_property_iterator empty_iterator = {NULL, 0, NULL};
|
133
127
|
|
134
128
|
grpc_auth_context *grpc_auth_context_create(grpc_auth_context *chained) {
|
135
|
-
grpc_auth_context *ctx =
|
136
|
-
memset(ctx, 0, sizeof(grpc_auth_context));
|
129
|
+
grpc_auth_context *ctx = gpr_zalloc(sizeof(grpc_auth_context));
|
137
130
|
gpr_ref_init(&ctx->refcount, 1);
|
138
131
|
if (chained != NULL) {
|
139
132
|
ctx->chained = GRPC_AUTH_CONTEXT_REF(chained, "chained");
|
@@ -115,8 +115,7 @@ static void composite_call_get_request_metadata(
|
|
115
115
|
grpc_composite_call_credentials *c = (grpc_composite_call_credentials *)creds;
|
116
116
|
grpc_composite_call_credentials_metadata_context *ctx;
|
117
117
|
|
118
|
-
ctx =
|
119
|
-
memset(ctx, 0, sizeof(grpc_composite_call_credentials_metadata_context));
|
118
|
+
ctx = gpr_zalloc(sizeof(grpc_composite_call_credentials_metadata_context));
|
120
119
|
ctx->auth_md_context = auth_md_context;
|
121
120
|
ctx->user_data = user_data;
|
122
121
|
ctx->cb = cb;
|
@@ -158,8 +157,7 @@ grpc_call_credentials *grpc_composite_call_credentials_create(
|
|
158
157
|
GPR_ASSERT(reserved == NULL);
|
159
158
|
GPR_ASSERT(creds1 != NULL);
|
160
159
|
GPR_ASSERT(creds2 != NULL);
|
161
|
-
c =
|
162
|
-
memset(c, 0, sizeof(grpc_composite_call_credentials));
|
160
|
+
c = gpr_zalloc(sizeof(grpc_composite_call_credentials));
|
163
161
|
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE;
|
164
162
|
c->base.vtable = &composite_call_credentials_vtable;
|
165
163
|
gpr_ref_init(&c->base.refcount, 1);
|
@@ -167,8 +165,7 @@ grpc_call_credentials *grpc_composite_call_credentials_create(
|
|
167
165
|
creds2_array = get_creds_array(&creds2);
|
168
166
|
c->inner.num_creds = creds1_array.num_creds + creds2_array.num_creds;
|
169
167
|
creds_array_byte_size = c->inner.num_creds * sizeof(grpc_call_credentials *);
|
170
|
-
c->inner.creds_array =
|
171
|
-
memset(c->inner.creds_array, 0, creds_array_byte_size);
|
168
|
+
c->inner.creds_array = gpr_zalloc(creds_array_byte_size);
|
172
169
|
for (i = 0; i < creds1_array.num_creds; i++) {
|
173
170
|
grpc_call_credentials *cur_creds = creds1_array.creds_array[i];
|
174
171
|
c->inner.creds_array[i] = grpc_call_credentials_ref(cur_creds);
|
@@ -262,8 +259,7 @@ static grpc_channel_credentials_vtable composite_channel_credentials_vtable = {
|
|
262
259
|
grpc_channel_credentials *grpc_composite_channel_credentials_create(
|
263
260
|
grpc_channel_credentials *channel_creds, grpc_call_credentials *call_creds,
|
264
261
|
void *reserved) {
|
265
|
-
grpc_composite_channel_credentials *c =
|
266
|
-
memset(c, 0, sizeof(*c));
|
262
|
+
grpc_composite_channel_credentials *c = gpr_zalloc(sizeof(*c));
|
267
263
|
GPR_ASSERT(channel_creds != NULL && call_creds != NULL && reserved == NULL);
|
268
264
|
GRPC_API_TRACE(
|
269
265
|
"grpc_composite_channel_credentials_create(channel_creds=%p, "
|
@@ -57,8 +57,7 @@ grpc_credentials_metadata_request *grpc_credentials_metadata_request_create(
|
|
57
57
|
grpc_call_credentials *creds, grpc_credentials_metadata_cb cb,
|
58
58
|
void *user_data) {
|
59
59
|
grpc_credentials_metadata_request *r =
|
60
|
-
|
61
|
-
memset(&r->response, 0, sizeof(r->response));
|
60
|
+
gpr_zalloc(sizeof(grpc_credentials_metadata_request));
|
62
61
|
r->creds = grpc_call_credentials_ref(creds);
|
63
62
|
r->cb = cb;
|
64
63
|
r->user_data = user_data;
|
@@ -160,6 +159,53 @@ grpc_channel_credentials_duplicate_without_call_credentials(
|
|
160
159
|
}
|
161
160
|
}
|
162
161
|
|
162
|
+
static void credentials_pointer_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) {
|
163
|
+
grpc_channel_credentials_unref(exec_ctx, p);
|
164
|
+
}
|
165
|
+
|
166
|
+
static void *credentials_pointer_arg_copy(void *p) {
|
167
|
+
return grpc_channel_credentials_ref(p);
|
168
|
+
}
|
169
|
+
|
170
|
+
static int credentials_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); }
|
171
|
+
|
172
|
+
static const grpc_arg_pointer_vtable credentials_pointer_vtable = {
|
173
|
+
credentials_pointer_arg_copy, credentials_pointer_arg_destroy,
|
174
|
+
credentials_pointer_cmp};
|
175
|
+
|
176
|
+
grpc_arg grpc_channel_credentials_to_arg(
|
177
|
+
grpc_channel_credentials *credentials) {
|
178
|
+
grpc_arg result;
|
179
|
+
result.type = GRPC_ARG_POINTER;
|
180
|
+
result.key = GRPC_ARG_CHANNEL_CREDENTIALS;
|
181
|
+
result.value.pointer.vtable = &credentials_pointer_vtable;
|
182
|
+
result.value.pointer.p = credentials;
|
183
|
+
return result;
|
184
|
+
}
|
185
|
+
|
186
|
+
grpc_channel_credentials *grpc_channel_credentials_from_arg(
|
187
|
+
const grpc_arg *arg) {
|
188
|
+
if (strcmp(arg->key, GRPC_ARG_CHANNEL_CREDENTIALS)) return NULL;
|
189
|
+
if (arg->type != GRPC_ARG_POINTER) {
|
190
|
+
gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type,
|
191
|
+
GRPC_ARG_CHANNEL_CREDENTIALS);
|
192
|
+
return NULL;
|
193
|
+
}
|
194
|
+
return arg->value.pointer.p;
|
195
|
+
}
|
196
|
+
|
197
|
+
grpc_channel_credentials *grpc_channel_credentials_find_in_args(
|
198
|
+
const grpc_channel_args *args) {
|
199
|
+
size_t i;
|
200
|
+
if (args == NULL) return NULL;
|
201
|
+
for (i = 0; i < args->num_args; i++) {
|
202
|
+
grpc_channel_credentials *credentials =
|
203
|
+
grpc_channel_credentials_from_arg(&args->args[i]);
|
204
|
+
if (credentials != NULL) return credentials;
|
205
|
+
}
|
206
|
+
return NULL;
|
207
|
+
}
|
208
|
+
|
163
209
|
grpc_server_credentials *grpc_server_credentials_ref(
|
164
210
|
grpc_server_credentials *creds) {
|
165
211
|
if (creds == NULL) return NULL;
|
@@ -100,6 +100,8 @@ void grpc_override_well_known_credentials_path_getter(
|
|
100
100
|
|
101
101
|
/* --- grpc_channel_credentials. --- */
|
102
102
|
|
103
|
+
#define GRPC_ARG_CHANNEL_CREDENTIALS "grpc.channel_credentials"
|
104
|
+
|
103
105
|
typedef struct {
|
104
106
|
void (*destruct)(grpc_exec_ctx *exec_ctx, grpc_channel_credentials *c);
|
105
107
|
|
@@ -140,6 +142,17 @@ grpc_channel_credentials *
|
|
140
142
|
grpc_channel_credentials_duplicate_without_call_credentials(
|
141
143
|
grpc_channel_credentials *creds);
|
142
144
|
|
145
|
+
/* Util to encapsulate the channel credentials in a channel arg. */
|
146
|
+
grpc_arg grpc_channel_credentials_to_arg(grpc_channel_credentials *credentials);
|
147
|
+
|
148
|
+
/* Util to get the channel credentials from a channel arg. */
|
149
|
+
grpc_channel_credentials *grpc_channel_credentials_from_arg(
|
150
|
+
const grpc_arg *arg);
|
151
|
+
|
152
|
+
/* Util to find the channel credentials from channel args. */
|
153
|
+
grpc_channel_credentials *grpc_channel_credentials_find_in_args(
|
154
|
+
const grpc_channel_args *args);
|
155
|
+
|
143
156
|
/* --- grpc_credentials_md. --- */
|
144
157
|
|
145
158
|
typedef struct {
|
@@ -50,8 +50,7 @@ static void store_ensure_capacity(grpc_credentials_md_store *store) {
|
|
50
50
|
grpc_credentials_md_store *grpc_credentials_md_store_create(
|
51
51
|
size_t initial_capacity) {
|
52
52
|
grpc_credentials_md_store *store =
|
53
|
-
|
54
|
-
memset(store, 0, sizeof(grpc_credentials_md_store));
|
53
|
+
gpr_zalloc(sizeof(grpc_credentials_md_store));
|
55
54
|
if (initial_capacity > 0) {
|
56
55
|
store->entries = gpr_malloc(initial_capacity * sizeof(grpc_credentials_md));
|
57
56
|
store->allocated = initial_capacity;
|
@@ -35,13 +35,13 @@
|
|
35
35
|
|
36
36
|
#include <string.h>
|
37
37
|
|
38
|
-
#include "src/core/lib/channel/channel_args.h"
|
39
|
-
#include "src/core/lib/iomgr/executor.h"
|
40
|
-
|
41
38
|
#include <grpc/support/alloc.h>
|
42
39
|
#include <grpc/support/log.h>
|
43
40
|
#include <grpc/support/string_util.h>
|
44
41
|
|
42
|
+
#include "src/core/lib/iomgr/executor.h"
|
43
|
+
#include "src/core/lib/support/string.h"
|
44
|
+
|
45
45
|
/* -- Fake transport security credentials. -- */
|
46
46
|
|
47
47
|
static grpc_security_status fake_transport_security_create_security_connector(
|
@@ -49,7 +49,7 @@ static grpc_security_status fake_transport_security_create_security_connector(
|
|
49
49
|
grpc_call_credentials *call_creds, const char *target,
|
50
50
|
const grpc_channel_args *args, grpc_channel_security_connector **sc,
|
51
51
|
grpc_channel_args **new_args) {
|
52
|
-
*sc = grpc_fake_channel_security_connector_create(call_creds);
|
52
|
+
*sc = grpc_fake_channel_security_connector_create(call_creds, target, args);
|
53
53
|
return GRPC_SECURITY_OK;
|
54
54
|
}
|
55
55
|
|
@@ -71,8 +71,7 @@ static grpc_server_credentials_vtable
|
|
71
71
|
|
72
72
|
grpc_channel_credentials *grpc_fake_transport_security_credentials_create(
|
73
73
|
void) {
|
74
|
-
grpc_channel_credentials *c =
|
75
|
-
memset(c, 0, sizeof(grpc_channel_credentials));
|
74
|
+
grpc_channel_credentials *c = gpr_zalloc(sizeof(grpc_channel_credentials));
|
76
75
|
c->type = GRPC_CHANNEL_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY;
|
77
76
|
c->vtable = &fake_transport_security_credentials_vtable;
|
78
77
|
gpr_ref_init(&c->refcount, 1);
|
@@ -131,8 +130,7 @@ static grpc_call_credentials_vtable md_only_test_vtable = {
|
|
131
130
|
grpc_call_credentials *grpc_md_only_test_credentials_create(
|
132
131
|
const char *md_key, const char *md_value, int is_async) {
|
133
132
|
grpc_md_only_test_credentials *c =
|
134
|
-
|
135
|
-
memset(c, 0, sizeof(grpc_md_only_test_credentials));
|
133
|
+
gpr_zalloc(sizeof(grpc_md_only_test_credentials));
|
136
134
|
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_OAUTH2;
|
137
135
|
c->base.vtable = &md_only_test_vtable;
|
138
136
|
gpr_ref_init(&c->base.refcount, 1);
|
@@ -38,6 +38,21 @@
|
|
38
38
|
|
39
39
|
/* -- Fake transport security credentials. -- */
|
40
40
|
|
41
|
+
/* Used to verify the target names given to the fake transport security
|
42
|
+
* connector.
|
43
|
+
*
|
44
|
+
* Its syntax by example:
|
45
|
+
* For LB channels:
|
46
|
+
* "backend_target_1,backend_target_2,...;lb_target_1,lb_target_2,..."
|
47
|
+
* For regular channels:
|
48
|
+
* "backend_taget_1,backend_target_2,..."
|
49
|
+
*
|
50
|
+
* That is to say, LB channels have a heading list of LB targets separated from
|
51
|
+
* the list of backend targets by a semicolon. For non-LB channels, only the
|
52
|
+
* latter is present. */
|
53
|
+
#define GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS \
|
54
|
+
"grpc.test_only.fake_security.expected_target"
|
55
|
+
|
41
56
|
/* Creates a fake transport security credentials object for testing. */
|
42
57
|
grpc_channel_credentials *grpc_fake_transport_security_credentials_create(void);
|
43
58
|
|
@@ -112,7 +112,7 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx *exec_ctx) {
|
|
112
112
|
on compute engine. */
|
113
113
|
gpr_timespec max_detection_delay = gpr_time_from_seconds(1, GPR_TIMESPAN);
|
114
114
|
|
115
|
-
grpc_pollset *pollset =
|
115
|
+
grpc_pollset *pollset = gpr_zalloc(grpc_pollset_size());
|
116
116
|
grpc_pollset_init(pollset, &g_polling_mu);
|
117
117
|
detector.pollent = grpc_polling_entity_create_from_pollset(pollset);
|
118
118
|
detector.is_done = 0;
|
@@ -154,7 +154,7 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx *exec_ctx) {
|
|
154
154
|
}
|
155
155
|
gpr_mu_unlock(g_polling_mu);
|
156
156
|
|
157
|
-
grpc_httpcli_context_destroy(&context);
|
157
|
+
grpc_httpcli_context_destroy(exec_ctx, &context);
|
158
158
|
grpc_closure_init(&destroy_closure, destroy_pollset,
|
159
159
|
grpc_polling_entity_pollset(&detector.pollent),
|
160
160
|
grpc_schedule_on_exec_ctx);
|
@@ -177,7 +177,7 @@ static grpc_error *create_default_creds_from_path(
|
|
177
177
|
grpc_auth_json_key key;
|
178
178
|
grpc_auth_refresh_token token;
|
179
179
|
grpc_call_credentials *result = NULL;
|
180
|
-
grpc_slice creds_data =
|
180
|
+
grpc_slice creds_data = grpc_empty_slice();
|
181
181
|
grpc_error *error = GRPC_ERROR_NONE;
|
182
182
|
if (creds_path == NULL) {
|
183
183
|
error = GRPC_ERROR_CREATE("creds_path unset");
|
@@ -72,8 +72,7 @@ grpc_call_credentials *grpc_google_iam_credentials_create(
|
|
72
72
|
GPR_ASSERT(reserved == NULL);
|
73
73
|
GPR_ASSERT(token != NULL);
|
74
74
|
GPR_ASSERT(authority_selector != NULL);
|
75
|
-
c =
|
76
|
-
memset(c, 0, sizeof(grpc_google_iam_credentials));
|
75
|
+
c = gpr_zalloc(sizeof(grpc_google_iam_credentials));
|
77
76
|
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_IAM;
|
78
77
|
c->base.vtable = &iam_vtable;
|
79
78
|
gpr_ref_init(&c->base.refcount, 1);
|
@@ -135,8 +135,7 @@ grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
|
|
135
135
|
gpr_log(GPR_ERROR, "Invalid input for jwt credentials creation");
|
136
136
|
return NULL;
|
137
137
|
}
|
138
|
-
c =
|
139
|
-
memset(c, 0, sizeof(grpc_service_account_jwt_access_credentials));
|
138
|
+
c = gpr_zalloc(sizeof(grpc_service_account_jwt_access_credentials));
|
140
139
|
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_JWT;
|
141
140
|
gpr_ref_init(&c->base.refcount, 1);
|
142
141
|
c->base.vtable = &jwt_vtable;
|
@@ -144,8 +144,7 @@ static void jose_header_destroy(grpc_exec_ctx *exec_ctx, jose_header *h) {
|
|
144
144
|
static jose_header *jose_header_from_json(grpc_exec_ctx *exec_ctx,
|
145
145
|
grpc_json *json, grpc_slice buffer) {
|
146
146
|
grpc_json *cur;
|
147
|
-
jose_header *h =
|
148
|
-
memset(h, 0, sizeof(jose_header));
|
147
|
+
jose_header *h = gpr_zalloc(sizeof(jose_header));
|
149
148
|
h->buffer = buffer;
|
150
149
|
for (cur = json->child; cur != NULL; cur = cur->next) {
|
151
150
|
if (strcmp(cur->key, "alg") == 0) {
|
@@ -363,8 +362,7 @@ static verifier_cb_ctx *verifier_cb_ctx_create(
|
|
363
362
|
const char *signed_jwt, size_t signed_jwt_len, void *user_data,
|
364
363
|
grpc_jwt_verification_done_cb cb) {
|
365
364
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
366
|
-
verifier_cb_ctx *ctx =
|
367
|
-
memset(ctx, 0, sizeof(verifier_cb_ctx));
|
365
|
+
verifier_cb_ctx *ctx = gpr_zalloc(sizeof(verifier_cb_ctx));
|
368
366
|
ctx->verifier = verifier;
|
369
367
|
ctx->pollent = grpc_polling_entity_create_from_pollset(pollset);
|
370
368
|
ctx->header = header;
|
@@ -878,8 +876,7 @@ error:
|
|
878
876
|
grpc_jwt_verifier *grpc_jwt_verifier_create(
|
879
877
|
const grpc_jwt_verifier_email_domain_key_url_mapping *mappings,
|
880
878
|
size_t num_mappings) {
|
881
|
-
grpc_jwt_verifier *v =
|
882
|
-
memset(v, 0, sizeof(grpc_jwt_verifier));
|
879
|
+
grpc_jwt_verifier *v = gpr_zalloc(sizeof(grpc_jwt_verifier));
|
883
880
|
grpc_httpcli_context_init(&v->http_ctx);
|
884
881
|
|
885
882
|
/* We know at least of one mapping. */
|
@@ -898,10 +895,10 @@ grpc_jwt_verifier *grpc_jwt_verifier_create(
|
|
898
895
|
return v;
|
899
896
|
}
|
900
897
|
|
901
|
-
void grpc_jwt_verifier_destroy(grpc_jwt_verifier *v) {
|
898
|
+
void grpc_jwt_verifier_destroy(grpc_exec_ctx *exec_ctx, grpc_jwt_verifier *v) {
|
902
899
|
size_t i;
|
903
900
|
if (v == NULL) return;
|
904
|
-
grpc_httpcli_context_destroy(&v->http_ctx);
|
901
|
+
grpc_httpcli_context_destroy(exec_ctx, &v->http_ctx);
|
905
902
|
if (v->mappings != NULL) {
|
906
903
|
for (i = 0; i < v->num_mappings; i++) {
|
907
904
|
gpr_free(v->mappings[i].email_domain);
|
@@ -109,7 +109,8 @@ grpc_jwt_verifier *grpc_jwt_verifier_create(
|
|
109
109
|
size_t num_mappings);
|
110
110
|
|
111
111
|
/*The verifier must not be destroyed if there are still outstanding callbacks.*/
|
112
|
-
void grpc_jwt_verifier_destroy(
|
112
|
+
void grpc_jwt_verifier_destroy(grpc_exec_ctx *exec_ctx,
|
113
|
+
grpc_jwt_verifier *verifier);
|
113
114
|
|
114
115
|
/* User provided callback that will be called when the verification of the JWT
|
115
116
|
is done (maybe in another thread).
|
@@ -124,7 +124,7 @@ static void oauth2_token_fetcher_destruct(grpc_exec_ctx *exec_ctx,
|
|
124
124
|
(grpc_oauth2_token_fetcher_credentials *)creds;
|
125
125
|
grpc_credentials_md_store_unref(exec_ctx, c->access_token_md);
|
126
126
|
gpr_mu_destroy(&c->mu);
|
127
|
-
grpc_httpcli_context_destroy(&c->httpcli_context);
|
127
|
+
grpc_httpcli_context_destroy(exec_ctx, &c->httpcli_context);
|
128
128
|
}
|
129
129
|
|
130
130
|
grpc_credentials_status
|
@@ -389,8 +389,7 @@ grpc_refresh_token_credentials_create_from_auth_refresh_token(
|
|
389
389
|
gpr_log(GPR_ERROR, "Invalid input for refresh token credentials creation");
|
390
390
|
return NULL;
|
391
391
|
}
|
392
|
-
c =
|
393
|
-
memset(c, 0, sizeof(grpc_google_refresh_token_credentials));
|
392
|
+
c = gpr_zalloc(sizeof(grpc_google_refresh_token_credentials));
|
394
393
|
init_oauth2_token_fetcher(&c->base, refresh_token_fetch_oauth2);
|
395
394
|
c->base.base.vtable = &refresh_token_vtable;
|
396
395
|
c->refresh_token = refresh_token;
|
@@ -450,14 +449,13 @@ static grpc_call_credentials_vtable access_token_vtable = {
|
|
450
449
|
grpc_call_credentials *grpc_access_token_credentials_create(
|
451
450
|
const char *access_token, void *reserved) {
|
452
451
|
grpc_access_token_credentials *c =
|
453
|
-
|
452
|
+
gpr_zalloc(sizeof(grpc_access_token_credentials));
|
454
453
|
char *token_md_value;
|
455
454
|
GRPC_API_TRACE(
|
456
455
|
"grpc_access_token_credentials_create(access_token=<redacted>, "
|
457
456
|
"reserved=%p)",
|
458
457
|
1, (reserved));
|
459
458
|
GPR_ASSERT(reserved == NULL);
|
460
|
-
memset(c, 0, sizeof(grpc_access_token_credentials));
|
461
459
|
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_OAUTH2;
|
462
460
|
c->base.vtable = &access_token_vtable;
|
463
461
|
gpr_ref_init(&c->base.refcount, 1);
|