aboutsummaryrefslogtreecommitdiffstats
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
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...
-rw-r--r--erts/preloaded/ebin/net.beambin5960 -> 6140 bytes
-rw-r--r--erts/preloaded/src/net.erl18
-rw-r--r--lib/sasl/src/systools_make.erl1
3 files changed, 18 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.
%% ===========================================================================
%%
diff --git a/lib/sasl/src/systools_make.erl b/lib/sasl/src/systools_make.erl
index 29395b3c82..b5a6b44f93 100644
--- a/lib/sasl/src/systools_make.erl
+++ b/lib/sasl/src/systools_make.erl
@@ -33,6 +33,7 @@
-export([read_application/4]).
-export([make_hybrid_boot/4]).
+-export([preloaded/0]). % Exported just for testing
-import(lists, [filter/2, keysort/2, keysearch/3, map/2, reverse/1,
append/1, foldl/3, member/2, foreach/2]).