From 1f0e43d33fb9f76c7d9fc0c6d306a0643a3b3f80 Mon Sep 17 00:00:00 2001 From: Scott Lystig Fritchie Date: Thu, 27 Feb 2014 12:36:02 +0900 Subject: [PATCH] Fix dumb think-o in corfurl_client:append_page() retry counter --- prototype/corfurl/src/corfurl_client.erl | 38 +++++++++++++++--------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/prototype/corfurl/src/corfurl_client.erl b/prototype/corfurl/src/corfurl_client.erl index 78dafb3..2c5fc1d 100644 --- a/prototype/corfurl/src/corfurl_client.erl +++ b/prototype/corfurl/src/corfurl_client.erl @@ -20,7 +20,8 @@ -module(corfurl_client). --export([append_page/2, read_page/2]). +-export([append_page/2]). +%% -export([append_page/2, read_page/2]). -export([restart_sequencer/1]). -include("corfurl.hrl"). @@ -29,10 +30,11 @@ %% -define(LONG_TIME, 30*1000). append_page(Proj, Page) -> - append_page(Proj, Page, 1). + append_page(Proj, Page, 50). -append_page(#proj{seq={Sequencer,_,_}} = Proj, Page, Retries) - when Retries < 50 -> +append_page(Proj, _Page, 0) -> + {error_failed, Proj}; +append_page(#proj{seq={Sequencer,_,_}} = Proj, Page, Retries) -> try case corfurl_sequencer:get(Sequencer, 1) of {ok, LPN} -> @@ -40,25 +42,23 @@ append_page(#proj{seq={Sequencer,_,_}} = Proj, Page, Retries) lost_race -> append_page(Proj, Page, Retries - 1); error_badepoch -> - case poll_for_new_epoch_projection(P) of - {ok, NewP} -> - append_page(NewProj, Page, Retries-1); + case poll_for_new_epoch_projection(Proj) of + {ok, NewProj} -> + append_page(NewProj, Page, Retries - 1); Else -> - {Else, P} + {Else, Proj} end; Else -> - {Else, P} + {Else, Proj} end end catch exit:{Reason,{_gen_server_or_pulse_gen_server,call,[Sequencer|_]}} when Reason == noproc; Reason == normal -> - append_page(restart_sequencer(P), Page, Retries); + append_page(restart_sequencer(Proj), Page, Retries); exit:Exit -> {failed, incomplete_code, Exit} - end; -append_page(Proj, _Page, _Retries) -> - {error_badepoch, Proj}. + end. append_page2(Proj, LPN, Page) -> case corfurl:write_page(Proj, LPN, Page) of @@ -74,8 +74,18 @@ append_page2(Proj, LPN, Page) -> %% Let it crash: error_unwritten end. +%% read_page(Proj, Page) -> +%% read_page(Proj, Page, 10). + %% read_page(Proj, LPN) -> -%% case corfurl:read_page(Proj, +%% case corfurl:read_page(Proj, LPN) of +%% error_badepoch -> +%% case poll_for_new_epoch_projection(P) of +%% {ok, NewP} -> +%% read_page(NewProj, Page); +%% Else -> +%% {Else, P} + %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% %%%%% %%%%%