提交 d4681b69 编写于 作者: C chegar

6905552: libnet/nio portability issues

Reviewed-by: alanb
上级 d9f971bf
...@@ -162,10 +162,11 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) { ...@@ -162,10 +162,11 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
NET_SockaddrEqualsInetAddress(JNIEnv *env, struct sockaddr *him, jobject iaObj) NET_SockaddrEqualsInetAddress(JNIEnv *env, struct sockaddr *him, jobject iaObj)
{ {
jint family = (*env)->GetIntField(env, iaObj, ia_familyID) == IPv4? jint family = AF_INET;
AF_INET : AF_INET6;
#ifdef AF_INET6 #ifdef AF_INET6
family = (*env)->GetIntField(env, iaObj, ia_familyID) == IPv4?
AF_INET : AF_INET6;
if (him->sa_family == AF_INET6) { if (him->sa_family == AF_INET6) {
#ifdef WIN32 #ifdef WIN32
struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him; struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
......
...@@ -46,11 +46,6 @@ ...@@ -46,11 +46,6 @@
#define HENT_BUF_SIZE 1024 #define HENT_BUF_SIZE 1024
#define BIG_HENT_BUF_SIZE 10240 /* a jumbo-sized one */ #define BIG_HENT_BUF_SIZE 10240 /* a jumbo-sized one */
#ifndef __GLIBC__
/* gethostname() is in libc.so but I can't find a header file for it */
extern int gethostname(char *buf, int buf_len);
#endif
/************************************************************************ /************************************************************************
* Inet4AddressImpl * Inet4AddressImpl
*/ */
......
...@@ -49,10 +49,6 @@ ...@@ -49,10 +49,6 @@
#define NI_MAXHOST 1025 #define NI_MAXHOST 1025
#endif #endif
#ifndef __GLIBC__
/* gethostname() is in libc.so but I can't find a header file for it */
extern int gethostname(char *buf, int buf_len);
#endif
/************************************************************************ /************************************************************************
* Inet6AddressImpl * Inet6AddressImpl
...@@ -360,8 +356,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, ...@@ -360,8 +356,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
} }
} }
#endif /* AF_INET6 */
cleanupAndReturn: cleanupAndReturn:
{ {
struct addrinfo *iterator, *tmp; struct addrinfo *iterator, *tmp;
...@@ -374,7 +368,6 @@ cleanupAndReturn: ...@@ -374,7 +368,6 @@ cleanupAndReturn:
JNU_ReleaseStringPlatformChars(env, host, hostname); JNU_ReleaseStringPlatformChars(env, host, hostname);
} }
#ifdef AF_INET6
if (NET_addrtransAvailable()) if (NET_addrtransAvailable())
(*freeaddrinfo_ptr)(res); (*freeaddrinfo_ptr)(res);
#endif /* AF_INET6 */ #endif /* AF_INET6 */
......
...@@ -253,8 +253,12 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0 ...@@ -253,8 +253,12 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0
(JNIEnv *env, jclass cls, jobject iaObj) { (JNIEnv *env, jclass cls, jobject iaObj) {
netif *ifs, *curr; netif *ifs, *curr;
#ifdef AF_INET6
int family = (*env)->GetIntField(env, iaObj, ni_iafamilyID) == IPv4? int family = (*env)->GetIntField(env, iaObj, ni_iafamilyID) == IPv4?
AF_INET : AF_INET6; AF_INET : AF_INET6;
#else
int family = AF_INET;
#endif
jobject obj = NULL; jobject obj = NULL;
jboolean match = JNI_FALSE; jboolean match = JNI_FALSE;
...@@ -1528,6 +1532,7 @@ JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0(JNIEnv *env, jclas ...@@ -1528,6 +1532,7 @@ JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0(JNIEnv *env, jclas
strcpy((caddr_t)&(lifr.lifr_name), name_utf); strcpy((caddr_t)&(lifr.lifr_name), name_utf);
if (ioctl(sock, SIOCGLIFMTU, (caddr_t)&lifr) >= 0) { if (ioctl(sock, SIOCGLIFMTU, (caddr_t)&lifr) >= 0) {
ret = lifr.lifr_mtu; ret = lifr.lifr_mtu;
#ifdef AF_INET6
} else { } else {
/* Try wIth an IPv6 socket in case the interface has only IPv6 addresses assigned to it */ /* Try wIth an IPv6 socket in case the interface has only IPv6 addresses assigned to it */
close(sock); close(sock);
...@@ -1547,6 +1552,12 @@ JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0(JNIEnv *env, jclas ...@@ -1547,6 +1552,12 @@ JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0(JNIEnv *env, jclas
"IOCTL failed"); "IOCTL failed");
} }
} }
#else
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"IOCTL failed");
}
#endif
#endif #endif
close(sock); close(sock);
} }
......
...@@ -605,8 +605,12 @@ Java_java_net_PlainDatagramSocketImpl_peek(JNIEnv *env, jobject this, ...@@ -605,8 +605,12 @@ Java_java_net_PlainDatagramSocketImpl_peek(JNIEnv *env, jobject this,
} }
iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&remote_addr, &port); iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&remote_addr, &port);
#ifdef AF_INET6
family = (*env)->GetIntField(env, iaObj, ia_familyID) == IPv4? family = (*env)->GetIntField(env, iaObj, ia_familyID) == IPv4?
AF_INET : AF_INET6; AF_INET : AF_INET6;
#else
family = AF_INET;
#endif
if (family == AF_INET) { /* this api can't handle IPV6 addresses */ if (family == AF_INET) { /* this api can't handle IPV6 addresses */
int address = (*env)->GetIntField(env, iaObj, ia_addressID); int address = (*env)->GetIntField(env, iaObj, ia_addressID);
(*env)->SetIntField(env, addressObj, ia_addressID, address); (*env)->SetIntField(env, addressObj, ia_addressID, address);
...@@ -812,9 +816,9 @@ Java_java_net_PlainDatagramSocketImpl_receive0(JNIEnv *env, jobject this, ...@@ -812,9 +816,9 @@ Java_java_net_PlainDatagramSocketImpl_receive0(JNIEnv *env, jobject this,
jboolean retry; jboolean retry;
#ifdef __linux__ #ifdef __linux__
jboolean connected = JNI_FALSE; jboolean connected = JNI_FALSE;
jobject connectedAddress; jobject connectedAddress = NULL;
jint connectedPort; jint connectedPort = 0;
jlong prevTime; jlong prevTime = 0;
#endif #endif
if (IS_NULL(fdObj)) { if (IS_NULL(fdObj)) {
...@@ -1186,6 +1190,7 @@ static void mcast_set_if_by_if_v4(JNIEnv *env, jobject this, int fd, jobject val ...@@ -1186,6 +1190,7 @@ static void mcast_set_if_by_if_v4(JNIEnv *env, jobject this, int fd, jobject val
* Set outgoing multicast interface designated by a NetworkInterface. * Set outgoing multicast interface designated by a NetworkInterface.
* Throw exception if failed. * Throw exception if failed.
*/ */
#ifdef AF_INET6
static void mcast_set_if_by_if_v6(JNIEnv *env, jobject this, int fd, jobject value) { static void mcast_set_if_by_if_v6(JNIEnv *env, jobject this, int fd, jobject value) {
static jfieldID ni_indexID; static jfieldID ni_indexID;
int index; int index;
...@@ -1222,6 +1227,7 @@ static void mcast_set_if_by_if_v6(JNIEnv *env, jobject this, int fd, jobject val ...@@ -1222,6 +1227,7 @@ static void mcast_set_if_by_if_v6(JNIEnv *env, jobject this, int fd, jobject val
} }
#endif #endif
} }
#endif /* AF_INET6 */
/* /*
* Set outgoing multicast interface designated by an InetAddress. * Set outgoing multicast interface designated by an InetAddress.
...@@ -1251,6 +1257,7 @@ static void mcast_set_if_by_addr_v4(JNIEnv *env, jobject this, int fd, jobject v ...@@ -1251,6 +1257,7 @@ static void mcast_set_if_by_addr_v4(JNIEnv *env, jobject this, int fd, jobject v
* Set outgoing multicast interface designated by an InetAddress. * Set outgoing multicast interface designated by an InetAddress.
* Throw exception if failed. * Throw exception if failed.
*/ */
#ifdef AF_INET6
static void mcast_set_if_by_addr_v6(JNIEnv *env, jobject this, int fd, jobject value) { static void mcast_set_if_by_addr_v6(JNIEnv *env, jobject this, int fd, jobject value) {
static jclass ni_class; static jclass ni_class;
if (ni_class == NULL) { if (ni_class == NULL) {
...@@ -1272,6 +1279,7 @@ static void mcast_set_if_by_addr_v6(JNIEnv *env, jobject this, int fd, jobject v ...@@ -1272,6 +1279,7 @@ static void mcast_set_if_by_addr_v6(JNIEnv *env, jobject this, int fd, jobject v
mcast_set_if_by_if_v6(env, this, fd, value); mcast_set_if_by_if_v6(env, this, fd, value);
} }
#endif
/* /*
* Sets the multicast interface. * Sets the multicast interface.
...@@ -1307,6 +1315,7 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, ...@@ -1307,6 +1315,7 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd,
/* /*
* value is an InetAddress. * value is an InetAddress.
*/ */
#ifdef AF_INET6
#ifdef __solaris__ #ifdef __solaris__
if (ipv6_available()) { if (ipv6_available()) {
mcast_set_if_by_addr_v6(env, this, fd, value); mcast_set_if_by_addr_v6(env, this, fd, value);
...@@ -1320,12 +1329,16 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, ...@@ -1320,12 +1329,16 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd,
mcast_set_if_by_addr_v6(env, this, fd, value); mcast_set_if_by_addr_v6(env, this, fd, value);
} }
#endif #endif
#else
mcast_set_if_by_addr_v4(env, this, fd, value);
#endif /* AF_INET6 */
} }
if (opt == java_net_SocketOptions_IP_MULTICAST_IF2) { if (opt == java_net_SocketOptions_IP_MULTICAST_IF2) {
/* /*
* value is a NetworkInterface. * value is a NetworkInterface.
*/ */
#ifdef AF_INET6
#ifdef __solaris__ #ifdef __solaris__
if (ipv6_available()) { if (ipv6_available()) {
mcast_set_if_by_if_v6(env, this, fd, value); mcast_set_if_by_if_v6(env, this, fd, value);
...@@ -1339,6 +1352,9 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, ...@@ -1339,6 +1352,9 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd,
mcast_set_if_by_if_v6(env, this, fd, value); mcast_set_if_by_if_v6(env, this, fd, value);
} }
#endif #endif
#else
mcast_set_if_by_if_v4(env, this, fd, value);
#endif /* AF_INET6 */
} }
} }
...@@ -1368,6 +1384,7 @@ static void mcast_set_loop_v4(JNIEnv *env, jobject this, int fd, jobject value) ...@@ -1368,6 +1384,7 @@ static void mcast_set_loop_v4(JNIEnv *env, jobject this, int fd, jobject value)
/* /*
* Enable/disable local loopback of multicast datagrams. * Enable/disable local loopback of multicast datagrams.
*/ */
#ifdef AF_INET6
static void mcast_set_loop_v6(JNIEnv *env, jobject this, int fd, jobject value) { static void mcast_set_loop_v6(JNIEnv *env, jobject this, int fd, jobject value) {
jclass cls; jclass cls;
jfieldID fid; jfieldID fid;
...@@ -1397,12 +1414,14 @@ static void mcast_set_loop_v6(JNIEnv *env, jobject this, int fd, jobject value) ...@@ -1397,12 +1414,14 @@ static void mcast_set_loop_v6(JNIEnv *env, jobject this, int fd, jobject value)
} }
#endif #endif
} }
#endif /* AF_INET6 */
/* /*
* Sets the multicast loopback mode. * Sets the multicast loopback mode.
*/ */
static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd, static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd,
jint opt, jobject value) { jint opt, jobject value) {
#ifdef AF_INET6
#ifdef __solaris__ #ifdef __solaris__
if (ipv6_available()) { if (ipv6_available()) {
mcast_set_loop_v6(env, this, fd, value); mcast_set_loop_v6(env, this, fd, value);
...@@ -1416,6 +1435,9 @@ static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd, ...@@ -1416,6 +1435,9 @@ static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd,
mcast_set_loop_v6(env, this, fd, value); mcast_set_loop_v6(env, this, fd, value);
} }
#endif #endif
#else
mcast_set_loop_v4(env, this, fd, value);
#endif /* AF_INET6 */
} }
/* /*
...@@ -1838,7 +1860,7 @@ Java_java_net_PlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobject this, ...@@ -1838,7 +1860,7 @@ Java_java_net_PlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobject this,
if (opt == java_net_SocketOptions_SO_BINDADDR) { if (opt == java_net_SocketOptions_SO_BINDADDR) {
/* find out local IP address */ /* find out local IP address */
SOCKADDR him; SOCKADDR him;
int len = 0; socklen_t len = 0;
int port; int port;
jobject iaObj; jobject iaObj;
...@@ -1941,6 +1963,7 @@ static void setTTL(JNIEnv *env, int fd, jint ttl) { ...@@ -1941,6 +1963,7 @@ static void setTTL(JNIEnv *env, int fd, jint ttl) {
/* /*
* Set hops limit for a socket. Throw exception if failed. * Set hops limit for a socket. Throw exception if failed.
*/ */
#ifdef AF_INET6
static void setHopLimit(JNIEnv *env, int fd, jint ttl) { static void setHopLimit(JNIEnv *env, int fd, jint ttl) {
int ittl = (int)ttl; int ittl = (int)ttl;
if (JVM_SetSockOpt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, if (JVM_SetSockOpt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
...@@ -1949,6 +1972,7 @@ static void setHopLimit(JNIEnv *env, int fd, jint ttl) { ...@@ -1949,6 +1972,7 @@ static void setHopLimit(JNIEnv *env, int fd, jint ttl) {
"Error setting socket option"); "Error setting socket option");
} }
} }
#endif
/* /*
* Class: java_net_PlainDatagramSocketImpl * Class: java_net_PlainDatagramSocketImpl
...@@ -1971,6 +1995,7 @@ Java_java_net_PlainDatagramSocketImpl_setTimeToLive(JNIEnv *env, jobject this, ...@@ -1971,6 +1995,7 @@ Java_java_net_PlainDatagramSocketImpl_setTimeToLive(JNIEnv *env, jobject this,
fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID); fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
} }
/* setsockopt to be correct ttl */ /* setsockopt to be correct ttl */
#ifdef AF_INET6
#ifdef __solaris__ #ifdef __solaris__
if (ipv6_available()) { if (ipv6_available()) {
setHopLimit(env, fd, ttl); setHopLimit(env, fd, ttl);
...@@ -1986,7 +2011,10 @@ Java_java_net_PlainDatagramSocketImpl_setTimeToLive(JNIEnv *env, jobject this, ...@@ -1986,7 +2011,10 @@ Java_java_net_PlainDatagramSocketImpl_setTimeToLive(JNIEnv *env, jobject this,
(*env)->SetIntField(env, this, pdsi_ttlID, ttl); (*env)->SetIntField(env, this, pdsi_ttlID, ttl);
} }
} }
#endif #endif // __linux__
#else
setTTL(env, fd, ttl);
#endif /* AF_INET6 */
} }
/* /*
......
...@@ -319,8 +319,6 @@ jint IPv6_supported() ...@@ -319,8 +319,6 @@ jint IPv6_supported()
#endif /* __solaris */ #endif /* __solaris */
#endif /* AF_INET6 */
/* /*
* OK we may have the stack available in the kernel, * OK we may have the stack available in the kernel,
* we should also check if the APIs are available. * we should also check if the APIs are available.
...@@ -354,6 +352,7 @@ jint IPv6_supported() ...@@ -354,6 +352,7 @@ jint IPv6_supported()
close(fd); close(fd);
return JNI_TRUE; return JNI_TRUE;
#endif /* AF_INET6 */
} }
void void
......
...@@ -133,7 +133,7 @@ extern jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout); ...@@ -133,7 +133,7 @@ extern jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout);
#else #else
#define SOCKADDR union { struct sockaddr_in him4 } #define SOCKADDR union { struct sockaddr_in him4; }
#define SOCKADDR_LEN sizeof(SOCKADDR) #define SOCKADDR_LEN sizeof(SOCKADDR)
#endif #endif
......
...@@ -44,7 +44,11 @@ JNIEXPORT void JNICALL ...@@ -44,7 +44,11 @@ JNIEXPORT void JNICALL
Java_sun_net_spi_SdpProvider_convert(JNIEnv *env, jclass cls, jint fd) Java_sun_net_spi_SdpProvider_convert(JNIEnv *env, jclass cls, jint fd)
{ {
#ifdef PROTO_SDP #ifdef PROTO_SDP
#ifdef AF_INET6
int domain = ipv6_available() ? AF_INET6 : AF_INET; int domain = ipv6_available() ? AF_INET6 : AF_INET;
#else
int domain = AF_INET;
#endif
int s = socket(domain, SOCK_STREAM, PROTO_SDP); int s = socket(domain, SOCK_STREAM, PROTO_SDP);
if (s < 0) { if (s < 0) {
JNU_ThrowIOExceptionWithLastError(env, "socket"); JNU_ThrowIOExceptionWithLastError(env, "socket");
......
...@@ -124,6 +124,7 @@ struct my_group_source_req { ...@@ -124,6 +124,7 @@ struct my_group_source_req {
* Copy IPv6 group, interface index, and IPv6 source address * Copy IPv6 group, interface index, and IPv6 source address
* into group_source_req structure. * into group_source_req structure.
*/ */
#ifdef AF_INET6
static void initGroupSourceReq(JNIEnv* env, jbyteArray group, jint index, static void initGroupSourceReq(JNIEnv* env, jbyteArray group, jint index,
jbyteArray source, struct my_group_source_req* req) jbyteArray source, struct my_group_source_req* req)
{ {
...@@ -139,7 +140,7 @@ static void initGroupSourceReq(JNIEnv* env, jbyteArray group, jint index, ...@@ -139,7 +140,7 @@ static void initGroupSourceReq(JNIEnv* env, jbyteArray group, jint index,
sin6->sin6_family = AF_INET6; sin6->sin6_family = AF_INET6;
COPY_INET6_ADDRESS(env, source, (jbyte*)&(sin6->sin6_addr)); COPY_INET6_ADDRESS(env, source, (jbyte*)&(sin6->sin6_addr));
} }
#endif
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_sun_nio_ch_Net_initIDs(JNIEnv *env, jclass clazz) Java_sun_nio_ch_Net_initIDs(JNIEnv *env, jclass clazz)
...@@ -159,7 +160,11 @@ Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6, ...@@ -159,7 +160,11 @@ Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6,
{ {
int fd; int fd;
int type = (stream ? SOCK_STREAM : SOCK_DGRAM); int type = (stream ? SOCK_STREAM : SOCK_DGRAM);
#ifdef AF_INET6
int domain = (ipv6_available() && preferIPv6) ? AF_INET6 : AF_INET; int domain = (ipv6_available() && preferIPv6) ? AF_INET6 : AF_INET;
#else
int domain = AF_INET;
#endif
fd = socket(domain, type, 0); fd = socket(domain, type, 0);
if (fd < 0) { if (fd < 0) {
...@@ -176,7 +181,7 @@ Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6, ...@@ -176,7 +181,7 @@ Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6,
return -1; return -1;
} }
} }
#ifdef __linux__ #if defined(__linux__) && defined(AF_INET6)
/* By default, Linux uses the route default */ /* By default, Linux uses the route default */
if (domain == AF_INET6 && type == SOCK_DGRAM) { if (domain == AF_INET6 && type == SOCK_DGRAM) {
int arg = 1; int arg = 1;
...@@ -424,6 +429,7 @@ JNIEXPORT jint JNICALL ...@@ -424,6 +429,7 @@ JNIEXPORT jint JNICALL
Java_sun_nio_ch_Net_joinOrDrop6(JNIEnv *env, jobject this, jboolean join, jobject fdo, Java_sun_nio_ch_Net_joinOrDrop6(JNIEnv *env, jobject this, jboolean join, jobject fdo,
jbyteArray group, jint index, jbyteArray source) jbyteArray group, jint index, jbyteArray source)
{ {
#ifdef AF_INET6
struct ipv6_mreq mreq6; struct ipv6_mreq mreq6;
struct my_group_source_req req; struct my_group_source_req req;
int opt, n, optlen; int opt, n, optlen;
...@@ -454,12 +460,17 @@ Java_sun_nio_ch_Net_joinOrDrop6(JNIEnv *env, jobject this, jboolean join, jobjec ...@@ -454,12 +460,17 @@ Java_sun_nio_ch_Net_joinOrDrop6(JNIEnv *env, jobject this, jboolean join, jobjec
handleSocketError(env, errno); handleSocketError(env, errno);
} }
return 0; return 0;
#else
JNU_ThrowInternalError(env, "Should not get here");
return IOS_THROWN;
#endif /* AF_INET6 */
} }
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
Java_sun_nio_ch_Net_blockOrUnblock6(JNIEnv *env, jobject this, jboolean block, jobject fdo, Java_sun_nio_ch_Net_blockOrUnblock6(JNIEnv *env, jobject this, jboolean block, jobject fdo,
jbyteArray group, jint index, jbyteArray source) jbyteArray group, jint index, jbyteArray source)
{ {
#ifdef AF_INET6
struct my_group_source_req req; struct my_group_source_req req;
int n; int n;
int opt = (block) ? MCAST_BLOCK_SOURCE : MCAST_UNBLOCK_SOURCE; int opt = (block) ? MCAST_BLOCK_SOURCE : MCAST_UNBLOCK_SOURCE;
...@@ -474,6 +485,10 @@ Java_sun_nio_ch_Net_blockOrUnblock6(JNIEnv *env, jobject this, jboolean block, j ...@@ -474,6 +485,10 @@ Java_sun_nio_ch_Net_blockOrUnblock6(JNIEnv *env, jobject this, jboolean block, j
handleSocketError(env, errno); handleSocketError(env, errno);
} }
return 0; return 0;
#else
JNU_ThrowInternalError(env, "Should not get here");
return IOS_THROWN;
#endif
} }
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
......
...@@ -168,14 +168,18 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpNet_socket0 ...@@ -168,14 +168,18 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpNet_socket0
(JNIEnv *env, jclass klass, jboolean oneToOne) { (JNIEnv *env, jclass klass, jboolean oneToOne) {
int fd; int fd;
struct sctp_event_subscribe event; struct sctp_event_subscribe event;
#ifdef AF_INET6
int domain = ipv6_available() ? AF_INET6 : AF_INET;
#else
int domain = AF_INET;
#endif
/* Try to load the socket API extension functions */ /* Try to load the socket API extension functions */
if (!funcsLoaded && !loadSocketExtensionFuncs(env)) { if (!funcsLoaded && !loadSocketExtensionFuncs(env)) {
return 0; return 0;
} }
fd = socket(ipv6_available() ? AF_INET6 : AF_INET, fd = socket(domain, (oneToOne ? SOCK_STREAM : SOCK_SEQPACKET), IPPROTO_SCTP);
(oneToOne ? SOCK_STREAM : SOCK_SEQPACKET), IPPROTO_SCTP);
if (fd < 0) { if (fd < 0) {
return handleSocketError(env, errno); return handleSocketError(env, errno);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册