Fix bug with fold termination

This commit is contained in:
Kresten Krab Thorup 2012-04-27 10:00:13 +02:00
parent 2d928fce73
commit f41aaa265e

View file

@ -110,10 +110,8 @@ close(Ref) ->
snapshot_range(Ref, FoldWorkerPID, Range) -> snapshot_range(Ref, FoldWorkerPID, Range) ->
proc_lib:spawn(fun() -> {ok, Folders} = plain_rpc:call(Ref, {init_snapshot_range_fold, FoldWorkerPID, Range, []}),
{ok, Folders} = plain_rpc:call(Ref, {init_snapshot_range_fold, FoldWorkerPID, Range, []}), FoldWorkerPID ! {initialize, Folders},
FoldWorkerPID ! {initialize, Folders}
end),
{ok, FoldWorkerPID}. {ok, FoldWorkerPID}.
blocking_range(Ref, FoldWorkerPID, Range) -> blocking_range(Ref, FoldWorkerPID, Range) ->
@ -527,8 +525,10 @@ main_loop(State = #state{ next=Next }) ->
?log("*** merge_died: ~p~n", [Reason]), ?log("*** merge_died: ~p~n", [Reason]),
restart_merge_then_loop(State#state{merge_pid=undefined}, Reason); restart_merge_then_loop(State#state{merge_pid=undefined}, Reason);
{'EXIT', PID, _} when [PID] == tl(State#state.folding); {'EXIT', PID, _} when PID == hd(State#state.folding);
hd(State#state.folding) == PID -> PID == hd(tl(State#state.folding));
PID == hd(tl(tl(State#state.folding)))
->
main_loop(State#state{ folding = lists:delete(PID,State#state.folding) }); main_loop(State#state{ folding = lists:delete(PID,State#state.folding) });
{'EXIT', PID, Reason} -> {'EXIT', PID, Reason} ->
error_logger:info_msg("got unexpected exit ~p from ~p~n", [Reason, PID]) error_logger:info_msg("got unexpected exit ~p from ~p~n", [Reason, PID])