[Libreoffice-commits] core.git: io/source jurt/com
Noel Grandin
noel at peralex.com
Tue Jan 20 02:41:19 PST 2015
io/source/acceptor/acc_socket.cxx | 6 +++++-
io/source/connector/connector.cxx | 4 +++-
jurt/com/sun/star/lib/connections/socket/socketAcceptor.java | 8 ++++----
jurt/com/sun/star/lib/connections/socket/socketConnector.java | 6 +++++-
4 files changed, 17 insertions(+), 7 deletions(-)
New commits:
commit c9e6b5854197dd33d4e20ed78aee8382472a0f01
Author: Noel Grandin <noel at peralex.com>
Date: Sun Jan 11 13:54:04 2015 +0200
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 at gmail.com>
Tested-by: Noel Grandin <noelgrandin at gmail.com>
diff --git a/io/source/acceptor/acc_socket.cxx b/io/source/acceptor/acc_socket.cxx
index 830a9b3..89fb44d 100644
--- a/io/source/acceptor/acc_socket.cxx
+++ b/io/source/acceptor/acc_socket.cxx
@@ -380,7 +380,11 @@ namespace io_acceptor {
}
pConn->completeConnectionString();
- if( m_bTcpNoDelay )
+ OUString remoteHostname = pConn->m_addr.getHostname();
+ // we enable tcpNoDelay for loopback connections because
+ // it can make a significant speed difference on linux boxes.
+ if( m_bTcpNoDelay || remoteHostname == "localhost" ||
+ remoteHostname.startsWith("127.0.0.") )
{
sal_Int32 nTcpNoDelay = sal_True;
pConn->m_socket.setOption( osl_Socket_OptionTcpNoDelay , &nTcpNoDelay,
diff --git a/io/source/connector/connector.cxx b/io/source/connector/connector.cxx
index 0aca22c..81bfdb6 100644
--- a/io/source/connector/connector.cxx
+++ b/io/source/connector/connector.cxx
@@ -132,7 +132,9 @@ namespace stoc_connector
delete pConn;
throw NoConnectException( sMessage );
}
- if( bTcpNoDelay )
+ // we enable tcpNoDelay for loopback connections because
+ // it can make a significant speed difference on linux boxes.
+ if( bTcpNoDelay || aHost == "localhost" || aHost.startsWith("127.0.0.") )
{
sal_Int32 nTcpNoDelay = sal_True;
pConn->m_socket.setOption( osl_Socket_OptionTcpNoDelay , &nTcpNoDelay,
diff --git a/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java b/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java
index e3dbea7..85790df 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 a0c4937..1d3c2b1 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);
More information about the Libreoffice-commits
mailing list