aboutsummaryrefslogtreecommitdiffstats
path: root/erts/preloaded
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2018-07-20 13:00:22 +0200
committerMicael Karlberg <[email protected]>2018-09-18 14:50:18 +0200
commit75498c0dd7682bae7787c4e2cd8d2680fa2b9c45 (patch)
tree0d9dcdf630ed818b688747b566b4dfa3bb82c4c9 /erts/preloaded
parent3f1d17f3031b71ca6ff1f8e051859ad55e55822b (diff)
downloadotp-75498c0dd7682bae7787c4e2cd8d2680fa2b9c45.tar.gz
otp-75498c0dd7682bae7787c4e2cd8d2680fa2b9c45.tar.bz2
otp-75498c0dd7682bae7787c4e2cd8d2680fa2b9c45.zip
[socket-nif] Add support for socket (level socket) option(s) [rcv|snd]lowat
Added support for socket level socket option RCVLOWAT and SNDLOWAT. These are both a little strange, at least on Linux. See the man pages for more info. For instance, sndlowat cannot be set on Linux. OTP-14831
Diffstat (limited to 'erts/preloaded')
-rw-r--r--erts/preloaded/ebin/socket.beambin56284 -> 56372 bytes
-rw-r--r--erts/preloaded/src/socket.erl16
2 files changed, 10 insertions, 6 deletions
diff --git a/erts/preloaded/ebin/socket.beam b/erts/preloaded/ebin/socket.beam
index cd4feb8a46..b8d0e86a20 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 15f9693490..3ccba06f6b 100644
--- a/erts/preloaded/src/socket.erl
+++ b/erts/preloaded/src/socket.erl
@@ -575,7 +575,7 @@
-define(SOCKET_OPT_SOCK_PROTOCOL, 18).
-define(SOCKET_OPT_SOCK_RCVBUF, 19).
%% -define(SOCKET_OPT_SOCK_RCVBUFFORCE, 20).
-%% -define(SOCKET_OPT_SOCK_RCVLOWAT, 21).
+-define(SOCKET_OPT_SOCK_RCVLOWAT, 21).
-define(SOCKET_OPT_SOCK_RCVTIMEO, 22).
-define(SOCKET_OPT_SOCK_REUSEADDR, 23).
-define(SOCKET_OPT_SOCK_REUSEPORT, 24).
@@ -583,7 +583,7 @@
%% -define(SOCKET_OPT_SOCK_SETFIB, 26).
-define(SOCKET_OPT_SOCK_SNDBUF, 27).
%% -define(SOCKET_OPT_SOCK_SNDBUFFORCE, 28).
-%% -define(SOCKET_OPT_SOCK_SNDLOWAT, 29).
+-define(SOCKET_OPT_SOCK_SNDLOWAT, 29).
-define(SOCKET_OPT_SOCK_SNDTIMEO, 30).
%% -define(SOCKET_OPT_SOCK_TIMESTAMP, 31).
-define(SOCKET_OPT_SOCK_TYPE, 32).
@@ -2125,6 +2125,8 @@ enc_setopt_value(socket, priority, V, _D, _T, _P) when is_integer(V) ->
V;
enc_setopt_value(socket, rcvbuf, V, _D, _T, _P) when is_integer(V) ->
V;
+enc_setopt_value(socket, rcvlowat, V, _D, _T, _P) when is_integer(V) ->
+ V;
enc_setopt_value(socket, rcvtimeo, #{sec := Sec, usec := USec} = V, _D, _T, _P)
when is_integer(Sec) andalso is_integer(USec) ->
V;
@@ -2134,6 +2136,8 @@ enc_setopt_value(socket, reuseport, V, _D, _T, _P) when is_boolean(V) ->
V;
enc_setopt_value(socket, sndbuf, V, _D, _T, _P) when is_integer(V) ->
V;
+enc_setopt_value(socket, sndlowat, V, _D, _T, _P) when is_integer(V) ->
+ V;
enc_setopt_value(socket, sndtimeo, #{sec := Sec, usec := USec} = V, _D, _T, _P)
when is_integer(Sec) andalso is_integer(USec) ->
V;
@@ -2523,8 +2527,8 @@ enc_sockopt_key(socket, rcvbuf = _Opt, _Dir, _D, _T, _P) ->
enc_sockopt_key(socket = L, rcvbufforce = Opt, _Dir, _D, _T, _P) ->
not_supported({L, Opt});
%% May not work on linux.
-enc_sockopt_key(socket = L, rcvlowat = Opt, _Dir, _D, _T, _P) ->
- not_supported({L, Opt});
+enc_sockopt_key(socket = _L, rcvlowat = _Opt, _Dir, _D, _T, _P) ->
+ ?SOCKET_OPT_SOCK_RCVLOWAT;
enc_sockopt_key(socket = _L, rcvtimeo = _Opt, _Dir, _D, _T, _P) ->
?SOCKET_OPT_SOCK_RCVTIMEO;
enc_sockopt_key(socket = _L, reuseaddr = _Opt, _Dir, _D, _T, _P) ->
@@ -2541,8 +2545,8 @@ enc_sockopt_key(socket = _L, sndbuf = _Opt, _Dir, _D, _T, _P) ->
enc_sockopt_key(socket = L, sndbufforce = Opt, _Dir, _D, _T, _P) ->
not_supported({L, Opt});
%% Not changeable on linux.
-enc_sockopt_key(socket = L, sndlowat = Opt, _Dir, _D, _T, _P) ->
- not_supported({L, Opt});
+enc_sockopt_key(socket = _L, sndlowat = _Opt, _Dir, _D, _T, _P) ->
+ ?SOCKET_OPT_SOCK_SNDLOWAT;
enc_sockopt_key(socket = _L, sndtimeo = _Opt, _Dir, _D, _T, _P) ->
?SOCKET_OPT_SOCK_SNDTIMEO;
enc_sockopt_key(socket = L, timestamp = Opt, _Dir, _D, _T, _P) ->