changeset 502:a4bb3b450016 jdk8-b108

Merge
author lana
date Tue, 17 Sep 2013 08:08:07 -0700
parents 260f00a95705 4853dc082c7d
children c1eb93f57603
files
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/corba/se/impl/transport/DefaultSocketFactoryImpl.java	Thu Sep 12 11:08:55 2013 -0700
+++ b/src/share/classes/com/sun/corba/se/impl/transport/DefaultSocketFactoryImpl.java	Tue Sep 17 08:08:07 2013 -0700
@@ -32,6 +32,7 @@
 import java.net.ServerSocket;
 import java.nio.channels.SocketChannel;
 import java.nio.channels.ServerSocketChannel;
+import java.security.PrivilegedAction;
 
 import com.sun.corba.se.pept.transport.Acceptor;
 
@@ -44,6 +45,22 @@
     implements ORBSocketFactory
 {
     private ORB orb;
+    private static final boolean keepAlive;
+
+    static {
+        keepAlive = java.security.AccessController.doPrivileged(
+            new PrivilegedAction<Boolean>() {
+                @Override
+                public Boolean run () {
+                    String value =
+                        System.getProperty("com.sun.CORBA.transport.enableTcpKeepAlive");
+                    if (value != null)
+                        return new Boolean(!"false".equalsIgnoreCase(value));
+
+                    return Boolean.FALSE;
+                }
+            });
+    }
 
     public void setORB(ORB orb)
     {
@@ -85,6 +102,9 @@
         // Disable Nagle's algorithm (i.e., always send immediately).
         socket.setTcpNoDelay(true);
 
+        if (keepAlive)
+            socket.setKeepAlive(true);
+
         return socket;
     }
 
@@ -95,6 +115,8 @@
     {
         // Disable Nagle's algorithm (i.e., always send immediately).
         socket.setTcpNoDelay(true);
+        if (keepAlive)
+            socket.setKeepAlive(true);
     }
 }