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
@@ -50,7 +50,7 @@
|
|
50
50
|
#define NOT_SET (~(size_t)0)
|
51
51
|
|
52
52
|
static grpc_uri *bad_uri(const char *uri_text, size_t pos, const char *section,
|
53
|
-
|
53
|
+
bool suppress_errors) {
|
54
54
|
char *line_prefix;
|
55
55
|
size_t pfx_len;
|
56
56
|
|
@@ -83,6 +83,11 @@ static char *decode_and_copy_component(grpc_exec_ctx *exec_ctx, const char *src,
|
|
83
83
|
return out;
|
84
84
|
}
|
85
85
|
|
86
|
+
static bool valid_hex(char c) {
|
87
|
+
return ((c >= 'a') && (c <= 'f')) || ((c >= 'A') && (c <= 'F')) ||
|
88
|
+
((c >= '0') && (c <= '9'));
|
89
|
+
}
|
90
|
+
|
86
91
|
/** Returns how many chars to advance if \a uri_text[i] begins a valid \a pchar
|
87
92
|
* production. If \a uri_text[i] introduces an invalid \a pchar (such as percent
|
88
93
|
* sign not followed by two hex digits), NOT_SET is returned. */
|
@@ -93,27 +98,36 @@ static size_t parse_pchar(const char *uri_text, size_t i) {
|
|
93
98
|
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
|
94
99
|
/ "*" / "+" / "," / ";" / "=" */
|
95
100
|
char c = uri_text[i];
|
96
|
-
|
97
|
-
|
98
|
-
(c
|
99
|
-
|
100
|
-
|
101
|
-
c == '=') /* sub-delims */) {
|
102
|
-
return 1;
|
103
|
-
}
|
104
|
-
if (c == '%') { /* pct-encoded */
|
105
|
-
size_t j;
|
106
|
-
if (uri_text[i + 1] == 0 || uri_text[i + 2] == 0) {
|
107
|
-
return NOT_SET;
|
108
|
-
}
|
109
|
-
for (j = i + 1; j < 2; j++) {
|
110
|
-
c = uri_text[j];
|
111
|
-
if (!(((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) ||
|
112
|
-
((c >= 'A') && (c <= 'F')))) {
|
113
|
-
return NOT_SET;
|
101
|
+
switch (c) {
|
102
|
+
default:
|
103
|
+
if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) ||
|
104
|
+
((c >= '0') && (c <= '9'))) {
|
105
|
+
return 1;
|
114
106
|
}
|
115
|
-
|
116
|
-
|
107
|
+
break;
|
108
|
+
case ':':
|
109
|
+
case '@':
|
110
|
+
case '-':
|
111
|
+
case '.':
|
112
|
+
case '_':
|
113
|
+
case '~':
|
114
|
+
case '!':
|
115
|
+
case '$':
|
116
|
+
case '&':
|
117
|
+
case '\'':
|
118
|
+
case '(':
|
119
|
+
case ')':
|
120
|
+
case '*':
|
121
|
+
case '+':
|
122
|
+
case ',':
|
123
|
+
case ';':
|
124
|
+
case '=':
|
125
|
+
return 1;
|
126
|
+
case '%': /* pct-encoded */
|
127
|
+
if (valid_hex(uri_text[i + 1]) && valid_hex(uri_text[i + 2])) {
|
128
|
+
return 2;
|
129
|
+
}
|
130
|
+
return NOT_SET;
|
117
131
|
}
|
118
132
|
return 0;
|
119
133
|
}
|
@@ -183,7 +197,7 @@ static void parse_query_parts(grpc_uri *uri) {
|
|
183
197
|
}
|
184
198
|
|
185
199
|
grpc_uri *grpc_uri_parse(grpc_exec_ctx *exec_ctx, const char *uri_text,
|
186
|
-
|
200
|
+
bool suppress_errors) {
|
187
201
|
grpc_uri *uri;
|
188
202
|
size_t scheme_begin = 0;
|
189
203
|
size_t scheme_end = NOT_SET;
|
@@ -53,7 +53,7 @@ typedef struct {
|
|
53
53
|
|
54
54
|
/** parse a uri, return NULL on failure */
|
55
55
|
grpc_uri *grpc_uri_parse(grpc_exec_ctx *exec_ctx, const char *uri_text,
|
56
|
-
|
56
|
+
bool suppress_errors);
|
57
57
|
|
58
58
|
/** return the part of a query string after the '=' in "?key=xxx&...", or NULL
|
59
59
|
* if key is not present */
|
@@ -29,7 +29,7 @@
|
|
29
29
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
30
|
//
|
31
31
|
|
32
|
-
#include "src/core/
|
32
|
+
#include "src/core/ext/filters/deadline/deadline_filter.h"
|
33
33
|
|
34
34
|
#include <stdbool.h>
|
35
35
|
#include <string.h>
|
@@ -39,9 +39,11 @@
|
|
39
39
|
#include <grpc/support/sync.h>
|
40
40
|
#include <grpc/support/time.h>
|
41
41
|
|
42
|
+
#include "src/core/lib/channel/channel_stack_builder.h"
|
42
43
|
#include "src/core/lib/iomgr/exec_ctx.h"
|
43
44
|
#include "src/core/lib/iomgr/timer.h"
|
44
45
|
#include "src/core/lib/slice/slice_internal.h"
|
46
|
+
#include "src/core/lib/surface/channel_init.h"
|
45
47
|
|
46
48
|
//
|
47
49
|
// grpc_deadline_state
|
@@ -141,18 +143,6 @@ static void inject_on_complete_cb(grpc_deadline_state* deadline_state,
|
|
141
143
|
op->on_complete = &deadline_state->on_complete;
|
142
144
|
}
|
143
145
|
|
144
|
-
void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
|
145
|
-
grpc_call_stack* call_stack) {
|
146
|
-
grpc_deadline_state* deadline_state = elem->call_data;
|
147
|
-
deadline_state->call_stack = call_stack;
|
148
|
-
}
|
149
|
-
|
150
|
-
void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx,
|
151
|
-
grpc_call_element* elem) {
|
152
|
-
grpc_deadline_state* deadline_state = elem->call_data;
|
153
|
-
cancel_timer_if_needed(exec_ctx, deadline_state);
|
154
|
-
}
|
155
|
-
|
156
146
|
// Callback and associated state for starting the timer after call stack
|
157
147
|
// initialization has been completed.
|
158
148
|
struct start_timer_after_init_state {
|
@@ -167,8 +157,11 @@ static void start_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg,
|
|
167
157
|
gpr_free(state);
|
168
158
|
}
|
169
159
|
|
170
|
-
void
|
171
|
-
|
160
|
+
void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
|
161
|
+
grpc_call_stack* call_stack,
|
162
|
+
gpr_timespec deadline) {
|
163
|
+
grpc_deadline_state* deadline_state = elem->call_data;
|
164
|
+
deadline_state->call_stack = call_stack;
|
172
165
|
// Deadline will always be infinite on servers, so the timer will only be
|
173
166
|
// set on clients with a finite deadline.
|
174
167
|
deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC);
|
@@ -189,6 +182,12 @@ void grpc_deadline_state_start(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
|
|
189
182
|
}
|
190
183
|
}
|
191
184
|
|
185
|
+
void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx,
|
186
|
+
grpc_call_element* elem) {
|
187
|
+
grpc_deadline_state* deadline_state = elem->call_data;
|
188
|
+
cancel_timer_if_needed(exec_ctx, deadline_state);
|
189
|
+
}
|
190
|
+
|
192
191
|
void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
|
193
192
|
gpr_timespec new_deadline) {
|
194
193
|
grpc_deadline_state* deadline_state = elem->call_data;
|
@@ -248,8 +247,7 @@ typedef struct server_call_data {
|
|
248
247
|
static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
|
249
248
|
grpc_call_element* elem,
|
250
249
|
const grpc_call_element_args* args) {
|
251
|
-
grpc_deadline_state_init(exec_ctx, elem, args->call_stack);
|
252
|
-
grpc_deadline_state_start(exec_ctx, elem, args->deadline);
|
250
|
+
grpc_deadline_state_init(exec_ctx, elem, args->call_stack, args->deadline);
|
253
251
|
return GRPC_ERROR_NONE;
|
254
252
|
}
|
255
253
|
|
@@ -346,3 +344,30 @@ const grpc_channel_filter grpc_server_deadline_filter = {
|
|
346
344
|
grpc_channel_next_get_info,
|
347
345
|
"deadline",
|
348
346
|
};
|
347
|
+
|
348
|
+
bool grpc_deadline_checking_enabled(const grpc_channel_args* channel_args) {
|
349
|
+
return grpc_channel_arg_get_bool(
|
350
|
+
grpc_channel_args_find(channel_args, GRPC_ARG_ENABLE_DEADLINE_CHECKS),
|
351
|
+
!grpc_channel_args_want_minimal_stack(channel_args));
|
352
|
+
}
|
353
|
+
|
354
|
+
static bool maybe_add_deadline_filter(grpc_exec_ctx* exec_ctx,
|
355
|
+
grpc_channel_stack_builder* builder,
|
356
|
+
void* arg) {
|
357
|
+
return grpc_deadline_checking_enabled(
|
358
|
+
grpc_channel_stack_builder_get_channel_arguments(builder))
|
359
|
+
? grpc_channel_stack_builder_prepend_filter(builder, arg, NULL,
|
360
|
+
NULL)
|
361
|
+
: true;
|
362
|
+
}
|
363
|
+
|
364
|
+
void grpc_deadline_filter_init(void) {
|
365
|
+
grpc_channel_init_register_stage(
|
366
|
+
GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
|
367
|
+
maybe_add_deadline_filter, (void*)&grpc_client_deadline_filter);
|
368
|
+
grpc_channel_init_register_stage(
|
369
|
+
GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
|
370
|
+
maybe_add_deadline_filter, (void*)&grpc_server_deadline_filter);
|
371
|
+
}
|
372
|
+
|
373
|
+
void grpc_deadline_filter_shutdown(void) {}
|
@@ -29,8 +29,8 @@
|
|
29
29
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
30
|
//
|
31
31
|
|
32
|
-
#ifndef
|
33
|
-
#define
|
32
|
+
#ifndef GRPC_CORE_EXT_FILTERS_DEADLINE_DEADLINE_FILTER_H
|
33
|
+
#define GRPC_CORE_EXT_FILTERS_DEADLINE_DEADLINE_FILTER_H
|
34
34
|
|
35
35
|
#include "src/core/lib/channel/channel_stack.h"
|
36
36
|
#include "src/core/lib/iomgr/timer.h"
|
@@ -64,15 +64,11 @@ typedef struct grpc_deadline_state {
|
|
64
64
|
|
65
65
|
// assumes elem->call_data is zero'd
|
66
66
|
void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
|
67
|
-
grpc_call_stack* call_stack
|
67
|
+
grpc_call_stack* call_stack,
|
68
|
+
gpr_timespec deadline);
|
68
69
|
void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx,
|
69
70
|
grpc_call_element* elem);
|
70
71
|
|
71
|
-
// Starts the timer with the specified deadline.
|
72
|
-
// Should be called from the filter's init_call_elem() method.
|
73
|
-
void grpc_deadline_state_start(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
|
74
|
-
gpr_timespec deadline);
|
75
|
-
|
76
72
|
// Cancels the existing timer and starts a new one with new_deadline.
|
77
73
|
//
|
78
74
|
// Note: It is generally safe to call this with an earlier deadline
|
@@ -93,10 +89,13 @@ void grpc_deadline_state_client_start_transport_stream_op_batch(
|
|
93
89
|
grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
|
94
90
|
grpc_transport_stream_op_batch* op);
|
95
91
|
|
92
|
+
// Should deadline checking be performed (according to channel args)
|
93
|
+
bool grpc_deadline_checking_enabled(const grpc_channel_args* args);
|
94
|
+
|
96
95
|
// Deadline filters for direct client channels and server channels.
|
97
96
|
// Note: Deadlines for non-direct client channels are handled by the
|
98
97
|
// client_channel filter.
|
99
98
|
extern const grpc_channel_filter grpc_client_deadline_filter;
|
100
99
|
extern const grpc_channel_filter grpc_server_deadline_filter;
|
101
100
|
|
102
|
-
#endif /*
|
101
|
+
#endif /* GRPC_CORE_EXT_FILTERS_DEADLINE_DEADLINE_FILTER_H */
|
@@ -30,7 +30,7 @@
|
|
30
30
|
*
|
31
31
|
*/
|
32
32
|
|
33
|
-
#include "src/core/
|
33
|
+
#include "src/core/ext/filters/http/client/http_client_filter.h"
|
34
34
|
#include <grpc/support/alloc.h>
|
35
35
|
#include <grpc/support/log.h>
|
36
36
|
#include <grpc/support/string_util.h>
|
@@ -220,10 +220,15 @@ static void continue_send_message(grpc_exec_ctx *exec_ctx,
|
|
220
220
|
call_data *calld = elem->call_data;
|
221
221
|
uint8_t *wrptr = calld->payload_bytes;
|
222
222
|
while (grpc_byte_stream_next(
|
223
|
-
exec_ctx, calld->send_op->payload->send_message.send_message,
|
224
|
-
&calld->
|
225
|
-
|
226
|
-
|
223
|
+
exec_ctx, calld->send_op->payload->send_message.send_message, ~(size_t)0,
|
224
|
+
&calld->got_slice)) {
|
225
|
+
grpc_byte_stream_pull(exec_ctx,
|
226
|
+
calld->send_op->payload->send_message.send_message,
|
227
|
+
&calld->incoming_slice);
|
228
|
+
if (GRPC_SLICE_LENGTH(calld->incoming_slice) > 0) {
|
229
|
+
memcpy(wrptr, GRPC_SLICE_START_PTR(calld->incoming_slice),
|
230
|
+
GRPC_SLICE_LENGTH(calld->incoming_slice));
|
231
|
+
}
|
227
232
|
wrptr += GRPC_SLICE_LENGTH(calld->incoming_slice);
|
228
233
|
grpc_slice_buffer_add(&calld->slices, calld->incoming_slice);
|
229
234
|
if (calld->send_length == calld->slices.length) {
|
@@ -237,6 +242,13 @@ static void got_slice(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) {
|
|
237
242
|
grpc_call_element *elem = elemp;
|
238
243
|
call_data *calld = elem->call_data;
|
239
244
|
calld->send_message_blocked = false;
|
245
|
+
if (GRPC_ERROR_NONE !=
|
246
|
+
grpc_byte_stream_pull(exec_ctx,
|
247
|
+
calld->send_op->payload->send_message.send_message,
|
248
|
+
&calld->incoming_slice)) {
|
249
|
+
/* Should never reach here */
|
250
|
+
abort();
|
251
|
+
}
|
240
252
|
grpc_slice_buffer_add(&calld->slices, calld->incoming_slice);
|
241
253
|
if (calld->send_length == calld->slices.length) {
|
242
254
|
/* Pass down the original send_message op that was blocked.*/
|
@@ -311,8 +323,7 @@ static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx,
|
|
311
323
|
estimated_len += grpc_base64_estimate_encoded_size(
|
312
324
|
op->payload->send_message.send_message->length, k_url_safe,
|
313
325
|
k_multi_line);
|
314
|
-
|
315
|
-
grpc_slice path_with_query_slice = grpc_slice_malloc(estimated_len);
|
326
|
+
grpc_slice path_with_query_slice = GRPC_SLICE_MALLOC(estimated_len);
|
316
327
|
|
317
328
|
/* memcopy individual pieces into this slice */
|
318
329
|
uint8_t *write_ptr =
|
@@ -332,10 +343,8 @@ static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx,
|
|
332
343
|
*/
|
333
344
|
char *t = (char *)GRPC_SLICE_START_PTR(path_with_query_slice);
|
334
345
|
/* safe to use strlen since base64_encode will always add '\0' */
|
335
|
-
size_t path_length = strlen(t) + 1;
|
336
|
-
*(t + path_length) = '\0';
|
337
346
|
path_with_query_slice =
|
338
|
-
|
347
|
+
grpc_slice_sub_no_ref(path_with_query_slice, 0, strlen(t));
|
339
348
|
|
340
349
|
/* substitute previous path with the new path+query */
|
341
350
|
grpc_mdelem mdelem_path_and_query = grpc_mdelem_from_slices(
|
@@ -349,7 +358,6 @@ static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx,
|
|
349
358
|
calld->on_complete = op->on_complete;
|
350
359
|
op->on_complete = &calld->hc_on_complete;
|
351
360
|
op->send_message = false;
|
352
|
-
grpc_slice_unref_internal(exec_ctx, path_with_query_slice);
|
353
361
|
} else {
|
354
362
|
/* Not all data is available. Fall back to POST. */
|
355
363
|
gpr_log(GPR_DEBUG,
|
@@ -30,18 +30,15 @@
|
|
30
30
|
*
|
31
31
|
*/
|
32
32
|
|
33
|
-
#ifndef
|
34
|
-
#define
|
33
|
+
#ifndef GRPC_CORE_EXT_FILTERS_HTTP_CLIENT_HTTP_CLIENT_FILTER_H
|
34
|
+
#define GRPC_CORE_EXT_FILTERS_HTTP_CLIENT_HTTP_CLIENT_FILTER_H
|
35
35
|
|
36
36
|
#include "src/core/lib/channel/channel_stack.h"
|
37
37
|
|
38
38
|
/* Processes metadata on the client side for HTTP2 transports */
|
39
39
|
extern const grpc_channel_filter grpc_http_client_filter;
|
40
40
|
|
41
|
-
/* Channel arg to override the http2 :scheme header */
|
42
|
-
#define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme"
|
43
|
-
|
44
41
|
/* Channel arg to determine maximum size of payload eligable for GET request */
|
45
42
|
#define GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET "grpc.max_payload_size_for_get"
|
46
43
|
|
47
|
-
#endif /*
|
44
|
+
#endif /* GRPC_CORE_EXT_FILTERS_HTTP_CLIENT_HTTP_CLIENT_FILTER_H */
|
@@ -0,0 +1,104 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2017, Google Inc.
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are
|
8
|
+
* met:
|
9
|
+
*
|
10
|
+
* * Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
* * Redistributions in binary form must reproduce the above
|
13
|
+
* copyright notice, this list of conditions and the following disclaimer
|
14
|
+
* in the documentation and/or other materials provided with the
|
15
|
+
* distribution.
|
16
|
+
* * Neither the name of Google Inc. nor the names of its
|
17
|
+
* contributors may be used to endorse or promote products derived from
|
18
|
+
* this software without specific prior written permission.
|
19
|
+
*
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
21
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
22
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
23
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
24
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
27
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
28
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
|
34
|
+
#include <string.h>
|
35
|
+
|
36
|
+
#include "src/core/ext/filters/http/client/http_client_filter.h"
|
37
|
+
#include "src/core/ext/filters/http/message_compress/message_compress_filter.h"
|
38
|
+
#include "src/core/ext/filters/http/server/http_server_filter.h"
|
39
|
+
#include "src/core/lib/channel/channel_stack_builder.h"
|
40
|
+
#include "src/core/lib/surface/call.h"
|
41
|
+
#include "src/core/lib/surface/channel_init.h"
|
42
|
+
#include "src/core/lib/transport/transport_impl.h"
|
43
|
+
|
44
|
+
typedef struct {
|
45
|
+
const grpc_channel_filter *filter;
|
46
|
+
const char *control_channel_arg;
|
47
|
+
} optional_filter;
|
48
|
+
|
49
|
+
static optional_filter compress_filter = {
|
50
|
+
&grpc_message_compress_filter, GRPC_ARG_ENABLE_PER_MESSAGE_COMPRESSION};
|
51
|
+
|
52
|
+
static bool is_building_http_like_transport(
|
53
|
+
grpc_channel_stack_builder *builder) {
|
54
|
+
grpc_transport *t = grpc_channel_stack_builder_get_transport(builder);
|
55
|
+
return t != NULL && strstr(t->vtable->name, "http");
|
56
|
+
}
|
57
|
+
|
58
|
+
static bool maybe_add_optional_filter(grpc_exec_ctx *exec_ctx,
|
59
|
+
grpc_channel_stack_builder *builder,
|
60
|
+
void *arg) {
|
61
|
+
if (!is_building_http_like_transport(builder)) return true;
|
62
|
+
optional_filter *filtarg = arg;
|
63
|
+
const grpc_channel_args *channel_args =
|
64
|
+
grpc_channel_stack_builder_get_channel_arguments(builder);
|
65
|
+
bool enable = grpc_channel_arg_get_bool(
|
66
|
+
grpc_channel_args_find(channel_args, filtarg->control_channel_arg),
|
67
|
+
!grpc_channel_args_want_minimal_stack(channel_args));
|
68
|
+
return enable ? grpc_channel_stack_builder_prepend_filter(
|
69
|
+
builder, filtarg->filter, NULL, NULL)
|
70
|
+
: true;
|
71
|
+
}
|
72
|
+
|
73
|
+
static bool maybe_add_required_filter(grpc_exec_ctx *exec_ctx,
|
74
|
+
grpc_channel_stack_builder *builder,
|
75
|
+
void *arg) {
|
76
|
+
return is_building_http_like_transport(builder)
|
77
|
+
? grpc_channel_stack_builder_prepend_filter(
|
78
|
+
builder, (const grpc_channel_filter *)arg, NULL, NULL)
|
79
|
+
: true;
|
80
|
+
}
|
81
|
+
|
82
|
+
void grpc_http_filters_init(void) {
|
83
|
+
grpc_register_tracer("compression", &grpc_compression_trace);
|
84
|
+
grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL,
|
85
|
+
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
|
86
|
+
maybe_add_optional_filter, &compress_filter);
|
87
|
+
grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL,
|
88
|
+
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
|
89
|
+
maybe_add_optional_filter, &compress_filter);
|
90
|
+
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL,
|
91
|
+
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
|
92
|
+
maybe_add_optional_filter, &compress_filter);
|
93
|
+
grpc_channel_init_register_stage(
|
94
|
+
GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
|
95
|
+
maybe_add_required_filter, (void *)&grpc_http_client_filter);
|
96
|
+
grpc_channel_init_register_stage(
|
97
|
+
GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
|
98
|
+
maybe_add_required_filter, (void *)&grpc_http_client_filter);
|
99
|
+
grpc_channel_init_register_stage(
|
100
|
+
GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
|
101
|
+
maybe_add_required_filter, (void *)&grpc_http_server_filter);
|
102
|
+
}
|
103
|
+
|
104
|
+
void grpc_http_filters_shutdown(void) {}
|