aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2018-06-21 11:00:25 +0200
committerLukas Larsson <[email protected]>2018-07-30 16:55:26 +0200
commita9d361b4be7d6329bedd7b37d454c1abf4f27233 (patch)
treea55a060d66bad33cff29fe00ab1ac1b171a4ce74 /erts/emulator
parent83445d0de88a1ad15066e6c415b2c2d9aa93d6a1 (diff)
downloadotp-a9d361b4be7d6329bedd7b37d454c1abf4f27233.tar.gz
otp-a9d361b4be7d6329bedd7b37d454c1abf4f27233.tar.bz2
otp-a9d361b4be7d6329bedd7b37d454c1abf4f27233.zip
erts: Limit the automatic max buffer for UDP to 2^16
There is no reason to have a larger buffer than this as the recvmsg call will never return more data. OTP-15206
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/drivers/common/inet_drv.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c
index 833befefd1..2048d0f625 100644
--- a/erts/emulator/drivers/common/inet_drv.c
+++ b/erts/emulator/drivers/common/inet_drv.c
@@ -1549,6 +1549,8 @@ static void *realloc_wrapper(void *current, ErlDrvSizeT size){
# define LOAD_ASSOC_ID LOAD_UINT
# define LOAD_ASSOC_ID_CNT LOAD_UINT_CNT
# define SCTP_ANC_BUFF_SIZE INET_DEF_BUFFER/2 /* XXX: not very good... */
+#else
+# define IS_SCTP(desc) 0
#endif
#ifdef HAVE_UDP
@@ -6436,7 +6438,12 @@ static int inet_set_opts(inet_descriptor* desc, char* ptr, int len)
(long)desc->port, desc->s, res));
if (type == SO_RCVBUF) {
/* make sure we have desc->bufsz >= SO_RCVBUF */
- if (ival > desc->bufsz)
+ if (ival > (1 << 16) && desc->stype == SOCK_DGRAM && !IS_SCTP(desc))
+ /* For UDP we don't want to automatically
+ set the buffer size to be larger than
+ the theoretical max MTU */
+ desc->bufsz = 1 << 16;
+ else if (ival > desc->bufsz)
desc->bufsz = ival;
}
}