aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2019-05-02 10:16:04 +0200
committerMicael Karlberg <[email protected]>2019-05-02 10:16:04 +0200
commit5c3b8ece50b2dfa66351198375acf4a5f08833ac (patch)
tree2d1d42872f10a68656793638c460c3f76859a8c5 /erts
parent202ac7dcd4060b463a08d6bca09529c95d5855f4 (diff)
parentb49f68d5d8a256a7a0847d939b2da8a4be6c728a (diff)
downloadotp-5c3b8ece50b2dfa66351198375acf4a5f08833ac.tar.gz
otp-5c3b8ece50b2dfa66351198375acf4a5f08833ac.tar.bz2
otp-5c3b8ece50b2dfa66351198375acf4a5f08833ac.zip
Merge branch 'bmk/erts/esock/20190430/configure_esock_include/OTP-15658'
Diffstat (limited to 'erts')
-rw-r--r--erts/configure.in24
-rw-r--r--erts/emulator/Makefile.in34
-rw-r--r--erts/emulator/test/net_SUITE.erl17
-rw-r--r--erts/emulator/test/socket_SUITE.erl31
-rw-r--r--erts/preloaded/ebin/erl_init.beambin1820 -> 2312 bytes
-rw-r--r--erts/preloaded/ebin/net.beambin5940 -> 6140 bytes
-rw-r--r--erts/preloaded/src/Makefile21
-rw-r--r--erts/preloaded/src/erl_init.erl26
-rw-r--r--erts/preloaded/src/erts.app.src3
-rw-r--r--erts/preloaded/src/net.erl21
10 files changed, 142 insertions, 35 deletions
diff --git a/erts/configure.in b/erts/configure.in
index 5f969a0a8b..2538505ee7 100644
--- a/erts/configure.in
+++ b/erts/configure.in
@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. -*-m4-*-
dnl %CopyrightBegin%
dnl
-dnl Copyright Ericsson AB 1997-2018. All Rights Reserved.
+dnl Copyright Ericsson AB 1997-2019. All Rights Reserved.
dnl
dnl Licensed under the Apache License, Version 2.0 (the "License");
dnl you may not use this file except in compliance with the License.
@@ -1329,6 +1329,28 @@ LIBS=$zlib_save_LIBS
fi
AC_SUBST(Z_LIB)
+
+dnl -------------
+dnl esock
+dnl -------------
+
+AC_ARG_ENABLE(esock,
+AS_HELP_STRING([--enable-esock], [enable builtin experimental socket (as a nif) support (default)])
+AS_HELP_STRING([--disable-esock], [disable builtin experimental socket (as a nif) support]))
+
+dnl Default value
+USE_ESOCK=yes
+
+if test "x$enable_esock" = "xyes"; then
+ USE_ESOCK=yes
+else
+ if test "x$enable_esock" = "xno"; then
+ USE_ESOCK=no
+ fi
+fi
+AC_SUBST(USE_ESOCK)
+
+
dnl
dnl This test kindly borrowed from Tcl
dnl
diff --git a/erts/emulator/Makefile.in b/erts/emulator/Makefile.in
index 448f41b523..a9f3bb8e89 100644
--- a/erts/emulator/Makefile.in
+++ b/erts/emulator/Makefile.in
@@ -633,6 +633,15 @@ GENERATE += $(TTF_DIR)/driver_tab.c
# This list must be consistent with PRE_LOADED_MODULES in
# erts/preloaded/src/Makefile.
+ifeq ($(USE_ESOCK), yes)
+ESOCK_PRELOAD_BEAM = \
+ $(ERL_TOP)/erts/preloaded/ebin/socket.beam \
+ $(ERL_TOP)/erts/preloaded/ebin/net.beam
+else
+ESOCK_PRELOAD_BEAM = \
+ $(ERL_TOP)/erts/preloaded/ebin/net.beam
+endif
+
PRELOAD_BEAM = $(ERL_TOP)/erts/preloaded/ebin/erts_code_purger.beam \
$(ERL_TOP)/erts/preloaded/ebin/erl_init.beam \
$(ERL_TOP)/erts/preloaded/ebin/init.beam \
@@ -641,8 +650,7 @@ PRELOAD_BEAM = $(ERL_TOP)/erts/preloaded/ebin/erts_code_purger.beam \
$(ERL_TOP)/erts/preloaded/ebin/prim_inet.beam \
$(ERL_TOP)/erts/preloaded/ebin/prim_file.beam \
$(ERL_TOP)/erts/preloaded/ebin/zlib.beam \
- $(ERL_TOP)/erts/preloaded/ebin/socket.beam \
- $(ERL_TOP)/erts/preloaded/ebin/net.beam \
+ $(ESOCK_PRELOAD_BEAM) \
$(ERL_TOP)/erts/preloaded/ebin/prim_zip.beam \
$(ERL_TOP)/erts/preloaded/ebin/erl_prim_loader.beam \
$(ERL_TOP)/erts/preloaded/ebin/erlang.beam \
@@ -835,6 +843,15 @@ EMU_OBJS = \
$(OBJDIR)/beam_catches.o $(OBJDIR)/code_ix.o \
$(OBJDIR)/beam_ranges.o
+
+ifeq ($(USE_ESOCK), yes)
+
+# WE ARE USING ESOCK
+
+ESOCK_NIF_OBJS = \
+ $(OBJDIR)/socket_nif.o \
+ $(OBJDIR)/net_nif.o
+
ifneq ($(TARGET), win32)
# These are *currently* only needed for non-win32,
# since the nif-functions for socket and net are basically
@@ -847,6 +864,16 @@ else
ESOCK_RUN_OBJS =
endif
+else
+
+# WE ARE *NOT* USING ESOCK
+
+ESOCK_NIF_OBJS =
+ESOCK_RUN_OBJS =
+
+endif
+
+
RUN_OBJS += \
$(OBJDIR)/erl_alloc.o $(OBJDIR)/erl_mtrace.o \
$(OBJDIR)/erl_alloc_util.o $(OBJDIR)/erl_goodfit_alloc.o \
@@ -903,8 +930,7 @@ NIF_OBJS = \
$(OBJDIR)/prim_buffer_nif.o \
$(OBJDIR)/prim_file_nif.o \
$(OBJDIR)/zlib_nif.o \
- $(OBJDIR)/socket_nif.o \
- $(OBJDIR)/net_nif.o
+ $(ESOCK_NIF_OBJS)
ifeq ($(TARGET),win32)
DRV_OBJS = \
diff --git a/erts/emulator/test/net_SUITE.erl b/erts/emulator/test/net_SUITE.erl
index 1a973cacb2..6111fc76a5 100644
--- a/erts/emulator/test/net_SUITE.erl
+++ b/erts/emulator/test/net_SUITE.erl
@@ -127,12 +127,17 @@ api_basic_cases() ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
init_per_suite(Config) ->
- case os:type() of
- {win32, _} ->
- not_yet_implemented();
- _ ->
- %% ?LOGGER:start(),
- Config
+ case lists:member(socket, erlang:loaded()) of
+ true ->
+ case os:type() of
+ {win32, _} ->
+ not_yet_implemented();
+ _ ->
+ %% ?LOGGER:start(),
+ Config
+ end;
+ false ->
+ {skip, "esock disabled"}
end.
end_per_suite(_) ->
diff --git a/erts/emulator/test/socket_SUITE.erl b/erts/emulator/test/socket_SUITE.erl
index cefbe4c1f8..e3545ccbf9 100644
--- a/erts/emulator/test/socket_SUITE.erl
+++ b/erts/emulator/test/socket_SUITE.erl
@@ -1385,22 +1385,27 @@ ttest_ssockt_csockt_cases() ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
init_per_suite(Config) ->
- case os:type() of
- {win32, _} ->
- not_yet_implemented();
- _ ->
- case quiet_mode(Config) of
- default ->
- ?LOGGER:start(),
- Config;
- Quiet ->
- ?LOGGER:start(Quiet),
- [{esock_test_quiet, Quiet}|Config]
- end
+ case lists:member(socket, erlang:loaded()) of
+ true ->
+ case os:type() of
+ {win32, _} ->
+ (catch not_yet_implemented());
+ _ ->
+ case quiet_mode(Config) of
+ default ->
+ ?LOGGER:start(),
+ Config;
+ Quiet ->
+ ?LOGGER:start(Quiet),
+ [{esock_test_quiet, Quiet}|Config]
+ end
+ end;
+ false ->
+ {skip, "esock disabled"}
end.
end_per_suite(_) ->
- ?LOGGER:stop(),
+ (catch ?LOGGER:stop()),
ok.
diff --git a/erts/preloaded/ebin/erl_init.beam b/erts/preloaded/ebin/erl_init.beam
index 81be5b021a..0313988e3e 100644
--- a/erts/preloaded/ebin/erl_init.beam
+++ b/erts/preloaded/ebin/erl_init.beam
Binary files differ
diff --git a/erts/preloaded/ebin/net.beam b/erts/preloaded/ebin/net.beam
index ebb1296b95..f61b2b4a69 100644
--- a/erts/preloaded/ebin/net.beam
+++ b/erts/preloaded/ebin/net.beam
Binary files differ
diff --git a/erts/preloaded/src/Makefile b/erts/preloaded/src/Makefile
index efeb92dce9..27d450c873 100644
--- a/erts/preloaded/src/Makefile
+++ b/erts/preloaded/src/Makefile
@@ -1,7 +1,7 @@
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2008-2018. All Rights Reserved.
+# Copyright Ericsson AB 2008-2019. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -33,14 +33,22 @@ STATIC_EBIN=../ebin
include $(ERL_TOP)/erts/vsn.mk
include $(ERL_TOP)/lib/kernel/vsn.mk
+ifeq ($(USE_ESOCK), yes)
+PRE_LOADED_ERL_ESOCK_MODULES = \
+ socket \
+ net
+else
+PRE_LOADED_ERL_ESOCK_MODULES = \
+ net
+endif
+
PRE_LOADED_ERL_MODULES = \
erl_prim_loader \
init \
prim_buffer \
prim_file \
prim_inet \
- socket \
- net \
+ $(PRE_LOADED_ERL_ESOCK_MODULES) \
zlib \
prim_zip \
erl_init \
@@ -73,6 +81,11 @@ STATIC_TARGET_FILES = $(PRE_LOADED_MODULES:%=$(STATIC_EBIN)/%.$(EMULATOR))
APP_FILE= erts.app
APP_SRC= $(APP_FILE).src
APP_TARGET= $(STATIC_EBIN)/$(APP_FILE)
+ifeq ($(USE_ESOCK), yes)
+APP_ESOCK_MODS= net, socket
+else
+APP_ESOCK_MODS= net
+endif
KERNEL_SRC=$(ERL_TOP)/lib/kernel/src
@@ -94,7 +107,7 @@ copy:
cp *.beam $(STATIC_EBIN)
$(APP_TARGET): $(APP_SRC) $(ERL_TOP)/erts/vsn.mk
- $(vsn_verbose)sed -e 's;%VSN%;$(VSN);' $< > $@
+ $(vsn_verbose)sed -e 's;%VSN%;$(VSN);' -e 's;%ESOCK_MODS%;$(APP_ESOCK_MODS);' $< > $@
include $(ERL_TOP)/make/otp_release_targets.mk
diff --git a/erts/preloaded/src/erl_init.erl b/erts/preloaded/src/erl_init.erl
index 6edead362c..d209c4033b 100644
--- a/erts/preloaded/src/erl_init.erl
+++ b/erts/preloaded/src/erl_init.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2000-2016. All Rights Reserved.
+%% Copyright Ericsson AB 2000-2019. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -35,8 +35,7 @@ start(Mod, BootArgs) ->
erl_tracer:on_load(),
prim_buffer:on_load(),
prim_file:on_load(),
- socket:on_load(),
- net:on_load(),
+ conditional_load(socket, [socket, net]), % socket:on_load(), net:on_load(),
%% Proceed to the specified boot module
run(Mod, boot, BootArgs).
@@ -48,3 +47,24 @@ run(M, F, A) ->
true ->
M:F(A)
end.
+
+conditional_load(CondMod, Mods2Load) ->
+ conditional_load(CondMod, erlang:loaded(), Mods2Load).
+
+conditional_load(_CondMod, [], _Mods2LOad) ->
+ ok;
+conditional_load(CondMod, [CondMod|_], Mods2Load) ->
+ on_load(Mods2Load);
+conditional_load(CondMod, [_|T], Mods2Load) ->
+ conditional_load(CondMod, T, Mods2Load).
+
+on_load([]) ->
+ ok;
+on_load([Mod|Mods]) ->
+ Mod:on_load(),
+ on_load(Mods).
+
+
+
+
+
diff --git a/erts/preloaded/src/erts.app.src b/erts/preloaded/src/erts.app.src
index c2a8511b6d..132397b478 100644
--- a/erts/preloaded/src/erts.app.src
+++ b/erts/preloaded/src/erts.app.src
@@ -36,8 +36,7 @@
atomics,
counters,
zlib,
- net,
- socket
+ %ESOCK_MODS%
]},
{registered, []},
{applications, []},
diff --git a/erts/preloaded/src/net.erl b/erts/preloaded/src/net.erl
index a24b5c8ce3..13d2e3a117 100644
--- a/erts/preloaded/src/net.erl
+++ b/erts/preloaded/src/net.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2018-2018. All Rights Reserved.
+%% Copyright Ericsson AB 2018-2019. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -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.
%% ===========================================================================
%%
@@ -334,3 +350,4 @@ nif_if_index2name(_Id) ->
nif_if_names() ->
erlang:nif_error(undef).
+