Permalink
Browse files

Clean-up handoff_ip code provided by micmac in pull request #176

Fix potential badmatch from re-using variable TNHandoffIP.

Change get_handoff_ip to use standard try/catch block, and default to
using the normal hostname if unable to resolve the handoff IP.
  • Loading branch information...
1 parent 8571f92 commit 1558e2f9ec044d19bca043f4023c72f8176240b4 @jtuple jtuple committed May 22, 2012
Showing with 7 additions and 6 deletions.
  1. +7 −6 src/riak_core_handoff_sender.erl
@@ -47,9 +47,10 @@ start_fold(TargetNode, Module, Partition, ParentPid, SslOpts) ->
try
[_Name,Host] = string:tokens(atom_to_list(TargetNode), "@"),
{ok, Port} = get_handoff_port(TargetNode),
- {ok, TNHandoffIP} = get_handoff_ip(TargetNode),
TNHandoffIP =
case get_handoff_ip(TargetNode) of
+ error ->
+ Host;
{ok, "0.0.0.0"} ->
Host;
{ok, Other} ->
@@ -245,11 +246,11 @@ visit_item(K, V, {Socket, Parent, Module, TcpMod, Ack, Total, Stats,
end.
get_handoff_ip(Node) when is_atom(Node) ->
- case catch(gen_server2:call({riak_core_handoff_listener, Node}, handoff_ip, infinity)) of
- {'EXIT', _} ->
- %% Check old location from previous release
- gen_server2:call({riak_kv_handoff_listener, Node}, handoff_ip, infinity);
- Other -> Other
+ try
+ gen_server2:call({riak_core_handoff_listener, Node}, handoff_ip, infinity)
+ catch
+ _:_ ->
+ error
end.
get_handoff_port(Node) when is_atom(Node) ->

0 comments on commit 1558e2f

Please sign in to comment.