mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8285515: (dc) DatagramChannel.disconnect fails with "Invalid argument" on macOS 12.4 beta2
Reviewed-by: dfuchs, alanb
This commit is contained in:
parent
c4f7a850c6
commit
269eae6189
2 changed files with 19 additions and 11 deletions
|
@ -50,20 +50,28 @@ Java_sun_nio_ch_DatagramChannelImpl_disconnect0(JNIEnv *env, jclass clazz,
|
|||
jint fd = fdval(env, fdo);
|
||||
int rv;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
// On macOS systems we use disconnectx
|
||||
rv = disconnectx(fd, SAE_ASSOCID_ANY, SAE_CONNID_ANY);
|
||||
#else
|
||||
SOCKETADDRESS sa;
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
#if defined(_ALLBSD_SOURCE)
|
||||
sa.sa.sa_family = isIPv6 ? AF_INET6 : AF_INET;
|
||||
#else
|
||||
sa.sa.sa_family = AF_UNSPEC;
|
||||
#endif
|
||||
socklen_t len = isIPv6 ? sizeof(struct sockaddr_in6) :
|
||||
sizeof(struct sockaddr_in);
|
||||
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
#if defined(_ALLBSD_SOURCE)
|
||||
sa.sa.sa_family = isIPv6 ? AF_INET6 : AF_INET;
|
||||
#else
|
||||
sa.sa.sa_family = AF_UNSPEC;
|
||||
rv = connect(fd, &sa.sa, len);
|
||||
#endif
|
||||
|
||||
rv = connect(fd, &sa.sa, len);
|
||||
|
||||
#if defined(_ALLBSD_SOURCE)
|
||||
#if defined(_ALLBSD_SOURCE) && !defined(__APPLE__)
|
||||
// On _ALLBSD_SOURCE except __APPLE__ we consider EADDRNOTAVAIL
|
||||
// error to be OK and ignore it. __APPLE__ systems are excluded
|
||||
// in this check since for __APPLE__ systems, unlike other BSD systems,
|
||||
// we issue a "disconnectx" call (a few lines above),
|
||||
// which isn't expected to return this error code.
|
||||
if (rv < 0 && errno == EADDRNOTAVAIL)
|
||||
rv = errno = 0;
|
||||
#elif defined(_AIX)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue