From f41aaa265ea1ac6c5fae4cc52aa08ba8824a21b7 Mon Sep 17 00:00:00 2001 From: Kresten Krab Thorup Date: Fri, 27 Apr 2012 10:00:13 +0200 Subject: [PATCH] Fix bug with fold termination --- src/hanoi_level.erl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hanoi_level.erl b/src/hanoi_level.erl index e04ba2b..13994d0 100644 --- a/src/hanoi_level.erl +++ b/src/hanoi_level.erl @@ -110,10 +110,8 @@ close(Ref) -> snapshot_range(Ref, FoldWorkerPID, Range) -> - proc_lib:spawn(fun() -> - {ok, Folders} = plain_rpc:call(Ref, {init_snapshot_range_fold, FoldWorkerPID, Range, []}), - FoldWorkerPID ! {initialize, Folders} - end), + {ok, Folders} = plain_rpc:call(Ref, {init_snapshot_range_fold, FoldWorkerPID, Range, []}), + FoldWorkerPID ! {initialize, Folders}, {ok, FoldWorkerPID}. blocking_range(Ref, FoldWorkerPID, Range) -> @@ -527,8 +525,10 @@ main_loop(State = #state{ next=Next }) -> ?log("*** merge_died: ~p~n", [Reason]), restart_merge_then_loop(State#state{merge_pid=undefined}, Reason); - {'EXIT', PID, _} when [PID] == tl(State#state.folding); - hd(State#state.folding) == PID -> + {'EXIT', PID, _} when PID == hd(State#state.folding); + PID == hd(tl(State#state.folding)); + PID == hd(tl(tl(State#state.folding))) + -> main_loop(State#state{ folding = lists:delete(PID,State#state.folding) }); {'EXIT', PID, Reason} -> error_logger:info_msg("got unexpected exit ~p from ~p~n", [Reason, PID])