diff options
author | Micael Karlberg <[email protected]> | 2019-05-20 15:23:48 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2019-06-14 12:32:44 +0200 |
commit | 2c08787a53d30bb60d2b604eedb19389dc5a0d9e (patch) | |
tree | 4f64870edf785ab04de6a2a45269453ceec851c9 /erts/preloaded/src | |
parent | 897a266c3e68d7d94d1f9699ae91cf57fb3b5cc8 (diff) | |
download | otp-2c08787a53d30bb60d2b604eedb19389dc5a0d9e.tar.gz otp-2c08787a53d30bb60d2b604eedb19389dc5a0d9e.tar.bz2 otp-2c08787a53d30bb60d2b604eedb19389dc5a0d9e.zip |
[esock,kernel] net -> prim_net and add (new) net
Renamed the current preloaded net module to prim_net
and removed the deprecated functions (call, cast, ...).
Introduce a "new" net module (in kernel) as an interface
module to the (preloaded) prim_net. This one also contains
the deprecated functions (call, cast, ...).
OTP-15765
Diffstat (limited to 'erts/preloaded/src')
-rw-r--r-- | erts/preloaded/src/Makefile | 9 | ||||
-rw-r--r-- | erts/preloaded/src/erl_init.erl | 3 | ||||
-rw-r--r-- | erts/preloaded/src/prim_net.erl (renamed from erts/preloaded/src/net.erl) | 74 |
3 files changed, 11 insertions, 75 deletions
diff --git a/erts/preloaded/src/Makefile b/erts/preloaded/src/Makefile index 27d450c873..e1bb2ee5c4 100644 --- a/erts/preloaded/src/Makefile +++ b/erts/preloaded/src/Makefile @@ -36,10 +36,9 @@ include $(ERL_TOP)/lib/kernel/vsn.mk ifeq ($(USE_ESOCK), yes) PRE_LOADED_ERL_ESOCK_MODULES = \ socket \ - net + prim_net else -PRE_LOADED_ERL_ESOCK_MODULES = \ - net +PRE_LOADED_ERL_ESOCK_MODULES = endif PRE_LOADED_ERL_MODULES = \ @@ -82,9 +81,9 @@ APP_FILE= erts.app APP_SRC= $(APP_FILE).src APP_TARGET= $(STATIC_EBIN)/$(APP_FILE) ifeq ($(USE_ESOCK), yes) -APP_ESOCK_MODS= net, socket +APP_ESOCK_MODS= prim_net, socket else -APP_ESOCK_MODS= net +APP_ESOCK_MODS= endif diff --git a/erts/preloaded/src/erl_init.erl b/erts/preloaded/src/erl_init.erl index d209c4033b..9fcb3969e4 100644 --- a/erts/preloaded/src/erl_init.erl +++ b/erts/preloaded/src/erl_init.erl @@ -35,7 +35,8 @@ start(Mod, BootArgs) -> erl_tracer:on_load(), prim_buffer:on_load(), prim_file:on_load(), - conditional_load(socket, [socket, net]), % socket:on_load(), net:on_load(), + %% socket:on_load(), prim_net:on_load(), + conditional_load(socket, [socket, prim_net]), %% Proceed to the specified boot module run(Mod, boot, BootArgs). diff --git a/erts/preloaded/src/net.erl b/erts/preloaded/src/prim_net.erl index 13d2e3a117..107043d1aa 100644 --- a/erts/preloaded/src/net.erl +++ b/erts/preloaded/src/prim_net.erl @@ -18,7 +18,7 @@ %% %CopyrightEnd% %% --module(net). +-module(prim_net). -compile(no_native). @@ -31,22 +31,14 @@ -export([ gethostname/0, - getnameinfo/1, getnameinfo/2, - getaddrinfo/1, getaddrinfo/2, + getnameinfo/2, + getaddrinfo/2, if_name2index/1, if_index2name/1, if_names/0 ]). -%% Deprecated functions from the "old" net module --export([call/4, - cast/4, - broadcast/3, - ping/1, - relay/1, - sleep/1]). - -export_type([ address_info/0, name_info/0, @@ -59,13 +51,6 @@ network_interface_index/0 ]). --deprecated({call, 4, eventually}). --deprecated({cast, 4, eventually}). --deprecated({broadcast, 3, eventually}). --deprecated({ping, 1, eventually}). --deprecated({relay, 1, eventually}). --deprecated({sleep, 1, eventually}). - -type name_info_flags() :: [name_info_flag()|name_info_flag_ext()]. -type name_info_flag() :: namereqd | @@ -88,21 +73,6 @@ %% =========================================================================== %% -%% D E P R E C A T E D F U N C T I O N S -%% -%% =========================================================================== - -call(N,M,F,A) -> rpc:call(N,M,F,A). -cast(N,M,F,A) -> rpc:cast(N,M,F,A). -broadcast(M,F,A) -> rpc:eval_everywhere(M,F,A). -ping(Node) -> net_adm:ping(Node). -sleep(T) -> receive after T -> ok end. -relay(X) -> slave:relay(X). - - - -%% =========================================================================== -%% %% Administrative and utility API %% %% =========================================================================== @@ -117,7 +87,7 @@ on_load() -> Extra :: map(). on_load(Extra) -> - ok = erlang:load_nif(atom_to_list(?MODULE), Extra). + ok = erlang:load_nif(atom_to_list(net), Extra). -spec info() -> list(). @@ -159,14 +129,6 @@ gethostname() -> %% %% --spec getnameinfo(SockAddr) -> {ok, Info} | {error, Reason} when - SockAddr :: socket:sockaddr(), - Info :: name_info(), - Reason :: term(). - -getnameinfo(SockAddr) -> - getnameinfo(SockAddr, undefined). - -spec getnameinfo(SockAddr, Flags) -> {ok, Info} | {error, Reason} when SockAddr :: socket:sockaddr(), Flags :: name_info_flags() | undefined, @@ -178,44 +140,18 @@ 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((catch ensure_sockaddr(SockAddr)), Flags); + nif_getnameinfo(socket: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. - %% =========================================================================== %% %% getaddrinfo - Network address and service translation %% %% There is also a "hint" argument that we "at some point" should implement. --spec getaddrinfo(Host) -> {ok, Info} | {error, Reason} when - Host :: string(), - Info :: [address_info()], - Reason :: term(). - -getaddrinfo(Host) when is_list(Host) -> - getaddrinfo(Host, undefined). - - -spec getaddrinfo(Host, undefined) -> {ok, Info} | {error, Reason} when Host :: string(), Info :: [address_info()], |