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
@@ -31,17 +31,18 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#include
|
35
|
-
#include <
|
36
|
-
#include "src/core/lib/support/string.h"
|
34
|
+
#include <limits.h>
|
35
|
+
#include <string.h>
|
37
36
|
|
38
37
|
#include <grpc/compression.h>
|
38
|
+
#include <grpc/grpc.h>
|
39
39
|
#include <grpc/support/alloc.h>
|
40
40
|
#include <grpc/support/log.h>
|
41
41
|
#include <grpc/support/string_util.h>
|
42
42
|
#include <grpc/support/useful.h>
|
43
43
|
|
44
|
-
#include
|
44
|
+
#include "src/core/lib/channel/channel_args.h"
|
45
|
+
#include "src/core/lib/support/string.h"
|
45
46
|
|
46
47
|
static grpc_arg copy_arg(const grpc_arg *src) {
|
47
48
|
grpc_arg dst;
|
@@ -329,7 +330,9 @@ const grpc_arg *grpc_channel_args_find(const grpc_channel_args *args,
|
|
329
330
|
return NULL;
|
330
331
|
}
|
331
332
|
|
332
|
-
int grpc_channel_arg_get_integer(grpc_arg *arg,
|
333
|
+
int grpc_channel_arg_get_integer(const grpc_arg *arg,
|
334
|
+
const grpc_integer_options options) {
|
335
|
+
if (arg == NULL) return options.default_value;
|
333
336
|
if (arg->type != GRPC_ARG_INTEGER) {
|
334
337
|
gpr_log(GPR_ERROR, "%s ignored: it must be an integer", arg->key);
|
335
338
|
return options.default_value;
|
@@ -347,9 +350,25 @@ int grpc_channel_arg_get_integer(grpc_arg *arg, grpc_integer_options options) {
|
|
347
350
|
return arg->value.integer;
|
348
351
|
}
|
349
352
|
|
353
|
+
bool grpc_channel_arg_get_bool(const grpc_arg *arg, bool default_value) {
|
354
|
+
if (arg == NULL) return default_value;
|
355
|
+
if (arg->type != GRPC_ARG_INTEGER) {
|
356
|
+
gpr_log(GPR_ERROR, "%s ignored: it must be an integer", arg->key);
|
357
|
+
return default_value;
|
358
|
+
}
|
359
|
+
switch (arg->value.integer) {
|
360
|
+
case 0:
|
361
|
+
return false;
|
362
|
+
case 1:
|
363
|
+
return true;
|
364
|
+
default:
|
365
|
+
gpr_log(GPR_ERROR, "%s treated as bool but set to %d (assuming true)",
|
366
|
+
arg->key, arg->value.integer);
|
367
|
+
return true;
|
368
|
+
}
|
369
|
+
}
|
370
|
+
|
350
371
|
bool grpc_channel_args_want_minimal_stack(const grpc_channel_args *args) {
|
351
|
-
|
352
|
-
|
353
|
-
if (arg->type == GRPC_ARG_INTEGER && arg->value.integer == 0) return false;
|
354
|
-
return true;
|
372
|
+
return grpc_channel_arg_get_bool(
|
373
|
+
grpc_channel_args_find(args, GRPC_ARG_MINIMAL_STACK), false);
|
355
374
|
}
|
@@ -120,7 +120,11 @@ typedef struct grpc_integer_options {
|
|
120
120
|
int min_value;
|
121
121
|
int max_value;
|
122
122
|
} grpc_integer_options;
|
123
|
+
|
123
124
|
/** Returns the value of \a arg, subject to the contraints in \a options. */
|
124
|
-
int grpc_channel_arg_get_integer(grpc_arg *arg,
|
125
|
+
int grpc_channel_arg_get_integer(const grpc_arg *arg,
|
126
|
+
const grpc_integer_options options);
|
127
|
+
|
128
|
+
bool grpc_channel_arg_get_bool(const grpc_arg *arg, bool default_value);
|
125
129
|
|
126
130
|
#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_H */
|
@@ -307,10 +307,10 @@ void grpc_call_element_signal_error(grpc_exec_ctx *exec_ctx,
|
|
307
307
|
grpc_call_element *cur_elem,
|
308
308
|
grpc_error *error);
|
309
309
|
|
310
|
-
extern
|
310
|
+
extern grpc_tracer_flag grpc_trace_channel;
|
311
311
|
|
312
312
|
#define GRPC_CALL_LOG_OP(sev, elem, op) \
|
313
|
-
if (grpc_trace_channel) grpc_call_log_op(sev, elem, op)
|
313
|
+
if (GRPC_TRACER_ON(grpc_trace_channel)) grpc_call_log_op(sev, elem, op)
|
314
314
|
|
315
315
|
#ifdef __cplusplus
|
316
316
|
}
|
@@ -38,7 +38,8 @@
|
|
38
38
|
#include <grpc/support/alloc.h>
|
39
39
|
#include <grpc/support/string_util.h>
|
40
40
|
|
41
|
-
|
41
|
+
grpc_tracer_flag grpc_trace_channel_stack_builder =
|
42
|
+
GRPC_TRACER_INITIALIZER(false);
|
42
43
|
|
43
44
|
typedef struct filter_node {
|
44
45
|
struct filter_node *next;
|
@@ -113,6 +114,17 @@ grpc_channel_stack_builder_create_iterator_at_last(
|
|
113
114
|
return create_iterator_at_filter_node(builder, &builder->end);
|
114
115
|
}
|
115
116
|
|
117
|
+
bool grpc_channel_stack_builder_iterator_is_end(
|
118
|
+
grpc_channel_stack_builder_iterator *iterator) {
|
119
|
+
return iterator->node == &iterator->builder->end;
|
120
|
+
}
|
121
|
+
|
122
|
+
const char *grpc_channel_stack_builder_iterator_filter_name(
|
123
|
+
grpc_channel_stack_builder_iterator *iterator) {
|
124
|
+
if (iterator->node->filter == NULL) return NULL;
|
125
|
+
return iterator->node->filter->name;
|
126
|
+
}
|
127
|
+
|
116
128
|
bool grpc_channel_stack_builder_move_next(
|
117
129
|
grpc_channel_stack_builder_iterator *iterator) {
|
118
130
|
if (iterator->node == &iterator->builder->end) return false;
|
@@ -98,6 +98,10 @@ bool grpc_channel_stack_builder_iterator_is_first(
|
|
98
98
|
bool grpc_channel_stack_builder_iterator_is_end(
|
99
99
|
grpc_channel_stack_builder_iterator *iterator);
|
100
100
|
|
101
|
+
/// What is the name of the filter at this iterator position?
|
102
|
+
const char *grpc_channel_stack_builder_iterator_filter_name(
|
103
|
+
grpc_channel_stack_builder_iterator *iterator);
|
104
|
+
|
101
105
|
/// Move an iterator to the next item
|
102
106
|
bool grpc_channel_stack_builder_move_next(
|
103
107
|
grpc_channel_stack_builder_iterator *iterator);
|
@@ -161,7 +165,7 @@ grpc_error *grpc_channel_stack_builder_finish(
|
|
161
165
|
void grpc_channel_stack_builder_destroy(grpc_exec_ctx *exec_ctx,
|
162
166
|
grpc_channel_stack_builder *builder);
|
163
167
|
|
164
|
-
extern
|
168
|
+
extern grpc_tracer_flag grpc_trace_channel_stack_builder;
|
165
169
|
|
166
170
|
#ifdef __cplusplus
|
167
171
|
}
|
@@ -128,7 +128,9 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
|
|
128
128
|
static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
|
129
129
|
grpc_channel_element *elem) {
|
130
130
|
channel_data *cd = (channel_data *)elem->channel_data;
|
131
|
-
|
131
|
+
if (cd->transport) {
|
132
|
+
grpc_transport_destroy(exec_ctx, cd->transport);
|
133
|
+
}
|
132
134
|
}
|
133
135
|
|
134
136
|
static char *con_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
|
@@ -50,8 +50,8 @@ typedef enum {
|
|
50
50
|
/// Reserved for traffic_class_context.
|
51
51
|
GRPC_CONTEXT_TRAFFIC,
|
52
52
|
|
53
|
-
///
|
54
|
-
|
53
|
+
/// Value is a \a grpc_grpclb_client_stats.
|
54
|
+
GRPC_GRPCLB_CLIENT_STATS,
|
55
55
|
|
56
56
|
GRPC_CONTEXT_COUNT
|
57
57
|
} grpc_context_index;
|
@@ -50,7 +50,7 @@ static int zlib_body(grpc_exec_ctx* exec_ctx, z_stream* zs,
|
|
50
50
|
int r;
|
51
51
|
int flush;
|
52
52
|
size_t i;
|
53
|
-
grpc_slice outbuf =
|
53
|
+
grpc_slice outbuf = GRPC_SLICE_MALLOC(OUTPUT_BLOCK_SIZE);
|
54
54
|
const uInt uint_max = ~(uInt)0;
|
55
55
|
|
56
56
|
GPR_ASSERT(GRPC_SLICE_LENGTH(outbuf) <= uint_max);
|
@@ -65,7 +65,7 @@ static int zlib_body(grpc_exec_ctx* exec_ctx, z_stream* zs,
|
|
65
65
|
do {
|
66
66
|
if (zs->avail_out == 0) {
|
67
67
|
grpc_slice_buffer_add_indexed(output, outbuf);
|
68
|
-
outbuf =
|
68
|
+
outbuf = GRPC_SLICE_MALLOC(OUTPUT_BLOCK_SIZE);
|
69
69
|
GPR_ASSERT(GRPC_SLICE_LENGTH(outbuf) <= uint_max);
|
70
70
|
zs->avail_out = (uInt)GRPC_SLICE_LENGTH(outbuf);
|
71
71
|
zs->next_out = GRPC_SLICE_START_PTR(outbuf);
|
data/src/core/lib/debug/trace.c
CHANGED
@@ -35,24 +35,31 @@
|
|
35
35
|
|
36
36
|
#include <string.h>
|
37
37
|
|
38
|
-
#include <grpc/grpc.h>
|
39
38
|
#include <grpc/support/alloc.h>
|
40
39
|
#include <grpc/support/log.h>
|
41
40
|
#include "src/core/lib/support/env.h"
|
42
41
|
|
42
|
+
int grpc_tracer_set_enabled(const char *name, int enabled);
|
43
|
+
|
43
44
|
typedef struct tracer {
|
44
45
|
const char *name;
|
45
|
-
|
46
|
+
grpc_tracer_flag *flag;
|
46
47
|
struct tracer *next;
|
47
48
|
} tracer;
|
48
49
|
static tracer *tracers;
|
49
50
|
|
50
|
-
|
51
|
+
#ifdef GRPC_THREADSAFE_TRACER
|
52
|
+
#define TRACER_SET(flag, on) gpr_atm_no_barrier_store(&(flag).value, (on))
|
53
|
+
#else
|
54
|
+
#define TRACER_SET(flag, on) (flag).value = (on)
|
55
|
+
#endif
|
56
|
+
|
57
|
+
void grpc_register_tracer(const char *name, grpc_tracer_flag *flag) {
|
51
58
|
tracer *t = gpr_malloc(sizeof(*t));
|
52
59
|
t->name = name;
|
53
60
|
t->flag = flag;
|
54
61
|
t->next = tracers;
|
55
|
-
*flag
|
62
|
+
TRACER_SET(*flag, false);
|
56
63
|
tracers = t;
|
57
64
|
}
|
58
65
|
|
@@ -121,13 +128,13 @@ int grpc_tracer_set_enabled(const char *name, int enabled) {
|
|
121
128
|
tracer *t;
|
122
129
|
if (0 == strcmp(name, "all")) {
|
123
130
|
for (t = tracers; t; t = t->next) {
|
124
|
-
*t->flag
|
131
|
+
TRACER_SET(*t->flag, enabled);
|
125
132
|
}
|
126
133
|
} else {
|
127
134
|
int found = 0;
|
128
135
|
for (t = tracers; t; t = t->next) {
|
129
136
|
if (0 == strcmp(name, t->name)) {
|
130
|
-
*t->flag
|
137
|
+
TRACER_SET(*t->flag, enabled);
|
131
138
|
found = 1;
|
132
139
|
}
|
133
140
|
}
|
data/src/core/lib/debug/trace.h
CHANGED
@@ -34,9 +34,35 @@
|
|
34
34
|
#ifndef GRPC_CORE_LIB_DEBUG_TRACE_H
|
35
35
|
#define GRPC_CORE_LIB_DEBUG_TRACE_H
|
36
36
|
|
37
|
+
#include <grpc/support/atm.h>
|
37
38
|
#include <grpc/support/port_platform.h>
|
39
|
+
#include <stdbool.h>
|
38
40
|
|
39
|
-
|
41
|
+
#if defined(__has_feature)
|
42
|
+
#if __has_feature(thread_sanitizer)
|
43
|
+
#define GRPC_THREADSAFE_TRACER
|
44
|
+
#endif
|
45
|
+
#endif
|
46
|
+
|
47
|
+
typedef struct {
|
48
|
+
#ifdef GRPC_THREADSAFE_TRACER
|
49
|
+
gpr_atm value;
|
50
|
+
#else
|
51
|
+
bool value;
|
52
|
+
#endif
|
53
|
+
} grpc_tracer_flag;
|
54
|
+
|
55
|
+
#ifdef GRPC_THREADSAFE_TRACER
|
56
|
+
#define GRPC_TRACER_ON(flag) (gpr_atm_no_barrier_load(&(flag).value) != 0)
|
57
|
+
#define GRPC_TRACER_INITIALIZER(on) \
|
58
|
+
{ (gpr_atm)(on) }
|
59
|
+
#else
|
60
|
+
#define GRPC_TRACER_ON(flag) ((flag).value)
|
61
|
+
#define GRPC_TRACER_INITIALIZER(on) \
|
62
|
+
{ (on) }
|
63
|
+
#endif
|
64
|
+
|
65
|
+
void grpc_register_tracer(const char *name, grpc_tracer_flag *flag);
|
40
66
|
void grpc_tracer_init(const char *env_var_name);
|
41
67
|
void grpc_tracer_shutdown(void);
|
42
68
|
|
data/src/core/lib/http/httpcli.c
CHANGED
@@ -105,7 +105,7 @@ static void finish(grpc_exec_ctx *exec_ctx, internal_request *req,
|
|
105
105
|
grpc_error *error) {
|
106
106
|
grpc_polling_entity_del_from_pollset_set(exec_ctx, req->pollent,
|
107
107
|
req->context->pollset_set);
|
108
|
-
grpc_closure_sched(exec_ctx, req->on_done, error);
|
108
|
+
grpc_closure_sched(exec_ctx, req->on_done, GRPC_ERROR_REF(error));
|
109
109
|
grpc_http_parser_destroy(&req->parser);
|
110
110
|
if (req->addresses != NULL) {
|
111
111
|
grpc_resolved_addresses_destroy(req->addresses);
|
@@ -106,9 +106,8 @@ static grpc_security_connector_vtable httpcli_ssl_vtable = {
|
|
106
106
|
httpcli_ssl_destroy, httpcli_ssl_check_peer};
|
107
107
|
|
108
108
|
static grpc_security_status httpcli_ssl_channel_security_connector_create(
|
109
|
-
grpc_exec_ctx *exec_ctx, const
|
110
|
-
|
111
|
-
grpc_channel_security_connector **sc) {
|
109
|
+
grpc_exec_ctx *exec_ctx, const char *pem_root_certs,
|
110
|
+
const char *secure_peer_name, grpc_channel_security_connector **sc) {
|
112
111
|
tsi_result result = TSI_OK;
|
113
112
|
grpc_httpcli_ssl_channel_security_connector *c;
|
114
113
|
|
@@ -126,8 +125,7 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
|
|
126
125
|
c->secure_peer_name = gpr_strdup(secure_peer_name);
|
127
126
|
}
|
128
127
|
result = tsi_create_ssl_client_handshaker_factory(
|
129
|
-
NULL,
|
130
|
-
0, &c->handshaker_factory);
|
128
|
+
NULL, pem_root_certs, NULL, NULL, 0, &c->handshaker_factory);
|
131
129
|
if (result != TSI_OK) {
|
132
130
|
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
|
133
131
|
tsi_result_to_string(result));
|
@@ -173,10 +171,9 @@ static void ssl_handshake(grpc_exec_ctx *exec_ctx, void *arg,
|
|
173
171
|
void (*on_done)(grpc_exec_ctx *exec_ctx, void *arg,
|
174
172
|
grpc_endpoint *endpoint)) {
|
175
173
|
grpc_channel_security_connector *sc = NULL;
|
176
|
-
const unsigned char *pem_root_certs = NULL;
|
177
174
|
on_done_closure *c = gpr_malloc(sizeof(*c));
|
178
|
-
|
179
|
-
if (pem_root_certs == NULL
|
175
|
+
const char *pem_root_certs = grpc_get_default_ssl_roots();
|
176
|
+
if (pem_root_certs == NULL) {
|
180
177
|
gpr_log(GPR_ERROR, "Could not get default pem root certs.");
|
181
178
|
on_done(exec_ctx, arg, NULL);
|
182
179
|
gpr_free(c);
|
@@ -186,8 +183,7 @@ static void ssl_handshake(grpc_exec_ctx *exec_ctx, void *arg,
|
|
186
183
|
c->arg = arg;
|
187
184
|
c->handshake_mgr = grpc_handshake_manager_create();
|
188
185
|
GPR_ASSERT(httpcli_ssl_channel_security_connector_create(
|
189
|
-
exec_ctx, pem_root_certs,
|
190
|
-
GRPC_SECURITY_OK);
|
186
|
+
exec_ctx, pem_root_certs, host, &sc) == GRPC_SECURITY_OK);
|
191
187
|
grpc_channel_security_connector_add_handshakers(exec_ctx, sc,
|
192
188
|
c->handshake_mgr);
|
193
189
|
grpc_handshake_manager_do_handshake(
|
data/src/core/lib/http/parser.c
CHANGED
@@ -40,7 +40,7 @@
|
|
40
40
|
#include <grpc/support/log.h>
|
41
41
|
#include <grpc/support/useful.h>
|
42
42
|
|
43
|
-
|
43
|
+
grpc_tracer_flag grpc_http1_trace = GRPC_TRACER_INITIALIZER(false);
|
44
44
|
|
45
45
|
static char *buf2str(void *buffer, size_t length) {
|
46
46
|
char *out = gpr_malloc(length + 1);
|
@@ -308,7 +308,7 @@ static grpc_error *addbyte(grpc_http_parser *parser, uint8_t byte,
|
|
308
308
|
case GRPC_HTTP_FIRST_LINE:
|
309
309
|
case GRPC_HTTP_HEADERS:
|
310
310
|
if (parser->cur_line_length >= GRPC_HTTP_PARSER_MAX_HEADER_LENGTH) {
|
311
|
-
if (grpc_http1_trace)
|
311
|
+
if (GRPC_TRACER_ON(grpc_http1_trace))
|
312
312
|
gpr_log(GPR_ERROR, "HTTP header max line length (%d) exceeded",
|
313
313
|
GRPC_HTTP_PARSER_MAX_HEADER_LENGTH);
|
314
314
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
data/src/core/lib/http/parser.h
CHANGED
@@ -36,6 +36,7 @@
|
|
36
36
|
|
37
37
|
#include <grpc/slice.h>
|
38
38
|
#include <grpc/support/port_platform.h>
|
39
|
+
#include "src/core/lib/debug/trace.h"
|
39
40
|
#include "src/core/lib/iomgr/error.h"
|
40
41
|
|
41
42
|
/* Maximum length of a header string of the form 'Key: Value\r\n' */
|
@@ -121,6 +122,6 @@ grpc_error *grpc_http_parser_eof(grpc_http_parser *parser);
|
|
121
122
|
void grpc_http_request_destroy(grpc_http_request *request);
|
122
123
|
void grpc_http_response_destroy(grpc_http_response *response);
|
123
124
|
|
124
|
-
extern
|
125
|
+
extern grpc_tracer_flag grpc_http1_trace;
|
125
126
|
|
126
127
|
#endif /* GRPC_CORE_LIB_HTTP_PARSER_H */
|
@@ -42,13 +42,13 @@
|
|
42
42
|
#include "src/core/lib/iomgr/workqueue.h"
|
43
43
|
#include "src/core/lib/profiling/timers.h"
|
44
44
|
|
45
|
-
|
45
|
+
grpc_tracer_flag grpc_combiner_trace = GRPC_TRACER_INITIALIZER(false);
|
46
46
|
|
47
|
-
#define GRPC_COMBINER_TRACE(fn)
|
48
|
-
do {
|
49
|
-
if (grpc_combiner_trace) {
|
50
|
-
fn;
|
51
|
-
}
|
47
|
+
#define GRPC_COMBINER_TRACE(fn) \
|
48
|
+
do { \
|
49
|
+
if (GRPC_TRACER_ON(grpc_combiner_trace)) { \
|
50
|
+
fn; \
|
51
|
+
} \
|
52
52
|
} while (0)
|
53
53
|
|
54
54
|
#define STATE_UNORPHANED 1
|
@@ -37,6 +37,7 @@
|
|
37
37
|
#include <stddef.h>
|
38
38
|
|
39
39
|
#include <grpc/support/atm.h>
|
40
|
+
#include "src/core/lib/debug/trace.h"
|
40
41
|
#include "src/core/lib/iomgr/exec_ctx.h"
|
41
42
|
#include "src/core/lib/support/mpscq.h"
|
42
43
|
|
@@ -78,6 +79,6 @@ grpc_closure_scheduler *grpc_combiner_finally_scheduler(grpc_combiner *lock,
|
|
78
79
|
|
79
80
|
bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx *exec_ctx);
|
80
81
|
|
81
|
-
extern
|
82
|
+
extern grpc_tracer_flag grpc_combiner_trace;
|
82
83
|
|
83
84
|
#endif /* GRPC_CORE_LIB_IOMGR_COMBINER_H */
|
data/src/core/lib/iomgr/error.c
CHANGED
@@ -217,8 +217,14 @@ static uint8_t get_placement(grpc_error **err, size_t size) {
|
|
217
217
|
if ((*err)->arena_size + slots > (*err)->arena_capacity) {
|
218
218
|
return UINT8_MAX;
|
219
219
|
}
|
220
|
+
#ifdef GRPC_ERROR_REFCOUNT_DEBUG
|
221
|
+
grpc_error *orig = *err;
|
222
|
+
#endif
|
220
223
|
*err = gpr_realloc(
|
221
224
|
*err, sizeof(grpc_error) + (*err)->arena_capacity * sizeof(intptr_t));
|
225
|
+
#ifdef GRPC_ERROR_REFCOUNT_DEBUG
|
226
|
+
if (*err != orig) gpr_log(GPR_DEBUG, "realloc %p -> %p", orig, *err);
|
227
|
+
#endif
|
222
228
|
}
|
223
229
|
uint8_t placement = (*err)->arena_size;
|
224
230
|
(*err)->arena_size = (uint8_t)((*err)->arena_size + slots);
|
@@ -313,7 +319,7 @@ static void internal_add_error(grpc_error **err, grpc_error *new) {
|
|
313
319
|
// It is very common to include and extra int and string in an error
|
314
320
|
#define SURPLUS_CAPACITY (2 * SLOTS_PER_INT + SLOTS_PER_TIME)
|
315
321
|
|
316
|
-
grpc_error *grpc_error_create(
|
322
|
+
grpc_error *grpc_error_create(const char *file, int line, grpc_slice desc,
|
317
323
|
grpc_error **referencing,
|
318
324
|
size_t num_referencing) {
|
319
325
|
GPR_TIMER_BEGIN("grpc_error_create", 0);
|
@@ -339,7 +345,8 @@ grpc_error *grpc_error_create(grpc_slice file, int line, grpc_slice desc,
|
|
339
345
|
memset(err->times, UINT8_MAX, GRPC_ERROR_TIME_MAX);
|
340
346
|
|
341
347
|
internal_set_int(&err, GRPC_ERROR_INT_FILE_LINE, line);
|
342
|
-
internal_set_str(&err, GRPC_ERROR_STR_FILE,
|
348
|
+
internal_set_str(&err, GRPC_ERROR_STR_FILE,
|
349
|
+
grpc_slice_from_static_string(file));
|
343
350
|
internal_set_str(&err, GRPC_ERROR_STR_DESCRIPTION, desc);
|
344
351
|
|
345
352
|
for (size_t i = 0; i < num_referencing; ++i) {
|
@@ -756,13 +763,13 @@ grpc_error *grpc_os_error(const char *file, int line, int err,
|
|
756
763
|
return grpc_error_set_str(
|
757
764
|
grpc_error_set_str(
|
758
765
|
grpc_error_set_int(
|
759
|
-
grpc_error_create(
|
766
|
+
grpc_error_create(file, line,
|
760
767
|
grpc_slice_from_static_string("OS Error"), NULL,
|
761
768
|
0),
|
762
769
|
GRPC_ERROR_INT_ERRNO, err),
|
763
770
|
GRPC_ERROR_STR_OS_ERROR,
|
764
771
|
grpc_slice_from_static_string(strerror(err))),
|
765
|
-
GRPC_ERROR_STR_SYSCALL,
|
772
|
+
GRPC_ERROR_STR_SYSCALL, grpc_slice_from_copied_string(call_name));
|
766
773
|
}
|
767
774
|
|
768
775
|
#ifdef GPR_WINDOWS
|
@@ -772,7 +779,7 @@ grpc_error *grpc_wsa_error(const char *file, int line, int err,
|
|
772
779
|
grpc_error *error = grpc_error_set_str(
|
773
780
|
grpc_error_set_str(
|
774
781
|
grpc_error_set_int(
|
775
|
-
grpc_error_create(
|
782
|
+
grpc_error_create(file, line,
|
776
783
|
grpc_slice_from_static_string("OS Error"), NULL,
|
777
784
|
0),
|
778
785
|
GRPC_ERROR_INT_WSA_ERROR, err),
|