diff options
author | 2015-06-16 22:41:18 -0700 | |
---|---|---|
committer | 2015-06-16 22:41:18 -0700 | |
commit | 759eb32207185ce19d61ce7043d67bd278b30006 (patch) | |
tree | df5a10c4bea4fab1b7a7c15ab9564b91f8e6f9e3 /src/core/transport/chttp2 | |
parent | 83fb070f15b2cdb96a2ad7c611a09ee33df001a3 (diff) |
First request/response with separated chttp2 lock passes
Diffstat (limited to 'src/core/transport/chttp2')
-rw-r--r-- | src/core/transport/chttp2/internal.h | 37 | ||||
-rw-r--r-- | src/core/transport/chttp2/parsing.c | 4 | ||||
-rw-r--r-- | src/core/transport/chttp2/stream_lists.c | 25 | ||||
-rw-r--r-- | src/core/transport/chttp2/writing.c | 4 |
4 files changed, 20 insertions, 50 deletions
diff --git a/src/core/transport/chttp2/internal.h b/src/core/transport/chttp2/internal.h index 7bd91334b4..078d1501bb 100644 --- a/src/core/transport/chttp2/internal.h +++ b/src/core/transport/chttp2/internal.h @@ -56,7 +56,6 @@ typedef struct grpc_chttp2_stream grpc_chttp2_stream; typedef enum { GRPC_CHTTP2_LIST_ALL_STREAMS, GRPC_CHTTP2_LIST_READ_WRITE_STATE_CHANGED, - GRPC_CHTTP2_LIST_INCOMING_WINDOW_STATE_CHANGED, GRPC_CHTTP2_LIST_WRITABLE, GRPC_CHTTP2_LIST_WRITING, GRPC_CHTTP2_LIST_WRITTEN, @@ -67,29 +66,6 @@ typedef enum { /** streams that are waiting to start because there are too many concurrent streams on the connection */ GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY, -#if 0 - /* streams that have pending writes */ - WRITABLE = 0, - /* streams that have been selected to be written */ - WRITING, - /* streams that have just been written, and included a close */ - WRITTEN_CLOSED, - /* streams that have been cancelled and have some pending state updates - to perform */ - CANCELLED, - /* streams that want to send window updates */ - WINDOW_UPDATE, - /* streams that are waiting to start because there are too many concurrent - streams on the connection */ - WAITING_FOR_CONCURRENCY, - /* streams that have finished reading: we wait until unlock to coalesce - all changes into one callback */ - FINISHED_READ_OP, - MAYBE_FINISH_READ_AFTER_PARSE, - PARSER_CHECK_WINDOW_UPDATES_AFTER_PARSE, - OTHER_CHECK_WINDOW_UPDATES_AFTER_PARSE, - NEW_OUTGOING_WINDOW, -#endif STREAM_LIST_COUNT /* must be last */ } grpc_chttp2_stream_list_id; @@ -543,6 +519,9 @@ int grpc_chttp2_list_pop_incoming_window_updated( grpc_chttp2_transport_parsing *transport_parsing, grpc_chttp2_stream_global **stream_global, grpc_chttp2_stream_parsing **stream_parsing); +void grpc_chttp2_list_remove_incoming_window_updated( + grpc_chttp2_transport_global *transport_global, + grpc_chttp2_stream_global *stream_global); void grpc_chttp2_list_add_writing_stream( grpc_chttp2_transport_writing *transport_writing, @@ -599,10 +578,6 @@ int grpc_chttp2_list_pop_read_write_state_changed( grpc_chttp2_transport_global *transport_global, grpc_chttp2_stream_global **stream_global); -void grpc_chttp2_list_add_incoming_window_state_changed( - grpc_chttp2_transport_global *transport_global, - grpc_chttp2_stream_global *stream_global); - /** schedule a closure to run without the transport lock taken */ void grpc_chttp2_schedule_closure( grpc_chttp2_transport_global *transport_global, grpc_iomgr_closure *closure, @@ -610,8 +585,6 @@ void grpc_chttp2_schedule_closure( grpc_chttp2_stream_parsing *grpc_chttp2_parsing_lookup_stream( grpc_chttp2_transport_parsing *transport_parsing, gpr_uint32 id); -void grpc_chttp2_parsing_remove_stream( - grpc_chttp2_transport_parsing *transport_parsing, gpr_uint32 id); grpc_chttp2_stream_parsing *grpc_chttp2_parsing_accept_stream( grpc_chttp2_transport_parsing *transport_parsing, gpr_uint32 id); @@ -619,10 +592,6 @@ void grpc_chttp2_add_incoming_goaway( grpc_chttp2_transport_global *transport_global, gpr_uint32 goaway_error, gpr_slice goaway_text); -void grpc_chttp2_remove_from_stream_map( - grpc_chttp2_transport_global *transport_global, - grpc_chttp2_stream_global *stream_global); - void grpc_chttp2_register_stream(grpc_chttp2_transport *t, grpc_chttp2_stream *s); void grpc_chttp2_unregister_stream(grpc_chttp2_transport *t, diff --git a/src/core/transport/chttp2/parsing.c b/src/core/transport/chttp2/parsing.c index bd04acf60f..1acf0a4b91 100644 --- a/src/core/transport/chttp2/parsing.c +++ b/src/core/transport/chttp2/parsing.c @@ -175,10 +175,6 @@ void grpc_chttp2_publish_reads( /* updating closed status */ if (stream_parsing->received_close) { stream_global->read_closed = 1; - if (stream_global->write_state != WRITE_STATE_OPEN) { - stream_global->in_stream_map = 0; - grpc_chttp2_parsing_remove_stream(transport_parsing, stream_parsing->id); - } grpc_chttp2_list_add_read_write_state_changed(transport_global, stream_global); } diff --git a/src/core/transport/chttp2/stream_lists.c b/src/core/transport/chttp2/stream_lists.c index b70ac8c9f7..72431ff6a6 100644 --- a/src/core/transport/chttp2/stream_lists.c +++ b/src/core/transport/chttp2/stream_lists.c @@ -100,6 +100,13 @@ static void stream_list_remove(grpc_chttp2_transport *t, grpc_chttp2_stream *s, } } +static void stream_list_maybe_remove(grpc_chttp2_transport *t, grpc_chttp2_stream *s, + grpc_chttp2_stream_list_id id) { + if (s->included[id]) { + stream_list_remove(t, s, id); + } +} + static void stream_list_add_tail(grpc_chttp2_transport *t, grpc_chttp2_stream *s, grpc_chttp2_stream_list_id id) { @@ -273,7 +280,7 @@ void grpc_chttp2_list_add_incoming_window_updated( grpc_chttp2_stream_global *stream_global) { stream_list_add(TRANSPORT_FROM_GLOBAL(transport_global), STREAM_FROM_GLOBAL(stream_global), - GRPC_CHTTP2_LIST_INCOMING_WINDOW_STATE_CHANGED); + GRPC_CHTTP2_LIST_INCOMING_WINDOW_UPDATED); } int grpc_chttp2_list_pop_incoming_window_updated( @@ -283,12 +290,18 @@ int grpc_chttp2_list_pop_incoming_window_updated( grpc_chttp2_stream_parsing **stream_parsing) { grpc_chttp2_stream *stream; int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream, - GRPC_CHTTP2_LIST_INCOMING_WINDOW_STATE_CHANGED); + GRPC_CHTTP2_LIST_INCOMING_WINDOW_UPDATED); *stream_global = &stream->global; *stream_parsing = &stream->parsing; return r; } +void grpc_chttp2_list_remove_incoming_window_updated( + grpc_chttp2_transport_global *transport_global, + grpc_chttp2_stream_global *stream_global) { + stream_list_maybe_remove(TRANSPORT_FROM_GLOBAL(transport_global), STREAM_FROM_GLOBAL(stream_global), GRPC_CHTTP2_LIST_INCOMING_WINDOW_UPDATED); +} + void grpc_chttp2_list_add_read_write_state_changed( grpc_chttp2_transport_global *transport_global, grpc_chttp2_stream_global *stream_global) { @@ -306,14 +319,6 @@ int grpc_chttp2_list_pop_read_write_state_changed( return r; } -void grpc_chttp2_list_add_incoming_window_state_changed( - grpc_chttp2_transport_global *transport_global, - grpc_chttp2_stream_global *stream_global) { - stream_list_add(TRANSPORT_FROM_GLOBAL(transport_global), - STREAM_FROM_GLOBAL(stream_global), - GRPC_CHTTP2_LIST_INCOMING_WINDOW_STATE_CHANGED); -} - void grpc_chttp2_register_stream(grpc_chttp2_transport *t, grpc_chttp2_stream *s) { stream_list_add_tail(t, s, GRPC_CHTTP2_LIST_ALL_STREAMS); diff --git a/src/core/transport/chttp2/writing.c b/src/core/transport/chttp2/writing.c index e83ec632b5..e7a00db062 100644 --- a/src/core/transport/chttp2/writing.c +++ b/src/core/transport/chttp2/writing.c @@ -98,7 +98,7 @@ int grpc_chttp2_unlocking_check_writes( stream_global->outgoing_sopb = NULL; grpc_chttp2_schedule_closure(transport_global, stream_global->send_done_closure, 1); - } else if (stream_global->outgoing_window) { + } else if (stream_global->outgoing_window > 0) { grpc_chttp2_list_add_writable_stream(transport_global, stream_global); } } @@ -112,6 +112,7 @@ int grpc_chttp2_unlocking_check_writes( [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] - stream_global->incoming_window; if (!stream_global->read_closed && window_delta > 0) { + GPR_ASSERT(stream_global->in_stream_map); gpr_slice_buffer_add( &transport_writing->outbuf, grpc_chttp2_window_update_create(stream_global->id, window_delta)); @@ -190,7 +191,6 @@ void grpc_chttp2_cleanup_writing( while (grpc_chttp2_list_pop_written_stream( transport_global, transport_writing, &stream_global, &stream_writing)) { - gpr_log(GPR_DEBUG, "sc:%d ws:%d", (int)stream_writing->send_closed, stream_global->write_state); if (stream_writing->send_closed != DONT_SEND_CLOSED) { stream_global->write_state = WRITE_STATE_SENT_CLOSE; if (!transport_global->is_client) { |