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
data/src/core/surface/init.c
CHANGED
@@ -46,6 +46,8 @@
|
|
46
46
|
#include "src/core/client_config/resolver_registry.h"
|
47
47
|
#include "src/core/client_config/resolvers/dns_resolver.h"
|
48
48
|
#include "src/core/client_config/resolvers/sockaddr_resolver.h"
|
49
|
+
#include "src/core/client_config/subchannel.h"
|
50
|
+
#include "src/core/client_config/subchannel_index.h"
|
49
51
|
#include "src/core/debug/trace.h"
|
50
52
|
#include "src/core/iomgr/executor.h"
|
51
53
|
#include "src/core/iomgr/iomgr.h"
|
@@ -127,6 +129,7 @@ void grpc_init(void) {
|
|
127
129
|
}
|
128
130
|
gpr_timers_global_init();
|
129
131
|
grpc_cq_global_init();
|
132
|
+
grpc_subchannel_index_init();
|
130
133
|
for (i = 0; i < g_number_of_plugins; i++) {
|
131
134
|
if (g_all_of_the_plugins[i].init != NULL) {
|
132
135
|
g_all_of_the_plugins[i].init();
|
@@ -145,6 +148,7 @@ void grpc_shutdown(void) {
|
|
145
148
|
grpc_executor_shutdown();
|
146
149
|
grpc_cq_global_shutdown();
|
147
150
|
grpc_iomgr_shutdown();
|
151
|
+
grpc_subchannel_index_shutdown();
|
148
152
|
census_shutdown();
|
149
153
|
gpr_timers_global_destroy();
|
150
154
|
grpc_tracer_shutdown();
|
@@ -78,8 +78,7 @@ static void lame_start_transport_stream_op(grpc_exec_ctx *exec_ctx,
|
|
78
78
|
} else if (op->recv_trailing_metadata != NULL) {
|
79
79
|
fill_metadata(elem, op->recv_trailing_metadata);
|
80
80
|
}
|
81
|
-
|
82
|
-
grpc_exec_ctx_enqueue(exec_ctx, op->recv_message_ready, false, NULL);
|
81
|
+
grpc_transport_stream_op_finish_with_failure(exec_ctx, op);
|
83
82
|
}
|
84
83
|
|
85
84
|
static char *lame_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
|
@@ -130,9 +130,9 @@ static void on_secure_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
|
|
130
130
|
static void on_initial_connect_string_sent(grpc_exec_ctx *exec_ctx, void *arg,
|
131
131
|
bool success) {
|
132
132
|
connector *c = arg;
|
133
|
-
|
134
|
-
|
135
|
-
|
133
|
+
grpc_channel_security_connector_do_handshake(exec_ctx, c->security_connector,
|
134
|
+
c->connecting_endpoint,
|
135
|
+
on_secure_handshake_done, c);
|
136
136
|
}
|
137
137
|
|
138
138
|
static void connected(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
|
@@ -153,9 +153,8 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
|
|
153
153
|
grpc_endpoint_write(exec_ctx, tcp, &c->initial_string_buffer,
|
154
154
|
&c->initial_string_sent);
|
155
155
|
} else {
|
156
|
-
|
157
|
-
|
158
|
-
on_secure_handshake_done, c);
|
156
|
+
grpc_channel_security_connector_do_handshake(
|
157
|
+
exec_ctx, c->security_connector, tcp, on_secure_handshake_done, c);
|
159
158
|
}
|
160
159
|
} else {
|
161
160
|
memset(c->result, 0, sizeof(*c->result));
|
@@ -238,7 +237,7 @@ static grpc_subchannel *subchannel_factory_create_subchannel(
|
|
238
237
|
gpr_mu_init(&c->mu);
|
239
238
|
gpr_ref_init(&c->refs, 1);
|
240
239
|
args->args = final_args;
|
241
|
-
s = grpc_subchannel_create(&c->base, args);
|
240
|
+
s = grpc_subchannel_create(exec_ctx, &c->base, args);
|
242
241
|
grpc_connector_unref(exec_ctx, &c->base);
|
243
242
|
grpc_channel_args_destroy(final_args);
|
244
243
|
return s;
|
data/src/core/surface/server.c
CHANGED
@@ -407,8 +407,15 @@ static void destroy_channel(grpc_exec_ctx *exec_ctx, channel_data *chand) {
|
|
407
407
|
maybe_finish_shutdown(exec_ctx, chand->server);
|
408
408
|
chand->finish_destroy_channel_closure.cb = finish_destroy_channel;
|
409
409
|
chand->finish_destroy_channel_closure.cb_arg = chand;
|
410
|
-
|
411
|
-
|
410
|
+
|
411
|
+
grpc_transport_op op;
|
412
|
+
memset(&op, 0, sizeof(op));
|
413
|
+
op.set_accept_stream = true;
|
414
|
+
op.on_consumed = &chand->finish_destroy_channel_closure;
|
415
|
+
grpc_channel_next_op(exec_ctx,
|
416
|
+
grpc_channel_stack_element(
|
417
|
+
grpc_channel_get_channel_stack(chand->channel), 0),
|
418
|
+
&op);
|
412
419
|
}
|
413
420
|
|
414
421
|
static void finish_start_new_rpc(grpc_exec_ctx *exec_ctx, grpc_server *server,
|
@@ -596,8 +603,8 @@ static void server_mutate_op(grpc_call_element *elem,
|
|
596
603
|
|
597
604
|
if (op->recv_initial_metadata != NULL) {
|
598
605
|
calld->recv_initial_metadata = op->recv_initial_metadata;
|
599
|
-
calld->on_done_recv_initial_metadata = op->
|
600
|
-
op->
|
606
|
+
calld->on_done_recv_initial_metadata = op->recv_initial_metadata_ready;
|
607
|
+
op->recv_initial_metadata_ready = &calld->server_on_recv_initial_metadata;
|
601
608
|
}
|
602
609
|
}
|
603
610
|
|
@@ -971,7 +978,8 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
|
|
971
978
|
|
972
979
|
GRPC_CHANNEL_INTERNAL_REF(channel, "connectivity");
|
973
980
|
memset(&op, 0, sizeof(op));
|
974
|
-
op.set_accept_stream =
|
981
|
+
op.set_accept_stream = true;
|
982
|
+
op.set_accept_stream_fn = accept_stream;
|
975
983
|
op.set_accept_stream_user_data = chand;
|
976
984
|
op.on_connectivity_state_change = &chand->channel_connectivity_changed;
|
977
985
|
op.connectivity_state = &chand->connectivity_state;
|
@@ -50,7 +50,7 @@ static int conforms_to(const char *s, size_t len, const uint8_t *legal_bits) {
|
|
50
50
|
|
51
51
|
int grpc_header_key_is_legal(const char *key, size_t length) {
|
52
52
|
static const uint8_t legal_header_bits[256 / 8] = {
|
53
|
-
0x00, 0x00, 0x00, 0x00, 0x00,
|
53
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xff, 0x03, 0x00, 0x00, 0x00,
|
54
54
|
0x80, 0xfe, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
55
55
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
56
56
|
if (length == 0) {
|
data/src/core/surface/version.c
CHANGED
@@ -358,6 +358,9 @@ struct grpc_chttp2_transport {
|
|
358
358
|
/** connectivity tracking */
|
359
359
|
grpc_connectivity_state_tracker state_tracker;
|
360
360
|
} channel_callback;
|
361
|
+
|
362
|
+
/** Transport op to be applied post-parsing */
|
363
|
+
grpc_transport_op *post_parsing_op;
|
361
364
|
};
|
362
365
|
|
363
366
|
typedef struct {
|
@@ -385,7 +388,7 @@ typedef struct {
|
|
385
388
|
grpc_closure *send_trailing_metadata_finished;
|
386
389
|
|
387
390
|
grpc_metadata_batch *recv_initial_metadata;
|
388
|
-
grpc_closure *
|
391
|
+
grpc_closure *recv_initial_metadata_ready;
|
389
392
|
grpc_byte_stream **recv_message;
|
390
393
|
grpc_closure *recv_message_ready;
|
391
394
|
grpc_metadata_batch *recv_trailing_metadata;
|
@@ -417,7 +420,7 @@ typedef struct {
|
|
417
420
|
/** HTTP2 stream id for this stream, or zero if one has not been assigned */
|
418
421
|
uint32_t id;
|
419
422
|
uint8_t fetching;
|
420
|
-
|
423
|
+
bool sent_initial_metadata;
|
421
424
|
uint8_t sent_message;
|
422
425
|
uint8_t sent_trailing_metadata;
|
423
426
|
uint8_t read_closed;
|
@@ -485,7 +488,8 @@ struct grpc_chttp2_stream {
|
|
485
488
|
|
486
489
|
/** Someone is unlocking the transport mutex: check to see if writes
|
487
490
|
are required, and schedule them if so */
|
488
|
-
int grpc_chttp2_unlocking_check_writes(
|
491
|
+
int grpc_chttp2_unlocking_check_writes(grpc_exec_ctx *exec_ctx,
|
492
|
+
grpc_chttp2_transport_global *global,
|
489
493
|
grpc_chttp2_transport_writing *writing,
|
490
494
|
int is_parsing);
|
491
495
|
void grpc_chttp2_perform_writes(
|
@@ -508,7 +512,7 @@ void grpc_chttp2_publish_reads(grpc_exec_ctx *exec_ctx,
|
|
508
512
|
grpc_chttp2_transport_global *global,
|
509
513
|
grpc_chttp2_transport_parsing *parsing);
|
510
514
|
|
511
|
-
|
515
|
+
bool grpc_chttp2_list_add_writable_stream(
|
512
516
|
grpc_chttp2_transport_global *transport_global,
|
513
517
|
grpc_chttp2_stream_global *stream_global);
|
514
518
|
/** Get a writable stream
|
@@ -518,14 +522,13 @@ int grpc_chttp2_list_pop_writable_stream(
|
|
518
522
|
grpc_chttp2_transport_writing *transport_writing,
|
519
523
|
grpc_chttp2_stream_global **stream_global,
|
520
524
|
grpc_chttp2_stream_writing **stream_writing);
|
521
|
-
|
525
|
+
bool grpc_chttp2_list_remove_writable_stream(
|
522
526
|
grpc_chttp2_transport_global *transport_global,
|
523
|
-
grpc_chttp2_stream_global *stream_global);
|
527
|
+
grpc_chttp2_stream_global *stream_global) GRPC_MUST_USE_RESULT;
|
524
528
|
|
525
|
-
|
526
|
-
int grpc_chttp2_list_add_writing_stream(
|
529
|
+
void grpc_chttp2_list_add_writing_stream(
|
527
530
|
grpc_chttp2_transport_writing *transport_writing,
|
528
|
-
grpc_chttp2_stream_writing *stream_writing)
|
531
|
+
grpc_chttp2_stream_writing *stream_writing);
|
529
532
|
int grpc_chttp2_list_have_writing_streams(
|
530
533
|
grpc_chttp2_transport_writing *transport_writing);
|
531
534
|
int grpc_chttp2_list_pop_writing_stream(
|
@@ -568,8 +571,12 @@ void grpc_chttp2_list_add_writing_stalled_by_transport(
|
|
568
571
|
grpc_chttp2_transport_writing *transport_writing,
|
569
572
|
grpc_chttp2_stream_writing *stream_writing);
|
570
573
|
void grpc_chttp2_list_flush_writing_stalled_by_transport(
|
571
|
-
grpc_chttp2_transport_writing *transport_writing,
|
574
|
+
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_writing *transport_writing,
|
575
|
+
bool is_window_available);
|
572
576
|
|
577
|
+
void grpc_chttp2_list_add_stalled_by_transport(
|
578
|
+
grpc_chttp2_transport_writing *transport_writing,
|
579
|
+
grpc_chttp2_stream_writing *stream_writing);
|
573
580
|
int grpc_chttp2_list_pop_stalled_by_transport(
|
574
581
|
grpc_chttp2_transport_global *transport_global,
|
575
582
|
grpc_chttp2_stream_global **stream_global);
|
@@ -765,4 +772,9 @@ void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx,
|
|
765
772
|
grpc_chttp2_transport_parsing *parsing,
|
766
773
|
const uint8_t *opaque_8bytes);
|
767
774
|
|
775
|
+
/** add a ref to the stream and add it to the writable list;
|
776
|
+
ref will be dropped in writing.c */
|
777
|
+
void grpc_chttp2_become_writable(grpc_chttp2_transport_global *transport_global,
|
778
|
+
grpc_chttp2_stream_global *stream_global);
|
779
|
+
|
768
780
|
#endif
|
@@ -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
|
@@ -149,7 +149,7 @@ void grpc_chttp2_publish_reads(
|
|
149
149
|
if (was_zero && !is_zero) {
|
150
150
|
while (grpc_chttp2_list_pop_stalled_by_transport(transport_global,
|
151
151
|
&stream_global)) {
|
152
|
-
|
152
|
+
grpc_chttp2_become_writable(transport_global, stream_global);
|
153
153
|
}
|
154
154
|
}
|
155
155
|
|
@@ -178,7 +178,7 @@ void grpc_chttp2_publish_reads(
|
|
178
178
|
outgoing_window);
|
179
179
|
is_zero = stream_global->outgoing_window <= 0;
|
180
180
|
if (was_zero && !is_zero) {
|
181
|
-
|
181
|
+
grpc_chttp2_become_writable(transport_global, stream_global);
|
182
182
|
}
|
183
183
|
|
184
184
|
stream_global->max_recv_bytes -= (uint32_t)GPR_MIN(
|
@@ -100,11 +100,14 @@ static void stream_list_remove(grpc_chttp2_transport *t, grpc_chttp2_stream *s,
|
|
100
100
|
}
|
101
101
|
}
|
102
102
|
|
103
|
-
static
|
103
|
+
static bool stream_list_maybe_remove(grpc_chttp2_transport *t,
|
104
104
|
grpc_chttp2_stream *s,
|
105
105
|
grpc_chttp2_stream_list_id id) {
|
106
106
|
if (s->included[id]) {
|
107
107
|
stream_list_remove(t, s, id);
|
108
|
+
return true;
|
109
|
+
} else {
|
110
|
+
return false;
|
108
111
|
}
|
109
112
|
}
|
110
113
|
|
@@ -125,23 +128,24 @@ static void stream_list_add_tail(grpc_chttp2_transport *t,
|
|
125
128
|
s->included[id] = 1;
|
126
129
|
}
|
127
130
|
|
128
|
-
static
|
129
|
-
|
131
|
+
static bool stream_list_add(grpc_chttp2_transport *t, grpc_chttp2_stream *s,
|
132
|
+
grpc_chttp2_stream_list_id id) {
|
130
133
|
if (s->included[id]) {
|
131
|
-
return
|
134
|
+
return false;
|
132
135
|
}
|
133
136
|
stream_list_add_tail(t, s, id);
|
134
|
-
return
|
137
|
+
return true;
|
135
138
|
}
|
136
139
|
|
137
140
|
/* wrappers for specializations */
|
138
141
|
|
139
|
-
|
142
|
+
bool grpc_chttp2_list_add_writable_stream(
|
140
143
|
grpc_chttp2_transport_global *transport_global,
|
141
144
|
grpc_chttp2_stream_global *stream_global) {
|
142
145
|
GPR_ASSERT(stream_global->id != 0);
|
143
|
-
stream_list_add(TRANSPORT_FROM_GLOBAL(transport_global),
|
144
|
-
|
146
|
+
return stream_list_add(TRANSPORT_FROM_GLOBAL(transport_global),
|
147
|
+
STREAM_FROM_GLOBAL(stream_global),
|
148
|
+
GRPC_CHTTP2_LIST_WRITABLE);
|
145
149
|
}
|
146
150
|
|
147
151
|
int grpc_chttp2_list_pop_writable_stream(
|
@@ -159,20 +163,20 @@ int grpc_chttp2_list_pop_writable_stream(
|
|
159
163
|
return r;
|
160
164
|
}
|
161
165
|
|
162
|
-
|
166
|
+
bool grpc_chttp2_list_remove_writable_stream(
|
163
167
|
grpc_chttp2_transport_global *transport_global,
|
164
168
|
grpc_chttp2_stream_global *stream_global) {
|
165
|
-
stream_list_maybe_remove(TRANSPORT_FROM_GLOBAL(transport_global),
|
166
|
-
|
167
|
-
|
169
|
+
return stream_list_maybe_remove(TRANSPORT_FROM_GLOBAL(transport_global),
|
170
|
+
STREAM_FROM_GLOBAL(stream_global),
|
171
|
+
GRPC_CHTTP2_LIST_WRITABLE);
|
168
172
|
}
|
169
173
|
|
170
|
-
|
174
|
+
void grpc_chttp2_list_add_writing_stream(
|
171
175
|
grpc_chttp2_transport_writing *transport_writing,
|
172
176
|
grpc_chttp2_stream_writing *stream_writing) {
|
173
|
-
|
174
|
-
|
175
|
-
|
177
|
+
GPR_ASSERT(stream_list_add(TRANSPORT_FROM_WRITING(transport_writing),
|
178
|
+
STREAM_FROM_WRITING(stream_writing),
|
179
|
+
GRPC_CHTTP2_LIST_WRITING));
|
176
180
|
}
|
177
181
|
|
178
182
|
int grpc_chttp2_list_have_writing_streams(
|
@@ -316,26 +320,40 @@ int grpc_chttp2_list_pop_check_read_ops(
|
|
316
320
|
void grpc_chttp2_list_add_writing_stalled_by_transport(
|
317
321
|
grpc_chttp2_transport_writing *transport_writing,
|
318
322
|
grpc_chttp2_stream_writing *stream_writing) {
|
319
|
-
|
320
|
-
|
323
|
+
grpc_chttp2_stream *stream = STREAM_FROM_WRITING(stream_writing);
|
324
|
+
if (!stream->included[GRPC_CHTTP2_LIST_WRITING_STALLED_BY_TRANSPORT]) {
|
325
|
+
GRPC_CHTTP2_STREAM_REF(&stream->global, "chttp2_writing_stalled");
|
326
|
+
}
|
327
|
+
stream_list_add(TRANSPORT_FROM_WRITING(transport_writing), stream,
|
321
328
|
GRPC_CHTTP2_LIST_WRITING_STALLED_BY_TRANSPORT);
|
322
329
|
}
|
323
330
|
|
324
331
|
void grpc_chttp2_list_flush_writing_stalled_by_transport(
|
325
|
-
grpc_chttp2_transport_writing *transport_writing,
|
332
|
+
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_writing *transport_writing,
|
326
333
|
bool is_window_available) {
|
327
334
|
grpc_chttp2_stream *stream;
|
328
335
|
grpc_chttp2_transport *transport = TRANSPORT_FROM_WRITING(transport_writing);
|
329
336
|
while (stream_list_pop(transport, &stream,
|
330
337
|
GRPC_CHTTP2_LIST_WRITING_STALLED_BY_TRANSPORT)) {
|
331
338
|
if (is_window_available) {
|
332
|
-
|
339
|
+
grpc_chttp2_become_writable(&transport->global, &stream->global);
|
333
340
|
} else {
|
334
|
-
|
341
|
+
grpc_chttp2_list_add_stalled_by_transport(transport_writing,
|
342
|
+
&stream->writing);
|
335
343
|
}
|
344
|
+
GRPC_CHTTP2_STREAM_UNREF(exec_ctx, &stream->global,
|
345
|
+
"chttp2_writing_stalled");
|
336
346
|
}
|
337
347
|
}
|
338
348
|
|
349
|
+
void grpc_chttp2_list_add_stalled_by_transport(
|
350
|
+
grpc_chttp2_transport_writing *transport_writing,
|
351
|
+
grpc_chttp2_stream_writing *stream_writing) {
|
352
|
+
stream_list_add(TRANSPORT_FROM_WRITING(transport_writing),
|
353
|
+
STREAM_FROM_WRITING(stream_writing),
|
354
|
+
GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT);
|
355
|
+
}
|
356
|
+
|
339
357
|
int grpc_chttp2_list_pop_stalled_by_transport(
|
340
358
|
grpc_chttp2_transport_global *transport_global,
|
341
359
|
grpc_chttp2_stream_global **stream_global) {
|
@@ -44,7 +44,7 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx,
|
|
44
44
|
grpc_chttp2_transport_writing *transport_writing);
|
45
45
|
|
46
46
|
int grpc_chttp2_unlocking_check_writes(
|
47
|
-
grpc_chttp2_transport_global *transport_global,
|
47
|
+
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *transport_global,
|
48
48
|
grpc_chttp2_transport_writing *transport_writing, int is_parsing) {
|
49
49
|
grpc_chttp2_stream_global *stream_global;
|
50
50
|
grpc_chttp2_stream_writing *stream_writing;
|
@@ -76,14 +76,15 @@ int grpc_chttp2_unlocking_check_writes(
|
|
76
76
|
GRPC_CHTTP2_FLOW_MOVE_TRANSPORT("write", transport_writing, outgoing_window,
|
77
77
|
transport_global, outgoing_window);
|
78
78
|
bool is_window_available = transport_writing->outgoing_window > 0;
|
79
|
-
grpc_chttp2_list_flush_writing_stalled_by_transport(
|
80
|
-
|
79
|
+
grpc_chttp2_list_flush_writing_stalled_by_transport(
|
80
|
+
exec_ctx, transport_writing, is_window_available);
|
81
81
|
|
82
82
|
/* for each grpc_chttp2_stream that's become writable, frame it's data
|
83
83
|
(according to available window sizes) and add to the output buffer */
|
84
84
|
while (grpc_chttp2_list_pop_writable_stream(
|
85
85
|
transport_global, transport_writing, &stream_global, &stream_writing)) {
|
86
|
-
|
86
|
+
bool sent_initial_metadata = stream_writing->sent_initial_metadata;
|
87
|
+
bool become_writable = false;
|
87
88
|
|
88
89
|
stream_writing->id = stream_global->id;
|
89
90
|
stream_writing->read_closed = stream_global->read_closed;
|
@@ -92,16 +93,12 @@ int grpc_chttp2_unlocking_check_writes(
|
|
92
93
|
outgoing_window, stream_global,
|
93
94
|
outgoing_window);
|
94
95
|
|
95
|
-
sent_initial_metadata = stream_writing->sent_initial_metadata;
|
96
96
|
if (!sent_initial_metadata && stream_global->send_initial_metadata) {
|
97
97
|
stream_writing->send_initial_metadata =
|
98
98
|
stream_global->send_initial_metadata;
|
99
99
|
stream_global->send_initial_metadata = NULL;
|
100
|
-
|
101
|
-
|
102
|
-
GRPC_CHTTP2_STREAM_REF(stream_global, "chttp2_writing");
|
103
|
-
}
|
104
|
-
sent_initial_metadata = 1;
|
100
|
+
become_writable = true;
|
101
|
+
sent_initial_metadata = true;
|
105
102
|
}
|
106
103
|
if (sent_initial_metadata) {
|
107
104
|
if (stream_global->send_message != NULL) {
|
@@ -128,23 +125,17 @@ int grpc_chttp2_unlocking_check_writes(
|
|
128
125
|
stream_writing->flow_controlled_buffer.length > 0) &&
|
129
126
|
stream_writing->outgoing_window > 0) {
|
130
127
|
if (transport_writing->outgoing_window > 0) {
|
131
|
-
|
132
|
-
stream_writing)) {
|
133
|
-
GRPC_CHTTP2_STREAM_REF(stream_global, "chttp2_writing");
|
134
|
-
}
|
128
|
+
become_writable = true;
|
135
129
|
} else {
|
136
|
-
|
137
|
-
|
130
|
+
grpc_chttp2_list_add_stalled_by_transport(transport_writing,
|
131
|
+
stream_writing);
|
138
132
|
}
|
139
133
|
}
|
140
134
|
if (stream_global->send_trailing_metadata) {
|
141
135
|
stream_writing->send_trailing_metadata =
|
142
136
|
stream_global->send_trailing_metadata;
|
143
137
|
stream_global->send_trailing_metadata = NULL;
|
144
|
-
|
145
|
-
stream_writing)) {
|
146
|
-
GRPC_CHTTP2_STREAM_REF(stream_global, "chttp2_writing");
|
147
|
-
}
|
138
|
+
become_writable = true;
|
148
139
|
}
|
149
140
|
}
|
150
141
|
|
@@ -153,10 +144,13 @@ int grpc_chttp2_unlocking_check_writes(
|
|
153
144
|
GRPC_CHTTP2_FLOW_MOVE_STREAM("write", transport_global, stream_writing,
|
154
145
|
announce_window, stream_global,
|
155
146
|
unannounced_incoming_window_for_writing);
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
147
|
+
become_writable = true;
|
148
|
+
}
|
149
|
+
|
150
|
+
if (become_writable) {
|
151
|
+
grpc_chttp2_list_add_writing_stream(transport_writing, stream_writing);
|
152
|
+
} else {
|
153
|
+
GRPC_CHTTP2_STREAM_UNREF(exec_ctx, stream_global, "chttp2_writing");
|
160
154
|
}
|
161
155
|
}
|
162
156
|
|
@@ -310,10 +304,7 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx,
|
|
310
304
|
(stream_writing->send_message && !stream_writing->fetching)) &&
|
311
305
|
stream_writing->outgoing_window > 0) {
|
312
306
|
if (transport_writing->outgoing_window > 0) {
|
313
|
-
|
314
|
-
stream_writing)) {
|
315
|
-
/* do nothing - already reffed */
|
316
|
-
}
|
307
|
+
grpc_chttp2_list_add_writing_stream(transport_writing, stream_writing);
|
317
308
|
} else {
|
318
309
|
grpc_chttp2_list_add_writing_stalled_by_transport(transport_writing,
|
319
310
|
stream_writing);
|