grpc 0.13.0 → 0.13.1.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/.yardopts +1 -0
- data/Makefile +1114 -937
- data/include/grpc/census.h +71 -89
- data/include/grpc/compression.h +7 -7
- data/include/grpc/grpc.h +65 -68
- data/include/grpc/grpc_security.h +38 -38
- data/include/grpc/impl/codegen/alloc.h +7 -7
- data/include/grpc/impl/codegen/byte_buffer.h +13 -13
- data/include/grpc/impl/codegen/grpc_types.h +7 -2
- data/include/grpc/impl/codegen/log.h +5 -5
- data/include/grpc/impl/codegen/port_platform.h +14 -6
- data/include/grpc/impl/codegen/slice.h +15 -15
- data/include/grpc/impl/codegen/slice_buffer.h +17 -17
- data/include/grpc/impl/codegen/sync.h +26 -22
- data/include/grpc/impl/codegen/time.h +22 -24
- data/include/grpc/support/avl.h +9 -8
- data/include/grpc/support/cmdline.h +12 -12
- data/include/grpc/support/cpu.h +2 -2
- data/include/grpc/support/histogram.h +22 -22
- data/include/grpc/support/host_port.h +2 -2
- data/include/grpc/support/log_win32.h +1 -1
- data/include/grpc/support/string_util.h +2 -2
- data/include/grpc/support/subprocess.h +5 -5
- data/include/grpc/support/thd.h +9 -9
- data/include/grpc/support/useful.h +3 -1
- data/src/core/census/context.c +64 -85
- data/src/core/census/grpc_filter.c +2 -2
- data/src/core/census/mlog.c +600 -0
- data/src/core/census/mlog.h +95 -0
- data/src/core/channel/channel_args.c +67 -6
- data/src/core/channel/channel_args.h +7 -1
- data/src/core/channel/client_channel.c +26 -36
- data/src/core/channel/client_uchannel.c +1 -1
- data/src/core/channel/http_client_filter.c +2 -2
- data/src/core/channel/http_server_filter.c +2 -2
- data/src/core/channel/subchannel_call_holder.c +5 -7
- data/src/core/client_config/connector.c +3 -2
- data/src/core/client_config/connector.h +2 -2
- data/src/core/client_config/lb_policies/load_balancer_api.c +163 -0
- data/src/core/client_config/lb_policies/load_balancer_api.h +85 -0
- data/src/core/client_config/lb_policies/pick_first.c +10 -11
- data/src/core/client_config/lb_policies/round_robin.c +7 -8
- data/src/core/client_config/lb_policy.c +3 -3
- data/src/core/client_config/lb_policy.h +3 -2
- data/src/core/client_config/subchannel.c +51 -21
- data/src/core/client_config/subchannel.h +15 -6
- data/src/core/client_config/subchannel_index.c +261 -0
- data/src/core/client_config/subchannel_index.h +77 -0
- data/src/core/compression/{algorithm.c → compression_algorithm.c} +0 -0
- data/src/core/httpcli/httpcli.c +13 -11
- data/src/core/httpcli/httpcli.h +3 -2
- data/src/core/httpcli/httpcli_security_connector.c +7 -7
- data/src/core/iomgr/fd_posix.c +4 -2
- data/src/core/iomgr/iocp_windows.c +10 -6
- data/src/core/iomgr/iocp_windows.h +9 -2
- data/src/core/iomgr/iomgr.c +18 -2
- data/src/core/iomgr/iomgr_internal.h +5 -1
- data/src/core/iomgr/pollset.h +9 -10
- data/src/core/iomgr/pollset_multipoller_with_epoll.c +1 -0
- data/src/core/iomgr/pollset_multipoller_with_poll_posix.c +10 -5
- data/src/core/iomgr/pollset_posix.c +30 -35
- data/src/core/iomgr/pollset_posix.h +10 -6
- data/src/core/iomgr/pollset_set.h +3 -9
- data/src/core/iomgr/pollset_set_posix.c +23 -3
- data/src/core/iomgr/pollset_set_posix.h +2 -18
- data/src/core/iomgr/pollset_set_windows.c +3 -3
- data/src/core/iomgr/pollset_set_windows.h +2 -2
- data/src/core/iomgr/pollset_windows.c +24 -21
- data/src/core/iomgr/pollset_windows.h +1 -5
- data/src/core/iomgr/tcp_client_posix.c +7 -5
- data/src/core/iomgr/tcp_posix.c +4 -2
- data/src/core/iomgr/tcp_server_windows.c +1 -2
- data/src/core/iomgr/timer.c +2 -3
- data/src/core/iomgr/timer.h +21 -1
- data/src/core/iomgr/timer_heap.c +10 -12
- data/src/core/iomgr/udp_server.c +5 -4
- data/src/core/iomgr/udp_server.h +1 -0
- data/src/core/iomgr/workqueue_posix.c +1 -0
- data/src/core/iomgr/workqueue_posix.h +3 -1
- data/src/core/proto/grpc/lb/v0/load_balancer.pb.c +119 -0
- data/src/core/proto/grpc/lb/v0/load_balancer.pb.h +182 -0
- data/src/core/security/{base64.c → b64.c} +1 -1
- data/src/core/security/{base64.h → b64.h} +1 -1
- data/src/core/security/client_auth_filter.c +0 -1
- data/src/core/security/credentials.c +12 -5
- data/src/core/security/credentials.h +3 -3
- data/src/core/security/google_default_credentials.c +24 -19
- data/src/core/security/handshake.c +15 -7
- data/src/core/security/handshake.h +2 -1
- data/src/core/security/json_token.c +1 -1
- data/src/core/security/jwt_verifier.c +1 -1
- data/src/core/security/security_connector.c +84 -64
- data/src/core/security/security_connector.h +42 -22
- data/src/core/security/security_context.c +8 -3
- data/src/core/security/server_auth_filter.c +2 -2
- data/src/core/security/server_secure_chttp2.c +7 -7
- data/src/core/support/avl.c +2 -2
- data/src/core/support/env_linux.c +17 -0
- data/src/core/support/{file.c → load_file.c} +2 -2
- data/src/core/support/{file.h → load_file.h} +4 -12
- data/src/core/support/sync.c +6 -1
- data/src/core/support/time_posix.c +1 -1
- data/src/core/{iomgr/timer_internal.h → support/tmpfile.h} +17 -23
- data/src/core/support/{file_posix.c → tmpfile_posix.c} +2 -2
- data/src/core/support/{file_win32.c → tmpfile_win32.c} +2 -2
- data/src/core/surface/alarm.c +3 -2
- data/src/core/surface/call.c +102 -52
- data/src/core/surface/channel_create.c +1 -1
- data/src/core/surface/completion_queue.c +73 -41
- data/src/core/surface/init.c +4 -0
- data/src/core/surface/lame_client.c +1 -2
- data/src/core/surface/secure_channel_create.c +6 -7
- data/src/core/surface/server.c +13 -5
- data/src/core/surface/validate_metadata.c +1 -1
- data/src/core/surface/version.c +1 -1
- data/src/core/transport/chttp2/internal.h +22 -10
- data/src/core/transport/chttp2/parsing.c +3 -3
- data/src/core/transport/chttp2/stream_lists.c +39 -21
- data/src/core/transport/chttp2/writing.c +19 -28
- data/src/core/transport/chttp2_transport.c +80 -37
- data/src/core/transport/metadata.c +8 -0
- data/src/core/transport/static_metadata.c +17 -17
- data/src/core/transport/static_metadata.h +3 -3
- data/src/core/transport/transport.c +2 -1
- data/src/core/transport/transport.h +12 -5
- data/src/ruby/ext/grpc/extconf.rb +1 -0
- data/src/ruby/ext/grpc/rb_call.c +6 -0
- data/src/ruby/ext/grpc/rb_call_credentials.c +12 -14
- data/src/ruby/ext/grpc/rb_channel.c +8 -14
- data/src/ruby/ext/grpc/rb_channel_credentials.c +11 -12
- data/src/ruby/ext/grpc/rb_grpc.c +19 -18
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +8 -2
- data/src/ruby/lib/grpc/core/time_consts.rb +2 -2
- data/src/ruby/lib/grpc/errors.rb +2 -2
- data/src/ruby/lib/grpc/generic/rpc_server.rb +58 -39
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/README.md +2 -2
- data/src/ruby/pb/generate_proto_ruby.sh +2 -2
- data/src/ruby/pb/grpc/health/checker.rb +11 -11
- data/src/ruby/pb/grpc/health/v1/health.rb +28 -0
- data/src/ruby/pb/grpc/health/{v1alpha → v1}/health_services.rb +4 -4
- data/src/ruby/spec/client_server_spec.rb +2 -1
- data/src/ruby/spec/generic/rpc_server_spec.rb +3 -22
- data/src/ruby/spec/pb/health/checker_spec.rb +22 -36
- data/third_party/nanopb/pb.h +547 -0
- data/third_party/nanopb/pb_common.c +97 -0
- data/third_party/nanopb/pb_common.h +42 -0
- data/third_party/nanopb/pb_decode.c +1319 -0
- data/third_party/nanopb/pb_decode.h +149 -0
- data/third_party/nanopb/pb_encode.c +690 -0
- data/third_party/nanopb/pb_encode.h +154 -0
- metadata +32 -16
- data/src/ruby/pb/grpc/health/v1alpha/health.rb +0 -29
@@ -36,6 +36,7 @@
|
|
36
36
|
|
37
37
|
#include <grpc/grpc_security.h>
|
38
38
|
#include "src/core/iomgr/endpoint.h"
|
39
|
+
#include "src/core/iomgr/tcp_server.h"
|
39
40
|
#include "src/core/tsi/transport_security_interface.h"
|
40
41
|
|
41
42
|
/* --- status enum. --- */
|
@@ -68,9 +69,6 @@ typedef void (*grpc_security_handshake_done_cb)(
|
|
68
69
|
|
69
70
|
typedef struct {
|
70
71
|
void (*destroy)(grpc_security_connector *sc);
|
71
|
-
void (*do_handshake)(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc,
|
72
|
-
grpc_endpoint *nonsecure_endpoint,
|
73
|
-
grpc_security_handshake_done_cb cb, void *user_data);
|
74
72
|
void (*check_peer)(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc,
|
75
73
|
tsi_peer peer, grpc_security_peer_check_cb cb,
|
76
74
|
void *user_data);
|
@@ -84,13 +82,7 @@ typedef struct grpc_security_connector_handshake_list {
|
|
84
82
|
struct grpc_security_connector {
|
85
83
|
const grpc_security_connector_vtable *vtable;
|
86
84
|
gpr_refcount refcount;
|
87
|
-
int is_client_side;
|
88
85
|
const char *url_scheme;
|
89
|
-
/* Used on server side only. */
|
90
|
-
/* TODO(yangg): Create a grpc_server_security_connector with these. */
|
91
|
-
gpr_mu mu;
|
92
|
-
grpc_security_connector_handshake_list *handshaking_handshakes;
|
93
|
-
const grpc_channel_args *channel_args;
|
94
86
|
};
|
95
87
|
|
96
88
|
/* Refcounting. */
|
@@ -113,13 +105,6 @@ grpc_security_connector *grpc_security_connector_ref(
|
|
113
105
|
void grpc_security_connector_unref(grpc_security_connector *policy);
|
114
106
|
#endif
|
115
107
|
|
116
|
-
/* Handshake. */
|
117
|
-
void grpc_security_connector_do_handshake(grpc_exec_ctx *exec_ctx,
|
118
|
-
grpc_security_connector *connector,
|
119
|
-
grpc_endpoint *nonsecure_endpoint,
|
120
|
-
grpc_security_handshake_done_cb cb,
|
121
|
-
void *user_data);
|
122
|
-
|
123
108
|
/* Check the peer. Callee takes ownership of the peer object.
|
124
109
|
The callback will include the resulting auth_context. */
|
125
110
|
void grpc_security_connector_check_peer(grpc_exec_ctx *exec_ctx,
|
@@ -128,9 +113,6 @@ void grpc_security_connector_check_peer(grpc_exec_ctx *exec_ctx,
|
|
128
113
|
grpc_security_peer_check_cb cb,
|
129
114
|
void *user_data);
|
130
115
|
|
131
|
-
void grpc_security_connector_shutdown(grpc_exec_ctx *exec_ctx,
|
132
|
-
grpc_security_connector *connector);
|
133
|
-
|
134
116
|
/* Util to encapsulate the connector in a channel arg. */
|
135
117
|
grpc_arg grpc_security_connector_to_arg(grpc_security_connector *sc);
|
136
118
|
|
@@ -153,12 +135,16 @@ typedef void (*grpc_security_call_host_check_cb)(grpc_exec_ctx *exec_ctx,
|
|
153
135
|
grpc_security_status status);
|
154
136
|
|
155
137
|
struct grpc_channel_security_connector {
|
156
|
-
grpc_security_connector base;
|
138
|
+
grpc_security_connector base;
|
157
139
|
grpc_call_credentials *request_metadata_creds;
|
158
140
|
void (*check_call_host)(grpc_exec_ctx *exec_ctx,
|
159
141
|
grpc_channel_security_connector *sc, const char *host,
|
160
142
|
grpc_auth_context *auth_context,
|
161
143
|
grpc_security_call_host_check_cb cb, void *user_data);
|
144
|
+
void (*do_handshake)(grpc_exec_ctx *exec_ctx,
|
145
|
+
grpc_channel_security_connector *sc,
|
146
|
+
grpc_endpoint *nonsecure_endpoint,
|
147
|
+
grpc_security_handshake_done_cb cb, void *user_data);
|
162
148
|
};
|
163
149
|
|
164
150
|
/* Checks that the host that will be set for a call is acceptable. */
|
@@ -167,6 +153,39 @@ void grpc_channel_security_connector_check_call_host(
|
|
167
153
|
const char *host, grpc_auth_context *auth_context,
|
168
154
|
grpc_security_call_host_check_cb cb, void *user_data);
|
169
155
|
|
156
|
+
/* Handshake. */
|
157
|
+
void grpc_channel_security_connector_do_handshake(
|
158
|
+
grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *connector,
|
159
|
+
grpc_endpoint *nonsecure_endpoint, grpc_security_handshake_done_cb cb,
|
160
|
+
void *user_data);
|
161
|
+
|
162
|
+
/* --- server_security_connector object. ---
|
163
|
+
|
164
|
+
A server security connector object represents away to configure the
|
165
|
+
underlying transport security mechanism on the server side. */
|
166
|
+
|
167
|
+
typedef struct grpc_server_security_connector grpc_server_security_connector;
|
168
|
+
|
169
|
+
struct grpc_server_security_connector {
|
170
|
+
grpc_security_connector base;
|
171
|
+
gpr_mu mu;
|
172
|
+
grpc_security_connector_handshake_list *handshaking_handshakes;
|
173
|
+
const grpc_channel_args *channel_args;
|
174
|
+
void (*do_handshake)(grpc_exec_ctx *exec_ctx,
|
175
|
+
grpc_server_security_connector *sc,
|
176
|
+
grpc_tcp_server_acceptor *acceptor,
|
177
|
+
grpc_endpoint *nonsecure_endpoint,
|
178
|
+
grpc_security_handshake_done_cb cb, void *user_data);
|
179
|
+
};
|
180
|
+
|
181
|
+
void grpc_server_security_connector_do_handshake(
|
182
|
+
grpc_exec_ctx *exec_ctx, grpc_server_security_connector *sc,
|
183
|
+
grpc_tcp_server_acceptor *acceptor, grpc_endpoint *nonsecure_endpoint,
|
184
|
+
grpc_security_handshake_done_cb cb, void *user_data);
|
185
|
+
|
186
|
+
void grpc_server_security_connector_shutdown(
|
187
|
+
grpc_exec_ctx *exec_ctx, grpc_server_security_connector *connector);
|
188
|
+
|
170
189
|
/* --- Creation security connectors. --- */
|
171
190
|
|
172
191
|
/* For TESTING ONLY!
|
@@ -176,7 +195,8 @@ grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
|
|
176
195
|
|
177
196
|
/* For TESTING ONLY!
|
178
197
|
Creates a fake connector that emulates real server security. */
|
179
|
-
|
198
|
+
grpc_server_security_connector *grpc_fake_server_security_connector_create(
|
199
|
+
void);
|
180
200
|
|
181
201
|
/* Config for ssl clients. */
|
182
202
|
typedef struct {
|
@@ -231,7 +251,7 @@ typedef struct {
|
|
231
251
|
specific error code otherwise.
|
232
252
|
*/
|
233
253
|
grpc_security_status grpc_ssl_server_security_connector_create(
|
234
|
-
const grpc_ssl_server_config *config,
|
254
|
+
const grpc_ssl_server_config *config, grpc_server_security_connector **sc);
|
235
255
|
|
236
256
|
/* Util. */
|
237
257
|
const tsi_peer_property *tsi_peer_get_property_by_name(const tsi_peer *peer,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
*
|
3
|
-
* Copyright 2015, Google Inc.
|
3
|
+
* Copyright 2015-2016, Google Inc.
|
4
4
|
* All rights reserved.
|
5
5
|
*
|
6
6
|
* Redistribution and use in source and binary forms, with or without
|
@@ -309,14 +309,19 @@ static void *auth_context_pointer_arg_copy(void *p) {
|
|
309
309
|
return GRPC_AUTH_CONTEXT_REF(p, "auth_context_pointer_arg");
|
310
310
|
}
|
311
311
|
|
312
|
+
static int auth_context_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); }
|
313
|
+
|
314
|
+
static const grpc_arg_pointer_vtable auth_context_pointer_vtable = {
|
315
|
+
auth_context_pointer_arg_copy, auth_context_pointer_arg_destroy,
|
316
|
+
auth_context_pointer_cmp};
|
317
|
+
|
312
318
|
grpc_arg grpc_auth_context_to_arg(grpc_auth_context *p) {
|
313
319
|
grpc_arg arg;
|
314
320
|
memset(&arg, 0, sizeof(grpc_arg));
|
315
321
|
arg.type = GRPC_ARG_POINTER;
|
316
322
|
arg.key = GRPC_AUTH_CONTEXT_ARG;
|
317
323
|
arg.value.pointer.p = p;
|
318
|
-
arg.value.pointer.
|
319
|
-
arg.value.pointer.destroy = auth_context_pointer_arg_destroy;
|
324
|
+
arg.value.pointer.vtable = &auth_context_pointer_vtable;
|
320
325
|
return arg;
|
321
326
|
}
|
322
327
|
|
@@ -176,8 +176,8 @@ static void set_recv_ops_md_callbacks(grpc_call_element *elem,
|
|
176
176
|
if (op->recv_initial_metadata != NULL) {
|
177
177
|
/* substitute our callback for the higher callback */
|
178
178
|
calld->recv_initial_metadata = op->recv_initial_metadata;
|
179
|
-
calld->on_done_recv = op->
|
180
|
-
op->
|
179
|
+
calld->on_done_recv = op->recv_initial_metadata_ready;
|
180
|
+
op->recv_initial_metadata_ready = &calld->auth_on_recv;
|
181
181
|
calld->transport_op = *op;
|
182
182
|
}
|
183
183
|
}
|
@@ -55,7 +55,7 @@
|
|
55
55
|
typedef struct grpc_server_secure_state {
|
56
56
|
grpc_server *server;
|
57
57
|
grpc_tcp_server *tcp;
|
58
|
-
|
58
|
+
grpc_server_security_connector *sc;
|
59
59
|
grpc_server_credentials *creds;
|
60
60
|
int is_shutdown;
|
61
61
|
gpr_mu mu;
|
@@ -74,7 +74,7 @@ static void state_unref(grpc_server_secure_state *state) {
|
|
74
74
|
gpr_mu_lock(&state->mu);
|
75
75
|
gpr_mu_unlock(&state->mu);
|
76
76
|
/* clean up */
|
77
|
-
GRPC_SECURITY_CONNECTOR_UNREF(state->sc, "server");
|
77
|
+
GRPC_SECURITY_CONNECTOR_UNREF(&state->sc->base, "server");
|
78
78
|
grpc_server_credentials_unref(state->creds);
|
79
79
|
gpr_free(state);
|
80
80
|
}
|
@@ -130,8 +130,8 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *statep, grpc_endpoint *tcp,
|
|
130
130
|
grpc_tcp_server_acceptor *acceptor) {
|
131
131
|
grpc_server_secure_state *state = statep;
|
132
132
|
state_ref(state);
|
133
|
-
|
134
|
-
|
133
|
+
grpc_server_security_connector_do_handshake(
|
134
|
+
exec_ctx, state->sc, acceptor, tcp, on_secure_handshake_done, state);
|
135
135
|
}
|
136
136
|
|
137
137
|
/* Server callback: start listening on our ports */
|
@@ -148,7 +148,7 @@ static void destroy_done(grpc_exec_ctx *exec_ctx, void *statep, bool success) {
|
|
148
148
|
state->destroy_callback->cb(exec_ctx, state->destroy_callback->cb_arg,
|
149
149
|
success);
|
150
150
|
}
|
151
|
-
|
151
|
+
grpc_server_security_connector_shutdown(exec_ctx, state->sc);
|
152
152
|
state_unref(state);
|
153
153
|
}
|
154
154
|
|
@@ -176,7 +176,7 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
|
|
176
176
|
int port_num = -1;
|
177
177
|
int port_temp;
|
178
178
|
grpc_security_status status = GRPC_SECURITY_ERROR;
|
179
|
-
|
179
|
+
grpc_server_security_connector *sc = NULL;
|
180
180
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
181
181
|
|
182
182
|
GRPC_API_TRACE(
|
@@ -256,7 +256,7 @@ error:
|
|
256
256
|
grpc_tcp_server_unref(&exec_ctx, tcp);
|
257
257
|
} else {
|
258
258
|
if (sc) {
|
259
|
-
GRPC_SECURITY_CONNECTOR_UNREF(sc, "server");
|
259
|
+
GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "server");
|
260
260
|
}
|
261
261
|
if (state) {
|
262
262
|
gpr_free(state);
|
data/src/core/support/avl.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
*
|
3
|
-
* Copyright 2015, Google Inc.
|
3
|
+
* Copyright 2015-2016, Google Inc.
|
4
4
|
* All rights reserved.
|
5
5
|
*
|
6
6
|
* Redistribution and use in source and binary forms, with or without
|
@@ -167,7 +167,7 @@ static gpr_avl_node *rotate_right_left(const gpr_avl_vtable *vtable, void *key,
|
|
167
167
|
vtable->copy_key(right->left->key),
|
168
168
|
vtable->copy_value(right->left->value),
|
169
169
|
new_node(key, value, left, ref_node(right->left->left)),
|
170
|
-
new_node(vtable->copy_key(right->key), vtable->
|
170
|
+
new_node(vtable->copy_key(right->key), vtable->copy_value(right->value),
|
171
171
|
ref_node(right->left->right), ref_node(right->right)));
|
172
172
|
unref_node(vtable, right);
|
173
173
|
return n;
|
@@ -43,7 +43,9 @@
|
|
43
43
|
#include "src/core/support/env.h"
|
44
44
|
|
45
45
|
#include <dlfcn.h>
|
46
|
+
#include <features.h>
|
46
47
|
#include <stdlib.h>
|
48
|
+
#include <string.h>
|
47
49
|
|
48
50
|
#include <grpc/support/log.h>
|
49
51
|
#include <grpc/support/string_util.h>
|
@@ -52,6 +54,7 @@
|
|
52
54
|
#include "src/core/support/string.h"
|
53
55
|
|
54
56
|
char *gpr_getenv(const char *name) {
|
57
|
+
#if defined(GPR_BACKWARDS_COMPATIBILITY_MODE)
|
55
58
|
typedef char *(*getenv_type)(const char *);
|
56
59
|
static getenv_type getenv_func = NULL;
|
57
60
|
/* Check to see which getenv variant is supported (go from most
|
@@ -59,9 +62,23 @@ char *gpr_getenv(const char *name) {
|
|
59
62
|
const char *names[] = {"secure_getenv", "__secure_getenv", "getenv"};
|
60
63
|
for (size_t i = 0; getenv_func == NULL && i < GPR_ARRAY_SIZE(names); i++) {
|
61
64
|
getenv_func = (getenv_type)dlsym(RTLD_DEFAULT, names[i]);
|
65
|
+
if (getenv_func != NULL && strstr(names[i], "secure") == NULL) {
|
66
|
+
gpr_log(GPR_DEBUG,
|
67
|
+
"Warning: insecure environment read function '%s' used",
|
68
|
+
names[i]);
|
69
|
+
}
|
62
70
|
}
|
63
71
|
char *result = getenv_func(name);
|
64
72
|
return result == NULL ? result : gpr_strdup(result);
|
73
|
+
#elif __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17)
|
74
|
+
char *result = secure_getenv(name);
|
75
|
+
return result == NULL ? result : gpr_strdup(result);
|
76
|
+
#else
|
77
|
+
gpr_log(GPR_DEBUG, "Warning: insecure environment read function '%s' used",
|
78
|
+
"getenv");
|
79
|
+
char *result = getenv(name);
|
80
|
+
return result == NULL ? result : gpr_strdup(result);
|
81
|
+
#endif
|
65
82
|
}
|
66
83
|
|
67
84
|
void gpr_setenv(const char *name, const char *value) {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
*
|
3
|
-
* Copyright 2015, Google Inc.
|
3
|
+
* Copyright 2015-2016, Google Inc.
|
4
4
|
* All rights reserved.
|
5
5
|
*
|
6
6
|
* Redistribution and use in source and binary forms, with or without
|
@@ -31,7 +31,7 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#include "src/core/support/
|
34
|
+
#include "src/core/support/load_file.h"
|
35
35
|
|
36
36
|
#include <errno.h>
|
37
37
|
#include <string.h>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
*
|
3
|
-
* Copyright 2015, Google Inc.
|
3
|
+
* Copyright 2015-2016, Google Inc.
|
4
4
|
* All rights reserved.
|
5
5
|
*
|
6
6
|
* Redistribution and use in source and binary forms, with or without
|
@@ -31,8 +31,8 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#ifndef
|
35
|
-
#define
|
34
|
+
#ifndef GRPC_INTERNAL_CORE_SUPPORT_LOAD_FILE_H
|
35
|
+
#define GRPC_INTERNAL_CORE_SUPPORT_LOAD_FILE_H
|
36
36
|
|
37
37
|
#include <stdio.h>
|
38
38
|
|
@@ -42,22 +42,14 @@
|
|
42
42
|
extern "C" {
|
43
43
|
#endif
|
44
44
|
|
45
|
-
/* File utility functions */
|
46
|
-
|
47
45
|
/* Loads the content of a file into a slice. add_null_terminator will add
|
48
46
|
a NULL terminator if non-zero. The success parameter, if not NULL,
|
49
47
|
will be set to 1 in case of success and 0 in case of failure. */
|
50
48
|
gpr_slice gpr_load_file(const char *filename, int add_null_terminator,
|
51
49
|
int *success);
|
52
50
|
|
53
|
-
/* Creates a temporary file from a prefix.
|
54
|
-
If tmp_filename is not NULL, *tmp_filename is assigned the name of the
|
55
|
-
created file and it is the responsibility of the caller to gpr_free it
|
56
|
-
unless an error occurs in which case it will be set to NULL. */
|
57
|
-
FILE *gpr_tmpfile(const char *prefix, char **tmp_filename);
|
58
|
-
|
59
51
|
#ifdef __cplusplus
|
60
52
|
}
|
61
53
|
#endif
|
62
54
|
|
63
|
-
#endif /*
|
55
|
+
#endif /* GRPC_INTERNAL_CORE_SUPPORT_LOAD_FILE_H */
|
data/src/core/support/sync.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
*
|
3
|
-
* Copyright 2015, Google Inc.
|
3
|
+
* Copyright 2015-2016, Google Inc.
|
4
4
|
* All rights reserved.
|
5
5
|
*
|
6
6
|
* Redistribution and use in source and binary forms, with or without
|
@@ -98,6 +98,11 @@ void gpr_ref_init(gpr_refcount *r, int n) { gpr_atm_rel_store(&r->count, n); }
|
|
98
98
|
|
99
99
|
void gpr_ref(gpr_refcount *r) { gpr_atm_no_barrier_fetch_add(&r->count, 1); }
|
100
100
|
|
101
|
+
void gpr_ref_non_zero(gpr_refcount *r) {
|
102
|
+
gpr_atm prior = gpr_atm_no_barrier_fetch_add(&r->count, 1);
|
103
|
+
GPR_ASSERT(prior > 0);
|
104
|
+
}
|
105
|
+
|
101
106
|
void gpr_refn(gpr_refcount *r, int n) {
|
102
107
|
gpr_atm_no_barrier_fetch_add(&r->count, n);
|
103
108
|
}
|
@@ -86,7 +86,7 @@ gpr_timespec gpr_now(gpr_clock_type clock_type) {
|
|
86
86
|
gpr_precise_clock_now(&ret);
|
87
87
|
return ret;
|
88
88
|
} else {
|
89
|
-
#if defined(
|
89
|
+
#if defined(GPR_BACKWARDS_COMPATIBILITY_MODE) && defined(__linux__)
|
90
90
|
/* avoid ABI problems by invoking syscalls directly */
|
91
91
|
syscall(SYS_clock_gettime, clockid_for_gpr_clock[clock_type], &now);
|
92
92
|
#else
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
*
|
3
|
-
* Copyright 2015, Google Inc.
|
3
|
+
* Copyright 2015-2016, Google Inc.
|
4
4
|
* All rights reserved.
|
5
5
|
*
|
6
6
|
* Redistribution and use in source and binary forms, with or without
|
@@ -31,31 +31,25 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#ifndef
|
35
|
-
#define
|
34
|
+
#ifndef GRPC_INTERNAL_CORE_SUPPORT_TMPFILE_H
|
35
|
+
#define GRPC_INTERNAL_CORE_SUPPORT_TMPFILE_H
|
36
36
|
|
37
|
-
#include
|
38
|
-
#include <grpc/support/sync.h>
|
39
|
-
#include <grpc/support/time.h>
|
37
|
+
#include <stdio.h>
|
40
38
|
|
41
|
-
|
39
|
+
#include <grpc/support/slice.h>
|
42
40
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
If next is non-null, TRY to update *next with the next running timer
|
47
|
-
IF that timer occurs before *next current value.
|
48
|
-
*next is never guaranteed to be updated on any given execution; however,
|
49
|
-
with high probability at least one thread in the system will see an update
|
50
|
-
at any time slice. */
|
41
|
+
#ifdef __cplusplus
|
42
|
+
extern "C" {
|
43
|
+
#endif
|
51
44
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
45
|
+
/* Creates a temporary file from a prefix.
|
46
|
+
If tmp_filename is not NULL, *tmp_filename is assigned the name of the
|
47
|
+
created file and it is the responsibility of the caller to gpr_free it
|
48
|
+
unless an error occurs in which case it will be set to NULL. */
|
49
|
+
FILE *gpr_tmpfile(const char *prefix, char **tmp_filename);
|
56
50
|
|
57
|
-
|
51
|
+
#ifdef __cplusplus
|
52
|
+
}
|
53
|
+
#endif
|
58
54
|
|
59
|
-
|
60
|
-
|
61
|
-
#endif /* GRPC_INTERNAL_CORE_IOMGR_TIMER_INTERNAL_H */
|
55
|
+
#endif /* GRPC_INTERNAL_CORE_SUPPORT_TMPFILE_H */
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
*
|
3
|
-
* Copyright 2015, Google Inc.
|
3
|
+
* Copyright 2015-2016, Google Inc.
|
4
4
|
* All rights reserved.
|
5
5
|
*
|
6
6
|
* Redistribution and use in source and binary forms, with or without
|
@@ -35,7 +35,7 @@
|
|
35
35
|
|
36
36
|
#ifdef GPR_POSIX_FILE
|
37
37
|
|
38
|
-
#include "src/core/support/
|
38
|
+
#include "src/core/support/tmpfile.h"
|
39
39
|
|
40
40
|
#include <errno.h>
|
41
41
|
#include <stdlib.h>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
*
|
3
|
-
* Copyright 2015, Google Inc.
|
3
|
+
* Copyright 2015-2016, Google Inc.
|
4
4
|
* All rights reserved.
|
5
5
|
*
|
6
6
|
* Redistribution and use in source and binary forms, with or without
|
@@ -44,8 +44,8 @@
|
|
44
44
|
#include <grpc/support/log.h>
|
45
45
|
#include <grpc/support/string_util.h>
|
46
46
|
|
47
|
-
#include "src/core/support/file.h"
|
48
47
|
#include "src/core/support/string_win32.h"
|
48
|
+
#include "src/core/support/tmpfile.h"
|
49
49
|
|
50
50
|
FILE *gpr_tmpfile(const char *prefix, char **tmp_filename_out) {
|
51
51
|
FILE *result = NULL;
|