[erlang-bugs] [BUG] net_adm:world() crashes if node started without name

Edwin Fine erlang-questions_efine@REDACTED
Mon Oct 13 06:31:09 CEST 2008


This report pertains to R12B-4.

If I call net_adm:world(), and a valid .erlang.hosts file exists in the
current directory, and I did not start Erlang with a node name, it crashes
with a case clause error.

$ erl
Erlang (BEAM) emulator version 5.6.4 [source] [64-bit] [smp:4]
[async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.6.4  (abort with ^G)
1> net_adm:host_file().
[ender]
2> net_adm:world().
** exception error: no case clause matching ignored
     in function  net_adm:longshort/1
     in call from net_adm:do_ping/3
     in call from net_adm:collect_nodes/2
     in call from net_adm:expand_hosts/2

The source of this is in net_adm:longshort/1, which follows:

longshort(Host) ->
    case net_kernel:longnames() of
    false ->
        uptodot(Host);
    true ->
        Host
    end.

net_kernel:longnames() returns 'ignored' if net_kernel is not running:

%% If the net_kernel isn't running we ignore all requests to the
%% kernel, thus basically accepting them :-)
request(Req) ->
    case whereis(net_kernel) of
    P when is_pid(P) ->
        gen_server:call(net_kernel,Req,infinity);
    _ -> ignored
    end.

longshort/1 should throw a meaningful (and documented) exception, e.g.

longshort(Host) ->
    case net_kernel:longnames() of
    false ->
        uptodot(Host);
    true ->
        Host
    ignored ->
        throw({error, net_kernel_not_running})
    end.

Regards,
Edwin Fine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20081013/7aa1f7ea/attachment.htm>


More information about the erlang-bugs mailing list