8035949: Remove unused macro USE_SELECT and clean up Unix version of net_util_md.{c,h}
Reviewed-by: chegar, alanb
--- a/jdk/src/aix/native/java/net/aix_close.c Fri Feb 28 15:39:15 2014 +0100
+++ b/jdk/src/aix/native/java/net/aix_close.c Fri Feb 28 17:14:08 2014 +0100
@@ -374,17 +374,9 @@
BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen) );
}
-#ifndef USE_SELECT
int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout) );
}
-#else
-int NET_Select(int s, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout) {
- BLOCKING_IO_RETURN_INT( s-1,
- select(s, readfds, writefds, exceptfds, timeout) );
-}
-#endif
/*
* Wrapper for poll(s, timeout).
--- a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c Fri Feb 28 15:39:15 2014 +0100
+++ b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c Fri Feb 28 17:14:08 2014 +0100
@@ -164,7 +164,7 @@
if (error) {
/* report error */
- ThrowUnknownHostExceptionWithGaiError(env, hostname, error);
+ NET_ThrowUnknownHostExceptionWithGaiError(env, hostname, error);
JNU_ReleaseStringPlatformChars(env, host, hostname);
return NULL;
} else {
@@ -416,7 +416,7 @@
if (error) {
/* report error */
- ThrowUnknownHostExceptionWithGaiError(env, hostname, error);
+ NET_ThrowUnknownHostExceptionWithGaiError(env, hostname, error);
JNU_ReleaseStringPlatformChars(env, host, hostname);
return NULL;
} else {
--- a/jdk/src/solaris/native/java/net/Inet6AddressImpl.c Fri Feb 28 15:39:15 2014 +0100
+++ b/jdk/src/solaris/native/java/net/Inet6AddressImpl.c Fri Feb 28 17:14:08 2014 +0100
@@ -305,7 +305,7 @@
if (error) {
/* report error */
- ThrowUnknownHostExceptionWithGaiError(env, hostname, error);
+ NET_ThrowUnknownHostExceptionWithGaiError(env, hostname, error);
JNU_ReleaseStringPlatformChars(env, host, hostname);
return NULL;
} else {
--- a/jdk/src/solaris/native/java/net/PlainSocketImpl.c Fri Feb 28 15:39:15 2014 +0100
+++ b/jdk/src/solaris/native/java/net/PlainSocketImpl.c Fri Feb 28 17:14:08 2014 +0100
@@ -27,7 +27,7 @@
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
-#if defined(__linux__) && !defined(USE_SELECT)
+#if defined(__linux__)
#include <sys/poll.h>
#endif
#include <netinet/tcp.h> /* Defines TCP_NODELAY, needed for 2.6 */
@@ -309,26 +309,11 @@
* See 6343810.
*/
while (1) {
-#ifndef USE_SELECT
- {
- struct pollfd pfd;
- pfd.fd = fd;
- pfd.events = POLLOUT;
+ struct pollfd pfd;
+ pfd.fd = fd;
+ pfd.events = POLLOUT;
- connect_rv = NET_Poll(&pfd, 1, -1);
- }
-#else
- {
- fd_set wr, ex;
-
- FD_ZERO(&wr);
- FD_SET(fd, &wr);
- FD_ZERO(&ex);
- FD_SET(fd, &ex);
-
- connect_rv = NET_Select(fd+1, 0, &wr, &ex, 0);
- }
-#endif
+ connect_rv = NET_Poll(&pfd, 1, -1);
if (connect_rv == -1) {
if (errno == EINTR) {
@@ -381,38 +366,18 @@
/*
* Wait for the connection to be established or a
- * timeout occurs. poll/select needs to handle EINTR in
+ * timeout occurs. poll needs to handle EINTR in
* case lwp sig handler redirects any process signals to
* this thread.
*/
while (1) {
jlong newTime;
-#ifndef USE_SELECT
- {
- struct pollfd pfd;
- pfd.fd = fd;
- pfd.events = POLLOUT;
+ struct pollfd pfd;
+ pfd.fd = fd;
+ pfd.events = POLLOUT;
- errno = 0;
- connect_rv = NET_Poll(&pfd, 1, timeout);
- }
-#else
- {
- fd_set wr, ex;
- struct timeval t;
-
- t.tv_sec = timeout / 1000;
- t.tv_usec = (timeout % 1000) * 1000;
-
- FD_ZERO(&wr);
- FD_SET(fd, &wr);
- FD_ZERO(&ex);
- FD_SET(fd, &ex);
-
- errno = 0;
- connect_rv = NET_Select(fd+1, 0, &wr, &ex, &t);
- }
-#endif
+ errno = 0;
+ connect_rv = NET_Poll(&pfd, 1, timeout);
if (connect_rv >= 0) {
break;
--- a/jdk/src/solaris/native/java/net/bsd_close.c Fri Feb 28 15:39:15 2014 +0100
+++ b/jdk/src/solaris/native/java/net/bsd_close.c Fri Feb 28 17:14:08 2014 +0100
@@ -322,17 +322,9 @@
BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen) );
}
-#ifndef USE_SELECT
int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout) );
}
-#else
-int NET_Select(int s, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout) {
- BLOCKING_IO_RETURN_INT( s-1,
- select(s, readfds, writefds, exceptfds, timeout) );
-}
-#endif
/*
* Wrapper for select(s, timeout). We are using select() on Mac OS due to Bug 7131399.
--- a/jdk/src/solaris/native/java/net/linux_close.c Fri Feb 28 15:39:15 2014 +0100
+++ b/jdk/src/solaris/native/java/net/linux_close.c Fri Feb 28 17:14:08 2014 +0100
@@ -304,17 +304,9 @@
BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen) );
}
-#ifndef USE_SELECT
int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout) );
}
-#else
-int NET_Select(int s, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout) {
- BLOCKING_IO_RETURN_INT( s-1,
- select(s, readfds, writefds, exceptfds, timeout) );
-}
-#endif
/*
* Wrapper for poll(s, timeout).
--- a/jdk/src/solaris/native/java/net/net_util_md.c Fri Feb 28 15:39:15 2014 +0100
+++ b/jdk/src/solaris/native/java/net/net_util_md.c Fri Feb 28 17:14:08 2014 +0100
@@ -75,13 +75,6 @@
#include "java_net_SocketOptions.h"
-/* needed from libsocket on Solaris 8 */
-
-getaddrinfo_f getaddrinfo_ptr = NULL;
-freeaddrinfo_f freeaddrinfo_ptr = NULL;
-gai_strerror_f gai_strerror_ptr = NULL;
-getnameinfo_f getnameinfo_ptr = NULL;
-
/*
* EXCLBIND socket options only on Solaris
*/
@@ -446,15 +439,14 @@
}
#endif /* DONT_ENABLE_IPV6 */
-void ThrowUnknownHostExceptionWithGaiError(JNIEnv *env,
- const char* hostname,
- int gai_error)
+void NET_ThrowUnknownHostExceptionWithGaiError(JNIEnv *env,
+ const char* hostname,
+ int gai_error)
{
int size;
char *buf;
const char *format = "%s: %s";
- const char *error_string =
- (gai_strerror_ptr == NULL) ? NULL : (*gai_strerror_ptr)(gai_error);
+ const char *error_string = gai_strerror(gai_error);
if (error_string == NULL)
error_string = "unknown error";
@@ -1614,7 +1606,7 @@
}
/**
- * Wrapper for select/poll with timeout on a single file descriptor.
+ * Wrapper for poll with timeout on a single file descriptor.
*
* flags (defined in net_util_md.h can be any combination of
* NET_WAIT_READ, NET_WAIT_WRITE & NET_WAIT_CONNECT.
@@ -1633,47 +1625,18 @@
while (1) {
jlong newTime;
-#ifndef USE_SELECT
- {
- struct pollfd pfd;
- pfd.fd = fd;
- pfd.events = 0;
- if (flags & NET_WAIT_READ)
- pfd.events |= POLLIN;
- if (flags & NET_WAIT_WRITE)
- pfd.events |= POLLOUT;
- if (flags & NET_WAIT_CONNECT)
- pfd.events |= POLLOUT;
-
- errno = 0;
- read_rv = NET_Poll(&pfd, 1, timeout);
- }
-#else
- {
- fd_set rd, wr, ex;
- struct timeval t;
+ struct pollfd pfd;
+ pfd.fd = fd;
+ pfd.events = 0;
+ if (flags & NET_WAIT_READ)
+ pfd.events |= POLLIN;
+ if (flags & NET_WAIT_WRITE)
+ pfd.events |= POLLOUT;
+ if (flags & NET_WAIT_CONNECT)
+ pfd.events |= POLLOUT;
- t.tv_sec = timeout / 1000;
- t.tv_usec = (timeout % 1000) * 1000;
-
- FD_ZERO(&rd);
- FD_ZERO(&wr);
- FD_ZERO(&ex);
- if (flags & NET_WAIT_READ) {
- FD_SET(fd, &rd);
- }
- if (flags & NET_WAIT_WRITE) {
- FD_SET(fd, &wr);
- }
- if (flags & NET_WAIT_CONNECT) {
- FD_SET(fd, &wr);
- FD_SET(fd, &ex);
- }
-
- errno = 0;
- read_rv = NET_Select(fd+1, &rd, &wr, &ex, &t);
- }
-#endif
+ errno = 0;
+ read_rv = NET_Poll(&pfd, 1, timeout);
newTime = JVM_CurrentTimeMillis(env, 0);
timeout -= (newTime - prevTime);
--- a/jdk/src/solaris/native/java/net/net_util_md.h Fri Feb 28 15:39:15 2014 +0100
+++ b/jdk/src/solaris/native/java/net/net_util_md.h Fri Feb 28 17:14:08 2014 +0100
@@ -32,9 +32,7 @@
#include <netinet/in.h>
#include <unistd.h>
-#ifndef USE_SELECT
#include <sys/poll.h>
-#endif
int NET_Timeout(int s, long timeout);
int NET_Read(int s, void* buf, size_t len);
@@ -43,54 +41,26 @@
int NET_ReadV(int s, const struct iovec * vector, int count);
int NET_Send(int s, void *msg, int len, unsigned int flags);
int NET_SendTo(int s, const void *msg, int len, unsigned int
- flags, const struct sockaddr *to, int tolen);
+ flags, const struct sockaddr *to, int tolen);
int NET_Writev(int s, const struct iovec * vector, int count);
int NET_Connect(int s, struct sockaddr *addr, int addrlen);
int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen);
int NET_SocketClose(int s);
int NET_Dup2(int oldfd, int newfd);
-#ifdef USE_SELECT
-extern int NET_Select(int s, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout);
-#else
-extern int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout);
-#endif
-
+int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout);
int NET_SocketAvailable(int s, jint *pbytes);
-#if defined(__linux__) && defined(AF_INET6)
-int getDefaultIPv6Interface(struct in6_addr *target_addr);
-#endif
-
-#ifdef __solaris__
-extern int net_getParam(char *driver, char *param);
-#endif
-
-/* needed from libsocket on Solaris 8 */
-
-typedef int (*getaddrinfo_f)(const char *nodename, const char *servname,
- const struct addrinfo *hints, struct addrinfo **res);
-
-typedef void (*freeaddrinfo_f)(struct addrinfo *);
-
-typedef const char * (*gai_strerror_f)(int ecode);
+void NET_ThrowUnknownHostExceptionWithGaiError(JNIEnv *env,
+ const char* hostname,
+ int gai_error);
+void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
+ const char *defaultDetail);
-typedef int (*getnameinfo_f)(const struct sockaddr *, size_t,
- char *, size_t, char *, size_t, int);
-
-extern getaddrinfo_f getaddrinfo_ptr;
-extern freeaddrinfo_f freeaddrinfo_ptr;
-extern getnameinfo_f getnameinfo_ptr;
+#define NET_WAIT_READ 0x01
+#define NET_WAIT_WRITE 0x02
+#define NET_WAIT_CONNECT 0x04
-void ThrowUnknownHostExceptionWithGaiError(JNIEnv *env,
- const char* hostname,
- int gai_error);
-
-#define NET_WAIT_READ 0x01
-#define NET_WAIT_WRITE 0x02
-#define NET_WAIT_CONNECT 0x04
-
-extern jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout);
+jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout);
/************************************************************************
* Macros and constants
@@ -127,12 +97,16 @@
/************************************************************************
* Utilities
*/
+
#ifdef __linux__
-extern int kernelIsV24();
+int kernelIsV24();
+#ifdef AF_INET6
+int getDefaultIPv6Interface(struct in6_addr *target_addr);
+#endif
#endif
-void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
- const char *defaultDetail);
-
+#ifdef __solaris__
+int net_getParam(char *driver, char *param);
+#endif
#endif /* NET_UTILS_MD_H */
--- a/jdk/src/solaris/native/java/net/solaris_close.c Fri Feb 28 15:39:15 2014 +0100
+++ b/jdk/src/solaris/native/java/net/solaris_close.c Fri Feb 28 17:14:08 2014 +0100
@@ -86,11 +86,6 @@
RESTARTABLE_RETURN_INT(poll(ufds, nfds, timeout));
}
-int NET_Select(int s, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout) {
- RESTARTABLE_RETURN_INT(select(s, readfds, writefds, exceptfds, timeout));
-}
-
int NET_Timeout(int s, long timeout) {
int result;
struct timeval t;