diff --git a/src/solaris/native/java/net/Inet6AddressImpl.c b/src/solaris/native/java/net/Inet6AddressImpl.c index e67e25ac4e9894bdb133dba1dcfd22839eee265f..e29a25daf52801e50baae5cc1eccb30c304ef32c 100644 --- a/src/solaris/native/java/net/Inet6AddressImpl.c +++ b/src/solaris/native/java/net/Inet6AddressImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,18 +75,14 @@ Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) { } else { // ensure null-terminated hostname[NI_MAXHOST] = '\0'; -#if defined(__linux__) || defined(_ALLBSD_SOURCE) - /* On Linux/FreeBSD gethostname() says "host.domain.sun.com". On - * Solaris gethostname() says "host", so extra work is needed. - */ -#else + /* Solaris doesn't want to give us a fully qualified domain name. * We do a reverse lookup to try and get one. This works * if DNS occurs before NIS in /etc/resolv.conf, but fails * if NIS comes first (it still gets only a partial name). * We use thread-safe system calls. */ -#ifdef AF_INET6 +#if defined(__solaris__) && defined(AF_INET6) struct addrinfo hints, *res; int error; @@ -111,8 +107,7 @@ Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) { freeaddrinfo(res); } -#endif /* AF_INET6 */ -#endif /* __linux__ || _ALLBSD_SOURCE */ +#endif } return (*env)->NewStringUTF(env, hostname); } diff --git a/src/solaris/native/java/net/net_util_md.c b/src/solaris/native/java/net/net_util_md.c index a284fed280f682b55befbc91325e55b2d76ee75a..9c276da3f81c6c881a9920b1de9f69179ecc5c79 100644 --- a/src/solaris/native/java/net/net_util_md.c +++ b/src/solaris/native/java/net/net_util_md.c @@ -333,6 +333,7 @@ jint IPv6_supported() if (getsockname(0, (struct sockaddr *)&sa, &sa_len) == 0) { struct sockaddr *saP = (struct sockaddr *)&sa; if (saP->sa_family != AF_INET6) { + close(fd); return JNI_FALSE; } } @@ -1207,16 +1208,10 @@ NET_GetSockOpt(int fd, int level, int opt, void *result, int *len) { int rv; + socklen_t socklen = *len; -#ifdef __solaris__ - rv = getsockopt(fd, level, opt, result, len); -#else - { - socklen_t socklen = *len; - rv = getsockopt(fd, level, opt, result, &socklen); - *len = socklen; - } -#endif + rv = getsockopt(fd, level, opt, result, &socklen); + *len = socklen; if (rv < 0) { return rv;