From bb967cb84147c36bbd1f799d6cda7de4a299eff8 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Fri, 8 May 2020 15:07:27 +1000 Subject: [PATCH 1/3] Issue #4789 - Name the ShutdownThread Signed-off-by: Lachlan Roberts --- .../main/java/org/eclipse/jetty/util/thread/ShutdownThread.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ShutdownThread.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ShutdownThread.java index 51831b4415b..066cfe231df 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ShutdownThread.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ShutdownThread.java @@ -48,6 +48,7 @@ public class ShutdownThread extends Thread */ private ShutdownThread() { + super("ShutdownThread"); } private synchronized void hook() From 908331acbdd134442020273cb04ffddda63be36c Mon Sep 17 00:00:00 2001 From: Lachlan Date: Fri, 8 May 2020 18:46:09 +1000 Subject: [PATCH 2/3] Add jetty to ShutdownThread name. --- .../main/java/org/eclipse/jetty/util/thread/ShutdownThread.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ShutdownThread.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ShutdownThread.java index 066cfe231df..8aba8713ddd 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ShutdownThread.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ShutdownThread.java @@ -48,7 +48,7 @@ public class ShutdownThread extends Thread */ private ShutdownThread() { - super("ShutdownThread"); + super("JettyShutdownThread"); } private synchronized void hook() From 409db8d065b8e89f2c64ed7d37669c0f84836625 Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Fri, 8 May 2020 11:17:12 +0200 Subject: [PATCH 3/3] introduce socket configuration properties in Jetty XML files Signed-off-by: Ludovic Orban --- .../src/main/config/etc/jetty-http.xml | 4 ++ .../src/main/config/etc/jetty-ssl.xml | 4 ++ jetty-server/src/main/config/modules/http.mod | 15 ++++ jetty-server/src/main/config/modules/ssl.mod | 15 ++++ .../eclipse/jetty/server/ServerConnector.java | 71 ++++++++++++++++++- 5 files changed, 108 insertions(+), 1 deletion(-) diff --git a/jetty-server/src/main/config/etc/jetty-http.xml b/jetty-server/src/main/config/etc/jetty-http.xml index e93bb68dfc1..ba8a605febb 100644 --- a/jetty-server/src/main/config/etc/jetty-http.xml +++ b/jetty-server/src/main/config/etc/jetty-http.xml @@ -34,6 +34,10 @@ + + + + diff --git a/jetty-server/src/main/config/etc/jetty-ssl.xml b/jetty-server/src/main/config/etc/jetty-ssl.xml index 562785754d2..729df2ab638 100644 --- a/jetty-server/src/main/config/etc/jetty-ssl.xml +++ b/jetty-server/src/main/config/etc/jetty-ssl.xml @@ -26,6 +26,10 @@ + + + + diff --git a/jetty-server/src/main/config/modules/http.mod b/jetty-server/src/main/config/modules/http.mod index 7c20880043f..b5a94b0dd86 100644 --- a/jetty-server/src/main/config/modules/http.mod +++ b/jetty-server/src/main/config/modules/http.mod @@ -39,6 +39,21 @@ etc/jetty-http.xml ## Thread priority delta to give to acceptor threads # jetty.http.acceptorPriorityDelta=0 +## The requested maximum length of the queue of incoming connections. +# jetty.http.acceptQueueSize=0 + +## Enable/disable the SO_REUSEADDR socket option. +# jetty.http.reuseAddress=true + +## Enable/disable TCP_NODELAY on accepted sockets. +# jetty.http.acceptedTcpNoDelay=true + +## The SO_RCVBUF option to set on accepted sockets. A value of -1 indicates that it is left to its default value. +# jetty.http.acceptedReceiveBufferSize=-1 + +## The SO_SNDBUF option to set on accepted sockets. A value of -1 indicates that it is left to its default value. +# jetty.http.acceptedSendBufferSize=-1 + ## Connect Timeout in milliseconds # jetty.http.connectTimeout=15000 diff --git a/jetty-server/src/main/config/modules/ssl.mod b/jetty-server/src/main/config/modules/ssl.mod index 6c1f5bb573d..dd730bb6120 100644 --- a/jetty-server/src/main/config/modules/ssl.mod +++ b/jetty-server/src/main/config/modules/ssl.mod @@ -43,6 +43,21 @@ basehome:modules/ssl/keystore|etc/keystore ## Thread priority delta to give to acceptor threads # jetty.ssl.acceptorPriorityDelta=0 +## The requested maximum length of the queue of incoming connections. +# jetty.ssl.acceptQueueSize=0 + +## Enable/disable the SO_REUSEADDR socket option. +# jetty.ssl.reuseAddress=true + +## Enable/disable TCP_NODELAY on accepted sockets. +# jetty.ssl.acceptedTcpNoDelay=true + +## The SO_RCVBUF option to set on accepted sockets. A value of -1 indicates that it is left to its default value. +# jetty.ssl.acceptedReceiveBufferSize=-1 + +## The SO_SNDBUF option to set on accepted sockets. A value of -1 indicates that it is left to its default value. +# jetty.ssl.acceptedSendBufferSize=-1 + ## Connect Timeout in milliseconds # jetty.ssl.connectTimeout=15000 diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java index d53244079c8..02e58fb50a4 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java @@ -83,6 +83,9 @@ public class ServerConnector extends AbstractNetworkConnector private volatile int _localPort = -1; private volatile int _acceptQueueSize = 0; private volatile boolean _reuseAddress = true; + private volatile boolean _acceptedTcpNoDelay = true; + private volatile int _acceptedReceiveBufferSize = -1; + private volatile int _acceptedSendBufferSize = -1; /** *

Construct a ServerConnector with a private instance of {@link HttpConnectionFactory} as the only factory.

@@ -399,7 +402,11 @@ public class ServerConnector extends AbstractNetworkConnector { try { - socket.setTcpNoDelay(true); + socket.setTcpNoDelay(_acceptedTcpNoDelay); + if (_acceptedReceiveBufferSize > -1) + socket.setReceiveBufferSize(_acceptedReceiveBufferSize); + if (_acceptedSendBufferSize > -1) + socket.setSendBufferSize(_acceptedSendBufferSize); } catch (SocketException e) { @@ -479,6 +486,7 @@ public class ServerConnector extends AbstractNetworkConnector * @return whether the server socket reuses addresses * @see ServerSocket#getReuseAddress() */ + @ManagedAttribute("Server Socket SO_REUSEADDR") public boolean getReuseAddress() { return _reuseAddress; @@ -493,6 +501,67 @@ public class ServerConnector extends AbstractNetworkConnector _reuseAddress = reuseAddress; } + /** + * @return whether the accepted socket gets {@link java.net.SocketOptions#TCP_NODELAY TCP_NODELAY} enabled. + * @see Socket#getTcpNoDelay() + */ + @ManagedAttribute("Accepted Socket TCP_NODELAY") + public boolean getAcceptedTcpNoDelay() + { + return _acceptedTcpNoDelay; + } + + /** + * @param tcpNoDelay whether {@link java.net.SocketOptions#TCP_NODELAY TCP_NODELAY} gets enabled on the the accepted socket. + * @see Socket#setTcpNoDelay(boolean) + */ + public void setAcceptedTcpNoDelay(boolean tcpNoDelay) + { + this._acceptedTcpNoDelay = tcpNoDelay; + } + + /** + * @return the {@link java.net.SocketOptions#SO_RCVBUF SO_RCVBUF} size to set onto the accepted socket. + * A value of -1 indicates that it is left to its default value. + * @see Socket#getReceiveBufferSize() + */ + @ManagedAttribute("Accepted Socket SO_RCVBUF") + public int getAcceptedReceiveBufferSize() + { + return _acceptedReceiveBufferSize; + } + + /** + * @param receiveBufferSize the {@link java.net.SocketOptions#SO_RCVBUF SO_RCVBUF} size to set onto the accepted socket. + * A value of -1 indicates that it is left to its default value. + * @see Socket#setReceiveBufferSize(int) + */ + public void setAcceptedReceiveBufferSize(int receiveBufferSize) + { + this._acceptedReceiveBufferSize = receiveBufferSize; + } + + /** + * @return the {@link java.net.SocketOptions#SO_SNDBUF SO_SNDBUF} size to set onto the accepted socket. + * A value of -1 indicates that it is left to its default value. + * @see Socket#getSendBufferSize() + */ + @ManagedAttribute("Accepted Socket SO_SNDBUF") + public int getAcceptedSendBufferSize() + { + return _acceptedSendBufferSize; + } + + /** + * @param sendBufferSize the {@link java.net.SocketOptions#SO_SNDBUF SO_SNDBUF} size to set onto the accepted socket. + * A value of -1 indicates that it is left to its default value. + * @see Socket#setSendBufferSize(int) + */ + public void setAcceptedSendBufferSize(int sendBufferSize) + { + this._acceptedSendBufferSize = sendBufferSize; + } + @Override public void setAccepting(boolean accepting) {