Skip to content

Commit

Permalink
If the incarnation file gets corrupted, go back to '0'
Browse files Browse the repository at this point in the history
  • Loading branch information
garret-smith committed Nov 15, 2013
1 parent 318e8e5 commit f3d846b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/gen_leader.erl
Expand Up @@ -1441,7 +1441,10 @@ incarnation(VarDir, RegName, Node) ->
0;
{ok,_} ->
{ok,Bin} = file:read_file(Name),
Incarn = binary_to_term(Bin),
Incarn = case catch binary_to_term(Bin) of
I when is_integer(I) -> I;
_ -> 0
end,
ok = file:write_file(Name,term_to_binary(Incarn+1)),
Incarn
end.
Expand Down

0 comments on commit f3d846b

Please sign in to comment.