8239355: (dc) Initial value of SO_SNDBUF should allow sending large datagrams (macOS)

Updates DatagramChannel so that the SO_SNDBUF is set to a minimum value of 65527 for IPv6 sockets and 65507 for IPv4 sockets on macOS.

Reviewed-by: alanb, dfuchs
This commit is contained in:
Patrick Concannon 2020-03-12 17:08:09 +00:00
parent e5ab701157
commit 0ed44d0aee
4 changed files with 198 additions and 3 deletions

View file

@ -265,6 +265,24 @@ Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6,
}
}
#endif
#ifdef __APPLE__
/**
* Attempt to set SO_SNDBUF to a minimum size to allow sending large datagrams
* (net.inet.udp.maxdgram defaults to 9216).
*/
if (type == SOCK_DGRAM) {
int size;
socklen_t arglen = sizeof(size);
if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, &arglen) == 0) {
int minSize = (domain == AF_INET6) ? 65527 : 65507;
if (size < minSize) {
setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &minSize, sizeof(minSize));
}
}
}
#endif
return fd;
}