src/solaris/native/java/net/net_util_md.c

Print this page
rev 8822 : 8024854: PPC64: Basic changes and files to build the class library on AIX
Reviewed-by: alanb, prr, sla, chegar, michaelm, mullan, art
Contributed-by: luchsh@linux.vnet.ibm.com, spoole@linux.vnet.ibm.com, thomas.stuefe@sap.com

@@ -736,18 +736,27 @@
         }
     }
     return 0;
 }
 
-void initLocalAddrTable () {
+void platformInit () {
     initLoopbackRoutes();
     initLocalIfs();
 }
 
+#elif defined(_AIX)
+
+/* Initialize stubs for blocking I/O workarounds (see src/solaris/native/java/net/linux_close.c) */
+extern void aix_close_init();
+
+void platformInit () {
+    aix_close_init();
+}
+
 #else
 
-void initLocalAddrTable () {}
+void platformInit () {}
 
 #endif
 
 void parseExclusiveBindProperty(JNIEnv *env) {
 #ifdef __solaris__

@@ -985,11 +994,15 @@
         { java_net_SocketOptions_SO_OOBINLINE,          SOL_SOCKET,     SO_OOBINLINE },
         { java_net_SocketOptions_SO_LINGER,             SOL_SOCKET,     SO_LINGER },
         { java_net_SocketOptions_SO_SNDBUF,             SOL_SOCKET,     SO_SNDBUF },
         { java_net_SocketOptions_SO_RCVBUF,             SOL_SOCKET,     SO_RCVBUF },
         { java_net_SocketOptions_SO_KEEPALIVE,          SOL_SOCKET,     SO_KEEPALIVE },
+#if defined(_AIX)
+        { java_net_SocketOptions_SO_REUSEADDR,          SOL_SOCKET,     SO_REUSEPORT },
+#else
         { java_net_SocketOptions_SO_REUSEADDR,          SOL_SOCKET,     SO_REUSEADDR },
+#endif
         { java_net_SocketOptions_SO_BROADCAST,          SOL_SOCKET,     SO_BROADCAST },
         { java_net_SocketOptions_IP_TOS,                IPPROTO_IP,     IP_TOS },
         { java_net_SocketOptions_IP_MULTICAST_IF,       IPPROTO_IP,     IP_MULTICAST_IF },
         { java_net_SocketOptions_IP_MULTICAST_IF2,      IPPROTO_IP,     IP_MULTICAST_IF },
         { java_net_SocketOptions_IP_MULTICAST_LOOP,     IPPROTO_IP,     IP_MULTICAST_LOOP },

@@ -1385,10 +1398,33 @@
             }
         }
     }
 #endif
 
+#ifdef _AIX
+    if (level == SOL_SOCKET) {
+        if (opt == SO_SNDBUF || opt == SO_RCVBUF) {
+            /*
+             * Just try to set the requested size. If it fails we will leave the
+             * socket option as is. Setting the buffer size means only a hint in
+             * the jse2/java software layer, see javadoc. In the previous
+             * solution the buffer has always been truncated to a length of
+             * 0x100000 Byte, even if the technical limit has not been reached.
+             * This kind of absolute truncation was unexpected in the jck tests.
+             */
+            int ret = setsockopt(fd, level, opt, arg, len);
+            if ((ret == 0) || (ret == -1 && errno == ENOBUFS)) {
+                // Accept failure because of insufficient buffer memory resources.
+                return 0;
+            } else {
+                // Deliver all other kinds of errors.
+                return ret;
+            }
+        }
+    }
+#endif
+
     /*
      * On Linux the receive buffer is used for both socket
      * structures and the the packet payload. The implication
      * is that if SO_RCVBUF is too small then small packets
      * must be discard.