aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2018-07-09 14:54:57 +0200
committerMicael Karlberg <[email protected]>2018-09-18 14:50:18 +0200
commit7ed2af8dcfd62a051686ac1e1326fbeca0b18334 (patch)
tree209abbff50dea92bd5191bdcf0564c0510b851d2 /erts
parentd45e3bf3dfeda0e849b07a9a7a19e50a52b04c35 (diff)
downloadotp-7ed2af8dcfd62a051686ac1e1326fbeca0b18334.tar.gz
otp-7ed2af8dcfd62a051686ac1e1326fbeca0b18334.tar.bz2
otp-7ed2af8dcfd62a051686ac1e1326fbeca0b18334.zip
[socket-nif] Add support for socket (level socket) option acceptconn
The socket (level socket) option acceptconn is now supported (for getopt). OTP-14831
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/nifs/common/socket_nif.c21
-rw-r--r--erts/preloaded/ebin/socket.beambin43604 -> 43616 bytes
-rw-r--r--erts/preloaded/src/socket.erl33
3 files changed, 43 insertions, 11 deletions
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c
index 70a5de912f..73da6455c3 100644
--- a/erts/emulator/nifs/common/socket_nif.c
+++ b/erts/emulator/nifs/common/socket_nif.c
@@ -346,6 +346,7 @@ typedef union {
#define SOCKET_OPT_OTP_IOW 1
#define SOCKET_OPT_OTP_CTRL_PROC 2
+#define SOCKET_OPT_SOCK_ACCEPTCONN 1
#define SOCKET_OPT_SOCK_BROADCAST 4
#define SOCKET_OPT_SOCK_DOMAIN 7
#define SOCKET_OPT_SOCK_DONTROUTE 8
@@ -929,6 +930,10 @@ static ERL_NIF_TERM ngetopt_level(ErlNifEnv* env,
static ERL_NIF_TERM ngetopt_lvl_socket(ErlNifEnv* env,
SocketDescriptor* descP,
int eOpt);
+#if defined(SO_ACCEPTCONN)
+static ERL_NIF_TERM ngetopt_lvl_sock_acceptconn(ErlNifEnv* env,
+ SocketDescriptor* descP);
+#endif
#if defined(SO_BROADCAST)
static ERL_NIF_TERM ngetopt_lvl_sock_broadcast(ErlNifEnv* env,
SocketDescriptor* descP);
@@ -4719,6 +4724,12 @@ ERL_NIF_TERM ngetopt_lvl_socket(ErlNifEnv* env,
ERL_NIF_TERM result;
switch (eOpt) {
+#if defined(SO_ACCEPTCONN)
+ case SOCKET_OPT_SOCK_ACCEPTCONN:
+ result = ngetopt_lvl_sock_acceptconn(env, descP);
+ break;
+#endif
+
#if defined(SO_BROADCAST)
case SOCKET_OPT_SOCK_BROADCAST:
result = ngetopt_lvl_sock_broadcast(env, descP);
@@ -4794,6 +4805,16 @@ ERL_NIF_TERM ngetopt_lvl_socket(ErlNifEnv* env,
}
+#if defined(SO_ACCEPTCONN)
+static
+ERL_NIF_TERM ngetopt_lvl_sock_acceptconn(ErlNifEnv* env,
+ SocketDescriptor* descP)
+{
+ return ngetopt_bool_opt(env, descP, SOL_SOCKET, SO_ACCEPTCONN);
+}
+#endif
+
+
#if defined(SO_BROADCAST)
static
ERL_NIF_TERM ngetopt_lvl_sock_broadcast(ErlNifEnv* env,
diff --git a/erts/preloaded/ebin/socket.beam b/erts/preloaded/ebin/socket.beam
index 952f869d54..f5248d8622 100644
--- a/erts/preloaded/ebin/socket.beam
+++ b/erts/preloaded/ebin/socket.beam
Binary files differ
diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl
index 4932e301fb..f22f9e5072 100644
--- a/erts/preloaded/src/socket.erl
+++ b/erts/preloaded/src/socket.erl
@@ -202,7 +202,7 @@
oobinline |
passcred |
peek_off |
- peek_cred |
+ peekcred |
priority |
protocol |
rcvbuf |
@@ -464,17 +464,28 @@
-define(SOCKET_OPT_OTP_IOW, 1).
-define(SOCKET_OPT_OTP_CTRL_PROC, 2).
+-define(SOCKET_OPT_SOCK_ACCEPTCONN, 1).
+%% -define(SOCKET_OPT_SOCK_ACCEPTFILTER, 2).
+%% -define(SOCKET_OPT_SOCK_BINDTODEVICE, 3).
-define(SOCKET_OPT_SOCK_BROADCAST, 4).
+%% -define(SOCKET_OPT_SOCK_BUSY_POLL, 5).
+%% -define(SOCKET_OPT_SOCK_DEBUG, 6).
-define(SOCKET_OPT_SOCK_DOMAIN, 7).
-define(SOCKET_OPT_SOCK_DONTROUTE, 8).
+%% -define(SOCKET_OPT_SOCK_ERROR, 9).
-define(SOCKET_OPT_SOCK_KEEPALIVE, 10).
-define(SOCKET_OPT_SOCK_LINGER, 11).
--define(SOCKET_OPT_SOCK_PRIORITY, 17).
--define(SOCKET_OPT_SOCK_PROTOCOL, 18).
--define(SOCKET_OPT_SOCK_RCVBUF, 19).
--define(SOCKET_OPT_SOCK_REUSEADDR, 23).
--define(SOCKET_OPT_SOCK_SNDBUF, 29).
--define(SOCKET_OPT_SOCK_TYPE, 34).
+%% -define(SOCKET_OPT_SOCK_MARK, 12).
+%% -define(SOCKET_OPT_SOCK_OOBINLLINE, 13).
+%% -define(SOCKET_OPT_SOCK_PASSCRED, 14).
+%% -define(SOCKET_OPT_SOCK_PEEK_OFF, 16).
+%% -define(SOCKET_OPT_SOCK_PEEKCRED, 17).
+-define(SOCKET_OPT_SOCK_PRIORITY, 18).
+-define(SOCKET_OPT_SOCK_PROTOCOL, 19).
+-define(SOCKET_OPT_SOCK_RCVBUF, 20).
+-define(SOCKET_OPT_SOCK_REUSEADDR, 24).
+-define(SOCKET_OPT_SOCK_SNDBUF, 30).
+-define(SOCKET_OPT_SOCK_TYPE, 35).
-define(SOCKET_OPT_IP_RECVTOS, 25).
-define(SOCKET_OPT_IP_ROUTER_ALERT, 28).
@@ -2021,10 +2032,10 @@ enc_sockopt_key(otp = L, Opt, _, _, _, _) ->
not_supported({L, Opt});
%% +++ SOCKET socket options +++
-enc_sockopt_key(socket = L, acceptconn = Opt, get = _Dir, _D, _T, _P) ->
+enc_sockopt_key(socket = _L, acceptconn = _Opt, get = _Dir, _D, _T, _P) ->
+ ?SOCKET_OPT_SOCK_ACCEPTCONN;
+enc_sockopt_key(socket = L, acceptfilter = Opt, _Dir, _D, _T, _P) ->
not_supported({L, Opt});
-enc_sockopt_key(socket, acceptfilter = Opt, _Dir, _D, _T, _P) ->
- not_supported(Opt);
%% Before linux 3.8, this socket option could be set.
%% Size of buffer for name: IFNAMSZ
%% So, we let the implementation decide.
@@ -2057,7 +2068,7 @@ enc_sockopt_key(socket = L, passcred = Opt, _Dir, _D, _T, _P) ->
not_supported({L, Opt});
enc_sockopt_key(socket = L, peek_off = Opt, _Dir, local = _D, _T, _P) ->
not_supported({L, Opt});
-enc_sockopt_key(socket = L, peek_cred = Opt, get = _Dir, _D, _T, _P) ->
+enc_sockopt_key(socket = L, peekcred = Opt, get = _Dir, _D, _T, _P) ->
not_supported({L, Opt});
enc_sockopt_key(socket, priority = _Opt, _Dir, _D, _T, _P) ->
?SOCKET_OPT_SOCK_PRIORITY;