Skip to content

Instantly share code, notes, and snippets.

@arekinath
Created May 29, 2013 01:05
Show Gist options
  • Save arekinath/5667290 to your computer and use it in GitHub Desktop.
Save arekinath/5667290 to your computer and use it in GitHub Desktop.
diff --git a/src/riak_cs_get_fsm.erl b/src/riak_cs_get_fsm.erl
index 0b953c8..63c84c7 100644
--- a/src/riak_cs_get_fsm.erl
+++ b/src/riak_cs_get_fsm.erl
@@ -239,7 +239,7 @@ waiting_chunks(get_next_chunk, From, State) ->
GotSize = orddict:size(Got),
MaxGotSize = riak_cs_lfs_utils:get_fsm_buffer_size_factor(),
if GotSize < MaxGotSize ->
- {next_state, waiting_chunks, UpdState, 0};
+ {next_state, waiting_chunks, read_blocks(UpdState)};
true ->
{next_state, waiting_chunks, UpdState}
end;
@@ -259,6 +259,7 @@ perhaps_send_to_user(From, #state{got_blocks=Got,
%% Must use gen_fsm:reply/2 here! We are shared
%% with an async event func and must return next_state.
gen_fsm:reply(From, {chunk, Block}),
+ erlang:garbage_collect(),
{sent, State#state{got_blocks=orddict:erase(NextBlock, Got)
blocks_intransit=UpdIntransit}};
error ->
@@ -266,12 +267,12 @@ perhaps_send_to_user(From, #state{got_blocks=Got,
end
end.
-waiting_chunks(timeout, State = #state{got_blocks = Got}) ->
- GotSize = orddict:size(Got),
- lager:debug("starting fetch again with ~p left in queue", [GotSize]),
- UpdState = read_blocks(State),
- erlang:garbage_collect(),
- {next_state, waiting_chunks, UpdState};
+%waiting_chunks(timeout, State = #state{got_blocks = Got}) ->
+% GotSize = orddict:size(Got),
+% lager:debug("starting fetch again with ~p left in queue", [GotSize]),
+% UpdState = read_blocks(State),
+% erlang:garbage_collect(),
+% {next_state, waiting_chunks, UpdState};
waiting_chunks({chunk, Pid, {NextBlock, BlockReturnValue}},
#state{from=From,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment