aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Favatella <[email protected]>2014-06-24 01:53:30 +0100
committerMarcus Arendt <[email protected]>2014-08-14 16:49:08 +0200
commitfcef4dd4614211ca5cc592c428655cbad0342fa2 (patch)
tree2c3176bc7107a1421a69d81941513c23befb53d8
parent7968b44240626bd4a76a9b4f36cad849c4c26431 (diff)
downloadotp-fcef4dd4614211ca5cc592c428655cbad0342fa2.tar.gz
otp-fcef4dd4614211ca5cc592c428655cbad0342fa2.tar.bz2
otp-fcef4dd4614211ca5cc592c428655cbad0342fa2.zip
Refactor erl_epmd:names/1
Simplify erl_epmd:names/1, keeping the same functionalities, relying on inet:gethostbyname/1 being able to handle both atoms and strings.
-rw-r--r--lib/kernel/src/erl_epmd.erl15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/kernel/src/erl_epmd.erl b/lib/kernel/src/erl_epmd.erl
index b4fae24ef3..f6e2ca0954 100644
--- a/lib/kernel/src/erl_epmd.erl
+++ b/lib/kernel/src/erl_epmd.erl
@@ -85,24 +85,19 @@ port_please1(Node,HostName, Timeout) ->
Else
end.
-names() ->
+names() ->
{ok, H} = inet:gethostname(),
names(H).
-names(HostName) when is_atom(HostName) ->
- names1(atom_to_list(HostName));
-names(HostName) when is_list(HostName) ->
- names1(HostName);
-names(EpmdAddr) ->
- get_names(EpmdAddr).
-
-names1(HostName) ->
+names(HostName) when is_atom(HostName); is_list(HostName) ->
case inet:gethostbyname(HostName) of
{ok,{hostent, _Name, _ , _Af, _Size, [EpmdAddr | _]}} ->
get_names(EpmdAddr);
Else ->
Else
- end.
+ end;
+names(EpmdAddr) ->
+ get_names(EpmdAddr).
register_node(Name, PortNo) ->