Skip to content

Commit

Permalink
Improve client side performance (#106)
Browse files Browse the repository at this point in the history
* Improve client side performance

* Fix client_server_SUITE
  • Loading branch information
Rafał Słota authored and tsloughter committed Jun 19, 2018
1 parent caec4b0 commit 7a3c64d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
20 changes: 13 additions & 7 deletions src/h2_connection.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1117,13 +1117,19 @@ handle_event({call, From}, streams,
handle_event({call, From}, {get_response, StreamId},
#connection{}=Conn) ->
Stream = h2_stream_set:get(StreamId, Conn#connection.streams),
Reply = case h2_stream_set:type(Stream) of
closed ->
{ok, h2_stream_set:response(Stream)};
active ->
not_ready
end,
{keep_state, Conn, [{reply, From, Reply}]};
{Reply, NewStreams} =
case h2_stream_set:type(Stream) of
closed ->
{_, NewStreams0} =
h2_stream_set:close(
Stream,
garbage,
Conn#connection.streams),
{{ok, h2_stream_set:response(Stream)}, NewStreams0};
active ->
{not_ready, Conn#connection.streams}
end,
{keep_state, Conn#connection{streams=NewStreams}, [{reply, From, Reply}]};
handle_event({call, From}, {new_stream, NotifyPid},
#connection{
streams=Streams,
Expand Down
3 changes: 1 addition & 2 deletions test/client_server_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ basic_push(_Config) ->
?assertEqual(0, (h2_stream_set:their_active_count(Streams))),

MyActiveStreams = h2_stream_set:my_active_streams(Streams),
?assertEqual(1, (length(MyActiveStreams))),
?assertEqual(1, (h2_stream_set:stream_id(hd(MyActiveStreams)))),
?assertEqual(0, (length(MyActiveStreams))), %% This closed stream should be GC'ed

TheirActiveStreams = h2_stream_set:their_active_streams(Streams),
?assertEqual(12, (length(TheirActiveStreams))),
Expand Down

0 comments on commit 7a3c64d

Please sign in to comment.