aboutsummaryrefslogtreecommitdiffstats
path: root/erts/preloaded
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2019-01-29 12:41:19 +0100
committerMicael Karlberg <[email protected]>2019-01-29 12:41:19 +0100
commit3d166efe4f3ee6a93edf361a9d72633a00fb486f (patch)
tree0f4e8866b0d6f264862f4ac842a4782f2108a693 /erts/preloaded
parentfe540a9079ea58f8b9b85069ff1558ce7a98f915 (diff)
downloadotp-3d166efe4f3ee6a93edf361a9d72633a00fb486f.tar.gz
otp-3d166efe4f3ee6a93edf361a9d72633a00fb486f.tar.bz2
otp-3d166efe4f3ee6a93edf361a9d72633a00fb486f.zip
[socket-nif] The otp rcvbuf option updated
Its now possible to set a rcvbuf (otp) option value of {N :: pos_integer(), BufSz :: pos_integer()}. This value is used for type stream and protocol tcp, when calling the function recv with length = 0 (zero). The second value, BufSz, is the actual size of the receive buffer used when calling the socket recv function, and the first value, N, is the max number of possible reads that will be performed (at most), even if there is more data to read. This is limit the effect of DoS attacks. OTP-15497
Diffstat (limited to 'erts/preloaded')
-rw-r--r--erts/preloaded/ebin/socket.beambin70344 -> 69888 bytes
-rw-r--r--erts/preloaded/src/socket.erl8
2 files changed, 7 insertions, 1 deletions
diff --git a/erts/preloaded/ebin/socket.beam b/erts/preloaded/ebin/socket.beam
index 06e7c2910d..0066ca2433 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 839087ef2a..80ccd7ea10 100644
--- a/erts/preloaded/src/socket.erl
+++ b/erts/preloaded/src/socket.erl
@@ -2553,9 +2553,15 @@ enc_setopt_value(otp, iow, V, _, _, _) when is_boolean(V) ->
enc_setopt_value(otp, controlling_process, V, _, _, _) when is_pid(V) ->
V;
enc_setopt_value(otp, rcvbuf, V, _, _, _) when (V =:= default) ->
- 0;
+ 0; % This will cause the nif-code to choose the default value
enc_setopt_value(otp, rcvbuf, V, _, _, _) when is_integer(V) andalso (V > 0) ->
V;
+%% N: Number of reads (when specifying length = 0)
+%% V: Size of the "read" buffer
+enc_setopt_value(otp, rcvbuf, {N, BufSz} = V, _, stream = _T, tcp = _P)
+ when (is_integer(N) andalso (N > 0)) andalso
+ (is_integer(BufSz) andalso (BufSz > 0)) ->
+ V;
enc_setopt_value(otp, rcvctrlbuf, V, _, _, _) when (V =:= default) ->
0;
enc_setopt_value(otp, rcvctrlbuf, V, _, _, _) when is_integer(V) andalso (V > 0) ->