mirror of
https://github.com/openjdk/jdk18u.git
synced 2025-12-10 00:37:05 -06:00
8285515: (dc) DatagramChannel.disconnect fails with "Invalid argument" on macOS 12.4
Backport-of: 269eae61894b6bd0a7512045a369b53df747f6e5
This commit is contained in:
parent
c08f40e722
commit
7af433da4d
@ -50,20 +50,28 @@ Java_sun_nio_ch_DatagramChannelImpl_disconnect0(JNIEnv *env, jclass clazz,
|
|||||||
jint fd = fdval(env, fdo);
|
jint fd = fdval(env, fdo);
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
// On macOS systems we use disconnectx
|
||||||
|
rv = disconnectx(fd, SAE_ASSOCID_ANY, SAE_CONNID_ANY);
|
||||||
|
#else
|
||||||
SOCKETADDRESS sa;
|
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) :
|
socklen_t len = isIPv6 ? sizeof(struct sockaddr_in6) :
|
||||||
sizeof(struct sockaddr_in);
|
sizeof(struct sockaddr_in);
|
||||||
|
rv = connect(fd, &sa.sa, len);
|
||||||
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
|
#endif
|
||||||
|
|
||||||
rv = connect(fd, &sa.sa, len);
|
#if defined(_ALLBSD_SOURCE) && !defined(__APPLE__)
|
||||||
|
// On _ALLBSD_SOURCE except __APPLE__ we consider EADDRNOTAVAIL
|
||||||
#if defined(_ALLBSD_SOURCE)
|
// 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)
|
if (rv < 0 && errno == EADDRNOTAVAIL)
|
||||||
rv = errno = 0;
|
rv = errno = 0;
|
||||||
#elif defined(_AIX)
|
#elif defined(_AIX)
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* @test
|
/* @test
|
||||||
* @bug 7132924
|
* @bug 7132924 8285515
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @key intermittent
|
* @key intermittent
|
||||||
* @summary Test DatagramChannel.disconnect when DatagramChannel is connected to an IPv4 socket
|
* @summary Test DatagramChannel.disconnect when DatagramChannel is connected to an IPv4 socket
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user