summaryrefslogtreecommitdiff
path: root/jurt
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-01-11 13:54:04 +0200
committerNoel Grandin <noelgrandin@gmail.com>2015-01-20 10:40:44 +0000
commitc9e6b5854197dd33d4e20ed78aee8382472a0f01 (patch)
tree644a9acc2b74a9f2812f686304455f023886661a /jurt
parent473c20d86ea0cdd1307bfd5c89f89c3ba2c316a1 (diff)
enable tcpNoDelay for loopback connections automatically
it can make a significant speed difference for applications talking to the office binary via UNO Change-Id: If6e901908fe6a6119ac1fd0bf8feebabe5602ff7 Reviewed-on: https://gerrit.libreoffice.org/13856 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'jurt')
-rw-r--r--jurt/com/sun/star/lib/connections/socket/socketAcceptor.java8
-rw-r--r--jurt/com/sun/star/lib/connections/socket/socketConnector.java6
2 files changed, 9 insertions, 5 deletions
diff --git a/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java b/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java
index e3dbea71c14b..85790dfdd21e 100644
--- a/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java
+++ b/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java
@@ -28,9 +28,7 @@ import com.sun.star.lang.XSingleServiceFactory;
import com.sun.star.registry.XRegistryKey;
import java.io.IOException;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
+import java.net.*;
/**
* A component that implements the <code>XAcceptor</code> interface.
@@ -152,7 +150,9 @@ public final class socketAcceptor implements XAcceptor {
System.err.println("##### " + getClass().getName()
+ ".accept: accepted " + socket);
}
- if (tcpNoDelay != null) {
+ // we enable tcpNoDelay for loopback connections because
+ // it can make a significant speed difference on linux boxes.
+ if (tcpNoDelay != null || ((InetSocketAddress)socket.getRemoteSocketAddress()).getAddress().isLoopbackAddress()) {
socket.setTcpNoDelay(tcpNoDelay.booleanValue());
}
return new SocketConnection(acceptingDescription, socket);
diff --git a/jurt/com/sun/star/lib/connections/socket/socketConnector.java b/jurt/com/sun/star/lib/connections/socket/socketConnector.java
index a0c49370c6b2..1d3c2b1b57c3 100644
--- a/jurt/com/sun/star/lib/connections/socket/socketConnector.java
+++ b/jurt/com/sun/star/lib/connections/socket/socketConnector.java
@@ -131,8 +131,10 @@ public final class socketConnector implements XConnector {
throw new ConnectionSetupException(e);
}
Socket socket = null;
+ boolean isLoopbackAddress = false;
for (int i = 0; i < adr.length; ++i) {
try {
+ isLoopbackAddress = adr[i].isLoopbackAddress();
socket = new Socket(adr[i], desc.getPort());
break;
} catch (IOException e) {
@@ -142,7 +144,9 @@ public final class socketConnector implements XConnector {
}
XConnection con;
try {
- if (desc.getTcpNoDelay() != null)
+ // we enable tcpNoDelay for loopback connections because
+ // it can make a significant speed difference on linux boxes.
+ if (desc.getTcpNoDelay() != null || isLoopbackAddress)
socket.setTcpNoDelay(desc.getTcpNoDelay().booleanValue());
con = new SocketConnection(connectionDescription, socket);