Permalink
Browse files

Rename `erl_epmd` internal functions `port_please1` to `get_port1`, a…

…nd `names1` to `get_names1`.

The functions `get_port` and `get_names` expect to receive as argument an `ip_address()`.

The renamed functions are actually simple wrappers for `get_port` and `get_names` respectively,
as their sole purpose is to take a hostname, call `inet:gethostbyname`, and delegate work.

The rename has been done in order to assist with enabling the overriding of the default
`erl_epmd` module behaviour, as described in the following email:
    http://erlang.org/pipermail/erlang-questions/2011-October/061975.html
  • Loading branch information...
1 parent b6dc1a8 commit d37811c78bb4187d0f4648f54c4d5d37e592b50e @cipriancraciun committed Oct 25, 2011
Showing with 20 additions and 21 deletions.
  1. +20 −21 lib/kernel/src/erl_epmd.erl
@@ -69,41 +69,24 @@ port_please(Node, Host) ->
port_please(Node, Host, infinity).
port_please(Node,HostName, Timeout) when is_atom(HostName) ->
- port_please1(Node,atom_to_list(HostName), Timeout);
+ get_port1(Node,atom_to_list(HostName), Timeout);
port_please(Node,HostName, Timeout) when is_list(HostName) ->
- port_please1(Node,HostName, Timeout);
+ get_port1(Node,HostName, Timeout);
port_please(Node, EpmdAddr, Timeout) ->
get_port(Node, EpmdAddr, Timeout).
-
-port_please1(Node,HostName, Timeout) ->
- case inet:gethostbyname(HostName, inet, Timeout) of
- {ok,{hostent, _Name, _ , _Af, _Size, [EpmdAddr | _]}} ->
- get_port(Node, EpmdAddr, Timeout);
- Else ->
- Else
- end.
-
names() ->
{ok, H} = inet:gethostname(),
names(H).
names(HostName) when is_atom(HostName) ->
- names1(atom_to_list(HostName));
+ get_names1(atom_to_list(HostName));
names(HostName) when is_list(HostName) ->
- names1(HostName);
+ get_names1(HostName);
names(EpmdAddr) ->
get_names(EpmdAddr).
-names1(HostName) ->
- case inet:gethostbyname(HostName) of
- {ok,{hostent, _Name, _ , _Af, _Size, [EpmdAddr | _]}} ->
- get_names(EpmdAddr);
- Else ->
- Else
- end.
-
register_node(Name, PortNo) ->
gen_server:call(erl_epmd, {register, Name, PortNo}, infinity).
@@ -301,6 +284,14 @@ get_port(Node, EpmdAddress, Timeout) ->
noport
end.
+get_port1(Node,HostName, Timeout) ->
+ case inet:gethostbyname(HostName, inet, Timeout) of
+ {ok,{hostent, _Name, _ , _Af, _Size, [EpmdAddr | _]}} ->
+ get_port(Node, EpmdAddr, Timeout);
+ Else ->
+ Else
+ end.
+
wait_for_port_reply(Socket, SoFar) ->
receive
@@ -423,6 +414,14 @@ get_names(EpmdAddress) ->
{error, address}
end.
+get_names1(HostName) ->
+ case inet:gethostbyname(HostName) of
+ {ok,{hostent, _Name, _ , _Af, _Size, [EpmdAddr | _]}} ->
+ get_names(EpmdAddr);
+ Else ->
+ Else
+ end.
+
do_get_names(Socket) ->
gen_tcp:send(Socket, [?int16(1),?EPMD_NAMES]),
receive

0 comments on commit d37811c

Please sign in to comment.