diff options
author | Micael Karlberg <[email protected]> | 2019-04-02 15:36:18 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2019-04-30 11:03:10 +0200 |
commit | b49f68d5d8a256a7a0847d939b2da8a4be6c728a (patch) | |
tree | 172e1a61316626a998f0e8dc56fbba25af48a8c2 /erts/preloaded/src/net.erl | |
parent | e87bc034ae3f13cfcfab8677a10a088850c747a0 (diff) | |
download | otp-b49f68d5d8a256a7a0847d939b2da8a4be6c728a.tar.gz otp-b49f68d5d8a256a7a0847d939b2da8a4be6c728a.tar.bz2 otp-b49f68d5d8a256a7a0847d939b2da8a4be6c728a.zip |
[net] Improvements (ahum) when --disable-esock
The net module uses socket, but when the system has
been built with --disable-esock, there is no socket...
Diffstat (limited to 'erts/preloaded/src/net.erl')
-rw-r--r-- | erts/preloaded/src/net.erl | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/erts/preloaded/src/net.erl b/erts/preloaded/src/net.erl index 0b069aa5c7..13d2e3a117 100644 --- a/erts/preloaded/src/net.erl +++ b/erts/preloaded/src/net.erl @@ -178,12 +178,28 @@ getnameinfo(SockAddr, [] = _Flags) -> getnameinfo(#{family := Fam, addr := _Addr} = SockAddr, Flags) when ((Fam =:= inet) orelse (Fam =:= inet6)) andalso (is_list(Flags) orelse (Flags =:= undefined)) -> - nif_getnameinfo(socket:ensure_sockaddr(SockAddr), Flags); + nif_getnameinfo((catch ensure_sockaddr(SockAddr)), Flags); getnameinfo(#{family := Fam, path := _Path} = SockAddr, Flags) when (Fam =:= local) andalso (is_list(Flags) orelse (Flags =:= undefined)) -> nif_getnameinfo(SockAddr, Flags). +%% This function is intended to "handle" the case when the user +%% has built their (OTP) system with "--disable-esock". +%% That means the socket module does not exist. This is not really +%% a problem since the nif_getnameinfo won't work either (since +%% the nif file is not part of the system). The result of calling +%% getnameinfo will be a undef exception (erlang:nif_error(undef)). +%% +%% The only functions in this module that actually work in this case +%% (--disable-esock) is the depricated stuff (call, cast, ...). +%% +ensure_sockaddr(SockAddr) -> + try socket:ensure_sockaddr(SockAddr) + catch + error:undef:_ -> + undefined + end. %% =========================================================================== %% |