aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2019-04-02 15:36:18 +0200
committerMicael Karlberg <[email protected]>2019-04-30 11:03:10 +0200
commitb49f68d5d8a256a7a0847d939b2da8a4be6c728a (patch)
tree172e1a61316626a998f0e8dc56fbba25af48a8c2 /erts
parente87bc034ae3f13cfcfab8677a10a088850c747a0 (diff)
downloadotp-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')
-rw-r--r--erts/preloaded/ebin/net.beambin5960 -> 6140 bytes
-rw-r--r--erts/preloaded/src/net.erl18
2 files changed, 17 insertions, 1 deletions
diff --git a/erts/preloaded/ebin/net.beam b/erts/preloaded/ebin/net.beam
index 8b5ee52cfa..f61b2b4a69 100644
--- a/erts/preloaded/ebin/net.beam
+++ b/erts/preloaded/ebin/net.beam
Binary files differ
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.
%% ===========================================================================
%%